Changeset 248380 in webkit


Ignore:
Timestamp:
Aug 7, 2019 12:05:43 PM (5 years ago)
Author:
dino@apple.com
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.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/PAL/ChangeLog

    r248371 r248380  
     12019-08-06  Dean Jackson  <dino@apple.com>
     2
     3        Context menu on a universal link produces a blank preview
     4        https://bugs.webkit.org/show_bug.cgi?id=200485
     5        <rdar://problem/53699620>
     6
     7        Reviewed by Tim Horton.
     8
     9        Define iTunesStoreURL from CoreServices.
     10
     11        * pal/spi/cocoa/LaunchServicesSPI.h:
     12
    1132019-08-07  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h

    r248371 r248380  
    3434#elif PLATFORM(IOS_FAMILY)
    3535#import <MobileCoreServices/LSAppLinkPriv.h>
     36#elif PLATFORM(IOS)
     37#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
     38#import <CoreServices/LSURLOverridePriv.h>
     39#else
     40#import <CoreServices/LSApplicationWorkspace.h>
     41#endif
    3642#endif
    3743
    38 #endif
     44#endif // USE(APPLE_INTERNAL_SDK)
    3945
    4046#if HAVE(APP_LINKS)
     
    7480#endif
    7581
     82@interface NSURL ()
     83- (NSURL *)iTunesStoreURL;
     84@end
     85
    7686#if PLATFORM(MAC)
    7787enum LSSessionID {
  • trunk/Source/WebKit/ChangeLog

    r248373 r248380  
     12019-08-06  Dean Jackson  <dino@apple.com>
     2
     3        Context menu on a universal link produces a blank preview
     4        https://bugs.webkit.org/show_bug.cgi?id=200485
     5        <rdar://problem/53699620>
     6
     7        Reviewed by Tim Horton.
     8
     9        If the context menu is activated on an iTunesStore URL, pass it
     10        on to DataDetectors, who should know how to handle it.
     11
     12        Two drive-by fixes:
     13        - make it clear that early returns do not produce a value. Instead call the
     14          completion handler first, then return.
     15        - The new API DataDetectors case doesn't need to worry about hiding link previews
     16          as DataDetectors itself will handle that.
     17
     18        * UIProcess/ios/WKContentViewInteraction.mm: If the URL is an iTunesStoreURL
     19        (as defined by CoreServices), let DataDetectors handle it.
     20        (-[WKContentView assignLegacyDataForContextMenuInteraction]):
     21        (-[WKContentView continueContextMenuInteraction:]):
     22        (-[WKContentView continueContextMenuInteractionWithDataDetectors:]): New method to
     23        use DataDetectors if possible.
     24
    1252019-08-07  Priyanka Agarwal  <pagarwal999@apple.com>
    226
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r248371 r248380  
    107107#import <pal/spi/cg/CoreGraphicsSPI.h>
    108108#import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
     109#import <pal/spi/cocoa/LaunchServicesSPI.h>
    109110#import <pal/spi/ios/DataDetectorsUISPI.h>
    110111#import <pal/spi/ios/GraphicsServicesSPI.h>
     
    78097810        // Previously, UIPreviewItemController would detect the case where there was no previewViewController
    78107811        // and create one. We need to replicate this code for the new API.
    7811         if (!previewViewController) {
     7812        if (!previewViewController || [(NSURL *)url iTunesStoreURL]) {
    78127813            auto ddContextMenuActionClass = getDDContextMenuActionClass();
    78137814            if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationForURL:identifier:selectedText:results:inView:context:menuIdentifier:)]) {
     
    79547955        _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
    79557956
    7956         // FIXME: Should we provide an identifier and ASSERT in delegates if we don't match?
    7957         return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
    7958     }
     7957        continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
     7958        return;
     7959    }
     7960
     7961#if ENABLE(DATA_DETECTION)
     7962    if ([(NSURL *)linkURL iTunesStoreURL]) {
     7963        if ([self continueContextMenuInteractionWithDataDetectors:continueWithContextMenuConfiguration])
     7964            return;
     7965    }
     7966#endif
    79597967
    79607968    auto completionBlock = makeBlockPtr([continueWithContextMenuConfiguration = makeBlockPtr(continueWithContextMenuConfiguration), linkURL = WTFMove(linkURL), weakSelf = WeakObjCPtr<WKContentView>(self)] (UIContextMenuConfiguration *configurationFromWKUIDelegate) mutable {
    79617969
    79627970        auto strongSelf = weakSelf.get();
    7963         if (!strongSelf)
    7964             return continueWithContextMenuConfiguration(nil);
     7971        if (!strongSelf) {
     7972            continueWithContextMenuConfiguration(nil);
     7973            return;
     7974        }
    79657975
    79667976        if (configurationFromWKUIDelegate) {
     
    79978007            };
    79988008
    7999             return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
     8009            continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
     8010            return;
    80008011        }
    80018012
     
    80088019        // FIXME: Support JavaScript urls here. But make sure they don't show a preview.
    80098020        // <rdar://problem/50572283>
    8010         if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL))
    8011             return continueWithContextMenuConfiguration(nil);
    8012 
    8013         BEGIN_BLOCK_OBJC_EXCEPTIONS;
    8014         auto ddContextMenuActionClass = getDDContextMenuActionClass();
    8015         if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationWithURL:inView:context:menuIdentifier:)]) {
    8016             NSDictionary *context = [strongSelf dataDetectionContextForPositionInformation:strongSelf->_positionInformation];
    8017             UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:strongSelf->_positionInformation.dataDetectorIdentifier selectedText:[strongSelf selectedText] results:strongSelf->_positionInformation.dataDetectorResults.get() inView:strongSelf.get() context:context menuIdentifier:nil];
    8018             strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES;
    8019             strongSelf->_page->startInteractionWithElementAtPosition(strongSelf->_positionInformation.request.point);
    8020             if (strongSelf->_showLinkPreviews)
    8021                 return continueWithContextMenuConfiguration(configurationFromDD);
    8022             return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:[configurationFromDD identifier] previewProvider:nil actionProvider:[configurationFromDD actionProvider]]);
     8021        if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL)) {
     8022            continueWithContextMenuConfiguration(nil);
     8023            return;
    80238024        }
    8024         END_BLOCK_OBJC_EXCEPTIONS;
    8025 #endif
    8026         return continueWithContextMenuConfiguration(nil);
     8025
     8026        if ([strongSelf continueContextMenuInteractionWithDataDetectors:continueWithContextMenuConfiguration.get()])
     8027            return;
     8028#endif
     8029        continueWithContextMenuConfiguration(nil);
    80278030    });
    80288031
     
    80488051        completionBlock(nil);
    80498052}
     8053
     8054#if ENABLE(DATA_DETECTION)
     8055- (BOOL)continueContextMenuInteractionWithDataDetectors:(void(^)(UIContextMenuConfiguration *))continueWithContextMenuConfiguration
     8056{
     8057    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     8058    auto ddContextMenuActionClass = getDDContextMenuActionClass();
     8059    if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationWithURL:inView:context:menuIdentifier:)]) {
     8060        URL linkURL = _positionInformation.url;
     8061        NSDictionary *context = [self dataDetectionContextForPositionInformation:_positionInformation];
     8062        UIContextMenuConfiguration *configurationFromDD = [ddContextMenuActionClass contextMenuConfigurationForURL:linkURL identifier:_positionInformation.dataDetectorIdentifier selectedText:[self selectedText] results:_positionInformation.dataDetectorResults.get() inView:self context:context menuIdentifier:nil];
     8063        _contextMenuActionProviderDelegateNeedsOverride = YES;
     8064        _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
     8065        continueWithContextMenuConfiguration(configurationFromDD);
     8066        return YES;
     8067    }
     8068    END_BLOCK_OBJC_EXCEPTIONS;
     8069
     8070    return NO;
     8071}
     8072#endif
    80508073
    80518074- (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration
Note: See TracChangeset for help on using the changeset viewer.