2010-12-09 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2010 02:45:53 +0000 (02:45 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2010 02:45:53 +0000 (02:45 +0000)
        Reviewed by Brady Eidson.

        WebKit2: Control-click doesn't invoke context menu
        https://bugs.webkit.org/show_bug.cgi?id=50793
        <rdar://problem/8664800>

        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::isContextClick): New helper function - on Mac, not only right clicks
        but also control-left-clicks are context clicks.
        (WebKit::handleMouseEvent): Use above.

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

WebKit2/ChangeLog
WebKit2/WebProcess/WebPage/WebPage.cpp

index 148e502dcd2d3a9671761d0868e2021599fd56ee..1a17de9abd68562fa88daf828f25a537a96ed213 100644 (file)
@@ -1,3 +1,16 @@
+2010-12-09  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Brady Eidson.
+
+        WebKit2: Control-click doesn't invoke context menu
+        https://bugs.webkit.org/show_bug.cgi?id=50793
+        <rdar://problem/8664800>
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::isContextClick): New helper function - on Mac, not only right clicks
+        but also control-left-clicks are context clicks.
+        (WebKit::handleMouseEvent): Use above.
+
 2010-12-09  Anders Carlsson  <andersca@apple.com>
 
         Fix clang++ build.
index e72546664c018ee26fc57bbc092455bb31f60328..59fdc63cdc81c92b7a61d62c304d6a41e7bd5af2 100644 (file)
@@ -627,6 +627,20 @@ private:
     const WebEvent* m_previousCurrentEvent;
 };
 
+static bool isContextClick(const PlatformMouseEvent& event)
+{
+    if (event.button() == WebCore::RightButton)
+        return true;
+
+#if PLATFORM(MAC)
+    // FIXME: this really should be about OSX-style UI, not about the Mac port
+    if (event.button() == WebCore::LeftButton && event.ctrlKey())
+        return true;
+#endif
+
+    return false;
+}
+
 static bool handleMouseEvent(const WebMouseEvent& mouseEvent, Page* page)
 {
     Frame* frame = page->mainFrame();
@@ -638,12 +652,12 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, Page* page)
     switch (platformMouseEvent.eventType()) {
         case WebCore::MouseEventPressed:
         {
-            if (platformMouseEvent.button() == WebCore::RightButton)
+            if (isContextClick(platformMouseEvent))
                 page->contextMenuController()->clearContextMenu();
             
             bool handled = frame->eventHandler()->handleMousePressEvent(platformMouseEvent);
             
-            if (platformMouseEvent.button() == WebCore::RightButton) {
+            if (isContextClick(platformMouseEvent)) {
                 handled = frame->eventHandler()->sendContextMenuEvent(platformMouseEvent);
                 if (handled)
                     page->chrome()->showContextMenu();