diff options
author | Leon Scroggins <scroggo@google.com> | 2009-10-23 16:14:33 -0400 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2009-10-27 16:06:11 -0400 |
commit | f74580c1504dcdd43fd15995b0e137982512dba2 (patch) | |
tree | 2b5a2cf15da1a42416c29d0152b10fb4859dfcd4 | |
parent | 64d1f380c954e4c93433fae705c6f27607f1d922 (diff) | |
download | external_webkit-f74580c1504dcdd43fd15995b0e137982512dba2.zip external_webkit-f74580c1504dcdd43fd15995b0e137982512dba2.tar.gz external_webkit-f74580c1504dcdd43fd15995b0e137982512dba2.tar.bz2 |
Allow touches to change the selection.
Fixes http://b/issue?id=1650395 Lets touches change the selection
while ignoring changes from trackball events. When a touch puts
a textfield in focus, tell the WebTextView to set mOkayForFocusNotToMatch.
Requires a change in frameworks/base.
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 23 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 13 |
2 files changed, 12 insertions, 24 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index d31d936..c574d5a 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -2023,35 +2023,16 @@ void WebViewCore::touchUp(int touchGeneration, " x=%d y=%d", m_touchGeneration, touchGeneration, x, y); return; // short circuit if a newer touch has been generated } + // This moves m_mousePos to the correct place, and handleMouseClick uses + // m_mousePos to determine where the click happens. moveMouse(frame, x, y); m_lastGeneration = touchGeneration; if (frame && CacheBuilder::validNode(m_mainFrame, frame, 0)) { frame->loader()->resetMultipleFormSubmissionProtection(); } - // If the click is on an unselected textfield/area we do not want to allow - // the click to change the selection, because we will set it ourselves - // elsewhere - beginning for textareas, end for textfields - bool needToIgnoreChangesToSelectedRange = true; - WebCore::Node* focusNode = currentFocus(); - if (focusNode) { - WebCore::RenderObject* renderer = focusNode->renderer(); - if (renderer && (renderer->isTextField() || renderer->isTextArea())) { - // Now check to see if the click is inside the focused textfield - if (focusNode->getRect().contains(x, y)) - needToIgnoreChangesToSelectedRange = false; - } - } - EditorClientAndroid* client = 0; - if (needToIgnoreChangesToSelectedRange) { - client = static_cast<EditorClientAndroid*>( - m_mainFrame->editor()->client()); - client->setShouldChangeSelectedRange(false); - } DBG_NAV_LOGD("touchGeneration=%d handleMouseClick frame=%p node=%p" " x=%d y=%d", touchGeneration, frame, node, x, y); handleMouseClick(frame, node); - if (needToIgnoreChangesToSelectedRange) - client->setShouldChangeSelectedRange(true); } // Common code for both clicking with the trackball and touchUp diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 4b32516..cc90396 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -106,6 +106,7 @@ struct JavaGlue { jmethodID m_getScaledMaxYScroll; jmethodID m_getVisibleRect; jmethodID m_rebuildWebTextView; + jmethodID m_setOkayToNotMatch; jmethodID m_displaySoftKeyboard; jmethodID m_viewInvalidate; jmethodID m_viewInvalidateRect; @@ -134,6 +135,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) m_javaGlue.m_getScaledMaxYScroll = GetJMethod(env, clazz, "getScaledMaxYScroll", "()I"); m_javaGlue.m_getVisibleRect = GetJMethod(env, clazz, "sendOurVisibleRect", "()Landroid/graphics/Rect;"); m_javaGlue.m_rebuildWebTextView = GetJMethod(env, clazz, "rebuildWebTextView", "()V"); + m_javaGlue.m_setOkayToNotMatch = GetJMethod(env, clazz, "setOkayNotToMatch", "()V"); m_javaGlue.m_displaySoftKeyboard = GetJMethod(env, clazz, "displaySoftKeyboard", "(Z)V"); m_javaGlue.m_viewInvalidate = GetJMethod(env, clazz, "viewInvalidate", "()V"); m_javaGlue.m_viewInvalidateRect = GetJMethod(env, clazz, "viewInvalidate", "(IIII)V"); @@ -835,7 +837,7 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll) void notifyProgressFinished() { DBG_NAV_LOGD("cursorIsTextInput=%d", cursorIsTextInput(DontAllowNewer)); - rebuildWebTextView(); + rebuildWebTextView(false); #if DEBUG_NAV_UI if (m_frameCacheUI) { const CachedNode* focus = m_frameCacheUI->currentFocus(); @@ -967,7 +969,7 @@ bool motionUp(int x, int y, int slop) } viewInvalidate(); if (result->isTextField() || result->isTextArea()) { - rebuildWebTextView(); + rebuildWebTextView(true); if (!result->isReadOnly()) { displaySoftKeyboard(true); } @@ -1267,7 +1269,7 @@ bool hasFocusNode() return focusNode; } -void rebuildWebTextView() +void rebuildWebTextView(bool needNotMatchFocus) { JNIEnv* env = JSC::Bindings::getJNIEnv(); AutoJObject obj = m_javaGlue.object(env); @@ -1277,6 +1279,10 @@ void rebuildWebTextView() return; env->CallVoidMethod(obj.get(), m_javaGlue.m_rebuildWebTextView); checkException(env); + if (needNotMatchFocus) { + env->CallVoidMethod(obj.get(), m_javaGlue.m_setOkayToNotMatch); + checkException(env); + } } void displaySoftKeyboard(bool isTextView) @@ -1927,6 +1933,7 @@ static void nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) static_cast<WebCore::Node*>(next->nodePointer()), pos.x(), pos.y()); view->scrollRectOnScreen(bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); + view->getWebViewCore()->m_moveGeneration++; } static jint nativeTextFieldAction(JNIEnv *env, jobject obj) |