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

Changeset 258333 in webkit


Ignore:
Timestamp:
Mar 12, 2020, 9:19:20 AM (7 years ago)
Author:
dbates@webkit.org
Message:

FocusController::setFocusedElement() should tell client of refocused element
https://bugs.webkit.org/show_bug.cgi?id=208880

Reviewed by Wenson Hsieh.

Source/WebCore:

If the specified new focus element is non-nullptr and is already focused then tell the client
that the element was re-focused so that it may update its input state, if needed. On iOS, this
lets the UI process evaluate again whether to start an input session (i.e. bring up the keyboard),
which may have been disallowed when the element was originally focused (say, it was programmatically
focused and there was no hardware keyboard attached).

  • page/FocusController.cpp:

(WebCore::FocusController::setFocusedElement):

Tools:

Adds a test to ensure that calling -selectPositionAtPoint on an already focused element tries
to start an input session. Currently, it does not even try.

  • TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm:

(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r258330 r258333  
     12020-03-12  Daniel Bates  <dabates@apple.com>
     2
     3        FocusController::setFocusedElement() should tell client of refocused element
     4        https://bugs.webkit.org/show_bug.cgi?id=208880
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        If the specified new focus element is non-nullptr and is already focused then tell the client
     9        that the element was re-focused so that it may update its input state, if needed. On iOS, this
     10        lets the UI process evaluate again whether to start an input session (i.e. bring up the keyboard),
     11        which may have been disallowed when the element was originally focused (say, it was programmatically
     12        focused and there was no hardware keyboard attached).
     13
     14        * page/FocusController.cpp:
     15        (WebCore::FocusController::setFocusedElement):
     16
    1172020-03-12  Rob Buis  <rbuis@igalia.com>
    218
  • trunk/Source/WebCore/page/FocusController.cpp

    r257592 r258333  
    821821   
    822822    Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : nullptr;
    823     if (oldFocusedElement == element)
     823    if (oldFocusedElement == element) {
     824        if (element)
     825            m_page.chrome().client().elementDidRefocus(*element);
    824826        return true;
     827    }
    825828
    826829    // FIXME: Might want to disable this check for caretBrowsing
  • trunk/Tools/ChangeLog

    r258328 r258333  
     12020-03-12  Daniel Bates  <dabates@apple.com>
     2
     3        FocusController::setFocusedElement() should tell client of refocused element
     4        https://bugs.webkit.org/show_bug.cgi?id=208880
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Adds a test to ensure that calling -selectPositionAtPoint on an already focused element tries
     9        to start an input session. Currently, it does not even try.
     10
     11        * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm:
     12        (TEST):
     13
    1142020-03-12  Michael Catanzaro  <mcatanzaro@gnome.org>
    215
  • trunk/Tools/TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm

    r257487 r258333  
    131131}
    132132
     133TEST(UIWKInteractionViewProtocol, SelectPositionAtPointInFocusedElementStartsInputSession)
     134{
     135    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]);
     136    auto inputDelegate = adoptNS([TestInputDelegate new]);
     137    [webView _setInputDelegate:inputDelegate.get()];
     138
     139    bool didCallDecidePolicyForFocusedElement = false;
     140    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
     141        didCallDecidePolicyForFocusedElement = true;
     142        return _WKFocusStartsInputSessionPolicyDisallow;
     143    }];
     144
     145    // 1. Focus element
     146    [webView synchronouslyLoadHTMLString:@"<body style='margin: 0; padding: 0'><div contenteditable='true' style='height: 200px; width: 200px'></div></body>"];
     147    [webView stringByEvaluatingJavaScript:@"document.querySelector('div').focus()"];
     148    TestWebKitAPI::Util::run(&didCallDecidePolicyForFocusedElement);
     149
     150    // 2. Focus the element again via selecting a position at a point inside it.
     151    didCallDecidePolicyForFocusedElement = false;
     152    [webView becomeFirstResponder];
     153    [webView selectPositionAtPoint:CGPointMake(8, 8)];
     154    TestWebKitAPI::Util::run(&didCallDecidePolicyForFocusedElement);
     155}
     156
    133157#endif
Note: See TracChangeset for help on using the changeset viewer.