⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 248360 in webkit


Ignore:
Timestamp:
Aug 6, 2019, 11:53:08 PM (7 years ago)
Author:
Kocsen Chung
Message:

Cherry-pick r248330. rdar://problem/54018116

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@248330 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608.1-branch/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608.1-branch/Source/WebCore/PAL/ChangeLog

    r247797 r248360  
     12019-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
    1492019-07-24  Alan Coon  <alancoon@apple.com>
    250
  • branches/safari-608.1-branch/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h

    r244600 r248360  
    3333#import <CoreServices/CoreServicesPriv.h>
    3434#elif PLATFORM(IOS_FAMILY)
     35#import <CoreServices/LSURLOverridePriv.h>
    3536#import <MobileCoreServices/LSAppLinkPriv.h>
    3637#endif
    3738
    38 #endif
     39#endif // USE(APPLE_INTERNAL_SDK)
    3940
    4041#if HAVE(APP_LINKS)
     
    7475#endif
    7576
     77@interface NSURL ()
     78- (NSURL *)iTunesStoreURL;
     79@end
     80
    7681#if PLATFORM(MAC)
    7782enum LSSessionID {
  • branches/safari-608.1-branch/Source/WebKit/ChangeLog

    r248357 r248360  
     12019-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
    1612019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
    262
  • branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r248357 r248360  
    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>
     
    77917792        // Previously, UIPreviewItemController would detect the case where there was no previewViewController
    77927793        // and create one. We need to replicate this code for the new API.
    7793         if (!previewViewController) {
     7794        if (!previewViewController || [(NSURL *)url iTunesStoreURL]) {
    77947795            auto ddContextMenuActionClass = getDDContextMenuActionClass();
    77957796            if ([ddContextMenuActionClass respondsToSelector:@selector(contextMenuConfigurationForURL:identifier:selectedText:results:inView:context:menuIdentifier:)]) {
     
    79367937        _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
    79377938
    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
    79417949
    79427950    auto completionBlock = makeBlockPtr([continueWithContextMenuConfiguration = makeBlockPtr(continueWithContextMenuConfiguration), linkURL = WTFMove(linkURL), weakSelf = WeakObjCPtr<WKContentView>(self)] (UIContextMenuConfiguration *configurationFromWKUIDelegate) mutable {
    79437951
    79447952        auto strongSelf = weakSelf.get();
    7945         if (!strongSelf)
    7946             return continueWithContextMenuConfiguration(nil);
     7953        if (!strongSelf) {
     7954            continueWithContextMenuConfiguration(nil);
     7955            return;
     7956        }
    79477957
    79487958        if (configurationFromWKUIDelegate) {
     
    79797989            };
    79807990
    7981             return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
     7991            continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
     7992            return;
    79827993        }
    79837994
     
    79908001        // FIXME: Support JavaScript urls here. But make sure they don't show a preview.
    79918002        // <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;
    80058006        }
    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);
    80098012    });
    80108013
     
    80308033        completionBlock(nil);
    80318034}
     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
    80328055
    80338056- (NSArray<UIMenuElement *> *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction overrideSuggestedActionsForConfiguration:(UIContextMenuConfiguration *)configuration
Note: See TracChangeset for help on using the changeset viewer.