[iOS] "touch-action: none" should not prevent text selection or tapping on a link
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2019 10:45:48 +0000 (10:45 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2019 10:45:48 +0000 (10:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194812
<rdar://problem/47901131>

Reviewed by Dean Jackson.

Source/WebKit:

We shouldn't prevent all gestures to be disabled when "touch-action: none" is set and instead follow the same code path we would use should
"pan-x", "pan-y" or "pinch-zoom" be used.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _handleTouchActionsForTouchEvent:]):

LayoutTests:

Add a new test which checks that tapping on a link with "touch-action: none" does not prevent navigation.

* pointerevents/ios/over-enter-out-leave.html:
* pointerevents/ios/touch-action-none-link-traversal-expected.txt: Added.
* pointerevents/ios/touch-action-none-link-traversal.html: Added.
* pointerevents/utils.js: Since we now have two tests performing a tap, we add a ui.tap() method which is a wrapper for uiController.singleTapAtPoint().
(const.ui.new.UIController.prototype.tap):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241760 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/pointerevents/ios/over-enter-out-leave.html
LayoutTests/pointerevents/ios/touch-action-none-link-traversal-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-none-link-traversal.html [new file with mode: 0644]
LayoutTests/pointerevents/utils.js
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 74027c8..53022cc 100644 (file)
@@ -1,3 +1,19 @@
+2019-02-19  Antoine Quint  <graouts@apple.com>
+
+        [iOS] "touch-action: none" should not prevent text selection or tapping on a link
+        https://bugs.webkit.org/show_bug.cgi?id=194812
+        <rdar://problem/47901131>
+
+        Reviewed by Dean Jackson.
+
+        Add a new test which checks that tapping on a link with "touch-action: none" does not prevent navigation.
+
+        * pointerevents/ios/over-enter-out-leave.html:
+        * pointerevents/ios/touch-action-none-link-traversal-expected.txt: Added.
+        * pointerevents/ios/touch-action-none-link-traversal.html: Added.
+        * pointerevents/utils.js: Since we now have two tests performing a tap, we add a ui.tap() method which is a wrapper for uiController.singleTapAtPoint().
+        (const.ui.new.UIController.prototype.tap):
+
 2019-02-18  Alex Christensen  <achristensen@webkit.org>
 
         Adjust test expectations after r241754
index a1ca1c2..3643aae 100644 (file)
@@ -18,11 +18,7 @@ target_test({ width: "200px", height: "200px" }, (target, test) => {
 
     const eventTracker = new EventTracker(target, ["pointerover", "pointerenter", "pointerdown", "pointerup", "pointerout", "pointerleave"]);
 
-    const touch = ui.finger();
-    ui.sequence([
-        touch.begin({ x: 100, y: 100 }),
-        touch.end()
-    ]).then(() => {
+    ui.tap({ x: 100, y: 100 }).then(() => {
         eventTracker.assertMatchesEvents([
             { type: "pointerover", x: 100, y: 100, isPrimary: true },
             { type: "pointerenter", x: 100, y: 100, isPrimary: true },
diff --git a/LayoutTests/pointerevents/ios/touch-action-none-link-traversal-expected.txt b/LayoutTests/pointerevents/ios/touch-action-none-link-traversal-expected.txt
new file mode 100644 (file)
index 0000000..9822e7b
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+PASS Testing that setting touch-action: none allows link traversal. 
+
diff --git a/LayoutTests/pointerevents/ios/touch-action-none-link-traversal.html b/LayoutTests/pointerevents/ios/touch-action-none-link-traversal.html
new file mode 100644 (file)
index 0000000..5e4baa7
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+iframe {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 400px;
+    height: 400px;
+    touch-action: none;
+}
+
+</style>
+</head>
+<body>
+<iframe></iframe>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../utils.js"></script>
+<script>
+
+'use strict';
+
+async_test(test => {
+    const iframe = document.body.firstElementChild;
+    const link = iframe.contentDocument.body.appendChild(document.createElement("a"));
+    link.href = "../disabled.html";
+    link.setAttribute("style", `
+        position: absolute;
+        left: 0;
+        top: 0;
+        width: 100%;
+        height: 100%;
+    `);
+
+    assert_equals(iframe.contentWindow.location.href, "about:blank", "The iframe initially has no URL.");
+
+    iframe.addEventListener("load", () => {
+        assert_true(iframe.contentWindow.location.href.includes("disabled.html"), "Upon navigation the URL has a location.");
+        test.done();
+    });
+
+    ui.tap({ x: 100, y: 100 });
+}, "Testing that setting touch-action: none allows link traversal.");
+
+</script>
+</body>
+</html>
\ No newline at end of file
index 52e9a1e..ba75890 100644 (file)
@@ -112,6 +112,11 @@ const ui = new (class UIController {
         return this._run(`uiController.dragFromPointToPoint(${from.x}, ${from.y}, ${to.x}, ${to.y}, ${durationInSeconds})`);
     }
 
+    tap(options)
+    {
+        return this._run(`uiController.singleTapAtPoint(${options.x}, ${options.y})`);
+    }
+
     pinchOut(options)
     {
         options.x = options.x || 0;
index 6256c8a..49a21d9 100644 (file)
@@ -1,3 +1,17 @@
+2019-02-19  Antoine Quint  <graouts@apple.com>
+
+        [iOS] "touch-action: none" should not prevent text selection or tapping on a link
+        https://bugs.webkit.org/show_bug.cgi?id=194812
+        <rdar://problem/47901131>
+
+        Reviewed by Dean Jackson.
+
+        We shouldn't prevent all gestures to be disabled when "touch-action: none" is set and instead follow the same code path we would use should
+        "pan-x", "pan-y" or "pinch-zoom" be used.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _handleTouchActionsForTouchEvent:]):
+
 2019-02-18  Alex Christensen  <achristensen@webkit.org>
 
         Revert functional part of r241451
index 7bd80fd..da150d8 100644 (file)
@@ -1226,19 +1226,15 @@ inline static UIKeyModifierFlags gestureRecognizerModifierFlags(UIGestureRecogni
         auto phase = touchPoint.phase();
         if (phase == WebKit::WebPlatformTouchPoint::TouchPressed) {
             auto touchActionData = scrollingCoordinator->touchActionDataAtPoint(touchPoint.location());
-            if (!touchActionData)
+            if (!touchActionData || touchActionData->touchActions.contains(WebCore::TouchAction::Manipulation))
                 continue;
-            if (touchActionData->touchActions == WebCore::TouchAction::None)
-                [_touchEventGestureRecognizer setDefaultPrevented:YES];
-            else if (!touchActionData->touchActions.contains(WebCore::TouchAction::Manipulation)) {
-                if (auto scrollingNodeID = touchActionData->scrollingNodeID)
-                    scrollingCoordinator->setTouchDataForTouchIdentifier(*touchActionData, touchPoint.identifier());
-                else {
-                    if (!touchActionData->touchActions.contains(WebCore::TouchAction::PinchZoom))
-                        _webView.scrollView.pinchGestureRecognizer.enabled = NO;
-                    _preventsPanningInXAxis = !touchActionData->touchActions.contains(WebCore::TouchAction::PanX);
-                    _preventsPanningInYAxis = !touchActionData->touchActions.contains(WebCore::TouchAction::PanY);
-                }
+            if (auto scrollingNodeID = touchActionData->scrollingNodeID)
+                scrollingCoordinator->setTouchDataForTouchIdentifier(*touchActionData, touchPoint.identifier());
+            else {
+                if (!touchActionData->touchActions.contains(WebCore::TouchAction::PinchZoom))
+                    _webView.scrollView.pinchGestureRecognizer.enabled = NO;
+                _preventsPanningInXAxis = !touchActionData->touchActions.contains(WebCore::TouchAction::PanX);
+                _preventsPanningInYAxis = !touchActionData->touchActions.contains(WebCore::TouchAction::PanY);
             }
         } else if (phase == WebKit::WebPlatformTouchPoint::TouchReleased || phase == WebKit::WebPlatformTouchPoint::TouchCancelled)
             scrollingCoordinator->clearTouchDataForTouchIdentifier(touchPoint.identifier());