Changeset 247212 in webkit


Ignore:
Timestamp:
Jul 8, 2019 11:00:33 AM (5 years ago)
Author:
graouts@webkit.org
Message:

[Pointer Events] "touch-action: none" does not prevent double-tap-to-zoom
https://bugs.webkit.org/show_bug.cgi?id=199571
<rdar://problem/51715002>

Reviewed by Wenson Hsieh.

Source/WebKit:

We add a new WKTouchActionGestureRecognizerDelegate method to check whether a gesture recognizer may lead to
zooming the page as a result of double-tapping, which can be caused by two different gesture recognizers
managed by WKContentViewInteraction. If that delegate method returns true and we have "touch-action: none"
set for this touch, we cause those gesture recognizers to fail and prevent double-tap-to-zoom behavior.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView gestureRecognizerMayDoubleTapToZoomWebView:]):

  • UIProcess/ios/WKTouchActionGestureRecognizer.h:
  • UIProcess/ios/WKTouchActionGestureRecognizer.mm:

(-[WKTouchActionGestureRecognizer canPreventGestureRecognizer:]):

LayoutTests:

Add two new tests that check that setting "touch-action: none" on an element does not allow double-tap-to-zoom
and that "touch-action: manipulation" allows it.

  • pointerevents/ios/touch-action-manipulation-double-tap-to-zoom-expected.txt: Added.
  • pointerevents/ios/touch-action-manipulation-double-tap-to-zoom.html: Added.
  • pointerevents/ios/touch-action-none-double-tap-to-zoom-expected.txt: Added.
  • pointerevents/ios/touch-action-none-double-tap-to-zoom.html: Added.
  • pointerevents/utils.js:

(const.ui.new.UIController.prototype.doubleTapToZoom):

Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247207 r247212  
     12019-07-08  Antoine Quint  <graouts@apple.com>
     2
     3        [Pointer Events] "touch-action: none" does not prevent double-tap-to-zoom
     4        https://bugs.webkit.org/show_bug.cgi?id=199571
     5        <rdar://problem/51715002>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Add two new tests that check that setting "touch-action: none" on an element does not allow double-tap-to-zoom
     10        and that "touch-action: manipulation" allows it.
     11
     12        * pointerevents/ios/touch-action-manipulation-double-tap-to-zoom-expected.txt: Added.
     13        * pointerevents/ios/touch-action-manipulation-double-tap-to-zoom.html: Added.
     14        * pointerevents/ios/touch-action-none-double-tap-to-zoom-expected.txt: Added.
     15        * pointerevents/ios/touch-action-none-double-tap-to-zoom.html: Added.
     16        * pointerevents/utils.js:
     17        (const.ui.new.UIController.prototype.doubleTapToZoom):
     18
    1192019-07-08  Charlie Turner  <cturner@igalia.com>
    220
  • trunk/LayoutTests/pointerevents/utils.js

    r246445 r247212  
    122122    {
    123123        return this._run(`uiController.singleTapAtPoint(${options.x}, ${options.y})`);
     124    }
     125
     126    doubleTapToZoom(options)
     127    {
     128        const durationInSeconds = 0.35;
     129        return new Promise(resolve => this._run(`uiController.doubleTapAtPoint(${options.x}, ${options.y})`).then(() =>
     130            setTimeout(resolve, durationInSeconds * 1000)
     131        ));
     132        return this._run();
    124133    }
    125134
  • trunk/Source/WebKit/ChangeLog

    r247210 r247212  
     12019-07-08  Antoine Quint  <graouts@apple.com>
     2
     3        [Pointer Events] "touch-action: none" does not prevent double-tap-to-zoom
     4        https://bugs.webkit.org/show_bug.cgi?id=199571
     5        <rdar://problem/51715002>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        We add a new WKTouchActionGestureRecognizerDelegate method to check whether a gesture recognizer may lead to
     10        zooming the page as a result of double-tapping, which can be caused by two different gesture recognizers
     11        managed by WKContentViewInteraction. If that delegate method returns true and we have "touch-action: none"
     12        set for this touch, we cause those gesture recognizers to fail and prevent double-tap-to-zoom behavior.
     13
     14        * UIProcess/ios/WKContentViewInteraction.mm:
     15        (-[WKContentView gestureRecognizerMayDoubleTapToZoomWebView:]):
     16        * UIProcess/ios/WKTouchActionGestureRecognizer.h:
     17        * UIProcess/ios/WKTouchActionGestureRecognizer.mm:
     18        (-[WKTouchActionGestureRecognizer canPreventGestureRecognizer:]):
     19
    1202019-07-08  Per Arne Vollan  <pvollan@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r247206 r247212  
    14041404}
    14051405
     1406- (BOOL)gestureRecognizerMayDoubleTapToZoomWebView:(UIGestureRecognizer *)gestureRecognizer
     1407{
     1408    return gestureRecognizer == _doubleTapGestureRecognizer || gestureRecognizer == _twoFingerDoubleTapGestureRecognizer;
     1409}
     1410
    14061411- (NSMapTable<NSNumber *, UITouch *> *)touchActionActiveTouches
    14071412{
  • trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.h

    r247205 r247212  
    4040@protocol WKTouchActionGestureRecognizerDelegate <NSObject>
    4141- (BOOL)gestureRecognizerMayPinchToZoomWebView:(UIGestureRecognizer *)gestureRecognizer;
     42- (BOOL)gestureRecognizerMayDoubleTapToZoomWebView:(UIGestureRecognizer *)gestureRecognizer;
    4243- (NSMapTable<NSNumber *, UITouch *> *)touchActionActiveTouches;
    4344@end
  • trunk/Source/WebKit/UIProcess/ios/WKTouchActionGestureRecognizer.mm

    r247205 r247212  
    9292        return NO;
    9393
    94     if (![_touchActionDelegate gestureRecognizerMayPinchToZoomWebView:preventedGestureRecognizer])
     94    auto mayPinchToZoom = [_touchActionDelegate gestureRecognizerMayPinchToZoomWebView:preventedGestureRecognizer];
     95    auto mayDoubleTapToZoom = [_touchActionDelegate gestureRecognizerMayDoubleTapToZoomWebView:preventedGestureRecognizer];
     96
     97    if (!mayPinchToZoom && !mayDoubleTapToZoom)
    9598        return NO;
    9699
     
    104107        if (iterator != _touchActionsByTouchIdentifier.end() && [[activeTouches objectForKey:touchIdentifier].gestureRecognizers containsObject:preventedGestureRecognizer]) {
    105108            // Pinch-to-zoom is only allowed if "pinch-zoom" or "manipulation" is specified.
    106             if (!iterator->value.containsAny({ WebCore::TouchAction::PinchZoom, WebCore::TouchAction::Manipulation }))
     109            if (mayPinchToZoom && !iterator->value.containsAny({ WebCore::TouchAction::PinchZoom, WebCore::TouchAction::Manipulation }))
     110                return YES;
     111            // Double-tap-to-zoom is only disallowed if "none" is specified.
     112            if (mayDoubleTapToZoom && iterator->value.contains(WebCore::TouchAction::None))
    107113                return YES;
    108114        }
Note: See TracChangeset for help on using the changeset viewer.