diff options
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 12 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index d83fc4285937..bb18270efa01 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -353,6 +353,18 @@ import junit.framework.Assert; return false; } + void ensureLayout() { + if (getLayout() == null) { + // Ensure we have a Layout + measure(mWidthSpec, mHeightSpec); + LayoutParams params = (LayoutParams) getLayoutParams(); + if (params != null) { + layout(params.x, params.y, params.x + params.width, + params.y + params.height); + } + } + } + /** * Determine whether this WebTextView currently represents the node * represented by ptr. diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 0959bfafd733..5b43953fd357 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3750,6 +3750,18 @@ public class WebView extends AbsoluteLayout clearTextEntry(); } if (inEditingMode()) { + // Since we just called rebuildWebTextView, the layout is not set + // properly. Update it so it can correctly find the word to select. + mWebTextView.ensureLayout(); + // Provide a touch down event to WebTextView, which will allow it + // to store the location to use in performLongClick. + AbsoluteLayout.LayoutParams params + = (AbsoluteLayout.LayoutParams) mWebTextView.getLayoutParams(); + MotionEvent fake = MotionEvent.obtain(mLastTouchTime, + mLastTouchTime, MotionEvent.ACTION_DOWN, + mLastTouchX - params.x + mScrollX, + mLastTouchY - params.y + mScrollY, 0); + mWebTextView.dispatchTouchEvent(fake); return mWebTextView.performLongClick(); } if (mSelectingText) return false; // long click does nothing on selection |