⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 110630 in webkit


Ignore:
Timestamp:
Mar 13, 2012, 3:57:43 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Input focus state should unfocus the frame selection instead of the field.
​https://bugs.webkit.org/show_bug.cgi?id=81023

Patch by Mike Fenton <​mifenton@rim.com> on 2012-03-13
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):

Location:
trunk/Source/WebKit/blackberry
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r110595 r110630  
    842842            toggleTextReflowIfEnabledForBlockZoomOnly();
    843843#endif
     844
     845            // Notify InputHandler of state change.
     846            m_inputHandler->enableInputMode(false);
    844847
    845848            // Set the scroll to origin here and notify the client since we'll be
    … …  
    35293532
    35303533    if (mouseEvent.eventType() == MouseEventPressed) {
     3534        m_inputHandler->enableInputMode();
    35313535        if (m_inputHandler->willOpenPopupForNode(node)) {
    35323536            // Do not allow any human generated mouse or keyboard events to select <option>s in the list box
  • trunk/Source/WebKit/blackberry/Api/WebPageClient.h

    r109959 r110630  
    130130    virtual void hideTapHighlight() = 0;
    131131
    132     virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle, bool waitForExplicitKeyboardShowCall) = 0;
     132    virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle) = 0;
    133133    virtual void inputFocusLost() = 0;
    134134    virtual void inputTextChanged() = 0;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r110595 r110630  
     12012-03-13  Mike Fenton  <mifenton@rim.com>
     2
     3        [BlackBerry] Input focus state should unfocus the frame selection instead of the field.
     4        https://bugs.webkit.org/show_bug.cgi?id=81023
     5
     6        Reviewed by Antonio Gomes.
     7
     8        PR 137400.
     9
     10        Prevent cursor drawing by unfocusing the frame selection
     11        when input mode is not ready.
     12
     13        Greatly simplify the decision to focus input fields by removing
     14        all ties to the page load state and base it on input.  Input mode
     15        is disabled when a page load begins and enabled on any user input.
     16
     17        The field is focused and ready for input immediately, only the
     18        frame selection (or cursor) is unfocused.
     19
     20        Reviewed Internally by Gen Mak, Antonio Gomes and Nima Ghanavatian.
     21
     22        * Api/WebPage.cpp:
     23        (BlackBerry::WebKit::WebPagePrivate::setLoadState):
     24        (BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
     25        * Api/WebPageClient.h:
     26        * WebCoreSupport/EditorClientBlackBerry.cpp:
     27        (WebCore::EditorClientBlackBerry::shouldBeginEditing):
     28        * WebKitSupport/InputHandler.cpp:
     29        (BlackBerry::WebKit::InputHandler::InputHandler):
     30        (BlackBerry::WebKit::InputHandler::setElementUnfocused):
     31        (BlackBerry::WebKit::InputHandler::enableInputMode):
     32        (BlackBerry::WebKit::InputHandler::setElementFocused):
     33        (BlackBerry::WebKit::InputHandler::ensureFocusTextElementVisible):
     34        (BlackBerry::WebKit::InputHandler::notifyClientOfKeyboardVisibilityChange):
     35        (BlackBerry::WebKit::InputHandler::handleKeyboardInput):
     36        (BlackBerry::WebKit::InputHandler::setComposingText):
     37        * WebKitSupport/InputHandler.h:
     38        (InputHandler):
     39        * WebKitSupport/TouchEventHandler.cpp:
     40        (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
     41
    1422012-03-13  Adam Barth  <abarth@webkit.org> && Benjamin Poulain  <bpoulain@apple.com>
    243
  • trunk/Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp

    r110230 r110630  
    160160        return m_webPagePrivate->m_dumpRenderTree->shouldBeginEditingInDOMRange(range);
    161161
    162     return m_webPagePrivate->m_inputHandler->shouldAcceptInputFocus();
     162    return true;
    163163}
    164164
  • trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp

    r110175 r110630  
    110110    : m_webPage(page)
    111111    , m_currentFocusElement(0)
     112    , m_inputModeEnabled(false)
    112113    , m_processingChange(false)
    113114    , m_changingFocus(false)
    … …  
    407408        m_webPage->m_client->inputFocusLost();
    408409        m_webPage->m_selectionHandler->selectionPositionChanged();
     410
     411        // If the frame selection isn't focused, focus it.
     412        if (!m_currentFocusElement->document()->frame()->selection()->isFocused())
     413            m_currentFocusElement->document()->frame()->selection()->setFocused(true);
    409414    }
    410415
    … …  
    414419}
    415420
    416 bool InputHandler::shouldAcceptInputFocus()
    417 {
    418     // If the DRT is running, always accept focus.
    419     if (m_webPage->m_dumpRenderTree)
    420         return true;
    421 
    422     if (Platform::Settings::get()->alwaysShowKeyboardOnFocus()) {
    423         FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus alwaysShowKeyboardOnFocus is active.");
    424         return true;
    425     }
    426 
    427     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
    428     if (!focusedFrame) {
    429         FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Frame not valid.");
    430         return false;
    431     }
    432 
    433     // Any user action should be respected. Mouse will be down when touch is
    434     // used to focus.
    435     if (focusedFrame->eventHandler()->mousePressed()) {
    436         FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Mouse is pressed focusing.");
    437         return true;
    438     }
    439 
    440     if (!m_webPage->m_client->hasKeyboardFocus()) {
    441         FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Client does not have input focus.");
    442         return false;
    443     }
    444 
    445     if (m_webPage->isLoading()) {
    446         FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus Webpage is loading.");
    447         return false;
    448     }
    449 
    450     // Make sure the focused frame is not processing load events.
    451     FocusLog(LogLevelInfo, "InputHandler::shouldAcceptInputFocus returning state of processingLoadEvent (%s).", !focusedFrame->document()->processingLoadEvent() ? "true" : "false");
    452     return !focusedFrame->document()->processingLoadEvent();
     421void InputHandler::enableInputMode(bool inputModeAllowed)
     422{
     423    FocusLog(LogLevelInfo, "InputHandler::enableInputMode %s, override is %s"
     424             , inputModeAllowed ? "true" : "false"
     425            , m_webPage->m_dumpRenderTree || Platform::Settings::get()->alwaysShowKeyboardOnFocus() ? "true" : "false");
     426
     427    m_inputModeEnabled = inputModeAllowed;
     428
     429    // If DRT is running or always show keyboard setting is active, do not delay
     430    // showing the keyboard.
     431    if (m_webPage->m_dumpRenderTree || Platform::Settings::get()->alwaysShowKeyboardOnFocus())
     432        m_inputModeEnabled = true;
     433
     434    // If the frame selection isn't focused, focus it.
     435    if (m_inputModeEnabled && isActiveTextEdit() && !m_currentFocusElement->document()->frame()->selection()->isFocused())
     436        m_currentFocusElement->document()->frame()->selection()->setFocused(true);
    453437}
    454438
    … …  
    458442    ASSERT(element->document() && element->document()->frame());
    459443
    460     if (!m_changingFocus && !shouldAcceptInputFocus()) {
    461         // Remove the focus from this element, but guard against recursion by
    462         // allowing a refocus during the blur to continue.
    463         // THIS IS A HACK that needs to be fixed. Instead of blur the field,
    464         // the frame or frame selection should be blurred. Google bypasses these
    465         // though so it can't be done right now.
    466         m_changingFocus = true;
    467         element->blur();
    468         m_changingFocus = false;
    469         return;
    470     }
     444    if (element->document()->frame()->selection()->isFocused() != m_inputModeEnabled)
     445        element->document()->frame()->selection()->setFocused(m_inputModeEnabled);
    471446
    472447    // Clear the existing focus node details.
    … …  
    482457
    483458    FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d", type, m_currentFocusElementTextEditMask);
    484 
    485     m_webPage->m_client->inputFocusGained(type,
    486                                           m_currentFocusElementTextEditMask,
    487                                           m_delayKeyboardVisibilityChange /* wait for explicit keyboard show call */);
     459    m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask);
    488460
    489461    handleInputLocaleChanged(m_webPage->m_webSettings->isWritingDirectionRTL());
     462
     463    if (!m_delayKeyboardVisibilityChange)
     464        notifyClientOfKeyboardVisibilityChange(true);
    490465}
    491466
    … …  
    553528void InputHandler::ensureFocusTextElementVisible(CaretScrollType scrollType)
    554529{
    555     if (!m_currentFocusElement || !m_currentFocusElement->document())
     530    if (!m_inputModeEnabled || !m_currentFocusElement || !m_currentFocusElement->document())
    556531        return;
    557532
    … …  
    755730void InputHandler::notifyClientOfKeyboardVisibilityChange(bool visible)
    756731{
     732    // If we aren't ready for input, keyboard changes should be ignored.
     733    if (!m_inputModeEnabled && visible)
     734        return;
     735
    757736    if (!m_delayKeyboardVisibilityChange) {
    758737        m_webPage->showVirtualKeyboard(visible);
    … …  
    909888{
    910889    InputLog(LogLevelInfo, "InputHandler::handleKeyboardInput received character=%lc, type=%d", keyboardEvent.character(), keyboardEvent.type());
     890
     891    // Enable input mode if we are processing a key event.
     892    enableInputMode();
    911893
    912894    // If we aren't specifically part of a composition, fail, IMF should never send key input
    … …  
    16901672    InputLog(LogLevelInfo, "InputHandler::setComposingText at relativeCursorPosition: %d", relativeCursorPosition);
    16911673
     1674    // Enable input mode if we are processing a key event.
     1675    enableInputMode();
     1676
    16921677    return setSpannableTextAndRelativeCursor(spannableString, relativeCursorPosition, true /* markTextAsComposing */) ? 0 : -1;
    16931678}
  • trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h

    r110175 r110630  
    5757    enum FocusElementType { TextEdit, TextPopup /* Date/Time & Color */, SelectPopup, Plugin };
    5858    enum CaretScrollType { CenterAlways, CenterIfNeeded, EdgeIfNeeded };
     59
     60    void enableInputMode(bool inputModeAllowed = true);
    5961
    6062    void focusedNodeChanged();
    … …  
    117119    int32_t commitText(spannable_string_t*, int32_t relativeCursorPosition);
    118120
    119     bool shouldAcceptInputFocus();
    120 
    121121private:
    122122    enum PendingKeyboardStateChange { NoChange, Visible, NotVisible };
    … …  
    178178
    179179    RefPtr<WebCore::Element> m_currentFocusElement;
     180    bool m_inputModeEnabled;
    180181
    181182    bool m_processingChange;
  • trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp

    r108721 r110630  
    175175bool TouchEventHandler::handleTouchPoint(Platform::TouchPoint& point)
    176176{
     177    // Enable input mode on any touch event.
     178    m_webPage->m_inputHandler->enableInputMode();
     179
    177180    switch (point.m_state) {
    178181    case Platform::TouchPoint::TouchPressed:
Note: See TracChangeset for help on using the changeset viewer.