OSDN Git Service

Use an integer to keep track of the blurring node.
authorLeon Scroggins <scroggo@google.com>
Tue, 25 Jan 2011 14:23:26 +0000 (09:23 -0500)
committerLeon Scroggins <scroggo@google.com>
Tue, 25 Jan 2011 14:35:53 +0000 (09:35 -0500)
Bug:3387251

Rather than storing the actual pointer to the Node, since
the pointer may no longer be valid and it is only used for
comparison anyway.

Change-Id: Icc6aabfa66c4a40b40fb6a8673d7ad34346360b6

WebKit/android/jni/WebViewCore.cpp
WebKit/android/jni/WebViewCore.h

index 52cdfed..1365977 100644 (file)
@@ -457,7 +457,7 @@ void WebViewCore::reset(bool fromConstructor)
     }
 
     m_lastFocused = 0;
-    m_blurringNode = 0;
+    m_blurringNodePointer = 0;
     m_lastFocusedBounds = WebCore::IntRect(0,0,0,0);
     m_focusBoundsChanged = false;
     m_lastFocusedSelStart = 0;
@@ -2983,7 +2983,6 @@ static void scrollLayer(WebCore::RenderObject* renderer, WebCore::IntPoint* pos)
 // in which case, 'fake' is set to true
 bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr, bool fake, int scrollY)
 {
-    m_lastClickWasOnTextInput = false;
     bool valid = framePtr == NULL
             || CacheBuilder::validNode(m_mainFrame, framePtr, nodePtr);
     WebFrame* webFrame = WebFrame::getWebFrame(m_mainFrame);
@@ -3041,11 +3040,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
             static_cast<RenderTextControl*>(renderer)->setScrollTop(scrollY);
         else
             scrollLayer(renderer, &m_mousePos);
-        if (isTextInput(nodePtr)) {
-            // The user clicked on a text input field.  If this causes a blur event
-            // on a different text input, do not hide the keyboard in formDidBlur
-            m_lastClickWasOnTextInput = true;
-        }
     }
     if (!valid || !framePtr)
         framePtr = m_mainFrame;
@@ -3061,8 +3055,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
     bool handled = framePtr->eventHandler()->handleMouseReleaseEvent(mouseUp);
     webFrame->setUserInitiatedAction(false);
 
-    m_lastClickWasOnTextInput = false;
-
     // If the user clicked on a textfield, make the focusController active
     // so we show the blinking cursor.
     WebCore::Node* focusNode = currentFocus();
@@ -3127,23 +3119,24 @@ void WebViewCore::popupReply(const int* array, int count)
 
 void WebViewCore::formDidBlur(const WebCore::Node* node)
 {
-    // This blur is the result of clicking on a different input.  Do not hide
-    // the keyboard, since it will just be opened again.
-    if (m_lastClickWasOnTextInput) return;
-    m_blurringNode = node;
+    // If the blur is on a text input, keep track of the node so we can
+    // hide the soft keyboard when the new focus is set, if it is not a
+    // text input.
+    if (isTextInput(node))
+        m_blurringNodePointer = reinterpret_cast<int>(node);
 }
 
 void WebViewCore::focusNodeChanged(const WebCore::Node* newFocus)
 {
-    if (!m_blurringNode)
+    if (!m_blurringNodePointer)
         return;
-    if (isTextInput(m_blurringNode) && !isTextInput(newFocus)) {
+    if (!isTextInput(newFocus)) {
         JNIEnv* env = JSC::Bindings::getJNIEnv();
         env->CallVoidMethod(m_javaGlue->object(env).get(),
-                m_javaGlue->m_formDidBlur, reinterpret_cast<int>(m_blurringNode));
+                m_javaGlue->m_formDidBlur, m_blurringNodePointer);
         checkException(env);
     }
-    m_blurringNode = 0;
+    m_blurringNodePointer = 0;
 }
 
 void WebViewCore::addMessageToConsole(const WTF::String& message, unsigned int lineNumber, const WTF::String& sourceID, int msgLevel) {
index ed67742..611ee59 100644 (file)
@@ -602,8 +602,7 @@ namespace android {
         WebCoreReply*          m_popupReply;
         WebCore::Node* m_lastFocused;
         WebCore::IntRect m_lastFocusedBounds;
-        bool m_lastClickWasOnTextInput;
-        const WebCore::Node* m_blurringNode;
+        int m_blurringNodePointer;
         int m_lastFocusedSelStart;
         int m_lastFocusedSelEnd;
         PictureSet m_content; // the set of pictures to draw