Add proper offset to position right click to simulate a context menu invocation.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 21:05:14 +0000 (21:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 21:05:14 +0000 (21:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76421

Patch by Marc-Andre Decoste <mad@chromium.org> on 2012-01-20
Reviewed by Ojan Vafai.

.:

* ManualTests/win/contextmenu-key3.html: Added.

Source/WebCore:

Manual tests only because DRT doesn't support context menu key.

* page/EventHandler.cpp:
(WebCore::EventHandler::sendContextMenuEventForKey):

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

ChangeLog
ManualTests/win/contextmenu-key3.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp

index 4988923..33f4dd6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-01-20  Marc-Andre Decoste  <mad@chromium.org>
+
+        Add proper offset to position right click to simulate a context menu invocation.
+        https://bugs.webkit.org/show_bug.cgi?id=76421
+
+        Reviewed by Ojan Vafai.
+
+        * ManualTests/win/contextmenu-key3.html: Added.
+
 2012-01-20  Kinuko Yasuda  <kinuko@chromium.org>
 
         Unreviewed; Windows buildbot update failure fix.
diff --git a/ManualTests/win/contextmenu-key3.html b/ManualTests/win/contextmenu-key3.html
new file mode 100644 (file)
index 0000000..dc328d7
--- /dev/null
@@ -0,0 +1,8 @@
+<p>Manual test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76421">bug 76421</a></p>
+<p>Left click on one of the lines in the text area and then hit the keyboard's context menu key to make sure the context menu pops up for the appropriate line.</p>
+
+<textarea style="min-height:75px;">
+  aaaaaaaaa
+  bbbbbbbbb
+  ccccccccc
+</textarea>
index 45af283..0cdee2e 100755 (executable)
@@ -1,3 +1,15 @@
+2012-01-20  Marc-Andre Decoste  <mad@chromium.org>
+
+        Add proper offset to position right click to simulate a context menu invocation.
+        https://bugs.webkit.org/show_bug.cgi?id=76421
+
+        Reviewed by Ojan Vafai.
+
+        Manual tests only because DRT doesn't support context menu key.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::sendContextMenuEventForKey):
+
 2012-01-20  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r105426.
index 8b3b38a..1e85da0 100644 (file)
@@ -2338,7 +2338,9 @@ bool EventHandler::sendContextMenuEventForKey()
         IntRect firstRect = m_frame->editor()->firstRectForRange(selectionRange.get());
 
         int x = rightAligned ? firstRect.maxX() : firstRect.x();
-        location = IntPoint(x, firstRect.maxY());
+        // In a multiline edit, firstRect.maxY() would endup on the next line, so -1.
+        int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0;
+        location = IntPoint(x, y);
     } else if (focusedNode) {
         RenderBoxModelObject* box = focusedNode->renderBoxModelObject();
         if (!box)