Title: [191412] trunk/Source/WebKit2
Revision
191412
Author
ander...@apple.com
Date
2015-10-21 16:14:31 -0700 (Wed, 21 Oct 2015)

Log Message

Move services menu handling out into a separate function
https://bugs.webkit.org/show_bug.cgi?id=150420

Reviewed by Tim Horton.

* UIProcess/mac/WebContextMenuProxyMac.h:
* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::showServicesMenu):
(WebKit::WebContextMenuProxyMac::show):
(WebKit::WebContextMenuProxyMac::showContextMenu):
(WebKit::WebContextMenuProxyMac::populate): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (191411 => 191412)


--- trunk/Source/WebKit2/ChangeLog	2015-10-21 23:10:45 UTC (rev 191411)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-21 23:14:31 UTC (rev 191412)
@@ -1,3 +1,17 @@
+2015-10-21  Anders Carlsson  <ander...@apple.com>
+
+        Move services menu handling out into a separate function
+        https://bugs.webkit.org/show_bug.cgi?id=150420
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/mac/WebContextMenuProxyMac.h:
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::showServicesMenu):
+        (WebKit::WebContextMenuProxyMac::show):
+        (WebKit::WebContextMenuProxyMac::showContextMenu):
+        (WebKit::WebContextMenuProxyMac::populate): Deleted.
+
 2015-10-21  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Single tapping clickable elements in unscalable pages should show a tap highlight

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h (191411 => 191412)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h	2015-10-21 23:10:45 UTC (rev 191411)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h	2015-10-21 23:14:31 UTC (rev 191412)
@@ -59,9 +59,10 @@
 private:
     virtual void show() override;
 
-    void populate(const Vector<RefPtr<WebContextMenuItem>>&);
+    void showContextMenu();
 
 #if ENABLE(SERVICE_CONTROLS)
+    void showServicesMenu();
     void setupServicesMenu();
     WebCore::ContextMenuItem shareMenuItem();
 #endif

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm (191411 => 191412)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm	2015-10-21 23:10:45 UTC (rev 191411)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm	2015-10-21 23:14:31 UTC (rev 191412)
@@ -318,6 +318,14 @@
         ServicesController::singleton().refreshExistingServices();
 }
 
+void WebContextMenuProxyMac::showServicesMenu()
+{
+    setupServicesMenu();
+
+    [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setMenuProxy:this];
+    [m_menu popUpMenuPositioningItem:nil atLocation:m_context.menuLocation() inView:m_webView];
+}
+
 void WebContextMenuProxyMac::clearServicesMenu()
 {
     [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setPicker:nullptr];
@@ -360,30 +368,22 @@
 }
 #endif
 
-void WebContextMenuProxyMac::populate(const Vector<RefPtr<WebContextMenuItem>>& items)
+void WebContextMenuProxyMac::show()
 {
+    Ref<WebPageProxy> protect(m_page);
+
 #if ENABLE(SERVICE_CONTROLS)
     if (m_context.isServicesMenu()) {
-        setupServicesMenu();
+        showServicesMenu();
         return;
     }
 #endif
 
-    m_menu = [[NSMenu alloc] initWithTitle:@""];
-    [m_menu setAutoenablesItems:NO];
-
-    populateNSMenu(m_menu.get(), nsMenuItemVector(items));
+    showContextMenu();
 }
 
-void WebContextMenuProxyMac::show()
+void WebContextMenuProxyMac::showContextMenu()
 {
-    // Unless this is an image control, give the PageContextMenuClient one last swipe at changing the menu.
-    bool askClientToChangeMenu = true;
-#if ENABLE(SERVICE_CONTROLS)
-    if (m_context.isServicesMenu() || m_context.controlledImage())
-        askClientToChangeMenu = false;
-#endif
-
     Vector<RefPtr<WebContextMenuItem>> proposedAPIItems;
     for (auto& item : m_context.menuItems()) {
         if (item.action() != ContextMenuItemTagShareMenu) {
@@ -401,30 +401,20 @@
     Vector<RefPtr<WebContextMenuItem>> clientItems;
     bool useProposedItems = true;
 
-    if (askClientToChangeMenu && m_page.contextMenuClient().getContextMenuFromProposedMenu(m_page, proposedAPIItems, clientItems, m_context.webHitTestResultData(), m_page.process().transformHandlesToObjects(m_userData.object()).get()))
+    if (m_page.contextMenuClient().getContextMenuFromProposedMenu(m_page, proposedAPIItems, clientItems, m_context.webHitTestResultData(), m_page.process().transformHandlesToObjects(m_userData.object()).get()))
         useProposedItems = false;
 
     const Vector<RefPtr<WebContextMenuItem>>& items = useProposedItems ? proposedAPIItems : clientItems;
 
-#if ENABLE(SERVICE_CONTROLS)
-    if (items.isEmpty() && !m_context.isServicesMenu())
-        return;
-#else
     if (items.isEmpty())
         return;
-#endif
 
-    populate(items);
+    m_menu = [[NSMenu alloc] initWithTitle:@""];
+    [m_menu setAutoenablesItems:NO];
 
-    [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
+    populateNSMenu(m_menu.get(), nsMenuItemVector(items));
 
-#if ENABLE(SERVICE_CONTROLS)
-    if (m_context.isServicesMenu())
-        [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setMenuProxy:this];
-#endif
-
-    Ref<WebPageProxy> protect(m_page);
-
+    [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
     [m_menu popUpMenuPositioningItem:nil atLocation:m_context.menuLocation() inView:m_webView];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to