WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2007 18:45:54 +0000 (18:45 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2007 18:45:54 +0000 (18:45 +0000)
        Reviewed by Beth Dakin and Darin Adler.

        - manual test for <rdar://problem/5346394> Contextmenu event doesn't fire on body element inside frame

        * manual-tests/context-click-unfocused-frame.html: Added.

WebKit/win:

        Reviewed by Beth Dakin and Darin Adler.

        - fix <rdar://problem/5346394> Contextmenu event doesn't fire on body element inside frame

        * WebView.cpp:
        (WebView::handleContextMenuEvent): Send the context menu event to the
        frame containing the node that was hit.

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

WebCore/ChangeLog
WebCore/manual-tests/context-click-unfocused-frame.html [new file with mode: 0644]
WebKit/win/ChangeLog
WebKit/win/WebView.cpp

index 2e64486..21a59b8 100644 (file)
@@ -1,3 +1,11 @@
+2007-11-29  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Beth Dakin and Darin Adler.
+
+        - manual test for <rdar://problem/5346394> Contextmenu event doesn't fire on body element inside frame
+
+        * manual-tests/context-click-unfocused-frame.html: Added.
+
 2007-11-28  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Geoff.
diff --git a/WebCore/manual-tests/context-click-unfocused-frame.html b/WebCore/manual-tests/context-click-unfocused-frame.html
new file mode 100644 (file)
index 0000000..3e94e85
--- /dev/null
@@ -0,0 +1,17 @@
+<frameset cols="*">
+    <frame src="data:text/html,
+        <script>
+            function contextMenu()
+            {
+                document.getElementById('result').appendChild(document.createTextNode('PASS'));
+            }
+        </script>
+        <body onmousedown='return false;' oncontextmenu='contextMenu(); return false;'>
+            <p>
+                Control-click (Mac) or right-click (Windows) below. The word 
+                %26ldquo;PASS%26rdquo; should appear. A contextual menu should not open.
+            </p>
+            <p id='result'></p>
+        </body>
+    ">
+</frameset>
index bc8ae1e..45327bc 100644 (file)
@@ -1,3 +1,13 @@
+2007-11-29  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Beth Dakin and Darin Adler.
+
+        - fix <rdar://problem/5346394> Contextmenu event doesn't fire on body element inside frame
+
+        * WebView.cpp:
+        (WebView::handleContextMenuEvent): Send the context menu event to the
+        frame containing the node that was hit.
+
 2007-11-28  Kevin McCullough  <kmccullough@apple.com>
 
         Reviewed by Tim.
index e847373..6770ab9 100644 (file)
@@ -1012,10 +1012,12 @@ bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam)
     // not run.
     m_page->contextMenuController()->clearContextMenu();
 
-    Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
-    focusedFrame->view()->setCursor(pointerCursor());
+    HitTestResult result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(IntPoint(coords.x, coords.y), false);
+    Frame* targetFrame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusedOrMainFrame();
+
+    targetFrame->view()->setCursor(pointerCursor());
     PlatformMouseEvent mouseEvent(m_viewWindow, WM_RBUTTONUP, wParam, lParam);
-    bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(mouseEvent);
+    bool handledEvent = targetFrame->eventHandler()->sendContextMenuEvent(mouseEvent);
     if (!handledEvent)
         return false;