Title: [196912] releases/WebKitGTK/webkit-2.10
Revision
196912
Author
carlo...@webkit.org
Date
2016-02-22 01:12:53 -0800 (Mon, 22 Feb 2016)

Log Message

Merge r196112 - Do not show context menu when right clicking on a scrollbar
https://bugs.webkit.org/show_bug.cgi?id=153493

Reviewed by Michael Catanzaro.

Source/WebCore:

Scrollbars don't currently handle right clicks, but we are showing
the context menu when they are right clicked. This is not desired
at least in GTK+ and I've checked that it isn't consistent with
other applications in Mac either.

Test: fast/events/contextmenu-on-scrollbars.html

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

LayoutTests:

Add a test to check that context menu event is not sent when right
clicking on a scrollbar.

* fast/events/contextmenu-on-scrollbars-expected.txt: Added.
* fast/events/contextmenu-on-scrollbars.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (196911 => 196912)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2016-02-22 09:09:52 UTC (rev 196911)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2016-02-22 09:12:53 UTC (rev 196912)
@@ -1,5 +1,18 @@
 2016-02-03  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        Do not show context menu when right clicking on a scrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=153493
+
+        Reviewed by Michael Catanzaro.
+
+        Add a test to check that context menu event is not sent when right
+        clicking on a scrollbar.
+
+        * fast/events/contextmenu-on-scrollbars-expected.txt: Added.
+        * fast/events/contextmenu-on-scrollbars.html: Added.
+
+2016-02-03  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK] Layout Test http/tests/appcache/different-https-origin-resource-main.html is failing
         https://bugs.webkit.org/show_bug.cgi?id=145253
 

Added: releases/WebKitGTK/webkit-2.10/LayoutTests/fast/events/contextmenu-on-scrollbars-expected.txt (0 => 196912)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/fast/events/contextmenu-on-scrollbars-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/fast/events/contextmenu-on-scrollbars-expected.txt	2016-02-22 09:12:53 UTC (rev 196912)
@@ -0,0 +1,4 @@
+This is a test for https://bugs.webkit.org/show_bug.cgi?id=153493
+
+SUCCESS
+

Added: releases/WebKitGTK/webkit-2.10/LayoutTests/fast/events/contextmenu-on-scrollbars.html (0 => 196912)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/fast/events/contextmenu-on-scrollbars.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/fast/events/contextmenu-on-scrollbars.html	2016-02-22 09:12:53 UTC (rev 196912)
@@ -0,0 +1,52 @@
+
+<style>
+    #scrollme {
+        width: 100px;
+        height: 100px;
+        overflow: auto;
+    }
+    #scrollme p {
+        height: 1000px;
+    }
+</style>
+<body style="min-height: 5000px">
+<p>This is a test for <a href=""
+<div id="scrollme"><p></p></div>
+<pre id="log"></pre>
+<div style="height: 150%"></div>
+<script>
+    function log(msg)
+    {
+        document.getElementById('log').appendChild(document.createTextNode(msg + "\n"));
+    }
+
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    var didSendContextMenu = false;
+
+    document._oncontextmenu_ = function() { didSendContextMenu = true; }
+
+    if (window.eventSender) {
+        var failed = false;
+
+        eventSender.mouseMoveTo(window.innerWidth - 4, window.innerHeight - 4);
+        eventSender.contextClick();
+        if (didSendContextMenu) {
+            log('FAILED: context menu event received on main frame scrollbar');
+            failed = true;
+            didSendContextMenu = false;
+        }
+
+        var div = document.querySelector('#scrollme');
+        eventSender.mouseMoveTo(div.offsetLeft + div.offsetWidth - 4, div.offsetTop + 1);
+        eventSender.contextClick();
+        if (didSendContextMenu) {
+            log('FAILED: context menu event received on div scrollbar');
+            failed = true;
+        }
+        if (!failed)
+            log('SUCCESS');
+    }
+</script>
+</body>

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (196911 => 196912)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-02-22 09:09:52 UTC (rev 196911)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2016-02-22 09:12:53 UTC (rev 196912)
@@ -1,5 +1,22 @@
 2016-02-03  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        Do not show context menu when right clicking on a scrollbar
+        https://bugs.webkit.org/show_bug.cgi?id=153493
+
+        Reviewed by Michael Catanzaro.
+
+        Scrollbars don't currently handle right clicks, but we are showing
+        the context menu when they are right clicked. This is not desired
+        at least in GTK+ and I've checked that it isn't consistent with
+        other applications in Mac either.
+
+        Test: fast/events/contextmenu-on-scrollbars.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::sendContextMenuEvent):
+
+2016-02-03  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK] Layout Test http/tests/appcache/different-https-origin-resource-main.html is failing
         https://bugs.webkit.org/show_bug.cgi?id=145253
 

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/page/EventHandler.cpp (196911 => 196912)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/page/EventHandler.cpp	2016-02-22 09:09:52 UTC (rev 196911)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/page/EventHandler.cpp	2016-02-22 09:12:53 UTC (rev 196912)
@@ -2814,20 +2814,23 @@
 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
 {
     Document* doc = m_frame.document();
-    FrameView* v = m_frame.view();
-    if (!v)
+    FrameView* view = m_frame.view();
+    if (!view)
         return false;
-    
+
     // Clear mouse press state to avoid initiating a drag while context menu is up.
     m_mousePressed = false;
     bool swallowEvent;
-    LayoutPoint viewportPos = v->windowToContents(event.position());
+    LayoutPoint viewportPos = view->windowToContents(event.position());
     HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
     MouseEventWithHitTestResults mouseEvent = doc->prepareMouseEvent(request, viewportPos, event);
 
+    // Do not show context menus when clicking on scrollbars.
+    if (mouseEvent.scrollbar() || view->scrollbarAtPoint(event.position()))
+        return false;
+
     if (m_frame.editor().behavior().shouldSelectOnContextualMenuClick()
         && !m_frame.selection().contains(viewportPos)
-        && !mouseEvent.scrollbar()
         // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
         // If the selection is non-editable, we do word selection to make it easier to use the contextual menu items
         // available for text selections.  But only if we're above text.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to