Changeset 245153 in webkit
- Timestamp:
- May 9, 2019 12:42:44 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r245151 r245153 1 2019-05-08 Dean Jackson <dino@apple.com> 2 3 Guard long press link preview with a USE macro rather than complicated includes 4 https://bugs.webkit.org/show_bug.cgi?id=197728 5 <rdar://problem/50604700> 6 7 Reviewed by Wenson Hsieh. 8 9 It was getting complicated to manage the coordination between WebKitAdditions 10 and WebKit without having to split up the includes into multiple files 11 or have lots of duplication. 12 13 Instead, WebKitAdditions will now define a USE macro which can be used 14 in various places through WebKit. 15 16 * UIProcess/ios/WKContentViewInteraction.h: 17 * UIProcess/ios/WKContentViewInteraction.mm: 18 (-[WKContentView dragInteraction:itemsForBeginningSession:]): 19 (-[WKContentView _contentsOfUserInterfaceItem:]): 20 (previewIdentifierForElementAction): 21 (-[WKContentView shouldUsePreviewForLongPress]): 22 (-[WKContentView _registerPreview]): 23 (-[WKContentView _unregisterPreview]): 24 (shouldUsePreviewForLongPress): Deleted. 25 (-[WKContentView _registerPreviewLongPress]): Deleted. 26 (-[WKContentView _unregisterPreviewLongPress]): Deleted. 27 1 28 2019-05-09 Alex Christensen <achristensen@webkit.org> 2 29 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r245112 r245153 62 62 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.h>) 63 63 #import <WebKitAdditions/WKInteractionPreviewAdditions.h> 64 #else65 #ifndef ADDITIONAL_LINK_PREVIEW_MEMBERS66 #define ADDITIONAL_LINK_PREVIEW_MEMBERS67 #endif68 #ifndef ADDITIONAL_LINK_PREVIEW_PROTOCOLS69 #define ADDITIONAL_LINK_PREVIEW_PROTOCOLS70 #endif71 64 #endif 72 65 … … 256 249 Vector<bool> _focusStateStack; 257 250 #if HAVE(LINK_PREVIEW) 251 #if USE(LONG_PRESS_FOR_LINK_PREVIEW) 252 LONG_PRESS_LINK_PREVIEW_MEMBERS 253 #else 258 254 RetainPtr<UIPreviewItemController> _previewItemController; 259 ADDITIONAL_LINK_PREVIEW_MEMBERS 255 #endif 260 256 #endif 261 257 … … 528 524 529 525 #if HAVE(LINK_PREVIEW) 530 @interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate ADDITIONAL_LINK_PREVIEW_PROTOCOLS> 526 #if USE(LONG_PRESS_FOR_LINK_PREVIEW) 527 @interface WKContentView (WKInteractionPreview) <LONG_PRESS_LINK_PREVIEW_PROTOCOL> 528 #else 529 @interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate> 530 #endif 531 531 532 532 @property (nonatomic, readonly) BOOL shouldUsePreviewForLongPress; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r245148 r245153 7216 7216 #if HAVE(LINK_PREVIEW) 7217 7217 if ([userInterfaceItem isEqualToString:@"linkPreviewPopoverContents"]) { 7218 #if USE(LONG_PRESS_FOR_LINK_PREVIEW) 7219 return @{ userInterfaceItem: @{ @"pageURL": WTF::userVisibleString(_positionInformation.url) } }; 7220 #else 7218 7221 NSString *url = [_previewItemController previewData][UIPreviewDataLink]; 7219 7222 return @{ userInterfaceItem: @{ @"pageURL": url } }; 7223 #endif 7220 7224 } 7221 7225 #endif … … 7234 7238 #if HAVE(LINK_PREVIEW) 7235 7239 7236 @implementation WKContentView (WKInteractionPreview) 7237 7238 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKInteractionPreviewAdditions.mm>) 7240 static NSString *previewIdentifierForElementAction(_WKElementAction *action) 7241 { 7242 switch (action.type) { 7243 case _WKElementActionTypeOpen: 7244 return WKPreviewActionItemIdentifierOpen; 7245 case _WKElementActionTypeCopy: 7246 return WKPreviewActionItemIdentifierCopy; 7247 #if !defined(TARGET_OS_IOS) || TARGET_OS_IOS 7248 case _WKElementActionTypeAddToReadingList: 7249 return WKPreviewActionItemIdentifierAddToReadingList; 7250 #endif 7251 case _WKElementActionTypeShare: 7252 return WKPreviewActionItemIdentifierShare; 7253 default: 7254 return nil; 7255 } 7256 ASSERT_NOT_REACHED(); 7257 return nil; 7258 } 7259 7260 #if USE(LONG_PRESS_FOR_LINK_PREVIEW) 7239 7261 #include <WebKitAdditions/WKInteractionPreviewAdditions.mm> 7240 7262 #else 7241 static BOOL shouldUsePreviewForLongPress() 7263 7264 @implementation WKContentView (WKInteractionPreview) 7265 7266 - (BOOL)shouldUsePreviewForLongPress 7242 7267 { 7243 7268 return NO; 7244 7269 } 7245 7270 7246 - (void)_registerPreviewLongPress7247 {7248 }7249 7250 - (void)_unregisterPreviewLongPress7251 {7252 }7253 #endif7254 7255 - (BOOL)shouldUsePreviewForLongPress7256 {7257 return shouldUsePreviewForLongPress();7258 }7259 7260 7271 - (void)_registerPreview 7261 7272 { … … 7263 7274 return; 7264 7275 7265 if (shouldUsePreviewForLongPress()) 7266 [self _registerPreviewLongPress]; 7267 else { 7268 _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]); 7269 [_previewItemController setDelegate:self]; 7270 _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer; 7271 if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)]) 7272 _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer; 7273 } 7276 _previewItemController = adoptNS([[UIPreviewItemController alloc] initWithView:self]); 7277 [_previewItemController setDelegate:self]; 7278 _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer; 7279 if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)]) 7280 _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer; 7274 7281 } 7275 7282 7276 7283 - (void)_unregisterPreview 7277 7284 { 7278 if (shouldUsePreviewForLongPress()) 7279 [self _unregisterPreviewLongPress]; 7280 else { 7281 [_previewItemController setDelegate:nil]; 7282 _previewGestureRecognizer = nil; 7283 _previewSecondaryGestureRecognizer = nil; 7284 _previewItemController = nil; 7285 } 7285 [_previewItemController setDelegate:nil]; 7286 _previewGestureRecognizer = nil; 7287 _previewSecondaryGestureRecognizer = nil; 7288 _previewItemController = nil; 7286 7289 } 7287 7290 … … 7417 7420 } 7418 7421 7419 static NSString *previewIdentifierForElementAction(_WKElementAction *action)7420 {7421 switch (action.type) {7422 case _WKElementActionTypeOpen:7423 return WKPreviewActionItemIdentifierOpen;7424 case _WKElementActionTypeCopy:7425 return WKPreviewActionItemIdentifierCopy;7426 #if !defined(TARGET_OS_IOS) || TARGET_OS_IOS7427 case _WKElementActionTypeAddToReadingList:7428 return WKPreviewActionItemIdentifierAddToReadingList;7429 #endif7430 case _WKElementActionTypeShare:7431 return WKPreviewActionItemIdentifierShare;7432 default:7433 return nil;7434 }7435 ASSERT_NOT_REACHED();7436 return nil;7437 }7438 7439 7422 - (UIViewController *)_presentedViewControllerForPreviewItemController:(UIPreviewItemController *)controller 7440 7423 { … … 7607 7590 @end 7608 7591 7592 #endif // USE(LONG_PRESS_FOR_LINK_PREVIEW) 7593 7609 7594 #endif // HAVE(LINK_PREVIEW) 7610 7595
Note: See TracChangeset
for help on using the changeset viewer.