Rename _highlightLongPressCanClick and only add gesture recognizer when necessary
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2019 12:23:20 +0000 (12:23 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2019 12:23:20 +0000 (12:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197231
<rdar://problem/50164234>

Reviewed by Antoine Quint.

Rename _highlightLongPressCanClick to _longPressCanClick since it will be
used in other places.

Only attach the _highlightLongPressGestureRecognizer when we're not
using long presses for preview. This might revert in the future, if we
can set up an appropriate gesture resolution between the two.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView _webTouchEvent:preventsNativeGestures:]):
(-[WKContentView _highlightLongPressRecognized:]):
(-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
(-[WKContentView _presentedViewControllerForPreviewItemController:]):
(-[WKContentView _previewItemControllerDidCancelPreview:]):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index a1dee46..c5857c0 100644 (file)
@@ -1,3 +1,27 @@
+2019-04-24  Dean Jackson  <dino@apple.com>
+
+        Rename _highlightLongPressCanClick and only add gesture recognizer when necessary
+        https://bugs.webkit.org/show_bug.cgi?id=197231
+        <rdar://problem/50164234>
+
+        Reviewed by Antoine Quint.
+
+        Rename _highlightLongPressCanClick to _longPressCanClick since it will be
+        used in other places.
+
+        Only attach the _highlightLongPressGestureRecognizer when we're not
+        using long presses for preview. This might revert in the future, if we
+        can set up an appropriate gesture resolution between the two.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView _webTouchEvent:preventsNativeGestures:]):
+        (-[WKContentView _highlightLongPressRecognized:]):
+        (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
+        (-[WKContentView _presentedViewControllerForPreviewItemController:]):
+        (-[WKContentView _previewItemControllerDidCancelPreview:]):
+
 2019-04-24  chris fleizach  <cfleizach@apple.com>
 
         AX: Remove deprecated Accessibility Object Model events
index 2651a6d..107a279 100644 (file)
@@ -309,7 +309,7 @@ struct WKAutoCorrectionData {
     BOOL _isTapHighlightIDValid;
     BOOL _potentialTapInProgress;
     BOOL _isDoubleTapPending;
-    BOOL _highlightLongPressCanClick;
+    BOOL _longPressCanClick;
     BOOL _hasTapHighlightForPotentialTap;
     BOOL _selectionNeedsUpdate;
     BOOL _shouldRestoreSelection;
index 4830129..0cfad5f 100644 (file)
@@ -745,12 +745,15 @@ static inline bool hasFocusedElement(WebKit::FocusedElementInformation focusedEl
     _highlightLongPressGestureRecognizer = adoptNS([[_UIWebHighlightLongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_highlightLongPressRecognized:)]);
     [_highlightLongPressGestureRecognizer setDelay:highlightDelay];
     [_highlightLongPressGestureRecognizer setDelegate:self];
-    [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
 
 #if HAVE(LINK_PREVIEW)
     if (!self.shouldUsePreviewForLongPress)
 #endif
+    {
+        [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
+
         [self _createAndConfigureLongPressGestureRecognizer];
+    }
 
 #if ENABLE(DATA_INTERACTION)
     [self setupDragAndDropInteractions];
@@ -1392,7 +1395,7 @@ static WebCore::FloatQuad inflateQuad(const WebCore::FloatQuad& quad, float infl
 - (void)_webTouchEvent:(const WebKit::NativeWebTouchEvent&)touchEvent preventsNativeGestures:(BOOL)preventsNativeGesture
 {
     if (preventsNativeGesture) {
-        _highlightLongPressCanClick = NO;
+        _longPressCanClick = NO;
 
         _canSendTouchEventsAsynchronously = YES;
         [_touchEventGestureRecognizer setDefaultPrevented:YES];
@@ -2187,22 +2190,22 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI
 
     switch ([gestureRecognizer state]) {
     case UIGestureRecognizerStateBegan:
-        _highlightLongPressCanClick = YES;
+        _longPressCanClick = YES;
         cancelPotentialTapIfNecessary(self);
         _page->tapHighlightAtPosition([gestureRecognizer startPoint], ++_latestTapID);
         _isTapHighlightIDValid = YES;
         break;
     case UIGestureRecognizerStateEnded:
-        if (_highlightLongPressCanClick && _positionInformation.isElement) {
+        if (_longPressCanClick && _positionInformation.isElement) {
             [self _attemptClickAtLocation:gestureRecognizer.startPoint modifierFlags:gestureRecognizerModifierFlags(gestureRecognizer)];
             [self _finishInteraction];
         } else
             [self _cancelInteraction];
-        _highlightLongPressCanClick = NO;
+        _longPressCanClick = NO;
         break;
     case UIGestureRecognizerStateCancelled:
         [self _cancelInteraction];
-        _highlightLongPressCanClick = NO;
+        _longPressCanClick = NO;
         break;
     default:
         break;
@@ -7195,7 +7198,7 @@ static BOOL shouldUsePreviewForLongPress()
 
 - (BOOL)_interactionShouldBeginFromPreviewItemController:(UIPreviewItemController *)controller forPosition:(CGPoint)position
 {
-    if (!_highlightLongPressCanClick)
+    if (!_longPressCanClick)
         return NO;
 
     WebKit::InteractionInformationRequest request(WebCore::roundedIntPoint(position));
@@ -7355,7 +7358,7 @@ static NSString *previewIdentifierForElementAction(_WKElementAction *action)
     bool isValidURLForImagePreview = !coreTargetURL.isEmpty() && (WTF::protocolIsInHTTPFamily(coreTargetURL) || WTF::protocolIs(coreTargetURL, "data"));
 
     if ([_previewItemController type] == UIPreviewItemTypeLink) {
-        _highlightLongPressCanClick = NO;
+        _longPressCanClick = NO;
         _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
 
         // Treat animated images like a link preview
@@ -7507,7 +7510,7 @@ static NSString *previewIdentifierForElementAction(_WKElementAction *action)
 
 - (void)_previewItemControllerDidCancelPreview:(UIPreviewItemController *)controller
 {
-    _highlightLongPressCanClick = NO;
+    _longPressCanClick = NO;
     
     [_webView _didDismissForcePressPreview];
 }