Title: [108702] trunk/Source/WebKit/blackberry
Revision
108702
Author
[email protected]
Date
2012-02-23 17:27:16 -0800 (Thu, 23 Feb 2012)

Log Message

[BlackBerry] InputHandler requires cleanup of Navigation Mode handling.
https://bugs.webkit.org/show_bug.cgi?id=79366

Patch by Mike Fenton <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (108701 => 108702)


--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-02-24 01:25:05 UTC (rev 108701)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-02-24 01:27:16 UTC (rev 108702)
@@ -171,9 +171,10 @@
     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;
 

Modified: trunk/Source/WebKit/blackberry/ChangeLog (108701 => 108702)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-02-24 01:25:05 UTC (rev 108701)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-02-24 01:27:16 UTC (rev 108702)
@@ -1,3 +1,40 @@
+2012-02-23  Mike Fenton  <[email protected]>
+
+        [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  <[email protected]>
 
         Remove the remaining uses of CSSStyleDeclaration in Editor

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (108701 => 108702)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-02-24 01:25:05 UTC (rev 108701)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-02-24 01:27:16 UTC (rev 108702)
@@ -110,14 +110,13 @@
     : 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 @@
 void InputHandler::nodeFocused(Node* node)
 {
     if (isActiveTextEdit() && m_currentFocusElement == node) {
-        setNavigationMode(true);
+        notifyClientOfKeyboardVisibilityChange(true);
         return;
     }
 
@@ -394,10 +393,10 @@
         // 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 @@
 
     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::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 @@
     setElementUnfocused(false /*refocusOccuring*/);
 }
 
-void InputHandler::setNavigationMode(bool active, bool sendMessage)
+void InputHandler::setDelayKeyboardVisibilityChange(bool value)
 {
-    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);
+    m_delayKeyboardVisibilityChange = value;
+    m_pendingKeyboardVisibilityChange = NoChange;
 }
 
-void InputHandler::setDelayClientNotificationOfNavigationModeChange(bool value)
+void InputHandler::processPendingKeyboardVisibilityChange()
 {
-    m_delayClientNotificationOfNavigationModeChange = value;
-    m_pendingKeyboardStateChange = NoChange;
-}
-
-void InputHandler::processPendingClientNavigationModeChangeNotification()
-{
-    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 @@
     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())

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h (108701 => 108702)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h	2012-02-24 01:25:05 UTC (rev 108701)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h	2012-02-24 01:27:16 UTC (rev 108702)
@@ -63,7 +63,6 @@
     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 @@
 
     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 @@
     RefPtr<WebCore::Element> m_currentFocusElement;
 
     bool m_processingChange;
-    bool m_navigationMode;
     bool m_changingFocus;
 
     FocusElementType m_currentFocusElementType;
@@ -191,8 +187,8 @@
     int m_composingTextStart;
     int m_composingTextEnd;
 
-    PendingKeyboardStateChange m_pendingKeyboardStateChange;
-    bool m_delayClientNotificationOfNavigationModeChange;
+    PendingKeyboardStateChange m_pendingKeyboardVisibilityChange;
+    bool m_delayKeyboardVisibilityChange;
 };
 
 }

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp (108701 => 108702)


--- trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp	2012-02-24 01:25:05 UTC (rev 108701)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp	2012-02-24 01:27:16 UTC (rev 108702)
@@ -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 @@
 
     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 @@
     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.

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp (108701 => 108702)


--- trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp	2012-02-24 01:25:05 UTC (rev 108701)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp	2012-02-24 01:27:16 UTC (rev 108702)
@@ -122,7 +122,7 @@
 
 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 @@
             // 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 @@
         }
     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) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to