Title: [245227] branches/safari-608.1.24-branch/Source/WebKit
Revision
245227
Author
bshaf...@apple.com
Date
2019-05-12 23:51:08 -0700 (Sun, 12 May 2019)

Log Message

Cherry-pick r245153. rdar://problem/50604700

    Guard long press link preview with a USE macro rather than complicated includes
    https://bugs.webkit.org/show_bug.cgi?id=197728
    <rdar://problem/50604700>

    Reviewed by Wenson Hsieh.

    It was getting complicated to manage the coordination between WebKitAdditions
    and WebKit without having to split up the includes into multiple files
    or have lots of duplication.

    Instead, WebKitAdditions will now define a USE macro which can be used
    in various places through WebKit.

    * UIProcess/ios/WKContentViewInteraction.h:
    * UIProcess/ios/WKContentViewInteraction.mm:
    (-[WKContentView dragInteraction:itemsForBeginningSession:]):
    (-[WKContentView _contentsOfUserInterfaceItem:]):
    (previewIdentifierForElementAction):
    (-[WKContentView shouldUsePreviewForLongPress]):
    (-[WKContentView _registerPreview]):
    (-[WKContentView _unregisterPreview]):
    (shouldUsePreviewForLongPress): Deleted.
    (-[WKContentView _registerPreviewLongPress]): Deleted.
    (-[WKContentView _unregisterPreviewLongPress]): Deleted.

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

Modified Paths

Diff

Modified: branches/safari-608.1.24-branch/Source/WebKit/ChangeLog (245226 => 245227)


--- branches/safari-608.1.24-branch/Source/WebKit/ChangeLog	2019-05-13 06:51:05 UTC (rev 245226)
+++ branches/safari-608.1.24-branch/Source/WebKit/ChangeLog	2019-05-13 06:51:08 UTC (rev 245227)
@@ -1,5 +1,63 @@
 2019-05-12  Babak Shafiei  <bshaf...@apple.com>
 
+        Cherry-pick r245153. rdar://problem/50604700
+
+    Guard long press link preview with a USE macro rather than complicated includes
+    https://bugs.webkit.org/show_bug.cgi?id=197728
+    <rdar://problem/50604700>
+    
+    Reviewed by Wenson Hsieh.
+    
+    It was getting complicated to manage the coordination between WebKitAdditions
+    and WebKit without having to split up the includes into multiple files
+    or have lots of duplication.
+    
+    Instead, WebKitAdditions will now define a USE macro which can be used
+    in various places through WebKit.
+    
+    * UIProcess/ios/WKContentViewInteraction.h:
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView dragInteraction:itemsForBeginningSession:]):
+    (-[WKContentView _contentsOfUserInterfaceItem:]):
+    (previewIdentifierForElementAction):
+    (-[WKContentView shouldUsePreviewForLongPress]):
+    (-[WKContentView _registerPreview]):
+    (-[WKContentView _unregisterPreview]):
+    (shouldUsePreviewForLongPress): Deleted.
+    (-[WKContentView _registerPreviewLongPress]): Deleted.
+    (-[WKContentView _unregisterPreviewLongPress]): Deleted.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-08  Dean Jackson  <d...@apple.com>
+
+            Guard long press link preview with a USE macro rather than complicated includes
+            https://bugs.webkit.org/show_bug.cgi?id=197728
+            <rdar://problem/50604700>
+
+            Reviewed by Wenson Hsieh.
+
+            It was getting complicated to manage the coordination between WebKitAdditions
+            and WebKit without having to split up the includes into multiple files
+            or have lots of duplication.
+
+            Instead, WebKitAdditions will now define a USE macro which can be used
+            in various places through WebKit.
+
+            * UIProcess/ios/WKContentViewInteraction.h:
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView dragInteraction:itemsForBeginningSession:]):
+            (-[WKContentView _contentsOfUserInterfaceItem:]):
+            (previewIdentifierForElementAction):
+            (-[WKContentView shouldUsePreviewForLongPress]):
+            (-[WKContentView _registerPreview]):
+            (-[WKContentView _unregisterPreview]):
+            (shouldUsePreviewForLongPress): Deleted.
+            (-[WKContentView _registerPreviewLongPress]): Deleted.
+            (-[WKContentView _unregisterPreviewLongPress]): Deleted.
+
+2019-05-12  Babak Shafiei  <bshaf...@apple.com>
+
         Cherry-pick r245148. rdar://problem/50457731
 
     REGRESSION (r241734): 1% slower PLT on iPad

Modified: branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (245226 => 245227)


--- branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-05-13 06:51:05 UTC (rev 245226)
+++ branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-05-13 06:51:08 UTC (rev 245227)
@@ -61,14 +61,7 @@
 
 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.h>)
 #import <WebKitAdditions/WKInteractionPreviewAdditions.h>
-#else
-#ifndef ADDITIONAL_LINK_PREVIEW_MEMBERS
-#define ADDITIONAL_LINK_PREVIEW_MEMBERS
 #endif
-#ifndef ADDITIONAL_LINK_PREVIEW_PROTOCOLS
-#define ADDITIONAL_LINK_PREVIEW_PROTOCOLS
-#endif
-#endif
 
 namespace API {
 class OpenPanelParameters;
@@ -255,9 +248,12 @@
     RetainPtr<UIGestureRecognizer> _previewSecondaryGestureRecognizer;
     Vector<bool> _focusStateStack;
 #if HAVE(LINK_PREVIEW)
+#if USE(LONG_PRESS_FOR_LINK_PREVIEW)
+    LONG_PRESS_LINK_PREVIEW_MEMBERS
+#else
     RetainPtr<UIPreviewItemController> _previewItemController;
-    ADDITIONAL_LINK_PREVIEW_MEMBERS
 #endif
+#endif
 
     std::unique_ptr<WebKit::SmartMagnificationController> _smartMagnificationController;
 
@@ -527,7 +523,11 @@
 @end
 
 #if HAVE(LINK_PREVIEW)
-@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate ADDITIONAL_LINK_PREVIEW_PROTOCOLS>
+#if USE(LONG_PRESS_FOR_LINK_PREVIEW)
+@interface WKContentView (WKInteractionPreview) <LONG_PRESS_LINK_PREVIEW_PROTOCOL>
+#else
+@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
+#endif
 
 @property (nonatomic, readonly) BOOL shouldUsePreviewForLongPress;
 

Modified: branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (245226 => 245227)


--- branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-05-13 06:51:05 UTC (rev 245226)
+++ branches/safari-608.1.24-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-05-13 06:51:08 UTC (rev 245227)
@@ -7215,8 +7215,12 @@
 
 #if HAVE(LINK_PREVIEW)
     if ([userInterfaceItem isEqualToString:@"linkPreviewPopoverContents"]) {
+#if USE(LONG_PRESS_FOR_LINK_PREVIEW)
+        return @{ userInterfaceItem: @{ @"pageURL": WTF::userVisibleString(_positionInformation.url) } };
+#else
         NSString *url = "" previewData][UIPreviewDataLink];
         return @{ userInterfaceItem: @{ @"pageURL": url } };
+#endif
     }
 #endif
 
@@ -7233,28 +7237,35 @@
 
 #if HAVE(LINK_PREVIEW)
 
-@implementation WKContentView (WKInteractionPreview)
+static NSString *previewIdentifierForElementAction(_WKElementAction *action)
+{
+    switch (action.type) {
+    case _WKElementActionTypeOpen:
+        return WKPreviewActionItemIdentifierOpen;
+    case _WKElementActionTypeCopy:
+        return WKPreviewActionItemIdentifierCopy;
+#if !defined(TARGET_OS_IOS) || TARGET_OS_IOS
+    case _WKElementActionTypeAddToReadingList:
+        return WKPreviewActionItemIdentifierAddToReadingList;
+#endif
+    case _WKElementActionTypeShare:
+        return WKPreviewActionItemIdentifierShare;
+    default:
+        return nil;
+    }
+    ASSERT_NOT_REACHED();
+    return nil;
+}
 
-#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.mm>)
+#if USE(LONG_PRESS_FOR_LINK_PREVIEW)
 #include <WebKitAdditions/WKInteractionPreviewAdditions.mm>
 #else
-static BOOL shouldUsePreviewForLongPress()
-{
-    return NO;
-}
 
-- (void)_registerPreviewLongPress
-{
-}
+@implementation WKContentView (WKInteractionPreview)
 
-- (void)_unregisterPreviewLongPress
-{
-}
-#endif
-
 - (BOOL)shouldUsePreviewForLongPress
 {
-    return shouldUsePreviewForLongPress();
+    return NO;
 }
 
 - (void)_registerPreview
@@ -7262,27 +7273,19 @@
     if (!_webView.allowsLinkPreview)
         return;
 
-    if (shouldUsePreviewForLongPress())
-        [self _registerPreviewLongPress];
-    else {
-        _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
-        [_previewItemController setDelegate:self];
-        _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
-        if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
-            _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
-    }
+    _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
+    [_previewItemController setDelegate:self];
+    _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
+    if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
+        _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
 }
 
 - (void)_unregisterPreview
 {
-    if (shouldUsePreviewForLongPress())
-        [self _unregisterPreviewLongPress];
-    else {
-        [_previewItemController setDelegate:nil];
-        _previewGestureRecognizer = nil;
-        _previewSecondaryGestureRecognizer = nil;
-        _previewItemController = nil;
-    }
+    [_previewItemController setDelegate:nil];
+    _previewGestureRecognizer = nil;
+    _previewSecondaryGestureRecognizer = nil;
+    _previewItemController = nil;
 }
 
 - (BOOL)_interactionShouldBeginFromPreviewItemController:(UIPreviewItemController *)controller forPosition:(CGPoint)position
@@ -7416,26 +7419,6 @@
     return _positionInformation.bounds;
 }
 
-static NSString *previewIdentifierForElementAction(_WKElementAction *action)
-{
-    switch (action.type) {
-    case _WKElementActionTypeOpen:
-        return WKPreviewActionItemIdentifierOpen;
-    case _WKElementActionTypeCopy:
-        return WKPreviewActionItemIdentifierCopy;
-#if !defined(TARGET_OS_IOS) || TARGET_OS_IOS
-    case _WKElementActionTypeAddToReadingList:
-        return WKPreviewActionItemIdentifierAddToReadingList;
-#endif
-    case _WKElementActionTypeShare:
-        return WKPreviewActionItemIdentifierShare;
-    default:
-        return nil;
-    }
-    ASSERT_NOT_REACHED();
-    return nil;
-}
-
 - (UIViewController *)_presentedViewControllerForPreviewItemController:(UIPreviewItemController *)controller
 {
     id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
@@ -7606,6 +7589,8 @@
 
 @end
 
+#endif // USE(LONG_PRESS_FOR_LINK_PREVIEW)
+
 #endif // HAVE(LINK_PREVIEW)
 
 // UITextRange, UITextPosition and UITextSelectionRect implementations for WK2
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to