Skip to content
Permalink
Browse files
Use additional members and protocols from WebKitAdditions in WKConten…
…tViewInteraction

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]):

Canonical link: https://commits.webkit.org/211415@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
grorg committed Apr 23, 2019
1 parent bdb2b7b commit 098246e2d9fcaa2e86f22ea810eef17a402c3620
Showing 3 changed files with 61 additions and 10 deletions.
@@ -1,3 +1,22 @@
2019-04-22 Dean Jackson <dino@apple.com>

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 <timothy_horton@apple.com>

Action sheet shares a stringified URL instead of a URL object
@@ -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 @@ struct WKAutoCorrectionData {
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 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
@end

#if HAVE(LINK_PREVIEW)
@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate ADDITIONAL_LINK_PREVIEW_PROTOCOLS>

@property (nonatomic, readonly) BOOL shouldUsePreviewForLongPress;

@@ -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 @@ static BOOL shouldUsePreviewForLongPress()
{
return NO;
}

- (void)_registerPreviewLongPress
{
}

- (void)_unregisterPreviewLongPress
{
}
#endif

- (BOOL)shouldUsePreviewForLongPress
@@ -7155,19 +7167,27 @@ - (void)_registerPreview
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

0 comments on commit 098246e

Please sign in to comment.