Title: [290103] trunk/Source
Revision
290103
Author
katherine_che...@apple.com
Date
2022-02-17 18:31:16 -0800 (Thu, 17 Feb 2022)

Log Message

Refactor share menu item presentation
https://bugs.webkit.org/show_bug.cgi?id=236806
<rdar://problem/88858606>

Reviewed by Aditya Keerthi.

Source/WebCore:

* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):

Source/WebCore/PAL:

* pal/spi/mac/NSSharingServicePickerSPI.h:

Source/WebKit:

* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::setupServicesMenu):
(WebKit::WebContextMenuProxyMac::getShareMenuItem):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290102 => 290103)


--- trunk/Source/WebCore/ChangeLog	2022-02-18 01:56:28 UTC (rev 290102)
+++ trunk/Source/WebCore/ChangeLog	2022-02-18 02:31:16 UTC (rev 290103)
@@ -1,3 +1,14 @@
+2022-02-17  Kate Cheney  <katherine_che...@apple.com>
+
+        Refactor share menu item presentation
+        https://bugs.webkit.org/show_bug.cgi?id=236806
+        <rdar://problem/88858606>
+
+        Reviewed by Aditya Keerthi.
+
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::populate):
+
 2022-02-17  Aditya Keerthi  <akeer...@apple.com>
 
         '-webkit-user-select: all' is not respected in editable views

Modified: trunk/Source/WebCore/PAL/ChangeLog (290102 => 290103)


--- trunk/Source/WebCore/PAL/ChangeLog	2022-02-18 01:56:28 UTC (rev 290102)
+++ trunk/Source/WebCore/PAL/ChangeLog	2022-02-18 02:31:16 UTC (rev 290103)
@@ -1,3 +1,13 @@
+2022-02-17  Kate Cheney  <katherine_che...@apple.com>
+
+        Refactor share menu item presentation
+        https://bugs.webkit.org/show_bug.cgi?id=236806
+        <rdar://problem/88858606>
+
+        Reviewed by Aditya Keerthi.
+
+        * pal/spi/mac/NSSharingServicePickerSPI.h:
+
 2022-02-17  Jer Noble  <jer.no...@apple.com>
 
         [Cocoa] Make AVFoundationSPI.h robust against changes in system headers

Modified: trunk/Source/WebCore/PAL/pal/spi/mac/NSSharingServicePickerSPI.h (290102 => 290103)


--- trunk/Source/WebCore/PAL/pal/spi/mac/NSSharingServicePickerSPI.h	2022-02-18 01:56:28 UTC (rev 290102)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSSharingServicePickerSPI.h	2022-02-18 02:31:16 UTC (rev 290103)
@@ -27,6 +27,10 @@
 
 #import <AppKit/NSSharingService_Private.h>
 
+@interface NSSharingServicePicker (Staging_r88855017)
+- (NSMenuItem *)standardShareMenuItem;
+@end
+
 #else
 
 #import <AppKit/NSSharingService.h>
@@ -40,6 +44,7 @@
 
 @interface NSSharingServicePicker (Private)
 @property NSSharingServicePickerStyle style;
+- (NSMenuItem *)standardShareMenuItem;
 - (NSMenu *)menu;
 - (void)getMenuWithCompletion:(void(^)(NSMenu *))completion;
 - (void)hide;

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (290102 => 290103)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2022-02-18 01:56:28 UTC (rev 290102)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2022-02-18 02:31:16 UTC (rev 290103)
@@ -840,7 +840,7 @@
 #if PLATFORM(GTK) || PLATFORM(WIN)
     ContextMenuItem ShareMenuItem;
 #else
-    ContextMenuItem ShareMenuItem(SubmenuType, ContextMenuItemTagShareMenu, emptyString());
+    ContextMenuItem ShareMenuItem(ActionType, ContextMenuItemTagShareMenu, emptyString());
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)

Modified: trunk/Source/WebKit/ChangeLog (290102 => 290103)


--- trunk/Source/WebKit/ChangeLog	2022-02-18 01:56:28 UTC (rev 290102)
+++ trunk/Source/WebKit/ChangeLog	2022-02-18 02:31:16 UTC (rev 290103)
@@ -1,3 +1,15 @@
+2022-02-17  Kate Cheney  <katherine_che...@apple.com>
+
+        Refactor share menu item presentation
+        https://bugs.webkit.org/show_bug.cgi?id=236806
+        <rdar://problem/88858606>
+
+        Reviewed by Aditya Keerthi.
+
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::setupServicesMenu):
+        (WebKit::WebContextMenuProxyMac::getShareMenuItem):
+
 2022-02-17  Aditya Keerthi  <akeer...@apple.com>
 
         '-webkit-user-select: all' is not respected in editable views

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (290102 => 290103)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2022-02-18 01:56:28 UTC (rev 290102)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2022-02-18 02:31:16 UTC (rev 290103)
@@ -258,7 +258,10 @@
     [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setSourceFrame:imageRect];
     [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setAttachmentID:m_context.controlledImageAttachmentID()];
 
-    m_menu = adoptNS([[picker menu] copy]);
+    if ([picker respondsToSelector:@selector(standardShareMenuItem)])
+        m_menu = adoptNS([[[picker standardShareMenuItem] menu] copy]);
+    else
+        m_menu = adoptNS([[picker menu] copy]);
 
     if (!hasControlledImage)
         [m_menu setShowsStateColumn:YES];
@@ -405,6 +408,14 @@
         return;
     }
 
+    auto sharingServicePicker = adoptNS([[NSSharingServicePicker alloc] initWithItems:items.get()]);
+    if ([sharingServicePicker respondsToSelector:@selector(standardShareMenuItem)]) {
+        NSMenuItem *shareMenuItem = [sharingServicePicker standardShareMenuItem];
+        shareMenuItem.identifier = _WKMenuItemIdentifierShareMenu;
+        completionHandler(shareMenuItem);
+        return;
+    }
+
     getStandardShareMenuItem(items.get(), makeBlockPtr([completionHandler = WTFMove(completionHandler), protectedThis = Ref { *this }, this](NSMenuItem *item) mutable {
         if (!item) {
             completionHandler(nil);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to