Title: [248564] branches/safari-608-branch/Source
Revision
248564
Author
[email protected]
Date
2019-08-12 16:42:05 -0700 (Mon, 12 Aug 2019)

Log Message

Cherry-pick r248380. rdar://problem/54018115

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248380 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebCore/PAL/ChangeLog (248563 => 248564)


--- branches/safari-608-branch/Source/WebCore/PAL/ChangeLog	2019-08-12 23:42:02 UTC (rev 248563)
+++ branches/safari-608-branch/Source/WebCore/PAL/ChangeLog	2019-08-12 23:42:05 UTC (rev 248564)
@@ -1,3 +1,51 @@
+2019-08-12  Alan Coon  <[email protected]>
+
+        Cherry-pick r248380. rdar://problem/54018115
+
+    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.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-06  Dean Jackson  <[email protected]>
+
+            Context menu on a universal link produces a blank preview
+            https://bugs.webkit.org/show_bug.cgi?id=200485
+            <rdar://problem/53699620>
+
+            Reviewed by Tim Horton.
+
+            Define iTunesStoreURL from CoreServices.
+
+            * pal/spi/cocoa/LaunchServicesSPI.h:
+
 2019-08-06  Alan Coon  <[email protected]>
 
         Apply patch. rdar://problem/53992160

Modified: branches/safari-608-branch/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h (248563 => 248564)


--- branches/safari-608-branch/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h	2019-08-12 23:42:02 UTC (rev 248563)
+++ branches/safari-608-branch/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h	2019-08-12 23:42:05 UTC (rev 248564)
@@ -33,10 +33,16 @@
 #import <CoreServices/CoreServicesPriv.h>
 #elif PLATFORM(IOS_FAMILY)
 #import <MobileCoreServices/LSAppLinkPriv.h>
+#elif PLATFORM(IOS)
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+#import <CoreServices/LSURLOverridePriv.h>
+#else
+#import <CoreServices/LSApplicationWorkspace.h>
 #endif
-
 #endif
 
+#endif // USE(APPLE_INTERNAL_SDK)
+
 #if HAVE(APP_LINKS)
 @class LSAppLink;
 typedef void (^LSAppLinkCompletionHandler)(LSAppLink *appLink, NSError *error);
@@ -73,6 +79,10 @@
 @end
 #endif
 
+@interface NSURL ()
+- (NSURL *)iTunesStoreURL;
+@end
+
 #if PLATFORM(MAC)
 enum LSSessionID {
     kLSDefaultSessionID = -2,

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248563 => 248564)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-12 23:42:02 UTC (rev 248563)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-12 23:42:05 UTC (rev 248564)
@@ -1,5 +1,65 @@
 2019-08-12  Alan Coon  <[email protected]>
 
+        Cherry-pick r248380. rdar://problem/54018115
+
+    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.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-06  Dean Jackson  <[email protected]>
+
+            Context menu on a universal link produces a blank preview
+            https://bugs.webkit.org/show_bug.cgi?id=200485
+            <rdar://problem/53699620>
+
+            Reviewed by Tim Horton.
+
+            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-12  Alan Coon  <[email protected]>
+
         Cherry-pick r248129. rdar://problem/53836595
 
     REGRESSION: HSBC Personal Banking download/print dialog is usually positioned off screen on iPad

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248563 => 248564)


--- branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-12 23:42:02 UTC (rev 248563)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-12 23:42:05 UTC (rev 248564)
@@ -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>
@@ -7810,7 +7811,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;
@@ -7955,15 +7956,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);
@@ -7998,7 +8008,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
@@ -8009,23 +8020,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;
@@ -8050,6 +8053,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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to