Title: [279625] trunk/Source/WebKit
Revision
279625
Author
drou...@apple.com
Date
2021-07-06 15:34:43 -0700 (Tue, 06 Jul 2021)

Log Message

Provide SPI for clients to override just the contextmenu preview instead of the entire `UIContextMenuConfiguration`
https://bugs.webkit.org/show_bug.cgi?id=227603
<rdar://problem/78832586>

Reviewed by Wenson Hsieh.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView continueContextMenuInteraction:]):
This allows Safari to remove some custom contextmenu code and use WebKit's default actions.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (279624 => 279625)


--- trunk/Source/WebKit/ChangeLog	2021-07-06 22:33:57 UTC (rev 279624)
+++ trunk/Source/WebKit/ChangeLog	2021-07-06 22:34:43 UTC (rev 279625)
@@ -1,3 +1,16 @@
+2021-07-06  Devin Rousso  <drou...@apple.com>
+
+        Provide SPI for clients to override just the contextmenu preview instead of the entire `UIContextMenuConfiguration`
+        https://bugs.webkit.org/show_bug.cgi?id=227603
+        <rdar://problem/78832586>
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView continueContextMenuInteraction:]):
+        This allows Safari to remove some custom contextmenu code and use WebKit's default actions.
+
 2021-07-06  Sihui Liu  <sihui_...@apple.com>
 
         WebIDBServer created after NetworkProcess::prepareToSuspend is not suspended correctly

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (279624 => 279625)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2021-07-06 22:33:57 UTC (rev 279624)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2021-07-06 22:34:43 UTC (rev 279625)
@@ -184,6 +184,7 @@
 // These can be removed once there is an API version.
 - (void)_webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator WK_API_AVAILABLE(ios(13.0));
 - (void)_webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(13.0));
+- (UIViewController *)_webView:(WKWebView *)webView contextMenuContentPreviewForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(15.0));
 - (void)_webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(13.0));
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (279624 => 279625)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-07-06 22:33:57 UTC (rev 279624)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-07-06 22:34:43 UTC (rev 279625)
@@ -11033,6 +11033,12 @@
                 if (!strongSelf)
                     return nil;
 
+                auto uiDelegate = static_cast<id<WKUIDelegatePrivate>>([strongSelf webViewUIDelegate]);
+                if ([uiDelegate respondsToSelector:@selector(_webView:contextMenuContentPreviewForElement:)]) {
+                    if (UIViewController *previewViewController = [uiDelegate _webView:[strongSelf webView] contextMenuContentPreviewForElement:strongSelf->_contextMenuElementInfo.get()])
+                        return previewViewController;
+                }
+
                 return adoptNS([[WKImagePreviewViewController alloc] initWithCGImage:cgImage defaultActions:nil elementInfo:elementInfo.get()]).autorelease();
             };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to