[BlackBerry] Always use the current focused node when processing focus changes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Mar 2012 18:21:57 +0000 (18:21 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Mar 2012 18:21:57 +0000 (18:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80594

Patch by Mike Fenton <mifenton@rim.com> on 2012-03-08
Reviewed by Antonio Gomes.

Update InputHandler focused node handling to strictly use
the currently focused node.  This prevents a handling loop
when JS is modifying the focus and we get a late notification
of a past change from ChromeClientBlackBerry with the previously
unfocused node.

* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::focusedNodeChanged):
* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):
(WebCore::EditorClientBlackBerry::setInputMethodState):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::focusedNodeChanged):
* WebKitSupport/InputHandler.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110175 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp
Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.h

index 3bb62a5..e47b5b6 100644 (file)
@@ -1,3 +1,25 @@
+2012-03-08  Mike Fenton  <mifenton@rim.com>
+
+        [BlackBerry] Always use the current focused node when processing focus changes
+        https://bugs.webkit.org/show_bug.cgi?id=80594
+
+        Reviewed by Antonio Gomes.
+
+        Update InputHandler focused node handling to strictly use
+        the currently focused node.  This prevents a handling loop
+        when JS is modifying the focus and we get a late notification
+        of a past change from ChromeClientBlackBerry with the previously
+        unfocused node.
+
+        * WebCoreSupport/ChromeClientBlackBerry.cpp:
+        (WebCore::ChromeClientBlackBerry::focusedNodeChanged):
+        * WebCoreSupport/EditorClientBlackBerry.cpp:
+        (WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):
+        (WebCore::EditorClientBlackBerry::setInputMethodState):
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::focusedNodeChanged):
+        * WebKitSupport/InputHandler.h:
+
 2012-03-07  Jacky Jiang  <zhajiang@rim.com>
 
         [BlackBerry] WebKit rendering problem when show/hide VKB
index bd93460..ee1f28f 100644 (file)
@@ -188,9 +188,9 @@ void ChromeClientBlackBerry::takeFocus(FocusDirection)
     notImplemented();
 }
 
-void ChromeClientBlackBerry::focusedNodeChanged(Node* node)
+void ChromeClientBlackBerry::focusedNodeChanged(Node*)
 {
-    m_webPagePrivate->m_inputHandler->nodeFocused(node);
+    m_webPagePrivate->m_inputHandler->focusedNodeChanged();
 }
 
 void ChromeClientBlackBerry::focusedFrameChanged(Frame*)
index 0e4441d..5d0ea36 100644 (file)
@@ -193,11 +193,9 @@ bool EditorClientBlackBerry::shouldChangeSelectedRange(Range* fromRange, Range*
         if (frame->document()->focusedNode() && frame->document()->focusedNode()->hasTagName(HTMLNames::selectTag))
             return false;
 
-        // Update the focus state to re-show the keyboard if needed.
-        // FIXME, this should be removed and strictly be a show keyboard call if
-        // focus is active.
-        if (m_webPagePrivate->m_inputHandler->isInputMode())
-            m_webPagePrivate->m_inputHandler->nodeFocused(frame->document()->focusedNode());
+        // Check if this change does not represent a focus change and input is active and if so ensure the keyboard is visible.
+        if (m_webPagePrivate->m_inputHandler->isInputMode() && (fromRange->startContainer() == toRange->startContainer()))
+            m_webPagePrivate->m_inputHandler->notifyClientOfKeyboardVisibilityChange(true);
     }
 
     return true;
@@ -604,25 +602,9 @@ void EditorClientBlackBerry::willSetInputMethodState()
     notImplemented();
 }
 
-void EditorClientBlackBerry::setInputMethodState(bool active)
+void EditorClientBlackBerry::setInputMethodState(bool)
 {
-    Frame* frame = m_webPagePrivate->focusedOrMainFrame();
-    // Determines whether or not to provide input assistance. Password fields
-    // do not have this flag active, so it needs to be overridden.
-    if (frame && frame->document()) {
-        if (Node* focusNode = frame->document()->focusedNode()) {
-            if (!active && focusNode->hasTagName(HTMLNames::inputTag)
-                && static_cast<HTMLInputElement*>(focusNode)->isPasswordField())
-                    active = true;
-
-            if (active) {
-                m_webPagePrivate->m_inputHandler->nodeFocused(focusNode);
-                return;
-            }
-        }
-    }
-    // No frame or document or a node that doesn't support IME.
-    m_webPagePrivate->m_inputHandler->nodeFocused(0);
+    m_webPagePrivate->m_inputHandler->focusedNodeChanged();
 }
 
 } // namespace WebCore
index b2d2a8c..a336228 100644 (file)
@@ -222,8 +222,15 @@ BlackBerryInputType InputHandler::elementType(Element* element) const
     return InputTypeTextArea;
 }
 
-void InputHandler::nodeFocused(Node* node)
+void InputHandler::focusedNodeChanged()
 {
+    ASSERT(m_webPage->m_page->focusController());
+    Frame* frame = m_webPage->m_page->focusController()->focusedOrMainFrame();
+    if (!frame || !frame->document())
+        return;
+
+    Node* node = frame->document()->focusedNode();
+
     if (isActiveTextEdit() && m_currentFocusElement == node) {
         notifyClientOfKeyboardVisibilityChange(true);
         return;
index 0f4cdd3..94c93ff 100644 (file)
@@ -57,7 +57,7 @@ public:
     enum FocusElementType { TextEdit, TextPopup /* Date/Time & Color */, SelectPopup, Plugin };
     enum CaretScrollType { CenterAlways, CenterIfNeeded, EdgeIfNeeded };
 
-    void nodeFocused(WebCore::Node*);
+    void focusedNodeChanged();
     void nodeTextChanged(const WebCore::Node*);
     void selectionChanged();
     void frameUnloaded(const WebCore::Frame*);