Changeset 167774 in webkit


Ignore:
Timestamp:
Apr 24, 2014 2:44:42 PM (10 years ago)
Author:
enrica@apple.com
Message:

[iOS WebKit2] Should properly handle focus redirect (keyboard state changes when focus changes).
https://bugs.webkit.org/show_bug.cgi?id=132136
<rdar://problem/16238336>

Reviewed by Benjamin Poulain.

Focusing a field from JavaScript should not make the keyboard or the select picker
appear unless the user has already started interacting with one of the fields in the page.
Adding a parameter to StartAssistingNode to indicate whether the focus change is a result
of a user action.

  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::startAssistingNode):

  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _startAssistingNode:userIsInteracting:userObject:]):

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::startAssistingNode):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage):
(WebKit::WebPage::dispatchTouchEvent):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::handleTap):
(WebKit::WebPage::elementDidFocus):

Location:
trunk/Source/WebKit2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167768 r167774  
     12014-04-24  Enrica Casucci  <enrica@apple.com>
     2
     3        [iOS WebKit2] Should properly handle focus redirect (keyboard state changes when focus changes).
     4        https://bugs.webkit.org/show_bug.cgi?id=132136
     5        <rdar://problem/16238336>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        Focusing a field from JavaScript should not make the keyboard or the select picker
     10        appear unless the user has already started interacting with one of the fields in the page.
     11        Adding a parameter to StartAssistingNode to indicate whether the focus change is a result
     12        of a user action.
     13
     14        * UIProcess/PageClient.h:
     15        * UIProcess/WebPageProxy.h:
     16        * UIProcess/WebPageProxy.messages.in:
     17        * UIProcess/ios/PageClientImplIOS.h:
     18        * UIProcess/ios/PageClientImplIOS.mm:
     19        (WebKit::PageClientImpl::startAssistingNode):
     20        * UIProcess/ios/WKContentViewInteraction.h:
     21        * UIProcess/ios/WKContentViewInteraction.mm:
     22        (-[WKContentView _startAssistingNode:userIsInteracting:userObject:]):
     23        * UIProcess/ios/WebPageProxyIOS.mm:
     24        (WebKit::WebPageProxy::startAssistingNode):
     25        * WebProcess/WebPage/WebPage.cpp:
     26        (WebKit::WebPage::WebPage):
     27        (WebKit::WebPage::dispatchTouchEvent):
     28        * WebProcess/WebPage/WebPage.h:
     29        * WebProcess/WebPage/ios/WebPageIOS.mm:
     30        (WebKit::WebPage::handleTap):
     31        (WebKit::WebPage::elementDidFocus):
     32
    1332014-04-24  Myles C. Maxfield  <mmaxfield@apple.com>
    234
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r167262 r167774  
    244244    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) = 0;
    245245
    246     virtual void startAssistingNode(const AssistedNodeInformation&, API::Object* userData) = 0;
     246    virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, API::Object* userData) = 0;
    247247    virtual void stopAssistingNode() = 0;
    248248    virtual void selectionDidChange() = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r167742 r167774  
    13571357    void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& geometries, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius);
    13581358
    1359     void startAssistingNode(const AssistedNodeInformation&, IPC::MessageDecoder&);
     1359    void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, IPC::MessageDecoder&);
    13601360    void stopAssistingNode();
    13611361
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r167519 r167774  
    321321    DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius)
    322322
    323     StartAssistingNode(WebKit::AssistedNodeInformation information, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
     323    StartAssistingNode(WebKit::AssistedNodeInformation information, bool userIsInteracting, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    324324    StopAssistingNode()
    325325    NotifyRevealedSelection()
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r167262 r167774  
    110110    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) override;
    111111
    112     virtual void startAssistingNode(const AssistedNodeInformation&, API::Object* userData) override;
     112    virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, API::Object* userData) override;
    113113    virtual void stopAssistingNode() override;
    114114    virtual void selectionDidChange() override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r167512 r167774  
    374374}
    375375
    376 void PageClientImpl::startAssistingNode(const AssistedNodeInformation& nodeInformation, API::Object* userData)
     376void PageClientImpl::startAssistingNode(const AssistedNodeInformation& nodeInformation, bool userIsInteracting, API::Object* userData)
    377377{
    378378    MESSAGE_CHECK(!userData || userData->type() == API::Object::Type::Data);
     
    390390    }
    391391
    392     [m_contentView _startAssistingNode:nodeInformation userObject:userObject];
     392    [m_contentView _startAssistingNode:nodeInformation userIsInteracting:userIsInteracting userObject:userObject];
    393393}
    394394
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r167698 r167774  
    134134- (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius;
    135135
    136 - (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userObject:(NSObject <NSSecureCoding> *)userObject;
     136- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting userObject:(NSObject <NSSecureCoding> *)userObject;
    137137- (void)_stopAssistingNode;
    138138- (void)_selectionChanged;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r167698 r167774  
    19801980}
    19811981
    1982 - (void)_startAssistingNode:(const AssistedNodeInformation&)information userObject:(NSObject <NSSecureCoding> *)userObject
    1983 {
     1982- (void)_startAssistingNode:(const AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting userObject:(NSObject <NSSecureCoding> *)userObject
     1983{
     1984    if (!userIsInteracting && !_textSelectionAssistant)
     1985        return;
     1986
    19841987    _isEditable = YES;
    19851988    _assistedNodeInformation = information;
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r167735 r167774  
    489489}
    490490
    491 void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information, IPC::MessageDecoder& decoder)
     491void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information, bool userIsInteracting, IPC::MessageDecoder& decoder)
    492492{
    493493    RefPtr<API::Object> userData;
     
    496496        return;
    497497
    498     m_pageClient.startAssistingNode(information, userData.get());
     498    m_pageClient.startAssistingNode(information, userIsInteracting, userData.get());
    499499}
    500500
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r167767 r167774  
    287287    , m_scaleWasSetByUIProcess(false)
    288288    , m_userHasChangedPageScaleFactor(false)
     289    , m_userIsInteracting(false)
    289290    , m_screenSize(parameters.screenSize)
    290291    , m_availableScreenSize(parameters.availableScreenSize)
     
    19561957void WebPage::dispatchTouchEvent(const WebTouchEvent& touchEvent, bool& handled)
    19571958{
     1959    RefPtr<Frame> oldFocusedFrame = m_page->focusController().focusedFrame();
     1960    RefPtr<Element> oldFocusedElement = oldFocusedFrame ? oldFocusedFrame->document()->focusedElement() : nullptr;
     1961    m_userIsInteracting = true;
     1962
    19581963    m_lastInteractionLocation = touchEvent.position();
    19591964    CurrentEvent currentEvent(touchEvent);
    19601965    handled = handleTouchEvent(touchEvent, m_page.get());
     1966
     1967    RefPtr<Frame> newFocusedFrame = m_page->focusController().focusedFrame();
     1968    RefPtr<Element> newFocusedElement = newFocusedFrame ? newFocusedFrame->document()->focusedElement() : nullptr;
     1969
     1970    // If the focus has not changed, we need to notify the client anyway, since it might be
     1971    // necessary to start assisting the node.
     1972    // If the node has been focused by JavaScript without user interaction, the
     1973    // keyboard is not on screen.
     1974    if (newFocusedElement && newFocusedElement == oldFocusedElement)
     1975        elementDidFocus(newFocusedElement.get());
     1976
     1977    m_userIsInteracting = false;
    19611978}
    19621979
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r167742 r167774  
    11631163    bool m_scaleWasSetByUIProcess;
    11641164    bool m_userHasChangedPageScaleFactor;
     1165    bool m_userIsInteracting;
    11651166    WebCore::FloatSize m_screenSize;
    11661167    WebCore::FloatSize m_availableScreenSize;
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r167738 r167774  
    313313        return;
    314314
     315    RefPtr<Frame> oldFocusedFrame = m_page->focusController().focusedFrame();
     316    RefPtr<Element> oldFocusedElement = oldFocusedFrame ? oldFocusedFrame->document()->focusedElement() : nullptr;
     317    m_userIsInteracting = true;
     318
    315319    m_lastInteractionLocation = roundedAdjustedPoint;
    316320    mainframe.eventHandler().handleMousePressEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, 0));
    317321    mainframe.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 1, false, false, false, false, 0));
     322
     323    RefPtr<Frame> newFocusedFrame = m_page->focusController().focusedFrame();
     324    RefPtr<Element> newFocusedElement = newFocusedFrame ? newFocusedFrame->document()->focusedElement() : nullptr;
     325
     326    // If the focus has not changed, we need to notify the client anyway, since it might be
     327    // necessary to start assisting the node.
     328    // If the node has been focused by JavaScript without user interaction, the
     329    // keyboard is not on screen.
     330    if (newFocusedElement && newFocusedElement == oldFocusedElement)
     331        elementDidFocus(newFocusedElement.get());
     332
     333    m_userIsInteracting = false;
    318334}
    319335
     
    17481764        RefPtr<API::Object> userData;
    17491765        m_formClient->willBeginInputSession(this, toElement(node), WebFrame::fromCoreFrame(*node->document().frame()), userData);
    1750         send(Messages::WebPageProxy::StartAssistingNode(information, InjectedBundleUserMessageEncoder(userData.get())));
     1766        send(Messages::WebPageProxy::StartAssistingNode(information, m_userIsInteracting, InjectedBundleUserMessageEncoder(userData.get())));
    17511767    }
    17521768}
Note: See TracChangeset for help on using the changeset viewer.