WebKit Bugzilla
Attachment 369452 Details for
Bug 197728
: Guard long press link preview with a USE macro rather than complicated includes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197728-20190509105030.patch (text/plain), 8.48 KB, created by
Dean Jackson
on 2019-05-08 17:50:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2019-05-08 17:50:31 PDT
Size:
8.48 KB
patch
obsolete
>Subversion Revision: 245023 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 7cb4a7c6935ecba83d3f695e052bef919358fedb..b9dff96f2e80c2cb94435af340991a73a100aaeb 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,30 @@ >+2019-05-08 Dean Jackson <dino@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 NOBODY (OOPS!). >+ >+ 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-07 John Wilander <wilander@apple.com> > > Change IsITPFirstPartyWebsiteDataRemovalEnabled from DEFAULT_EXPERIMENTAL_FEATURES_ENABLED to true. >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index 99839a204a3f9048b061080edef863bd32df7180..2bf2d7945f3899809cf1d083dba5249e934f588f 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -60,13 +60,6 @@ > > #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 { >@@ -254,8 +247,11 @@ struct WKAutoCorrectionData { > 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; >@@ -522,7 +518,11 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW) > @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; > >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index abf883cedc476ec1f4bcd3d23252996f0e9926b6..6bf983d9ed899867153647f7d39c04f920e14332 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -7187,8 +7187,12 @@ static WebEventFlags webEventFlagsForUIKeyModifierFlags(UIKeyModifierFlags flags > > #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 = [_previewItemController previewData][UIPreviewDataLink]; > return @{ userInterfaceItem: @{ @"pageURL": url } }; >+#endif > } > #endif > >@@ -7205,28 +7209,35 @@ static WebEventFlags webEventFlagsForUIKeyModifierFlags(UIKeyModifierFlags flags > > #if HAVE(LINK_PREVIEW) > >-@implementation WKContentView (WKInteractionPreview) >- >-#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.mm>) >-#include <WebKitAdditions/WKInteractionPreviewAdditions.mm> >-#else >-static BOOL shouldUsePreviewForLongPress() >+static NSString *previewIdentifierForElementAction(_WKElementAction *action) > { >- return NO; >+ 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; > } > >-- (void)_registerPreviewLongPress >-{ >-} >+#if USE(LONG_PRESS_FOR_LINK_PREVIEW) >+#include <WebKitAdditions/WKInteractionPreviewAdditions.mm> >+#else > >-- (void)_unregisterPreviewLongPress >-{ >-} >-#endif >+@implementation WKContentView (WKInteractionPreview) > > - (BOOL)shouldUsePreviewForLongPress > { >- return shouldUsePreviewForLongPress(); >+ return NO; > } > > - (void)_registerPreview >@@ -7234,27 +7245,19 @@ static BOOL shouldUsePreviewForLongPress() > 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 >@@ -7388,26 +7391,6 @@ static BOOL shouldUsePreviewForLongPress() > 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]); >@@ -7578,6 +7561,8 @@ static NSString *previewIdentifierForElementAction(_WKElementAction *action) > > @end > >+#endif // USE(LONG_PRESS_FOR_LINK_PREVIEW) >+ > #endif // HAVE(LINK_PREVIEW) > > // UITextRange, UITextPosition and UITextSelectionRect implementations for WK2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
wenson_hsieh
:
review+
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197728
: 369452 |
369458