Provide option to not create a longpress gesture recognizer
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 21:58:08 +0000 (21:58 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 21:58:08 +0000 (21:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196937
<rdar://problem/49918278>

Reviewed by Antoine Quint.

A WebKitAdditions file has changed name to WKContentViewInteractionWKInteraction.mm.

Add a property to toggle if we should add a long press gesture
recognizer.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(shouldUsePreviewForLongPress):
(-[WKContentView shouldUsePreviewForLongPress]):

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

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

index 54ff0ca..f6c4d70 100644 (file)
@@ -1,3 +1,22 @@
+2019-04-15  Dean Jackson  <dino@apple.com>
+
+        Provide option to not create a longpress gesture recognizer
+        https://bugs.webkit.org/show_bug.cgi?id=196937
+        <rdar://problem/49918278>
+
+        Reviewed by Antoine Quint.
+
+        A WebKitAdditions file has changed name to WKContentViewInteractionWKInteraction.mm.
+
+        Add a property to toggle if we should add a long press gesture
+        recognizer.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (shouldUsePreviewForLongPress):
+        (-[WKContentView shouldUsePreviewForLongPress]):
+
 2019-04-15  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] WebCore derived sources should only be referenced inside WebCore
index eb5bd43..92ba204 100644 (file)
@@ -502,8 +502,11 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 #if HAVE(LINK_PREVIEW)
 @interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
 
+@property (nonatomic, readonly) BOOL shouldUsePreviewForLongPress;
+
 - (void)_registerPreview;
 - (void)_unregisterPreview;
+
 @end
 #endif
 
index f0aa5b7..61b408c 100644 (file)
@@ -742,7 +742,8 @@ static inline bool hasFocusedElement(WebKit::FocusedElementInformation focusedEl
     [_highlightLongPressGestureRecognizer setDelegate:self];
     [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
 
-    [self _createAndConfigureLongPressGestureRecognizer];
+    if (!self.shouldUsePreviewForLongPress)
+        [self _createAndConfigureLongPressGestureRecognizer];
 
 #if ENABLE(DATA_INTERACTION)
     [self setupDragAndDropInteractions];
@@ -1699,8 +1700,8 @@ static NSValue *nsSizeForTapHighlightBorderRadius(WebCore::IntSize borderRadius,
     return _page->editorState().postLayoutData().focusedElementRect;
 }
 
-#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKContentViewInteraction.mm>)
-#include <WebKitAdditions/WKContentViewInteraction.mm>
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKContentViewInteractionWKInteraction.mm>)
+#include <WebKitAdditions/WKContentViewInteractionWKInteraction.mm>
 #else
 
 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer
@@ -7129,6 +7130,20 @@ static WebEventFlags webEventFlagsForUIKeyModifierFlags(UIKeyModifierFlags flags
 
 @implementation WKContentView (WKInteractionPreview)
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.mm>)
+#include <WebKitAdditions/WKInteractionPreviewAdditions.mm>
+#else
+static BOOL shouldUsePreviewForLongPress()
+{
+    return NO;
+}
+#endif
+
+- (BOOL)shouldUsePreviewForLongPress
+{
+    return shouldUsePreviewForLongPress();
+}
+
 - (void)_registerPreview
 {
     if (!_webView.allowsLinkPreview)