Title: [219157] trunk/Source/WebKit2
Revision
219157
Author
wenson_hs...@apple.com
Date
2017-07-05 14:40:31 -0700 (Wed, 05 Jul 2017)

Log Message

[iOS DnD] [WK2] 3D touch fails to recognize when UIDragInteraction is enabled on phone
https://bugs.webkit.org/show_bug.cgi?id=174171
<rdar://problem/32956929>

Reviewed by Tim Horton.

By default, UIKit defers all competing long press gesture recognizers if dragging is enabled. However, this
would cause 3D touch to be prevented, due to UIKit asking us whether or not we can proceed with the 3D touch
gesture in -_interactionShouldBeginFromPreviewItemController:forPosition:, while the highlight long press
gesture recognizer is being deferred. To address this, we use SPI on UIDragInteraction to allow the highlight
long press gesture recognizer to recognize alongside the drag lift gesture. We then (already) manually cancel
the highlight long press gesture in _dragInteraction:prepareForSession:completion:.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (219156 => 219157)


--- trunk/Source/WebKit2/ChangeLog	2017-07-05 21:26:23 UTC (rev 219156)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-05 21:40:31 UTC (rev 219157)
@@ -1,3 +1,21 @@
+2017-07-05  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS DnD] [WK2] 3D touch fails to recognize when UIDragInteraction is enabled on phone
+        https://bugs.webkit.org/show_bug.cgi?id=174171
+        <rdar://problem/32956929>
+
+        Reviewed by Tim Horton.
+
+        By default, UIKit defers all competing long press gesture recognizers if dragging is enabled. However, this
+        would cause 3D touch to be prevented, due to UIKit asking us whether or not we can proceed with the 3D touch
+        gesture in -_interactionShouldBeginFromPreviewItemController:forPosition:, while the highlight long press
+        gesture recognizer is being deferred. To address this, we use SPI on UIDragInteraction to allow the highlight
+        long press gesture recognizer to recognize alongside the drag lift gesture. We then (already) manually cancel
+        the highlight long press gesture in _dragInteraction:prepareForSession:completion:.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _dragInteraction:shouldDelayCompetingGestureRecognizer:]):
+
 2017-07-03  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Remove copy of ICU headers from WebKit

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (219156 => 219157)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-07-05 21:26:23 UTC (rev 219156)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-07-05 21:40:31 UTC (rev 219157)
@@ -4523,6 +4523,18 @@
 
 #pragma mark - UIDragInteractionDelegate
 
+- (BOOL)_dragInteraction:(UIDragInteraction *)interaction shouldDelayCompetingGestureRecognizer:(UIGestureRecognizer *)competingGestureRecognizer
+{
+    if (_highlightLongPressGestureRecognizer == competingGestureRecognizer) {
+        // Since 3D touch still recognizes alongside the drag lift, and also requires the highlight long press
+        // gesture to be active to support cancelling when `touchstart` is prevented, we should also allow the
+        // highlight long press to recognize simultaneously, and manually cancel it when the drag lift is
+        // recognized (see _dragInteraction:prepareForSession:completion:).
+        return NO;
+    }
+    return [competingGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]];
+}
+
 - (void)_dragInteraction:(UIDragInteraction *)interaction prepareForSession:(id <UIDragSession>)session completion:(dispatch_block_t)completion
 {
     [self _cancelLongPressGestureRecognizer];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to