Title: [280057] trunk
Revision
280057
Author
wenson_hs...@apple.com
Date
2021-07-19 17:00:14 -0700 (Mon, 19 Jul 2021)

Log Message

[iOS] Tapping images on twitter.com should not toggle tab bar visibility
https://bugs.webkit.org/show_bug.cgi?id=228086
rdar://79667219

Reviewed by Geoffrey Garen.

Treat taps over elements that are explicitly marked draggable and also respond to click events as "meaningful"
with respect to the private UIDelegate method `-_webView:didTapAtPoint:withResult:`. In doing this, we use the
combination of responding to drags and clicks as a proxy for content that probably results in some meaningful
interaction when tapped.

Test: fast/events/ios/meaningful-click-when-tapping-draggable-content.html

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::isProbablyMeaningfulClick):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/events/ios/meaningful-click-when-tapping-draggable-content-expected.txt (0 => 280057)


--- trunk/LayoutTests/fast/events/ios/meaningful-click-when-tapping-draggable-content-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/meaningful-click-when-tapping-draggable-content-expected.txt	2021-07-20 00:00:14 UTC (rev 280057)
@@ -0,0 +1,12 @@
+This test exercises the 'meaningful click' heuristic when tapping draggable content.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS didHandleTap became true
+PASS didHandleTapAsMeaningfulClick is true
+PASS didHandleTap became true
+PASS didHandleTapAsMeaningfulClick is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/ios/meaningful-click-when-tapping-draggable-content.html (0 => 280057)


--- trunk/LayoutTests/fast/events/ios/meaningful-click-when-tapping-draggable-content.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/meaningful-click-when-tapping-draggable-content.html	2021-07-20 00:00:14 UTC (rev 280057)
@@ -0,0 +1,66 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+<style>
+body, html {
+    font-size: 18px;
+    font-family: system-ui;
+    width: 100%;
+    height: 100%;
+    margin: 0;
+}
+
+#target {
+    width: 100%;
+    height: 100%;
+    background-color: silver;
+}
+</style>
+<script src=""
+<script src=""
+<script>
+jsTestIsAsync = true;
+
+addEventListener("load", async () => {
+    description("This test exercises the 'meaningful click' heuristic when tapping draggable content.");
+
+    if (!window.testRunner)
+        return;
+
+    const target = document.getElementById("target");
+    target.addEventListener("mousedown", () => { });
+
+    async function simulateTap(expectMeaningfulClick) {
+        didHandleTap = false;
+        didHandleTapAsMeaningfulClick = false;
+        testRunner.installDidHandleTapCallback(wasMeaningful => {
+            didHandleTap = true;
+            didHandleTapAsMeaningfulClick = wasMeaningful;
+        });
+
+        await UIHelper.activateElement(target);
+        await shouldBecomeEqual("didHandleTap", "true");
+        if (expectMeaningfulClick)
+            shouldBeTrue("didHandleTapAsMeaningfulClick");
+        else
+            shouldBeFalse("didHandleTapAsMeaningfulClick");
+        testRunner.clearTestRunnerCallbacks();
+        await UIHelper.waitForDoubleTapDelay();
+    }
+
+    await simulateTap(true);
+
+    target.removeAttribute("draggable");
+    await simulateTap(false);
+
+    finishJSTest();
+});
+</script>
+</head>
+<body>
+    <div id="description"></div>
+    <div id="console"></div>
+    <div id="target" draggable="true"></div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebKit/ChangeLog (280056 => 280057)


--- trunk/Source/WebKit/ChangeLog	2021-07-20 00:00:13 UTC (rev 280056)
+++ trunk/Source/WebKit/ChangeLog	2021-07-20 00:00:14 UTC (rev 280057)
@@ -1,3 +1,21 @@
+2021-07-19  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Tapping images on twitter.com should not toggle tab bar visibility
+        https://bugs.webkit.org/show_bug.cgi?id=228086
+        rdar://79667219
+
+        Reviewed by Geoffrey Garen.
+
+        Treat taps over elements that are explicitly marked draggable and also respond to click events as "meaningful"
+        with respect to the private UIDelegate method `-_webView:didTapAtPoint:withResult:`. In doing this, we use the
+        combination of responding to drags and clicks as a proxy for content that probably results in some meaningful
+        interaction when tapped.
+
+        Test: fast/events/ios/meaningful-click-when-tapping-draggable-content.html
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::isProbablyMeaningfulClick):
+
 2021-07-19  Sihui Liu  <sihui_...@apple.com>
 
         Implement IDBTransaction.commit()

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (280056 => 280057)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-07-20 00:00:13 UTC (rev 280056)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-07-20 00:00:14 UTC (rev 280057)
@@ -846,6 +846,9 @@
     if (is<HTMLBodyElement>(clickNode) || is<Document>(clickNode) || clickNode.document().documentElement() == &clickNode)
         return false;
 
+    if (is<Element>(clickNode) && equalLettersIgnoringASCIICase(downcast<Element>(clickNode).attributeWithoutSynchronization(HTMLNames::draggableAttr), "true"))
+        return true;
+
     if (auto view = makeRefPtr(frame->mainFrame().view())) {
         auto elementBounds = WebPage::rootViewInteractionBounds(clickNode);
         auto unobscuredRect = view->unobscuredContentRect();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to