Bug 215943

Summary: WKUIDelegate's contextMenuConfigurationForElement API method isn't called for images
Product: WebKit Reporter: Ali Juma <ajuma>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: achristensen, beidson, dino, gambard, rohitrao, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ali Juma 2020-08-28 12:15:49 PDT
The public API method -[WKUIDelegate webView:contextMenuConfigurationForElement:completionHandler] is only called for links, not for images. The SPI version (-[WKUIDelegate _webView:contextMenuConfigurationForElement:completionHandler]) does get called for images.

This means that WKWebView embedders cannot easily customize the context menu shown for images.

The logic for this is in -[WKContentViewInteraction continueContextMenuInteraction:], which does:
 if (_positionInformation.isLink && [uiDelegate respondsToSelector:@selector(webView:contextMenuConfigurationForElement:completionHandler:)]) {
     .....
 } else if ([uiDelegate respondsToSelector:@selector(_webView:contextMenuConfigurationForElement:completionHandler:)]) {
     .....
 }

Could we change the first condition to also include |_positionInformation.isImage|?
Comment 1 Radar WebKit Bug Importer 2020-08-29 11:25:40 PDT
<rdar://problem/68000830>
Comment 2 Alex Christensen 2020-08-31 18:19:46 PDT
This API was designed to be a replacement for the API it deprecated without substantial changes.  We are considering improving the context menu API, and this input is noted.