+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
: 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)
{
}
void InputHandler::nodeFocused(Node* node)
{
if (isActiveTextEdit() && m_currentFocusElement == node) {
- setNavigationMode(true);
+ notifyClientOfKeyboardVisibilityChange(true);
return;
}
// 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();
}
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());
}
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)
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()
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())
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&);
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);
RefPtr<WebCore::Element> m_currentFocusElement;
bool m_processingChange;
- bool m_navigationMode;
bool m_changingFocus;
FocusElementType m_currentFocusElementType;
int m_composingTextStart;
int m_composingTextEnd;
- PendingKeyboardStateChange m_pendingKeyboardStateChange;
- bool m_delayClientNotificationOfNavigationModeChange;
+ PendingKeyboardStateChange m_pendingKeyboardVisibilityChange;
+ bool m_delayKeyboardVisibilityChange;
};
}
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.
// 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();
}
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) {