Title: [244555] trunk/Source/WebKit
Revision
244555
Author
[email protected]
Date
2019-04-23 12:35:30 -0700 (Tue, 23 Apr 2019)

Log Message

Use additional members and protocols from WebKitAdditions in WKContentViewInteraction
https://bugs.webkit.org/show_bug.cgi?id=197184
<rdar://problem/50113848>

Reviewed by Wenson Hsieh.

WebKitAdditions defines some macros to include additional members
and protocols for WKContentViewInteraction.

It also defines some new functions. Provide empty version
of those functions when WebKitAdditions is not available.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _registerPreview]):
(-[WKContentView _unregisterPreview]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (244554 => 244555)


--- trunk/Source/WebKit/ChangeLog	2019-04-23 19:13:48 UTC (rev 244554)
+++ trunk/Source/WebKit/ChangeLog	2019-04-23 19:35:30 UTC (rev 244555)
@@ -1,3 +1,22 @@
+2019-04-22  Dean Jackson  <[email protected]>
+
+        Use additional members and protocols from WebKitAdditions in WKContentViewInteraction
+        https://bugs.webkit.org/show_bug.cgi?id=197184
+        <rdar://problem/50113848>
+
+        Reviewed by Wenson Hsieh.
+
+        WebKitAdditions defines some macros to include additional members
+        and protocols for WKContentViewInteraction.
+
+        It also defines some new functions. Provide empty version
+        of those functions when WebKitAdditions is not available.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _registerPreview]):
+        (-[WKContentView _unregisterPreview]):
+
 2019-04-23  Tim Horton  <[email protected]>
 
         Action sheet shares a stringified URL instead of a URL object

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (244554 => 244555)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-04-23 19:13:48 UTC (rev 244554)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-04-23 19:35:30 UTC (rev 244555)
@@ -57,6 +57,17 @@
 #import <wtf/WeakObjCPtr.h>
 #import <wtf/text/WTFString.h>
 
+#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;
 }
@@ -240,6 +251,7 @@
     Vector<bool> _focusStateStack;
 #if HAVE(LINK_PREVIEW)
     RetainPtr<UIPreviewItemController> _previewItemController;
+    ADDITIONAL_LINK_PREVIEW_MEMBERS
 #endif
 
     std::unique_ptr<WebKit::SmartMagnificationController> _smartMagnificationController;
@@ -503,7 +515,7 @@
 @end
 
 #if HAVE(LINK_PREVIEW)
-@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
+@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate ADDITIONAL_LINK_PREVIEW_PROTOCOLS>
 
 @property (nonatomic, readonly) BOOL shouldUsePreviewForLongPress;
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (244554 => 244555)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-04-23 19:13:48 UTC (rev 244554)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-04-23 19:35:30 UTC (rev 244555)
@@ -148,6 +148,10 @@
 SOFT_LINK_CONSTANT(ManagedConfiguration, MCFeatureDefinitionLookupAllowed, NSString *)
 #endif
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.h>)
+#import <WebKitAdditions/WKInteractionPreviewAdditions.h>
+#endif
+
 #if PLATFORM(WATCHOS)
 
 @interface WKContentView (WatchSupport) <WKFocusedFormControlViewDelegate, WKSelectMenuListViewControllerDelegate, WKTextInputListViewControllerDelegate>
@@ -7143,6 +7147,14 @@
 {
     return NO;
 }
+
+- (void)_registerPreviewLongPress
+{
+}
+
+- (void)_unregisterPreviewLongPress
+{
+}
 #endif
 
 - (BOOL)shouldUsePreviewForLongPress
@@ -7155,19 +7167,27 @@
     if (!_webView.allowsLinkPreview)
         return;
 
-    _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]);
-    [_previewItemController setDelegate:self];
-    _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
-    if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
-        _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
+    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;
+    }
 }
 
 - (void)_unregisterPreview
 {
-    [_previewItemController setDelegate:nil];
-    _previewGestureRecognizer = nil;
-    _previewSecondaryGestureRecognizer = nil;
-    _previewItemController = nil;
+    if (shouldUsePreviewForLongPress())
+        [self _unregisterPreviewLongPress];
+    else {
+        [_previewItemController setDelegate:nil];
+        _previewGestureRecognizer = nil;
+        _previewSecondaryGestureRecognizer = nil;
+        _previewItemController = nil;
+    }
 }
 
 - (BOOL)_interactionShouldBeginFromPreviewItemController:(UIPreviewItemController *)controller forPosition:(CGPoint)position
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to