Changeset 247321 in webkit


Ignore:
Timestamp:
Jul 10, 2019 1:04:26 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

Context menus are not presented for WKWebViews that don't have UIDelegates
https://bugs.webkit.org/show_bug.cgi?id=199678

Reviewed by Dean Jackson.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView continueContextMenuInteraction:]):
Remove this unnecessary early-return if we don't have a UIDelegate.
We have a default behavior that we totally want to happen.
Also, rename completion() to continueWithContextMenuConfiguration()
to reduce confusion between completion() and completionBlock() in
this method.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247317 r247321  
     12019-07-10  Tim Horton  <timothy_horton@apple.com>
     2
     3        Context menus are not presented for WKWebViews that don't have UIDelegates
     4        https://bugs.webkit.org/show_bug.cgi?id=199678
     5
     6        Reviewed by Dean Jackson.
     7
     8        * UIProcess/ios/WKContentViewInteraction.mm:
     9        (-[WKContentView continueContextMenuInteraction:]):
     10        Remove this unnecessary early-return if we don't have a UIDelegate.
     11        We have a default behavior that we totally want to happen.
     12        Also, rename completion() to continueWithContextMenuConfiguration()
     13        to reduce confusion between completion() and completionBlock() in
     14        this method.
     15
    1162019-07-10  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r247265 r247321  
    78027802}
    78037803
    7804 - (void)continueContextMenuInteraction:(void(^)(UIContextMenuConfiguration *))completion
     7804- (void)continueContextMenuInteraction:(void(^)(UIContextMenuConfiguration *))continueWithContextMenuConfiguration
    78057805{
    78067806    if (!_positionInformation.touchCalloutEnabled)
    7807         return completion(nil);
     7807        return continueWithContextMenuConfiguration(nil);
    78087808
    78097809    if (!_positionInformation.isLink && !_positionInformation.isImage && !_positionInformation.isAttachment)
    7810         return completion(nil);
     7810        return continueWithContextMenuConfiguration(nil);
    78117811
    78127812    URL linkURL = _positionInformation.url;
    78137813
    78147814    if (_positionInformation.isLink && linkURL.isEmpty())
    7815         return completion(nil);
     7815        return continueWithContextMenuConfiguration(nil);
    78167816
    78177817    auto uiDelegate = static_cast<id<WKUIDelegatePrivate>>(_webView.UIDelegate);
    7818     if (!uiDelegate)
    7819         return completion(nil);
    78207818
    78217819    if (needsDeprecatedPreviewAPI(uiDelegate)) {
    7822 
    78237820        if (_positionInformation.isLink) {
    78247821            ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     
    78267823                auto previewElementInfo = adoptNS([[WKPreviewElementInfo alloc] _initWithLinkURL:linkURL]);
    78277824                if (![uiDelegate webView:_webView shouldPreviewElement:previewElementInfo.get()])
    7828                     return completion(nil);
     7825                    return continueWithContextMenuConfiguration(nil);
    78297826            }
    78307827            ALLOW_DEPRECATED_DECLARATIONS_END
     
    78357832#if ENABLE(DATA_DETECTION)
    78367833                if (!WebCore::DataDetection::canBePresentedByDataDetectors(linkURL))
    7837                     return completion(nil);
     7834                    return continueWithContextMenuConfiguration(nil);
    78387835#endif
    78397836            }
     
    78667863
    78677864        // FIXME: Should we provide an identifier and ASSERT in delegates if we don't match?
    7868         return completion([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
    7869     }
    7870 
    7871     auto completionBlock = makeBlockPtr([completion = makeBlockPtr(completion), linkURL = WTFMove(linkURL), weakSelf = WeakObjCPtr<WKContentView>(self)] (UIContextMenuConfiguration *configurationFromWKUIDelegate) mutable {
     7865        return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
     7866    }
     7867
     7868    auto completionBlock = makeBlockPtr([continueWithContextMenuConfiguration = makeBlockPtr(continueWithContextMenuConfiguration), linkURL = WTFMove(linkURL), weakSelf = WeakObjCPtr<WKContentView>(self)] (UIContextMenuConfiguration *configurationFromWKUIDelegate) mutable {
    78727869
    78737870        auto strongSelf = weakSelf.get();
    78747871        if (!strongSelf)
    7875             return completion(nil);
     7872            return continueWithContextMenuConfiguration(nil);
    78767873
    78777874        if (configurationFromWKUIDelegate) {
    78787875            strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES;
    7879             completion(configurationFromWKUIDelegate);
     7876            continueWithContextMenuConfiguration(configurationFromWKUIDelegate);
    78807877            return;
    78817878        }
     
    78907887        // <rdar://problem/50572283>
    78917888        if (!linkURL.protocolIsInHTTPFamily() && !WebCore::DataDetection::canBePresentedByDataDetectors(linkURL))
    7892             return completion(nil);
     7889            return continueWithContextMenuConfiguration(nil);
    78937890
    78947891        BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
    78997896            strongSelf->_contextMenuActionProviderDelegateNeedsOverride = YES;
    79007897            if (strongSelf->_showLinkPreviews)
    7901                 return completion(configurationFromDD);
    7902             return completion([UIContextMenuConfiguration configurationWithIdentifier:[configurationFromDD identifier] previewProvider:nil actionProvider:[configurationFromDD actionProvider]]);
     7898                return continueWithContextMenuConfiguration(configurationFromDD);
     7899            return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:[configurationFromDD identifier] previewProvider:nil actionProvider:[configurationFromDD actionProvider]]);
    79037900        }
    79047901        END_BLOCK_OBJC_EXCEPTIONS;
    79057902#endif
    7906         return completion(nil);
     7903        return continueWithContextMenuConfiguration(nil);
    79077904    });
    79087905
Note: See TracChangeset for help on using the changeset viewer.