REGRESSION (r191407): Context menus are missing Services
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Nov 2015 00:47:29 +0000 (00:47 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Nov 2015 00:47:29 +0000 (00:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151167
rdar://problem/23500769

Reviewed by Tim Horton.

* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::showContextMenu):
Use contentsToRootView to better indicate which coordinate system we're using.

* WebProcess/WebPage/WebContextMenu.cpp:
(WebKit::WebContextMenu::show):
Use +[NSMenu popUpContextMenu:withEvent:forView:] so we'll get service menus where applicable.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192335 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp

index 4133b69..5bae526 100644 (file)
@@ -1,5 +1,21 @@
 2015-11-11  Anders Carlsson  <andersca@apple.com>
 
+        REGRESSION (r191407): Context menus are missing Services
+        https://bugs.webkit.org/show_bug.cgi?id=151167
+        rdar://problem/23500769
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::showContextMenu):
+        Use contentsToRootView to better indicate which coordinate system we're using.
+
+        * WebProcess/WebPage/WebContextMenu.cpp:
+        (WebKit::WebContextMenu::show):
+        Use +[NSMenu popUpContextMenu:withEvent:forView:] so we'll get service menus where applicable.
+
+2015-11-11  Anders Carlsson  <andersca@apple.com>
+
         Remove more dead context menu code
         https://bugs.webkit.org/show_bug.cgi?id=151163
 
index 520ee63..f9fc8f0 100644 (file)
@@ -391,7 +391,10 @@ void WebContextMenuProxyMac::showContextMenu()
     m_menu = m_page.contextMenuClient().menuFromProposedMenu(m_page, menu.get(), m_context.webHitTestResultData());
 
     [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
-    [m_menu popUpMenuPositioningItem:nil atLocation:m_context.menuLocation() inView:m_webView];
+
+    NSPoint menuLocation = [m_webView convertPoint:m_context.menuLocation() toView:nil];
+    NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseUp location:menuLocation modifierFlags:0 timestamp:0 windowNumber:m_webView.window.windowNumber context:nil eventNumber:0 clickCount:0 pressure:0];
+    [NSMenu popUpContextMenu:m_menu.get() withEvent:event forView:m_webView];
 }
 
 NSWindow *WebContextMenuProxyMac::window() const
index a3dff4f..0e247c0 100644 (file)
@@ -64,7 +64,8 @@ void WebContextMenu::show()
     RefPtr<API::Object> userData;
     menuItemsWithUserData(menuItems, userData);
 
-    auto menuLocation = view->contentsToWindow(controller.hitTestResult().roundedPointInInnerNodeFrame());
+    auto menuLocation = view->contentsToRootView(controller.hitTestResult().roundedPointInInnerNodeFrame());
+
     ContextMenuContextData contextMenuContextData(menuLocation, menuItems, controller.context());
 
     // Mark the WebPage has having a shown context menu then notify the UIProcess.