Changeset 248360 in webkit
- Timestamp:
- Aug 6, 2019, 11:53:08 PM (7 years ago)
- Location:
- branches/safari-608.1-branch/Source
- Files:
-
- 4 edited
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/ios/WKContentViewInteraction.mm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1-branch/Source/WebCore/PAL/ChangeLog
r247797 r248360 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r248330. rdar://problem/54018116 4 5 Context menu on a universal link produces a blank preview 6 https://bugs.webkit.org/show_bug.cgi?id=200485 7 <rdar://problem/53699620> 8 9 Reviewed by Dean Jackson. 10 11 Source/WebCore/PAL: 12 13 Define iTunesStoreURL from CoreServices. 14 15 * pal/spi/cocoa/LaunchServicesSPI.h: 16 17 Source/WebKit: 18 19 If the context menu is activated on an iTunesStore URL, pass it 20 on to DataDetectors, who should know how to handle it. 21 22 Two drive-by fixes: 23 - make it clear that early returns do not produce a value. Instead call the 24 completion handler first, then return. 25 - The new API DataDetectors case doesn't need to worry about hiding link previews 26 as DataDetectors itself will handle that. 27 28 * UIProcess/ios/WKContentViewInteraction.mm: If the URL is an iTunesStoreURL 29 (as defined by CoreServices), let DataDetectors handle it. 30 (-[WKContentView assignLegacyDataForContextMenuInteraction]): 31 (-[WKContentView continueContextMenuInteraction:]): 32 (-[WKContentView continueContextMenuInteractionWithDataDetectors:]): New method to 33 use DataDetectors if possible. 34 35 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248330 268f45cc-cd09-0410-ab3c-d52691b4dbfc 36 37 2019-08-06 Dean Jackson <dino@apple.com> 38 39 Context menu on a universal link produces a blank preview 40 https://bugs.webkit.org/show_bug.cgi?id=200485 41 <rdar://problem/53699620> 42 43 Reviewed by Dean Jackson. 44 45 Define iTunesStoreURL from CoreServices. 46 47 * pal/spi/cocoa/LaunchServicesSPI.h: 48 1 49 2019-07-24 Alan Coon <alancoon@apple.com> 2 50 -
branches/safari-608.1-branch/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h
r244600 r248360 33 33 #import <CoreServices/CoreServicesPriv.h> 34 34 #elif PLATFORM(IOS_FAMILY) 35 #import <CoreServices/LSURLOverridePriv.h> 35 36 #import <MobileCoreServices/LSAppLinkPriv.h> 36 37 #endif 37 38 38 #endif 39 #endif // USE(APPLE_INTERNAL_SDK) 39 40 40 41 #if HAVE(APP_LINKS) … … 74 75 #endif 75 76 77 @interface NSURL () 78 - (NSURL *)iTunesStoreURL; 79 @end 80 76 81 #if PLATFORM(MAC) 77 82 enum LSSessionID { -
branches/safari-608.1-branch/Source/WebKit/ChangeLog
r248357 r248360 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r248330. rdar://problem/54018116 4 5 Context menu on a universal link produces a blank preview 6 https://bugs.webkit.org/show_bug.cgi?id=200485 7 <rdar://problem/53699620> 8 9 Reviewed by Dean Jackson. 10 11 Source/WebCore/PAL: 12 13 Define iTunesStoreURL from CoreServices. 14 15 * pal/spi/cocoa/LaunchServicesSPI.h: 16 17 Source/WebKit: 18 19 If the context menu is activated on an iTunesStore URL, pass it 20 on to DataDetectors, who should know how to handle it. 21 22 Two drive-by fixes: 23 - make it clear that early returns do not produce a value. Instead call the 24 completion handler first, then return. 25 - The new API DataDetectors case doesn't need to worry about hiding link previews 26 as DataDetectors itself will handle that. 27 28 * UIProcess/ios/WKContentViewInteraction.mm: If the URL is an iTunesStoreURL 29 (as defined by CoreServices), let DataDetectors handle it. 30 (-[WKContentView assignLegacyDataForContextMenuInteraction]): 31 (-[WKContentView continueContextMenuInteraction:]): 32 (-[WKContentView continueContextMenuInteractionWithDataDetectors:]): New method to 33 use DataDetectors if possible. 34 35 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248330 268f45cc-cd09-0410-ab3c-d52691b4dbfc 36 37 2019-08-06 Dean Jackson <dino@apple.com> 38 39 Context menu on a universal link produces a blank preview 40 https://bugs.webkit.org/show_bug.cgi?id=200485 41 <rdar://problem/53699620> 42 43 Reviewed by Dean Jackson. 44 45 If the context menu is activated on an iTunesStore URL, pass it 46 on to DataDetectors, who should know how to handle it. 47 48 Two drive-by fixes: 49 - make it clear that early returns do not produce a value. Instead call the 50 completion handler first, then return. 51 - The new API DataDetectors case doesn't need to worry about hiding link previews 52 as DataDetectors itself will handle that. 53 54 * UIProcess/ios/WKContentViewInteraction.mm: If the URL is an iTunesStoreURL 55 (as defined by CoreServices), let DataDetectors handle it. 56 (-[WKContentView assignLegacyDataForContextMenuInteraction]): 57 (-[WKContentView continueContextMenuInteraction:]): 58 (-[WKContentView continueContextMenuInteractionWithDataDetectors:]): New method to 59 use DataDetectors if possible. 60 1 61 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 62 -
branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r248357 r248360 107 107 #import <pal/spi/cg/CoreGraphicsSPI.h> 108 108 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h> 109 #import <pal/spi/cocoa/LaunchServicesSPI.h> 109 110 #import <pal/spi/ios/DataDetectorsUISPI.h> 110 111 #import <pal/spi/ios/GraphicsServicesSPI.h> … … 7791 7792 // Previously, UIPreviewItemController would detect the case where there was no previewViewController 7792 7793 // and create one. We need to replicate this code for the new API. 7793 if (!previewViewController ) {7794 if (!previewViewController || [(NSURL *)url iTunesStoreURL]) { 7794 7795 auto ddContextMenuActionClass = getDDContextMenuActionClass(); 7795 7796 if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationForURL:identifier:selectedText:results:inView:context:menuIdentifier:)]) { … … 7936 7937 _page->startInteractionWithElementAtPosition(_positionInformation.request.point); 7937 7938 7938 // FIXME: Should we provide an identifier and ASSERT in delegates if we don't match? 7939 return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]); 7940 } 7939 continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]); 7940 return; 7941 } 7942 7943 #if ENABLE(DATA_DETECTION) 7944 if ([(NSURL *)linkURL iTunesStoreURL]) { 7945 if ([self continueContextMenuInteractionWithDataDetectors:continueWithContextMenuConfiguration]) 7946 return; 7947 } 7948 #endif 7941 7949 7942 7950 auto completionBlock = makeBlockPtr([continueWithContextMenuConfiguration = makeBlockPtr(continueWithContextMenuConfiguration), linkURL = WTFMove(linkURL), weakSelf = WeakObjCPtr<WKContentView>(self)] (UIContextMenuConfiguration *configurationFromWKUIDelegate) mutable { 7943 7951 7944 7952 auto strongSelf = weakSelf.get(); 7945 if (!strongSelf) 7946 return continueWithContextMenuConfiguration(nil); 7953 if (!strongSelf) { 7954 continueWithContextMenuConfiguration(nil); 7955 return; 7956 } 7947 7957 7948 7958 if (configurationFromWKUIDelegate) { … … 7979 7989 }; 7980 7990 7981 return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]); 7991 continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]); 7992 return; 7982 7993 } 7983 7994 … … 7990 8001 // FIXME: Support JavaScript urls here. But make sure they don't show a preview. 7991 8002 // <rdar://problem/50572283> 7992 if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL)) 7993 return continueWithContextMenuConfiguration(nil); 7994 7995 BEGIN_BLOCK_OBJC_EXCEPTIONS; 7996 auto ddContextMenuActionClass = getDDContextMenuActionClass(); 7997 if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationWithURL:inView:context:menuIdentifier:)]) { 7998 NSDictionary *context = [strongSelf dataDetectionContextForPositionInformation:strongSelf->_positionInformation]; 7999 UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:strongSelf->_positionInformation.dataDetectorIdentifier selectedText:[strongSelf selectedText] results:strongSelf->_positionInformation.dataDetectorResults.get() inView:strongSelf.get() context:context menuIdentifier:nil]; 8000 strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES; 8001 strongSelf->_page->startInteractionWithElementAtPosition(strongSelf->_positionInformation.request.point); 8002 if (strongSelf->_showLinkPreviews) 8003 return continueWithContextMenuConfiguration(configurationFromDD); 8004 return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:[configurationFromDD identifier] previewProvider:nil actionProvider:[configurationFromDD actionProvider]]); 8003 if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL)) { 8004 continueWithContextMenuConfiguration(nil); 8005 return; 8005 8006 } 8006 END_BLOCK_OBJC_EXCEPTIONS; 8007 #endif 8008 return continueWithContextMenuConfiguration(nil); 8007 8008 if ([strongSelf continueContextMenuInteractionWithDataDetectors:continueWithContextMenuConfiguration.get()]) 8009 return; 8010 #endif 8011 continueWithContextMenuConfiguration(nil); 8009 8012 }); 8010 8013 … … 8030 8033 completionBlock(nil); 8031 8034 } 8035 8036 #if ENABLE(DATA_DETECTION) 8037 - (BOOL)continueContextMenuInteractionWithDataDetectors:(void(^)(UIContextMenuConfiguration *))continueWithContextMenuConfiguration 8038 { 8039 BEGIN_BLOCK_OBJC_EXCEPTIONS; 8040 auto ddContextMenuActionClass = getDDContextMenuActionClass(); 8041 if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationWithURL:inView:context:menuIdentifier:)]) { 8042 URL linkURL = _positionInformation.url; 8043 NSDictionary *context = [self dataDetectionContextForPositionInformation:_positionInformation]; 8044 UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:_positionInformation.dataDetectorIdentifier selectedText:[self selectedText] results:_positionInformation.dataDetectorResults.get() inView:self context:context menuIdentifier:nil]; 8045 _contextMenuActionProviderDelegateNeedsOverride = YES; 8046 _page->startInteractionWithElementAtPosition(_positionInformation.request.point); 8047 continueWithContextMenuConfiguration(configurationFromDD); 8048 return YES; 8049 } 8050 END_BLOCK_OBJC_EXCEPTIONS; 8051 8052 return NO; 8053 } 8054 #endif 8032 8055 8033 8056 - (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration
Note:
See TracChangeset
for help on using the changeset viewer.