OSDN Git Service

Move check to clear the text input to the webcore thread.
authorLeon Scroggins III <scroggo@google.com>
Thu, 12 Aug 2010 16:15:11 +0000 (12:15 -0400)
committerLeon Scroggins III <scroggo@google.com>
Mon, 16 Aug 2010 16:41:56 +0000 (12:41 -0400)
Originally written in response to bug 2835685, which was
fixed in
https://android-git.corp.google.com/g/#change,61059

WebViewCore.cpp:
Send a message to clear the text input/remove the soft
keyboard if the click results in no text input field
being in focus.

WebView.cpp:
Remove the old checks to clear the WebTextView, which
is now done in WebViewCore.cpp.  This makes clearing it
consistent with the checks for opening the WebTextView.

Change-Id: I06ba7aadc95302c90af67da16edccd46896fcdbf

WebKit/android/jni/WebViewCore.cpp
WebKit/android/nav/WebView.cpp

index 31c6120..6cd1280 100644 (file)
@@ -2498,10 +2498,23 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
             } else {
                 requestKeyboard(false);
             }
-        } else if (focusNode->isContentEditable()) {
-            setFocusControllerActive(framePtr, true);
-            requestKeyboard(true);
+        } else {
+            // If the focusNode is contentEditable, show the keyboard and enable
+            // the focus controller so the user can type.  Otherwise hide the
+            // keyboard and disable the focus controller because no text input
+            // is needed.
+            bool keyboard = focusNode->isContentEditable();
+            setFocusControllerActive(framePtr, keyboard);
+            if (keyboard) {
+                requestKeyboard(true);
+            } else {
+                clearTextEntry();
+            }
         }
+    } else {
+        // There is no focusNode, so the keyboard is not needed.
+        setFocusControllerActive(framePtr, false);
+        clearTextEntry();
     }
     return handled;
 }
index efaa509..2132957 100644 (file)
@@ -105,7 +105,6 @@ enum DrawExtras { // keep this in sync with WebView.java
 struct JavaGlue {
     jweak       m_obj;
     jmethodID   m_calcOurContentVisibleRectF;
-    jmethodID   m_clearTextEntry;
     jmethodID   m_overrideLoading;
     jmethodID   m_scrollBy;
     jmethodID   m_sendMoveFocus;
@@ -141,7 +140,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
     m_javaGlue.m_obj = env->NewWeakGlobalRef(javaWebView);
     m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(IIZ)Z");
     m_javaGlue.m_calcOurContentVisibleRectF = GetJMethod(env, clazz, "calcOurContentVisibleRectF", "(Landroid/graphics/RectF;)V");
-    m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "(Z)V");
     m_javaGlue.m_overrideLoading = GetJMethod(env, clazz, "overrideLoading", "(Ljava/lang/String;)V");
     m_javaGlue.m_sendMoveFocus = GetJMethod(env, clazz, "sendMoveFocus", "(II)V");
     m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V");
@@ -222,15 +220,6 @@ void hideCursor()
     viewInvalidate();
 }
 
-void clearTextEntry()
-{
-    DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
-    JNIEnv* env = JSC::Bindings::getJNIEnv();
-    env->CallVoidMethod(m_javaGlue.object(env).get(),
-        m_javaGlue.m_clearTextEntry, true);
-    checkException(env);
-}
-
 #if DUMP_NAV_CACHE
 void debugDump()
 {
@@ -893,7 +882,6 @@ bool motionUp(int x, int y, int slop)
         sendMotionUp(frame ? (WebCore::Frame*) frame->framePointer() : 0,
             0, x, y);
         viewInvalidate();
-        clearTextEntry();
         return pageScrolled;
     }
     DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result,
@@ -914,7 +902,6 @@ bool motionUp(int x, int y, int slop)
     }
     viewInvalidate();
     if (!result->isTextInput()) {
-        clearTextEntry();
         if (!result->isSelect() && !result->isContentEditable())
             setFollowedLink(true);
         if (syntheticLink)