[BlackBerry] InputHandler requires cleanup of Navigation Mode handling.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 01:27:16 +0000 (01:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2012 01:27:16 +0000 (01:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79366

Patch by Mike Fenton <mifenton@rim.com> on 2012-02-23
Reviewed by Rob Buis.

Cleanup InputHandler navigation based code.

1) Remove the concept of NavigationMode and replace it
   with simple showKeyboard calls.

2) Remove navigation move events and replace with standard
   key events.

3) Standardize function/variable names and remove obsolete
   functions.

* Api/WebPageClient.h:
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::InputHandler):
(BlackBerry::WebKit::InputHandler::nodeFocused):
(BlackBerry::WebKit::InputHandler::setElementUnfocused):
(BlackBerry::WebKit::InputHandler::setElementFocused):
(BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
(BlackBerry::WebKit::InputHandler::setDelayKeyboardVisibilityChange):
(BlackBerry::WebKit::InputHandler::processPendingKeyboardVisibilityChange):
(BlackBerry::WebKit::InputHandler::notifyClientOfKeyboardVisibilityChange):
* WebKitSupport/InputHandler.h:
(InputHandler):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::setCaretPosition):
(BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
* WebKitSupport/TouchEventHandler.cpp:
(BlackBerry::WebKit::TouchEventHandler::touchEventCancel):
(BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):

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

Source/WebKit/blackberry/Api/WebPageClient.h
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.h
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp

index 0803c08..02839c0 100644 (file)
@@ -171,9 +171,10 @@ public:
     virtual void inputFocusLost() = 0;
     virtual void inputTextChanged() = 0;
     virtual void inputSelectionChanged(unsigned selectionStart, unsigned selectionEnd) = 0;
-    virtual void inputSetNavigationMode(bool) = 0;
     virtual void inputLearnText(wchar_t* text, int length) = 0;
 
+    virtual void showVirtualKeyboard(bool) = 0;
+
     virtual void checkSpellingOfString(const unsigned short* text, int length, int& misspellingLocation, int& misspellingLength) = 0;
     virtual void requestSpellingSuggestionsForString(unsigned start, unsigned end) = 0;
 
index db8b410..759ec91 100644 (file)
@@ -1,3 +1,40 @@
+2012-02-23  Mike Fenton  <mifenton@rim.com>
+
+        [BlackBerry] InputHandler requires cleanup of Navigation Mode handling.
+        https://bugs.webkit.org/show_bug.cgi?id=79366
+
+        Reviewed by Rob Buis.
+
+        Cleanup InputHandler navigation based code.
+
+        1) Remove the concept of NavigationMode and replace it
+           with simple showKeyboard calls.
+
+        2) Remove navigation move events and replace with standard
+           key events.
+
+        3) Standardize function/variable names and remove obsolete
+           functions.
+
+        * Api/WebPageClient.h:
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::InputHandler):
+        (BlackBerry::WebKit::InputHandler::nodeFocused):
+        (BlackBerry::WebKit::InputHandler::setElementUnfocused):
+        (BlackBerry::WebKit::InputHandler::setElementFocused):
+        (BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
+        (BlackBerry::WebKit::InputHandler::setDelayKeyboardVisibilityChange):
+        (BlackBerry::WebKit::InputHandler::processPendingKeyboardVisibilityChange):
+        (BlackBerry::WebKit::InputHandler::notifyClientOfKeyboardVisibilityChange):
+        * WebKitSupport/InputHandler.h:
+        (InputHandler):
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::setCaretPosition):
+        (BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
+        * WebKitSupport/TouchEventHandler.cpp:
+        (BlackBerry::WebKit::TouchEventHandler::touchEventCancel):
+        (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
+
 2012-02-21  Ryosuke Niwa  <rniwa@webkit.org>
 
         Remove the remaining uses of CSSStyleDeclaration in Editor
index 8caa45b..27b941e 100644 (file)
@@ -110,14 +110,13 @@ InputHandler::InputHandler(WebPagePrivate* page)
     : m_webPage(page)
     , m_currentFocusElement(0)
     , m_processingChange(false)
-    , m_navigationMode(false)
     , m_changingFocus(false)
     , m_currentFocusElementType(TextEdit)
     , m_currentFocusElementTextEditMask(DEFAULT_STYLE)
     , m_composingTextStart(0)
     , m_composingTextEnd(0)
-    , m_pendingKeyboardStateChange(NoChange)
-    , m_delayClientNotificationOfNavigationModeChange(false)
+    , m_pendingKeyboardVisibilityChange(NoChange)
+    , m_delayKeyboardVisibilityChange(false)
 {
 }
 
@@ -226,7 +225,7 @@ BlackBerryInputType InputHandler::elementType(Element* element) const
 void InputHandler::nodeFocused(Node* node)
 {
     if (isActiveTextEdit() && m_currentFocusElement == node) {
-        setNavigationMode(true);
+        notifyClientOfKeyboardVisibilityChange(true);
         return;
     }
 
@@ -394,10 +393,10 @@ void InputHandler::setElementUnfocused(bool refocusOccuring)
         // End any composition that is in progress.
         finishComposition();
 
-        // Send change notifications. Only cancel navigation mode if we are not
-        // refocusing to avoid flashing the keyboard when switching between two
-        // input fields.
-        setNavigationMode(false, !refocusOccuring);
+        // Only hide the keyboard if we aren't refocusing on a new input field.
+        if (!refocusOccuring)
+            notifyClientOfKeyboardVisibilityChange(false);
+
         m_webPage->m_client->inputFocusLost();
         m_webPage->m_selectionHandler->selectionPositionChanged();
     }
@@ -478,8 +477,7 @@ void InputHandler::setElementFocused(Element* element)
 
     m_webPage->m_client->inputFocusGained(type,
                                           m_currentFocusElementTextEditMask,
-                                          m_delayClientNotificationOfNavigationModeChange /* wait an explicit keyboard show call */);
-    m_navigationMode = true;
+                                          m_delayKeyboardVisibilityChange /* wait for explicit keyboard show call */);
 
     handleInputLocaleChanged(m_webPage->m_webSettings->isWritingDirectionRTL());
 }
@@ -547,7 +545,7 @@ void InputHandler::nodeTextChanged(const Node* node)
 
 void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
 {
-    if (!m_currentFocusElement || !m_navigationMode || !m_currentFocusElement->document())
+    if (!m_currentFocusElement || !m_currentFocusElement->document())
         return;
 
     if (!BlackBerry::Platform::Settings::get()->allowCenterScrollAdjustmentForInputFields() && scrollType != EdgeIfNeeded)
@@ -725,66 +723,36 @@ void InputHandler::frameUnloaded(Frame* frame)
     setElementUnfocused(false /*refocusOccuring*/);
 }
 
-void InputHandler::setNavigationMode(bool active, bool sendMessage)
-{
-    if (active && !isActiveTextEdit()) {
-        if (!m_navigationMode)
-            return;
-
-        // We can't be active if there is no element. Send out notification that we
-        // aren't in navigation mode.
-        active = false;
-    }
-
-    // Don't send the change if it's setting the event setting navigationMode true
-    // if we are already in navigation mode and this is a navigation move event.
-    // We need to send the event when it's triggered by a touch event or mouse
-    // event to allow display of the VKB, but do not want to send it when it's
-    // triggered by a navigation event as it has no effect.
-    // Touch events are simulated as mouse events so mousePressed will be active
-    // when it is a re-entry event.
-    // See RIM Bugs #369 & #878.
-    if (active && active == m_navigationMode && !m_webPage->m_mainFrame->eventHandler()->mousePressed())
-        return;
-
-    m_navigationMode = active;
-
-    InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::setNavigationMode %s, %s", active ? "true" : "false", sendMessage ? "message sent" : "message not sent");
-
-    if (sendMessage)
-        notifyClientOfNavigationModeChange(active);
-}
-
-void InputHandler::setDelayClientNotificationOfNavigationModeChange(bool value)
+void InputHandler::setDelayKeyboardVisibilityChange(bool value)
 {
-    m_delayClientNotificationOfNavigationModeChange = value;
-    m_pendingKeyboardStateChange = NoChange;
+    m_delayKeyboardVisibilityChange = value;
+    m_pendingKeyboardVisibilityChange = NoChange;
 }
 
-void InputHandler::processPendingClientNavigationModeChangeNotification()
+void InputHandler::processPendingKeyboardVisibilityChange()
 {
-    if (!m_delayClientNotificationOfNavigationModeChange) {
-        ASSERT(m_pendingKeyboardStateChange == NoChange);
+    if (!m_delayKeyboardVisibilityChange) {
+        ASSERT(m_pendingKeyboardVisibilityChange == NoChange);
         return;
     }
 
-    m_delayClientNotificationOfNavigationModeChange = false;
+    m_delayKeyboardVisibilityChange = false;
 
-    if (m_pendingKeyboardStateChange == NoChange)
+    if (m_pendingKeyboardVisibilityChange == NoChange)
         return;
 
-    notifyClientOfNavigationModeChange(m_pendingKeyboardStateChange == Visible);
-    m_pendingKeyboardStateChange = NoChange;
+    notifyClientOfKeyboardVisibilityChange(m_pendingKeyboardVisibilityChange == Visible);
+    m_pendingKeyboardVisibilityChange = NoChange;
 }
 
-void InputHandler::notifyClientOfNavigationModeChange(bool active)
+void InputHandler::notifyClientOfKeyboardVisibilityChange(bool visible)
 {
-    if (!m_delayClientNotificationOfNavigationModeChange) {
-        m_webPage->m_client->inputSetNavigationMode(active);
+    if (!m_delayKeyboardVisibilityChange) {
+        m_webPage->showVirtualKeyboard(visible);
         return;
     }
 
-    m_pendingKeyboardStateChange = active ? Visible : NotVisible;
+    m_pendingKeyboardVisibilityChange = visible ? Visible : NotVisible;
 }
 
 bool InputHandler::selectionAtStartOfElement()
@@ -971,68 +939,6 @@ bool InputHandler::handleKeyboardInput(const BlackBerry::Platform::KeyboardEvent
     return keyboardEventHandled;
 }
 
-bool InputHandler::handleNavigationMove(unsigned short character, bool shiftDown, bool altDown, bool canExitField)
-{
-    InputLog(BlackBerry::Platform::LogLevelInfo, "InputHandler::handleNavigationMove received character=%lc", character);
-
-    bool eventHandled = false;
-    ASSERT(m_webPage->m_page->focusController());
-    if (Frame* focusedFrame = m_webPage->m_page->focusController()->focusedFrame()) {
-        // If alt is down, do not break out of the field.
-        if (canExitField && !altDown) {
-            if ((character == KEYCODE_LEFT || character == KEYCODE_UP) && selectionAtStartOfElement()
-                || (character == KEYCODE_RIGHT || character == KEYCODE_DOWN) && selectionAtEndOfElement()) {
-                setNavigationMode(false);
-                return true;
-            }
-        }
-
-        switch (character) {
-        case KEYCODE_LEFT:
-            if (altDown && shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveToBeginningOfLineAndModifySelection").execute();
-            else if (altDown)
-                eventHandled = focusedFrame->editor()->command("MoveToBeginningOfLine").execute();
-            else if (shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveLeftAndModifySelection").execute();
-            else
-                eventHandled = focusedFrame->editor()->command("MoveLeft").execute();
-            break;
-        case KEYCODE_RIGHT:
-            if (altDown && shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveToEndOfLineAndModifySelection").execute();
-            else if (altDown)
-                eventHandled = focusedFrame->editor()->command("MoveToEndOfLine").execute();
-            else if (shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveRightAndModifySelection").execute();
-            else
-                eventHandled = focusedFrame->editor()->command("MoveRight").execute();
-            break;
-        case KEYCODE_UP:
-            if (altDown && shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveToBeginningOfDocumentAndModifySelection").execute();
-            else if (altDown)
-                eventHandled = focusedFrame->editor()->command("MoveToBeginningOfDocument").execute();
-            else if (shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveUpAndModifySelection").execute();
-            else
-                eventHandled = focusedFrame->editor()->command("MoveUp").execute();
-            break;
-        case KEYCODE_DOWN:
-            if (altDown && shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveToEndOfDocumentAndModifySelection").execute();
-            else if (altDown)
-                eventHandled = focusedFrame->editor()->command("MoveToEndOfDocument").execute();
-            else if (shiftDown)
-                eventHandled = focusedFrame->editor()->command("MoveDownAndModifySelection").execute();
-            else
-                eventHandled = focusedFrame->editor()->command("MoveDown").execute();
-            break;
-        }
-    }
-    return eventHandled;
-}
-
 bool InputHandler::deleteSelection()
 {
     if (!isActiveTextEdit())
index 6adb9b4..1b64a78 100644 (file)
@@ -63,7 +63,6 @@ public:
     void frameUnloaded(WebCore::Frame*);
 
     bool handleKeyboardInput(const BlackBerry::Platform::KeyboardEvent&, bool changeIsPartOfComposition = false);
-    bool handleNavigationMove(const unsigned short character, bool shiftDown, bool altDown, bool canExitField = true);
 
     bool deleteSelection();
     void insertText(const WTF::String&);
@@ -77,16 +76,14 @@ public:
 
     void setInputValue(const WTF::String&);
 
-    void setDelayClientNotificationOfNavigationModeChange(bool value);
-    void processPendingClientNavigationModeChangeNotification();
+    void setDelayKeyboardVisibilityChange(bool value);
+    void processPendingKeyboardVisibilityChange();
 
-    void notifyClientOfNavigationModeChange(bool active);
+    void notifyClientOfKeyboardVisibilityChange(bool visible);
 
     bool isInputMode() const { return isActiveTextEdit(); }
     bool isMultilineInputMode() const { return isActiveTextEdit() && elementType(m_currentFocusElement.get()) == BlackBerry::Platform::InputTypeTextArea; }
 
-    void setNavigationMode(bool active, bool sendMessage = true);
-
     void ensureFocusElementVisible(bool centerFieldInDisplay = true);
     void handleInputLocaleChanged(bool isRTL);
 
@@ -182,7 +179,6 @@ private:
     RefPtr<WebCore::Element> m_currentFocusElement;
 
     bool m_processingChange;
-    bool m_navigationMode;
     bool m_changingFocus;
 
     FocusElementType m_currentFocusElementType;
@@ -191,8 +187,8 @@ private:
     int m_composingTextStart;
     int m_composingTextEnd;
 
-    PendingKeyboardStateChange m_pendingKeyboardStateChange;
-    bool m_delayClientNotificationOfNavigationModeChange;
+    PendingKeyboardStateChange m_pendingKeyboardVisibilityChange;
+    bool m_delayKeyboardVisibilityChange;
 };
 
 }
index ab2ddf8..5577692 100644 (file)
@@ -43,6 +43,8 @@
 #include "htmlediting.h"
 #include "visible_units.h"
 
+#include <BlackBerryPlatformKeyboardEvent.h>
+
 #include <sys/keycodes.h>
 
 #define SHOWDEBUG_SELECTIONHANDLER 0
@@ -221,7 +223,7 @@ void SelectionHandler::setCaretPosition(const IntPoint &position)
 
     if (!DOMSupport::isPositionInNode(m_webPage->focusedOrMainFrame()->document()->focusedNode(), visibleCaretPosition.deepEquivalent())) {
         if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
-            m_webPage->m_inputHandler->handleNavigationMove(character, false /* shiftDown */, false /* altDown */, false /* canExitField */);
+            m_webPage->m_inputHandler->handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(character));
 
         selectionPositionChanged();
         return;
@@ -398,10 +400,10 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti
     if (!character)
         return false;
 
-    DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setSelection making selection change attempt using navigation");
+    DEBUG_SELECTION(BlackBerry::Platform::LogLevelInfo, "SelectionHandler::setSelection making selection change attempt using key event %d", character);
 
     if (shouldExtendSelectionInDirection(controller->selection(), character))
-        m_webPage->m_inputHandler->handleNavigationMove(character, true /* shiftDown */, false /* altDown */, false /* canExitField */);
+        m_webPage->m_inputHandler->handleKeyboardInput(BlackBerry::Platform::KeyboardEvent(character, BlackBerry::Platform::KeyboardEvent::KeyDown, KEYMOD_SHIFT));
 
     // Must send the selectionPositionChanged every time, sometimes this will duplicate but an accepted
     // handleNavigationMove may not make an actual selection change.
index bb63b2b..50ad9d4 100644 (file)
@@ -122,7 +122,7 @@ bool TouchEventHandler::shouldSuppressMouseDownOnTouchDown() const
 
 void TouchEventHandler::touchEventCancel()
 {
-    m_webPage->m_inputHandler->processPendingClientNavigationModeChangeNotification();
+    m_webPage->m_inputHandler->processPendingKeyboardVisibilityChange();
 
     if (!shouldSuppressMouseDownOnTouchDown()) {
         // Input elements delay mouse down and do not need to be released on touch cancel.
@@ -203,7 +203,7 @@ bool TouchEventHandler::handleTouchPoint(Platform::TouchPoint& point)
             // let only delay client notifications when there is not input text node involved.
             if (m_convertTouchToMouse
                 && (m_webPage->m_inputHandler->isInputMode() && !m_lastFatFingersResult.isTextInput())) {
-                m_webPage->m_inputHandler->setDelayClientNotificationOfNavigationModeChange(true);
+                m_webPage->m_inputHandler->setDelayKeyboardVisibilityChange(true);
                 handleFatFingerPressed();
             } else if (!shouldSuppressMouseDownOnTouchDown())
                 handleFatFingerPressed();
@@ -212,17 +212,20 @@ bool TouchEventHandler::handleTouchPoint(Platform::TouchPoint& point)
         }
     case Platform::TouchPoint::TouchReleased:
         {
-            m_webPage->m_inputHandler->processPendingClientNavigationModeChangeNotification();
+            // Apply any suppressed changes. This does not eliminate the need
+            // for the show after the handling of fat finger pressed as it may
+            // have triggered a state change.
+            m_webPage->m_inputHandler->processPendingKeyboardVisibilityChange();
 
             if (shouldSuppressMouseDownOnTouchDown())
                 handleFatFingerPressed();
 
             // The rebase has eliminated a necessary event when the mouse does not
             // trigger an actual selection change preventing re-showing of the
-            // keyboard. If input mode is active, call setNavigationMode which
+            // keyboard. If input mode is active, call showVirtualKeyboard which
             // will update the state and display keyboard if needed.
             if (m_webPage->m_inputHandler->isInputMode())
-                m_webPage->m_inputHandler->setNavigationMode(true);
+                m_webPage->m_inputHandler->notifyClientOfKeyboardVisibilityChange(true);
 
             IntPoint adjustedPoint;
             if (m_convertTouchToMouse) {