Diff
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (110629 => 110630)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-03-13 22:57:43 UTC (rev 110630)
@@ -842,6 +842,9 @@
toggleTextReflowIfEnabledForBlockZoomOnly();
#endif
+ // Notify InputHandler of state change.
+ m_inputHandler->enableInputMode(false);
+
// Set the scroll to origin here and notify the client since we'll be
// zooming below without any real contents yet thus the contents size
// we report to the client could make our current scroll position invalid.
@@ -3528,6 +3531,7 @@
}
if (mouseEvent.eventType() == MouseEventPressed) {
+ m_inputHandler->enableInputMode();
if (m_inputHandler->willOpenPopupForNode(node)) {
// Do not allow any human generated mouse or keyboard events to select <option>s in the list box
// because we use a pop up dialog to handle the actual selections. This prevents options from
Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (110629 => 110630)
--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2012-03-13 22:57:43 UTC (rev 110630)
@@ -129,7 +129,7 @@
virtual void drawTapHighlight(const Platform::IntRectRegion&, int red, int green, int blue, int alpha, bool hideAfterScroll) = 0;
virtual void hideTapHighlight() = 0;
- virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle, bool waitForExplicitKeyboardShowCall) = 0;
+ virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle) = 0;
virtual void inputFocusLost() = 0;
virtual void inputTextChanged() = 0;
virtual void inputSelectionChanged(unsigned selectionStart, unsigned selectionEnd) = 0;
Modified: trunk/Source/WebKit/blackberry/ChangeLog (110629 => 110630)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-03-13 22:57:43 UTC (rev 110630)
@@ -1,3 +1,44 @@
+2012-03-13 Mike Fenton <[email protected]>
+
+ [BlackBerry] Input focus state should unfocus the frame selection instead of the field.
+ https://bugs.webkit.org/show_bug.cgi?id=81023
+
+ Reviewed by Antonio Gomes.
+
+ PR 137400.
+
+ Prevent cursor drawing by unfocusing the frame selection
+ when input mode is not ready.
+
+ Greatly simplify the decision to focus input fields by removing
+ all ties to the page load state and base it on input. Input mode
+ is disabled when a page load begins and enabled on any user input.
+
+ The field is focused and ready for input immediately, only the
+ frame selection (or cursor) is unfocused.
+
+ Reviewed Internally by Gen Mak, Antonio Gomes and Nima Ghanavatian.
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::setLoadState):
+ (BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
+ * Api/WebPageClient.h:
+ * WebCoreSupport/EditorClientBlackBerry.cpp:
+ (WebCore::EditorClientBlackBerry::shouldBeginEditing):
+ * WebKitSupport/InputHandler.cpp:
+ (BlackBerry::WebKit::InputHandler::InputHandler):
+ (BlackBerry::WebKit::InputHandler::setElementUnfocused):
+ (BlackBerry::WebKit::InputHandler::enableInputMode):
+ (BlackBerry::WebKit::InputHandler::setElementFocused):
+ (BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
+ (BlackBerry::WebKit::InputHandler::notifyClientOfKeyboardVisibilityChange):
+ (BlackBerry::WebKit::InputHandler::handleKeyboardInput):
+ (BlackBerry::WebKit::InputHandler::setComposingText):
+ * WebKitSupport/InputHandler.h:
+ (InputHandler):
+ * WebKitSupport/TouchEventHandler.cpp:
+ (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
+
2012-03-13 Adam Barth <[email protected]> && Benjamin Poulain <[email protected]>
Always enable ENABLE(CLIENT_BASED_GEOLOCATION)
Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp (110629 => 110630)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp 2012-03-13 22:57:43 UTC (rev 110630)
@@ -159,7 +159,7 @@
if (m_webPagePrivate->m_dumpRenderTree)
return m_webPagePrivate->m_dumpRenderTree->shouldBeginEditingInDOMRange(range);
- return m_webPagePrivate->m_inputHandler->shouldAcceptInputFocus();
+ return true;
}
bool EditorClientBlackBerry::shouldEndEditing(Range* range)
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (110629 => 110630)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-03-13 22:57:43 UTC (rev 110630)
@@ -109,6 +109,7 @@
InputHandler::InputHandler(WebPagePrivate* page)
: m_webPage(page)
, m_currentFocusElement(0)
+ , m_inputModeEnabled(false)
, m_processingChange(false)
, m_changingFocus(false)
, m_currentFocusElementType(TextEdit)
@@ -406,6 +407,10 @@
m_webPage->m_client->inputFocusLost();
m_webPage->m_selectionHandler->selectionPositionChanged();
+
+ // If the frame selection isn't focused, focus it.
+ if (!m_currentFocusElement->document()->frame()->selection()->isFocused())
+ m_currentFocusElement->document()->frame()->selection()->setFocused(true);
}
// Clear the node details.
@@ -413,43 +418,22 @@
m_currentFocusElementType = TextEdit;
}
-bool InputHandler::shouldAcceptInputFocus()
+void InputHandler::enableInputMode(bool inputModeAllowed)
{
- // If the DRT is running, always accept focus.
- if (m_webPage->m_dumpRenderTree)
- return true;
+ FocusLog(LogLevelInfo, "InputHandler::enableInputMode %s, override is %s"
+ , inputModeAllowed ? "true" : "false"
+ , m_webPage->m_dumpRenderTree || Platform::Settings::get()->alwaysShowKeyboardOnFocus() ? "true" : "false");
- if (Platform::Settings::get()->alwaysShowKeyboardOnFocus()) {
- FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus alwaysShowKeyboardOnFocus is active.");
- return true;
- }
+ m_inputModeEnabled = inputModeAllowed;
- Frame* focusedFrame = m_webPage->focusedOrMainFrame();
- if (!focusedFrame) {
- FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Frame not valid.");
- return false;
- }
+ // If DRT is running or always show keyboard setting is active, do not delay
+ // showing the keyboard.
+ if (m_webPage->m_dumpRenderTree || Platform::Settings::get()->alwaysShowKeyboardOnFocus())
+ m_inputModeEnabled = true;
- // Any user action should be respected. Mouse will be down when touch is
- // used to focus.
- if (focusedFrame->eventHandler()->mousePressed()) {
- FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Mouse is pressed focusing.");
- return true;
- }
-
- if (!m_webPage->m_client->hasKeyboardFocus()) {
- FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Client does not have input focus.");
- return false;
- }
-
- if (m_webPage->isLoading()) {
- FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Webpage is loading.");
- return false;
- }
-
- // Make sure the focused frame is not processing load events.
- FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus returning state of processingLoadEvent (%s).", !focusedFrame->document()->processingLoadEvent() ? "true" : "false");
- return !focusedFrame->document()->processingLoadEvent();
+ // If the frame selection isn't focused, focus it.
+ if (m_inputModeEnabled && isActiveTextEdit() && !m_currentFocusElement->document()->frame()->selection()->isFocused())
+ m_currentFocusElement->document()->frame()->selection()->setFocused(true);
}
void InputHandler::setElementFocused(Element* element)
@@ -457,17 +441,8 @@
ASSERT(DOMSupport::isTextBasedContentEditableElement(element));
ASSERT(element->document() && element->document()->frame());
- if (!m_changingFocus && !shouldAcceptInputFocus()) {
- // Remove the focus from this element, but guard against recursion by
- // allowing a refocus during the blur to continue.
- // THIS IS A HACK that needs to be fixed. Instead of blur the field,
- // the frame or frame selection should be blurred. Google bypasses these
- // though so it can't be done right now.
- m_changingFocus = true;
- element->blur();
- m_changingFocus = false;
- return;
- }
+ if (element->document()->frame()->selection()->isFocused() != m_inputModeEnabled)
+ element->document()->frame()->selection()->setFocused(m_inputModeEnabled);
// Clear the existing focus node details.
setElementUnfocused(true /*refocusOccuring*/);
@@ -481,12 +456,12 @@
m_currentFocusElementTextEditMask = inputStyle(type, element);
FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d", type, m_currentFocusElementTextEditMask);
+ m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask);
- m_webPage->m_client->inputFocusGained(type,
- m_currentFocusElementTextEditMask,
- m_delayKeyboardVisibilityChange /* wait for explicit keyboard show call */);
-
handleInputLocaleChanged(m_webPage->m_webSettings->isWritingDirectionRTL());
+
+ if (!m_delayKeyboardVisibilityChange)
+ notifyClientOfKeyboardVisibilityChange(true);
}
bool InputHandler::openDatePopup(HTMLInputElement* element, BlackBerryInputType type)
@@ -552,7 +527,7 @@
void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
{
- if (!m_currentFocusElement || !m_currentFocusElement->document())
+ if (!m_inputModeEnabled || !m_currentFocusElement || !m_currentFocusElement->document())
return;
if (!Platform::Settings::get()->allowCenterScrollAdjustmentForInputFields() && scrollType != EdgeIfNeeded)
@@ -754,6 +729,10 @@
void InputHandler::notifyClientOfKeyboardVisibilityChange(bool visible)
{
+ // If we aren't ready for input, keyboard changes should be ignored.
+ if (!m_inputModeEnabled && visible)
+ return;
+
if (!m_delayKeyboardVisibilityChange) {
m_webPage->showVirtualKeyboard(visible);
return;
@@ -909,6 +888,9 @@
{
InputLog(LogLevelInfo, "InputHandler::handleKeyboardInput received character=%lc, type=%d", keyboardEvent.character(), keyboardEvent.type());
+ // Enable input mode if we are processing a key event.
+ enableInputMode();
+
// If we aren't specifically part of a composition, fail, IMF should never send key input
// while composing text. If IMF has failed, we should have already finished the
// composition manually.
@@ -1689,6 +1671,9 @@
InputLog(LogLevelInfo, "InputHandler::setComposingText at relativeCursorPosition: %d", relativeCursorPosition);
+ // Enable input mode if we are processing a key event.
+ enableInputMode();
+
return setSpannableTextAndRelativeCursor(spannableString, relativeCursorPosition, true /* markTextAsComposing */) ? 0 : -1;
}
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h (110629 => 110630)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h 2012-03-13 22:57:43 UTC (rev 110630)
@@ -57,6 +57,8 @@
enum FocusElementType { TextEdit, TextPopup /* Date/Time & Color */, SelectPopup, Plugin };
enum CaretScrollType { CenterAlways, CenterIfNeeded, EdgeIfNeeded };
+ void enableInputMode(bool inputModeAllowed = true);
+
void focusedNodeChanged();
void nodeTextChanged(const WebCore::Node*);
void selectionChanged();
@@ -116,8 +118,6 @@
int32_t setComposingText(spannable_string_t*, int32_t relativeCursorPosition);
int32_t commitText(spannable_string_t*, int32_t relativeCursorPosition);
- bool shouldAcceptInputFocus();
-
private:
enum PendingKeyboardStateChange { NoChange, Visible, NotVisible };
@@ -177,6 +177,7 @@
WebPagePrivate* m_webPage;
RefPtr<WebCore::Element> m_currentFocusElement;
+ bool m_inputModeEnabled;
bool m_processingChange;
bool m_changingFocus;
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp (110629 => 110630)
--- trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp 2012-03-13 22:53:35 UTC (rev 110629)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp 2012-03-13 22:57:43 UTC (rev 110630)
@@ -174,6 +174,9 @@
bool TouchEventHandler::handleTouchPoint(Platform::TouchPoint& point)
{
+ // Enable input mode on any touch event.
+ m_webPage->m_inputHandler->enableInputMode();
+
switch (point.m_state) {
case Platform::TouchPoint::TouchPressed:
{