Title: [248330] trunk/Source
- Revision
- 248330
- Author
- d...@apple.com
- Date
- 2019-08-06 17:17:24 -0700 (Tue, 06 Aug 2019)
Log Message
Context menu on a universal link produces a blank preview
https://bugs.webkit.org/show_bug.cgi?id=200485
<rdar://problem/53699620>
Reviewed by Dean Jackson.
Source/WebCore/PAL:
Define iTunesStoreURL from CoreServices.
* pal/spi/cocoa/LaunchServicesSPI.h:
Source/WebKit:
If the context menu is activated on an iTunesStore URL, pass it
on to DataDetectors, who should know how to handle it.
Two drive-by fixes:
- make it clear that early returns do not produce a value. Instead call the
completion handler first, then return.
- The new API DataDetectors case doesn't need to worry about hiding link previews
as DataDetectors itself will handle that.
* UIProcess/ios/WKContentViewInteraction.mm: If the URL is an iTunesStoreURL
(as defined by CoreServices), let DataDetectors handle it.
(-[WKContentView assignLegacyDataForContextMenuInteraction]):
(-[WKContentView continueContextMenuInteraction:]):
(-[WKContentView continueContextMenuInteractionWithDataDetectors:]): New method to
use DataDetectors if possible.
Modified Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (248329 => 248330)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-08-07 00:06:59 UTC (rev 248329)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-08-07 00:17:24 UTC (rev 248330)
@@ -1,3 +1,15 @@
+2019-08-06 Dean Jackson <d...@apple.com>
+
+ Context menu on a universal link produces a blank preview
+ https://bugs.webkit.org/show_bug.cgi?id=200485
+ <rdar://problem/53699620>
+
+ Reviewed by Dean Jackson.
+
+ Define iTunesStoreURL from CoreServices.
+
+ * pal/spi/cocoa/LaunchServicesSPI.h:
+
2019-07-31 Youenn Fablet <you...@apple.com>
Use CTFontCreateForCharactersWithLanguageAndOption if available instead of CTFontCreateForCharactersWithLanguage
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h (248329 => 248330)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h 2019-08-07 00:06:59 UTC (rev 248329)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h 2019-08-07 00:17:24 UTC (rev 248330)
@@ -32,10 +32,11 @@
#if PLATFORM(MAC)
#import <CoreServices/CoreServicesPriv.h>
#elif PLATFORM(IOS_FAMILY)
+#import <CoreServices/LSURLOverridePriv.h>
#import <MobileCoreServices/LSAppLinkPriv.h>
#endif
-#endif
+#endif // USE(APPLE_INTERNAL_SDK)
#if HAVE(APP_LINKS)
@class LSAppLink;
@@ -73,6 +74,10 @@
@end
#endif
+@interface NSURL ()
+- (NSURL *)iTunesStoreURL;
+@end
+
#if PLATFORM(MAC)
enum LSSessionID {
kLSDefaultSessionID = -2,
Modified: trunk/Source/WebKit/ChangeLog (248329 => 248330)
--- trunk/Source/WebKit/ChangeLog 2019-08-07 00:06:59 UTC (rev 248329)
+++ trunk/Source/WebKit/ChangeLog 2019-08-07 00:17:24 UTC (rev 248330)
@@ -1,3 +1,27 @@
+2019-08-06 Dean Jackson <d...@apple.com>
+
+ Context menu on a universal link produces a blank preview
+ https://bugs.webkit.org/show_bug.cgi?id=200485
+ <rdar://problem/53699620>
+
+ Reviewed by Dean Jackson.
+
+ If the context menu is activated on an iTunesStore URL, pass it
+ on to DataDetectors, who should know how to handle it.
+
+ Two drive-by fixes:
+ - make it clear that early returns do not produce a value. Instead call the
+ completion handler first, then return.
+ - The new API DataDetectors case doesn't need to worry about hiding link previews
+ as DataDetectors itself will handle that.
+
+ * UIProcess/ios/WKContentViewInteraction.mm: If the URL is an iTunesStoreURL
+ (as defined by CoreServices), let DataDetectors handle it.
+ (-[WKContentView assignLegacyDataForContextMenuInteraction]):
+ (-[WKContentView continueContextMenuInteraction:]):
+ (-[WKContentView continueContextMenuInteractionWithDataDetectors:]): New method to
+ use DataDetectors if possible.
+
2019-08-06 Chris Dumez <cdu...@apple.com>
Avoid unnecessary ResourceRequest copy under NetworkResourceLoader::isCrossOriginPrefetch()
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248329 => 248330)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-08-07 00:06:59 UTC (rev 248329)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-08-07 00:17:24 UTC (rev 248330)
@@ -106,6 +106,7 @@
#import <WebKit/WebSelectionRect.h> // FIXME: WK2 should not include WebKit headers!
#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
+#import <pal/spi/cocoa/LaunchServicesSPI.h>
#import <pal/spi/ios/DataDetectorsUISPI.h>
#import <pal/spi/ios/GraphicsServicesSPI.h>
#import <wtf/BlockObjCExceptions.h>
@@ -7808,7 +7809,7 @@
// Previously, UIPreviewItemController would detect the case where there was no previewViewController
// and create one. We need to replicate this code for the new API.
- if (!previewViewController) {
+ if (!previewViewController || [(NSURL *)url iTunesStoreURL]) {
auto ddContextMenuActionClass = getDDContextMenuActionClass();
if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationForURL:identifier:selectedText:results:inView:context:menuIdentifier:)]) {
BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -7953,15 +7954,24 @@
_page->startInteractionWithElementAtPosition(_positionInformation.request.point);
- // FIXME: Should we provide an identifier and ASSERT in delegates if we don't match?
- return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
+ continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
+ return;
}
+#if ENABLE(DATA_DETECTION)
+ if ([(NSURL *)linkURL iTunesStoreURL]) {
+ if ([self continueContextMenuInteractionWithDataDetectors:continueWithContextMenuConfiguration])
+ return;
+ }
+#endif
+
auto completionBlock = makeBlockPtr([continueWithContextMenuConfiguration = makeBlockPtr(continueWithContextMenuConfiguration), linkURL = WTFMove(linkURL), weakSelf = WeakObjCPtr<WKContentView>(self)] (UIContextMenuConfiguration *configurationFromWKUIDelegate) mutable {
auto strongSelf = weakSelf.get();
- if (!strongSelf)
- return continueWithContextMenuConfiguration(nil);
+ if (!strongSelf) {
+ continueWithContextMenuConfiguration(nil);
+ return;
+ }
if (configurationFromWKUIDelegate) {
strongSelf->_page->startInteractionWithElementAtPosition(strongSelf->_positionInformation.request.point);
@@ -7996,7 +8006,8 @@
return [[[WKImagePreviewViewController alloc] initWithCGImage:cgImage defaultActions:nil elementInfo:elementInfo.get()] autorelease];
};
- return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
+ continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
+ return;
}
// At this point we have an object we might want to show a context menu for, but the
@@ -8007,23 +8018,15 @@
#if ENABLE(DATA_DETECTION)
// FIXME: Support _javascript_ urls here. But make sure they don't show a preview.
// <rdar://problem/50572283>
- if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL))
- return continueWithContextMenuConfiguration(nil);
+ if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL)) {
+ continueWithContextMenuConfiguration(nil);
+ return;
+ }
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- auto ddContextMenuActionClass = getDDContextMenuActionClass();
- if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationWithURL:inView:context:menuIdentifier:)]) {
- NSDictionary *context = [strongSelf dataDetectionContextForPositionInformation:strongSelf->_positionInformation];
- UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:strongSelf->_positionInformation.dataDetectorIdentifier selectedText:[strongSelf selectedText] results:strongSelf->_positionInformation.dataDetectorResults.get() inView:strongSelf.get() context:context menuIdentifier:nil];
- strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES;
- strongSelf->_page->startInteractionWithElementAtPosition(strongSelf->_positionInformation.request.point);
- if (strongSelf->_showLinkPreviews)
- return continueWithContextMenuConfiguration(configurationFromDD);
- return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:[configurationFromDD identifier] previewProvider:nil actionProvider:[configurationFromDD actionProvider]]);
- }
- END_BLOCK_OBJC_EXCEPTIONS;
+ if ([strongSelf continueContextMenuInteractionWithDataDetectors:continueWithContextMenuConfiguration.get()])
+ return;
#endif
- return continueWithContextMenuConfiguration(nil);
+ continueWithContextMenuConfiguration(nil);
});
_contextMenuActionProviderDelegateNeedsOverride = NO;
@@ -8048,6 +8051,26 @@
completionBlock(nil);
}
+#if ENABLE(DATA_DETECTION)
+- (BOOL)continueContextMenuInteractionWithDataDetectors:(void(^)(UIContextMenuConfiguration *))continueWithContextMenuConfiguration
+{
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ auto ddContextMenuActionClass = getDDContextMenuActionClass();
+ if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationWithURL:inView:context:menuIdentifier:)]) {
+ URL linkURL = _positionInformation.url;
+ NSDictionary *context = [self dataDetectionContextForPositionInformation:_positionInformation];
+ UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:_positionInformation.dataDetectorIdentifier selectedText:[self selectedText] results:_positionInformation.dataDetectorResults.get() inView:self context:context menuIdentifier:nil];
+ _contextMenuActionProviderDelegateNeedsOverride = YES;
+ _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
+ continueWithContextMenuConfiguration(configurationFromDD);
+ return YES;
+ }
+ END_BLOCK_OBJC_EXCEPTIONS;
+
+ return NO;
+}
+#endif
+
- (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration
{
if (_contextMenuActionProviderDelegateNeedsOverride) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes