Changeset 247265 in webkit


Ignore:
Timestamp:
Jul 9, 2019 11:43:57 AM (5 years ago)
Author:
graouts@webkit.org
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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247259 r247265  
     12019-07-09  Antoine Quint  <graouts@apple.com>
     2
     3        [Pointer Events] Scroll indicators should not show for scrollable content with touch-action: none
     4        https://bugs.webkit.org/show_bug.cgi?id=199618
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add a new test that swipes "overflow: scroll" content which would show scroll indicators without scrolling
     9        prior to this patch.
     10
     11        * pointerevents/ios/touch-action-none-no-scroll-indicators-expected.html: Added.
     12        * pointerevents/ios/touch-action-none-no-scroll-indicators.html: Added.
     13
    1142019-07-09  Charlie Turner  <cturner@igalia.com>
    215
  • trunk/Source/WebKit/ChangeLog

    r247264 r247265  
     12019-07-09  Antoine Quint  <graouts@apple.com>
     2
     3        [Pointer Events] Scroll indicators should not show for scrollable content with touch-action: none
     4        https://bugs.webkit.org/show_bug.cgi?id=199618
     5
     6        Reviewed by Simon Fraser.
     7
     8        Even though we correctly didn't scroll when "touch-action: none" was specified on an element, we would only apply
     9        scrolling constraints after the panning gesture was recognized and the backing UIScrollView would show its scroll
     10        indicators. While this is correct when only "pan-x" or "pan-y" is specified, we should not show the scroll indicators
     11        at all for "touch-action: none" since no scrolling should happen.
     12
     13        To do this, we add a new method to the WKTouchActionGestureRecognizerDelegate protocol to indicate whether a given
     14        gesture recognizer may pan content in the WKWebView. If the gesture recognizer is the top-level scroll view or one
     15        created within the page to back "overflow: scroll" content or an iframe, we correctly make that gesture recognizer
     16        fail to recognize if neither "pan-x" nor "pan-y" is specified for this touch identifier.
     17
     18        * UIProcess/ios/WKContentViewInteraction.mm:
     19        (-[WKContentView gestureRecognizerMayPanWebView:]):
     20        * UIProcess/ios/WKTouchActionGestureRecognizer.h:
     21        * UIProcess/ios/WKTouchActionGestureRecognizer.mm:
     22        (-[WKTouchActionGestureRecognizer canPreventGestureRecognizer:]):
     23
    1242019-07-09  Chris Dumez  <cdumez@apple.com>
    225
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r247233 r247265  
    13881388#pragma mark - WKTouchActionGestureRecognizerDelegate implementation
    13891389
     1390- (BOOL)gestureRecognizerMayPanWebView:(UIGestureRecognizer *)gestureRecognizer
     1391{
     1392    // The gesture recognizer is the main UIScrollView's UIPanGestureRecognizer.
     1393    if (gestureRecognizer == [_webView scrollView].panGestureRecognizer)
     1394        return YES;
     1395
     1396    // The gesture recognizer is a child UIScrollView's UIPanGestureRecognizer created by WebKit.
     1397    if (gestureRecognizer.view && [gestureRecognizer.view isKindOfClass:[WKChildScrollView class]])
     1398        return YES;
     1399
     1400    return NO;
     1401}
     1402
    13901403- (BOOL)gestureRecognizerMayPinchToZoomWebView:(UIGestureRecognizer *)gestureRecognizer
    13911404{
  • trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.h

    r247212 r247265  
    3939
    4040@protocol WKTouchActionGestureRecognizerDelegate <NSObject>
     41- (BOOL)gestureRecognizerMayPanWebView:(UIGestureRecognizer *)gestureRecognizer;
    4142- (BOOL)gestureRecognizerMayPinchToZoomWebView:(UIGestureRecognizer *)gestureRecognizer;
    4243- (BOOL)gestureRecognizerMayDoubleTapToZoomWebView:(UIGestureRecognizer *)gestureRecognizer;
  • trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.mm

    r247212 r247265  
    9292        return NO;
    9393
     94    auto mayPan = [_touchActionDelegate gestureRecognizerMayPanWebView:preventedGestureRecognizer];
    9495    auto mayPinchToZoom = [_touchActionDelegate gestureRecognizerMayPinchToZoomWebView:preventedGestureRecognizer];
    9596    auto mayDoubleTapToZoom = [_touchActionDelegate gestureRecognizerMayDoubleTapToZoomWebView:preventedGestureRecognizer];
    9697
    97     if (!mayPinchToZoom && !mayDoubleTapToZoom)
     98    if (!mayPan && !mayPinchToZoom && !mayDoubleTapToZoom)
    9899        return NO;
    99100
     
    106107        auto iterator = _touchActionsByTouchIdentifier.find([touchIdentifier unsignedIntegerValue]);
    107108        if (iterator != _touchActionsByTouchIdentifier.end() && [[activeTouches objectForKey:touchIdentifier].gestureRecognizers containsObject:preventedGestureRecognizer]) {
     109            // Panning is only allowed if "pan-x", "pan-y" or "manipulation" is specified. Additional work is needed to respect individual values, but this takes
     110            // care of the case where no panning is allowed.
     111            if (mayPan && !iterator->value.containsAny({ WebCore::TouchAction::PanX, WebCore::TouchAction::PanY, WebCore::TouchAction::Manipulation }))
     112                return YES;
    108113            // Pinch-to-zoom is only allowed if "pinch-zoom" or "manipulation" is specified.
    109114            if (mayPinchToZoom && !iterator->value.containsAny({ WebCore::TouchAction::PinchZoom, WebCore::TouchAction::Manipulation }))
Note: See TracChangeset for help on using the changeset viewer.