From: Leon Scroggins Date: Fri, 23 Oct 2009 20:14:33 +0000 (-0400) Subject: Allow touches to change the selection. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f74580c1;p=android-x86%2Fexternal-webkit.git 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. --- diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index d31d93697..c574d5a3b 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( - 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 4b325165d..cc90396d3 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(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)