Title: [265117] trunk
Revision
265117
Author
[email protected]
Date
2020-07-30 16:31:59 -0700 (Thu, 30 Jul 2020)

Log Message

[iPadOS] Two taps are required to choose a country/region when creating an account on ea.com
https://bugs.webkit.org/show_bug.cgi?id=214984
<rdar://problem/66261490>

Reviewed by Devin Rousso.

Source/WebKit:

On the desktop version of the account creation page on ea.com, tapping a custom selection menu element
programmatically focuses a real `select` element that is positioned far outside the viewport. As a result, on
iPad, we still attempt to show a popover for this focused select at the element location. This popover is not
visible to the user, but on iOS 13, it still steals modal focus from the web view, which means that an
additional tap anywhere in the window is required to dismiss the (invisible) popover before the user can choose
one of the options in the custom in-page menu that is shown.

Furthermore, upon choosing one of these options, the page programmatically focuses the offscreen select again.
This causes us to re-present the offscreen popover, which requires yet another tap to dismiss on iOS 13.
However, on iOS 14, this actually results in a crash when attempting to scroll the popover's inner UITableView
to the selected row.

To fix both the crash on iOS 14 and the multiple redundant taps required to dismiss the popover on iOS 13, avoid
showing popovers altogether if the popover's presentation rect is outside the bounds of the content view, since
we cannot reasonably expect a user to interact with such a popover anyways.

Test: fast/forms/ios/repeatedly-focus-offscreen-select.html

* UIProcess/ios/forms/WKFormPopover.mm:
(-[WKRotatingPopover presentPopoverAnimated:]):

LayoutTests:

Add a test that exercises both the crash and the UI bug on iPadOS. Note that this test already passes on iOS,
where we don't use popovers for focused selects.

* fast/forms/ios/repeatedly-focus-offscreen-select-expected.txt: Added.
* fast/forms/ios/repeatedly-focus-offscreen-select.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265116 => 265117)


--- trunk/LayoutTests/ChangeLog	2020-07-30 23:22:55 UTC (rev 265116)
+++ trunk/LayoutTests/ChangeLog	2020-07-30 23:31:59 UTC (rev 265117)
@@ -1,3 +1,17 @@
+2020-07-30  Wenson Hsieh  <[email protected]>
+
+        [iPadOS] Two taps are required to choose a country/region when creating an account on ea.com
+        https://bugs.webkit.org/show_bug.cgi?id=214984
+        <rdar://problem/66261490>
+
+        Reviewed by Devin Rousso.
+
+        Add a test that exercises both the crash and the UI bug on iPadOS. Note that this test already passes on iOS,
+        where we don't use popovers for focused selects.
+
+        * fast/forms/ios/repeatedly-focus-offscreen-select-expected.txt: Added.
+        * fast/forms/ios/repeatedly-focus-offscreen-select.html: Added.
+
 2020-07-30  Antoine Quint  <[email protected]>
 
         [ iOS ] webanimations/accelerated-animation-with-easing.html is still flaky

Added: trunk/LayoutTests/fast/forms/ios/repeatedly-focus-offscreen-select-expected.txt (0 => 265117)


--- trunk/LayoutTests/fast/forms/ios/repeatedly-focus-offscreen-select-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/repeatedly-focus-offscreen-select-expected.txt	2020-07-30 23:31:59 UTC (rev 265117)
@@ -0,0 +1,11 @@
+This test verifies that focusing an offscreen select element does not present an offscreen popover on iPad. To manually run the test, tap the button three times.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS clickCount became 3
+PASS document.activeElement is select
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Focus the offscreen select 

Added: trunk/LayoutTests/fast/forms/ios/repeatedly-focus-offscreen-select.html (0 => 265117)


--- trunk/LayoutTests/fast/forms/ios/repeatedly-focus-offscreen-select.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/repeatedly-focus-offscreen-select.html	2020-07-30 23:31:59 UTC (rev 265117)
@@ -0,0 +1,51 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+<head>
+    <script src=""
+    <script src=""
+    <style>
+        select {
+            position: absolute;
+            top: 0;
+            left: -10000px;
+            font-size: 20px;
+        }
+    </style>
+</head>
+<body>
+    <button>Focus the offscreen select</button>
+    <select>
+        <option id="one">One</option>
+        <option id="two">Two</option>
+        <option id="three">Three</option>
+    </select>
+</body>
+<script>
+window.jsTestIsAsync = true;
+let clickCount = 0;
+let button = document.querySelector("button");
+let select = document.querySelector("select");
+
+window.addEventListener("load", async () => {
+    button.addEventListener("click", (event) => {
+        document.querySelector("select").focus();
+        ++clickCount;
+    });
+
+    description("This test verifies that focusing an offscreen select element does not present an offscreen popover on iPad. To manually run the test, tap the button three times.");
+
+    if (window.testRunner) {
+        for (let i = 0; i < 3; ++i) {
+            await UIHelper.activateElement(button);
+            await UIHelper.waitForDoubleTapDelay();
+        }
+    }
+
+    await new Promise(resolve => shouldBecomeEqual("clickCount", "3", resolve));
+    shouldBe("document.activeElement", "select");
+    document.activeElement.blur();
+    finishJSTest();
+});
+</script>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebKit/ChangeLog (265116 => 265117)


--- trunk/Source/WebKit/ChangeLog	2020-07-30 23:22:55 UTC (rev 265116)
+++ trunk/Source/WebKit/ChangeLog	2020-07-30 23:31:59 UTC (rev 265117)
@@ -1,3 +1,32 @@
+2020-07-30  Wenson Hsieh  <[email protected]>
+
+        [iPadOS] Two taps are required to choose a country/region when creating an account on ea.com
+        https://bugs.webkit.org/show_bug.cgi?id=214984
+        <rdar://problem/66261490>
+
+        Reviewed by Devin Rousso.
+
+        On the desktop version of the account creation page on ea.com, tapping a custom selection menu element
+        programmatically focuses a real `select` element that is positioned far outside the viewport. As a result, on
+        iPad, we still attempt to show a popover for this focused select at the element location. This popover is not
+        visible to the user, but on iOS 13, it still steals modal focus from the web view, which means that an
+        additional tap anywhere in the window is required to dismiss the (invisible) popover before the user can choose
+        one of the options in the custom in-page menu that is shown.
+
+        Furthermore, upon choosing one of these options, the page programmatically focuses the offscreen select again.
+        This causes us to re-present the offscreen popover, which requires yet another tap to dismiss on iOS 13.
+        However, on iOS 14, this actually results in a crash when attempting to scroll the popover's inner UITableView
+        to the selected row.
+
+        To fix both the crash on iOS 14 and the multiple redundant taps required to dismiss the popover on iOS 13, avoid
+        showing popovers altogether if the popover's presentation rect is outside the bounds of the content view, since
+        we cannot reasonably expect a user to interact with such a popover anyways.
+
+        Test: fast/forms/ios/repeatedly-focus-offscreen-select.html
+
+        * UIProcess/ios/forms/WKFormPopover.mm:
+        (-[WKRotatingPopover presentPopoverAnimated:]):
+
 2020-07-30  Jer Noble  <[email protected]>
 
         [Cocoa] Adopt -[AVContentKeyRequest willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:]

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormPopover.mm (265116 => 265117)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormPopover.mm	2020-07-30 23:22:55 UTC (rev 265116)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormPopover.mm	2020-07-30 23:31:59 UTC (rev 265117)
@@ -133,26 +133,22 @@
 
 - (void)presentPopoverAnimated:(BOOL)animated
 {
+    auto directions = [self popoverArrowDirections];
+    CGRect presentationRect;
+    if (CGPointEqualToPoint(self.presentationPoint, CGPointZero))
+        presentationRect = _view.focusedElementInformation.interactionRect;
+    else {
+        auto scale = _view.page->pageScaleFactor();
+        presentationRect = CGRectMake(self.presentationPoint.x * scale, self.presentationPoint.y * scale, 1, 1);
+    }
+
+    if (!CGRectIntersectsRect(presentationRect, _view.bounds))
+        return;
+
 #if PLATFORM(MACCATALYST)
     [_view startRelinquishingFirstResponderToFocusedElement];
 #endif
-
-    UIPopoverArrowDirection directions = [self popoverArrowDirections];
-
-    BOOL presentWithPoint = !CGPointEqualToPoint(self.presentationPoint, CGPointZero);
-    if (presentWithPoint) {
-        CGFloat scale = [_view page]->pageScaleFactor();
-        [_popoverController presentPopoverFromRect:CGRectIntegral(CGRectMake(self.presentationPoint.x * scale, self.presentationPoint.y * scale, 1, 1))
-                                            inView:_view
-                          permittedArrowDirections:directions
-                                          animated:animated];
-    } else {
-        CGRect boundingBoxOfDOMNode = _view.focusedElementInformation.interactionRect;
-        [_popoverController presentPopoverFromRect:CGRectIntegral(boundingBoxOfDOMNode)
-                                            inView:_view
-                          permittedArrowDirections:directions
-                                          animated:animated];
-    }
+    [_popoverController presentPopoverFromRect:CGRectIntegral(presentationRect) inView:_view permittedArrowDirections:directions animated:animated];
 }
 
 - (void)dismissPopoverAnimated:(BOOL)animated
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to