Title: [247265] trunk
Revision
247265
Author
grao...@webkit.org
Date
2019-07-09 11:43:57 -0700 (Tue, 09 Jul 2019)

Log Message

[Pointer Events] Scroll indicators should not show for scrollable content with touch-action: none
https://bugs.webkit.org/show_bug.cgi?id=199618

Reviewed by Simon Fraser.

Source/WebKit:

Even though we correctly didn't scroll when "touch-action: none" was specified on an element, we would only apply
scrolling constraints after the panning gesture was recognized and the backing UIScrollView would show its scroll
indicators. While this is correct when only "pan-x" or "pan-y" is specified, we should not show the scroll indicators
at all for "touch-action: none" since no scrolling should happen.

To do this, we add a new method to the WKTouchActionGestureRecognizerDelegate protocol to indicate whether a given
gesture recognizer may pan content in the WKWebView. If the gesture recognizer is the top-level scroll view or one
created within the page to back "overflow: scroll" content or an iframe, we correctly make that gesture recognizer
fail to recognize if neither "pan-x" nor "pan-y" is specified for this touch identifier.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView gestureRecognizerMayPanWebView:]):
* UIProcess/ios/WKTouchActionGestureRecognizer.h:
* UIProcess/ios/WKTouchActionGestureRecognizer.mm:
(-[WKTouchActionGestureRecognizer canPreventGestureRecognizer:]):

LayoutTests:

Add a new test that swipes "overflow: scroll" content which would show scroll indicators without scrolling
prior to this patch.

* pointerevents/ios/touch-action-none-no-scroll-indicators-expected.html: Added.
* pointerevents/ios/touch-action-none-no-scroll-indicators.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (247264 => 247265)


--- trunk/LayoutTests/ChangeLog	2019-07-09 18:41:46 UTC (rev 247264)
+++ trunk/LayoutTests/ChangeLog	2019-07-09 18:43:57 UTC (rev 247265)
@@ -1,3 +1,16 @@
+2019-07-09  Antoine Quint  <grao...@apple.com>
+
+        [Pointer Events] Scroll indicators should not show for scrollable content with touch-action: none
+        https://bugs.webkit.org/show_bug.cgi?id=199618
+
+        Reviewed by Simon Fraser.
+
+        Add a new test that swipes "overflow: scroll" content which would show scroll indicators without scrolling
+        prior to this patch.
+
+        * pointerevents/ios/touch-action-none-no-scroll-indicators-expected.html: Added.
+        * pointerevents/ios/touch-action-none-no-scroll-indicators.html: Added.
+
 2019-07-09  Charlie Turner  <ctur...@igalia.com>
 
         [GStreamer] HLS media test gardening

Added: trunk/LayoutTests/pointerevents/ios/touch-action-none-no-scroll-indicators-expected.html (0 => 247265)


--- trunk/LayoutTests/pointerevents/ios/touch-action-none-no-scroll-indicators-expected.html	                        (rev 0)
+++ trunk/LayoutTests/pointerevents/ios/touch-action-none-no-scroll-indicators-expected.html	2019-07-09 18:43:57 UTC (rev 247265)
@@ -0,0 +1 @@
+

Added: trunk/LayoutTests/pointerevents/ios/touch-action-none-no-scroll-indicators.html (0 => 247265)


--- trunk/LayoutTests/pointerevents/ios/touch-action-none-no-scroll-indicators.html	                        (rev 0)
+++ trunk/LayoutTests/pointerevents/ios/touch-action-none-no-scroll-indicators.html	2019-07-09 18:43:57 UTC (rev 247265)
@@ -0,0 +1,36 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+<meta charset=utf-8>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+    #container {
+        position: absolute;
+        left: 0;
+        top: 0;
+        width: 200px;
+        height: 200px;
+        overflow: scroll;
+    }
+
+    #content {
+        position: absolute;
+        width: 200%;
+        height: 200%;
+        touch-action: none;
+    }
+
+</style>
+</head>
+<body>
+<div id="container"><div id="content"></div></div>
+<script src=""
+<script>
+
+if (window.testRunner)
+    ui.swipe({ x: 150, y: 150 }, { x: 50, y: 50 }).then(() => testRunner.notifyDone());
+
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebKit/ChangeLog (247264 => 247265)


--- trunk/Source/WebKit/ChangeLog	2019-07-09 18:41:46 UTC (rev 247264)
+++ trunk/Source/WebKit/ChangeLog	2019-07-09 18:43:57 UTC (rev 247265)
@@ -1,3 +1,26 @@
+2019-07-09  Antoine Quint  <grao...@apple.com>
+
+        [Pointer Events] Scroll indicators should not show for scrollable content with touch-action: none
+        https://bugs.webkit.org/show_bug.cgi?id=199618
+
+        Reviewed by Simon Fraser.
+
+        Even though we correctly didn't scroll when "touch-action: none" was specified on an element, we would only apply
+        scrolling constraints after the panning gesture was recognized and the backing UIScrollView would show its scroll
+        indicators. While this is correct when only "pan-x" or "pan-y" is specified, we should not show the scroll indicators
+        at all for "touch-action: none" since no scrolling should happen.
+
+        To do this, we add a new method to the WKTouchActionGestureRecognizerDelegate protocol to indicate whether a given
+        gesture recognizer may pan content in the WKWebView. If the gesture recognizer is the top-level scroll view or one
+        created within the page to back "overflow: scroll" content or an iframe, we correctly make that gesture recognizer
+        fail to recognize if neither "pan-x" nor "pan-y" is specified for this touch identifier.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView gestureRecognizerMayPanWebView:]):
+        * UIProcess/ios/WKTouchActionGestureRecognizer.h:
+        * UIProcess/ios/WKTouchActionGestureRecognizer.mm:
+        (-[WKTouchActionGestureRecognizer canPreventGestureRecognizer:]):
+
 2019-07-09  Chris Dumez  <cdu...@apple.com>
 
         Validate reply block signature in [WKRemoteObjectRegistry _invokeMethod]

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (247264 => 247265)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-09 18:41:46 UTC (rev 247264)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-09 18:43:57 UTC (rev 247265)
@@ -1387,6 +1387,19 @@
 
 #pragma mark - WKTouchActionGestureRecognizerDelegate implementation
 
+- (BOOL)gestureRecognizerMayPanWebView:(UIGestureRecognizer *)gestureRecognizer
+{
+    // The gesture recognizer is the main UIScrollView's UIPanGestureRecognizer.
+    if (gestureRecognizer == [_webView scrollView].panGestureRecognizer)
+        return YES;
+
+    // The gesture recognizer is a child UIScrollView's UIPanGestureRecognizer created by WebKit.
+    if (gestureRecognizer.view && [gestureRecognizer.view isKindOfClass:[WKChildScrollView class]])
+        return YES;
+
+    return NO;
+}
+
 - (BOOL)gestureRecognizerMayPinchToZoomWebView:(UIGestureRecognizer *)gestureRecognizer
 {
     // The gesture recognizer is the main UIScrollView's UIPinchGestureRecognizer.

Modified: trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.h (247264 => 247265)


--- trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.h	2019-07-09 18:41:46 UTC (rev 247264)
+++ trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.h	2019-07-09 18:43:57 UTC (rev 247265)
@@ -38,6 +38,7 @@
 @end
 
 @protocol WKTouchActionGestureRecognizerDelegate <NSObject>
+- (BOOL)gestureRecognizerMayPanWebView:(UIGestureRecognizer *)gestureRecognizer;
 - (BOOL)gestureRecognizerMayPinchToZoomWebView:(UIGestureRecognizer *)gestureRecognizer;
 - (BOOL)gestureRecognizerMayDoubleTapToZoomWebView:(UIGestureRecognizer *)gestureRecognizer;
 - (NSMapTable<NSNumber *, UITouch *> *)touchActionActiveTouches;

Modified: trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.mm (247264 => 247265)


--- trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.mm	2019-07-09 18:41:46 UTC (rev 247264)
+++ trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.mm	2019-07-09 18:43:57 UTC (rev 247265)
@@ -91,10 +91,11 @@
     if (_touchActionsByTouchIdentifier.isEmpty())
         return NO;
 
+    auto mayPan = [_touchActionDelegate gestureRecognizerMayPanWebView:preventedGestureRecognizer];
     auto mayPinchToZoom = [_touchActionDelegate gestureRecognizerMayPinchToZoomWebView:preventedGestureRecognizer];
     auto mayDoubleTapToZoom = [_touchActionDelegate gestureRecognizerMayDoubleTapToZoomWebView:preventedGestureRecognizer];
 
-    if (!mayPinchToZoom && !mayDoubleTapToZoom)
+    if (!mayPan && !mayPinchToZoom && !mayDoubleTapToZoom)
         return NO;
 
     // Now that we've established that this gesture recognizer may yield an interaction that is preventable by the "touch-action"
@@ -105,6 +106,10 @@
     for (NSNumber *touchIdentifier in activeTouches) {
         auto iterator = _touchActionsByTouchIdentifier.find([touchIdentifier unsignedIntegerValue]);
         if (iterator != _touchActionsByTouchIdentifier.end() && [[activeTouches objectForKey:touchIdentifier].gestureRecognizers containsObject:preventedGestureRecognizer]) {
+            // Panning is only allowed if "pan-x", "pan-y" or "manipulation" is specified. Additional work is needed to respect individual values, but this takes
+            // care of the case where no panning is allowed.
+            if (mayPan && !iterator->value.containsAny({ WebCore::TouchAction::PanX, WebCore::TouchAction::PanY, WebCore::TouchAction::Manipulation }))
+                return YES;
             // Pinch-to-zoom is only allowed if "pinch-zoom" or "manipulation" is specified.
             if (mayPinchToZoom && !iterator->value.containsAny({ WebCore::TouchAction::PinchZoom, WebCore::TouchAction::Manipulation }))
                 return YES;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to