From 3ccd3655a09633794f4d815ff85f35fa986a10d4 Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Fri, 26 Jun 2009 17:22:50 -0400 Subject: Fix a WebView longpress bug. Longpressing on a WebView while the WebTextView is up calls WebTextView::performLongPress(). This used to be fine, but now we may still leave the WebTextView up while the user is longpressing on something else. Check to ensure that the focus is the same as the cursor before calling WebTextView's version. Also, send a click if the user longpresses on a different WebTextView, so it will now behave appropriately. Requires a change in external/webkit. Also remove a duplicate check for inEditingMode(). --- core/java/android/webkit/WebView.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index b067d7194de7..ddcec3cab39b 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2505,6 +2505,14 @@ public class WebView extends AbsoluteLayout @Override public boolean performLongClick() { + if (mNativeClass != 0 && nativeCursorIsTextInput()) { + // Send the click so that the textfield is in focus + // FIXME: When we start respecting changes to the native textfield's + // selection, need to make sure that this does not change it. + mWebViewCore.sendMessage(EventHub.CLICK, nativeCursorFramePointer(), + nativeCursorNodePointer()); + rebuildWebTextView(); + } if (inEditingMode()) { return mWebTextView.performLongClick(); } else { @@ -3484,9 +3492,7 @@ public class WebView extends AbsoluteLayout public void onChildViewRemoved(View p, View child) { if (child == this) { - if (inEditingMode()) { - clearTextEntry(); - } + clearTextEntry(); } } @@ -4025,9 +4031,10 @@ public class WebView extends AbsoluteLayout if (ev.getAction() == MotionEvent.ACTION_DOWN) { mPrivateHandler.removeMessages(SWITCH_TO_CLICK); mTrackballDown = true; - if (mNativeClass != 0) { - nativeRecordButtons(hasFocus() && hasWindowFocus(), true, true); + if (mNativeClass == 0) { + return false; } + nativeRecordButtons(hasFocus() && hasWindowFocus(), true, true); if (time - mLastCursorTime <= TRACKBALL_TIMEOUT && !mLastCursorBounds.equals(nativeGetCursorRingBounds())) { nativeSelectBestAt(mLastCursorBounds); -- cgit v1.2.3-59-g8ed1b