| Differences between
and this patch
- a/Source/WebKit/ChangeLog +26 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2019-06-18  Daniel Bates  <dabates@apple.com>
2
3
        REGRESSION (r240757): Cannot dismiss the keyboard on http://apple.com/apple-tv-plus
4
        https://bugs.webkit.org/show_bug.cgi?id=198922
5
        <rdar://problem/50300056>
6
7
        Reviewed by Wenson Hsieh.
8
9
        Actually dismiss the keyboard as intended in r240757. Do not wait for the round-trip
10
        to the WebProcess to run through the -elementDidBlur steps in the UIProcess and hide
11
        the keyboard when a person explicitly dismisses the keyboard via the Done button (iPhone)
12
        or hide keyboard button (iPad).
13
14
        Note that r240757 revealed another bug in this code, <https://bugs.webkit.org/show_bug.cgi?id=198928>.
15
        I am unclear of the implications of that bug, but it is clear for this bug that it
16
        never makes sense to round-trip to the WebProcess when the keyboard is dismissed by
17
        a user gesture.
18
19
        * UIProcess/ios/WKContentViewInteraction.mm:
20
        (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]): Invoke -_elementDidBlur
21
        to blur the element in the UIProcess and hide the keyboard.
22
        (-[WKContentView _elementDidBlur]): Prevent duplicate invocations of -didEndFormControlInteraction
23
        and setIsShowingInputViewForFocusedElement messages by only doing these actions when
24
        editablity changes. This covers the case where -_elementDidBlur may be invoked a second
25
        time (the reply in the round-trip). In that case we don't need to do these actions.
26
1
2019-06-18  Alex Christensen  <achristensen@webkit.org>
27
2019-06-18  Alex Christensen  <achristensen@webkit.org>
2
28
3
        NetworkSession::networkStorageSession can return null
29
        NetworkSession::networkStorageSession can return null
- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm -5 / +10 lines
Lines 1226-1233 - (void)endEditingAndUpdateFocusAppearanceWithReason:(EndEditingReason)reason a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm_sec1
1226
    if (!_webView._retainingActiveFocusedState) {
1226
    if (!_webView._retainingActiveFocusedState) {
1227
        // We need to complete the editing operation before we blur the element.
1227
        // We need to complete the editing operation before we blur the element.
1228
        [self _endEditing];
1228
        [self _endEditing];
1229
        if ((reason == EndEditingReasonAccessoryDone && !currentUserInterfaceIdiomIsPad()) || _keyboardDidRequestDismissal)
1229
        if ((reason == EndEditingReasonAccessoryDone && !currentUserInterfaceIdiomIsPad()) || _keyboardDidRequestDismissal) {
1230
            _page->blurFocusedElement();
1230
            _page->blurFocusedElement();
1231
            // Don't wait for WebPageProxy::blurFocusedElement() to round-trip back to us to hide the keyboard
1232
            // because we know that the user explicitly requested us to do so.
1233
            [self _elementDidBlur];
1234
        }
1231
    }
1235
    }
1232
1236
1233
    [self _cancelInteraction];
1237
    [self _cancelInteraction];
Lines 5282-5293 - (void)_elementDidBlur a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm_sec2
5282
        [self removeFocusedFormControlOverlay];
5286
        [self removeFocusedFormControlOverlay];
5283
#endif
5287
#endif
5284
5288
5285
    // The custom fixed position rect behavior is affected by -isFocusingElement, so if that changes we need to recompute rects.
5289
    if (editableChanged) {
5286
    if (editableChanged)
5290
        // The custom fixed position rect behavior is affected by -isFocusingElement, so if that changes we need to recompute rects.
5287
        [_webView _scheduleVisibleContentRectUpdate];
5291
        [_webView _scheduleVisibleContentRectUpdate];
5288
5292
5289
    [_webView didEndFormControlInteraction];
5293
        [_webView didEndFormControlInteraction];
5290
    _page->setIsShowingInputViewForFocusedElement(false);
5294
        _page->setIsShowingInputViewForFocusedElement(false);
5295
    }
5291
5296
5292
    if (!_isChangingFocus)
5297
    if (!_isChangingFocus)
5293
        _didAccessoryTabInitiateFocus = NO;
5298
        _didAccessoryTabInitiateFocus = NO;
- a/LayoutTests/ChangeLog +16 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2019-06-18  Daniel Bates  <dabates@apple.com>
2
3
        REGRESSION (r240757): Cannot dismiss the keyboard on http://apple.com/apple-tv-plus
4
        https://bugs.webkit.org/show_bug.cgi?id=198922
5
        <rdar://problem/50300056>
6
7
        Reviewed by Wenson Hsieh.
8
9
        Add a test to ensure that pressing Done hides the keyboard after tapping outside the focused
10
        element's frame.
11
12
        * fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt: Added.
13
        * fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field.html: Added.
14
        * resources/ui-helper.js:
15
        (window.UIHelper.dismissFormAccessoryView): Added.
16
1
2019-06-18  Alexey Shvayka  <shvaikalesh@gmail.com>
17
2019-06-18  Alexey Shvayka  <shvaikalesh@gmail.com>
2
18
3
        [ESNExt] String.prototype.matchAll
19
        [ESNExt] String.prototype.matchAll
- a/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt +13 lines
Line 0 a/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field-expected.txt_sec1
1
This test focuses the text field in the iframe, taps outside the iframe and then presses the Done button. The keyboard should hide.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
6
dispatched blur to main frame
7
dispatched focus to <input>
8
dispatched focus to main frame
9
PASS dismissed form accessory
10
PASS successfullyParsed is true
11
12
TEST COMPLETE
13
- a/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field.html +45 lines
Line 0 a/LayoutTests/fast/events/ios/should-be-able-to-dismiss-form-accessory-after-tapping-outside-iframe-with-focused-field.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta name="viewport" content="width=device-width">
5
<script src="../../../resources/js-test.js"></script>
6
<script src="../../../resources/ui-helper.js"></script>
7
</head>
8
<body>
9
<iframe id="frame" srcdoc="<style>body { margin: 0; padding: 0 }</style><input placeholder='Tap here'><script>window.parent.runTest()</script>"></iframe>
10
<script>
11
window.jsTestIsAsync = true;
12
13
description("This test focuses the text field in the iframe, taps outside the iframe and then presses the Done button. The keyboard should hide.")
14
15
async function runTest()
16
{
17
    let frame = document.getElementById("frame");
18
    let inputElementInFrame = frame.contentDocument.querySelector("input");
19
20
    // 1. Add listeners
21
    window.addEventListener("focus", () => debug("dispatched focus to main frame"), { once: true });
22
    window.addEventListener("blur", () => debug("dispatched blur to main frame"), { once: true });
23
    inputElementInFrame.addEventListener("focus", () => debug("dispatched focus to &lt;input&gt;"), { once: true });
24
    inputElementInFrame.addEventListener("blur", () => debug("dispatched blur to &lt;input&gt;"), { once: true });
25
26
    if (!window.testRunner)
27
        return;
28
29
    // 2. Focus the <input> in the <iframe>.
30
    let x = frame.offsetLeft + inputElementInFrame.offsetLeft + Math.floor(inputElementInFrame.offsetWidth / 2);
31
    let y = frame.offsetTop + inputElementInFrame.offsetTop + Math.floor(inputElementInFrame.offsetHeight / 2);
32
    await UIHelper.activateAndWaitForInputSessionAt(x, y);
33
34
    // 3. Tap somewhere in the main frame, then press the Done button.
35
    await UIHelper.activateAt(0, 0);
36
    await UIHelper.dismissFormAccessoryView(); // Press the Done button; ends the input session.
37
    await UIHelper.waitForKeyboardToHide();
38
39
    testPassed("dismissed form accessory");
40
    document.body.removeChild(document.getElementById("frame"));
41
    finishJSTest();
42
}
43
</script>
44
</body>
45
</html>
- a/LayoutTests/resources/ui-helper.js +14 lines
Lines 351-356 window.UIHelper = class UIHelper { a/LayoutTests/resources/ui-helper.js_sec1
351
        });
351
        });
352
    }
352
    }
353
353
354
    static dismissFormAccessoryView()
355
    {
356
        if (!this.isWebKit2() || !this.isIOSFamily())
357
            return Promise.resolve();
358
359
        return new Promise(resolve => {
360
            testRunner.runUIScript(`
361
                (function() {
362
                    uiController.dismissFormAccessoryView();
363
                    uiController.uiScriptComplete();
364
                })()`, resolve);
365
        });
366
    }
367
354
    static isShowingKeyboard()
368
    static isShowingKeyboard()
355
    {
369
    {
356
        return new Promise(resolve => {
370
        return new Promise(resolve => {

Return to Bug 198922