- Revision
- 135436
- Author
- [email protected]
- Date
- 2012-11-21 14:34:01 -0800 (Wed, 21 Nov 2012)
Log Message
Clear MousePressed state on context menu to avoid initiating a drag
https://bugs.webkit.org/show_bug.cgi?id=101786
Reviewed by Ojan Vafai.
Source/WebCore:
If a user initiates a drag via left mouse down, brings up the context menu,
and then cancels the context menu while keeping the left mouse button down,
then the drag operation will continue. This does not match the platform
conventions on Windows, Linux or Mac .
This change cancels the drag if the context menu is about to be displayed.
Test: fast/events/context-nodrag.html
* page/EventHandler.cpp:
(WebCore::EventHandler::sendContextMenuEvent):
Tools:
* DumpRenderTree/chromium/TestRunner/src/EventSender.cpp:
(WebTestRunner):
(WebTestRunner::EventSender::EventSender):
(WebTestRunner::EventSender::contextClick):
Only send a MouseUp on Windows. Keep the current mouse pressed state when
calling up a context menu.
LayoutTests:
If a user initiates a drag via left mouse down, brings up the context menu,
and then cancels the context menu while keeping the left mouse button down,
then the drag operation will continue. This does not match the platform
conventions on Windows, Linux or Mac .
This change cancels the drag if the context menu is about to be displayed.
* fast/events/context-nodrag.html: Added.
* fast/events/context-nodrag-expected.txt: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (135435 => 135436)
--- trunk/LayoutTests/ChangeLog 2012-11-21 22:31:40 UTC (rev 135435)
+++ trunk/LayoutTests/ChangeLog 2012-11-21 22:34:01 UTC (rev 135436)
@@ -1,3 +1,20 @@
+2012-11-21 Fady Samuel <[email protected]>
+
+ Clear MousePressed state on context menu to avoid initiating a drag
+ https://bugs.webkit.org/show_bug.cgi?id=101786
+
+ Reviewed by Ojan Vafai.
+
+ If a user initiates a drag via left mouse down, brings up the context menu,
+ and then cancels the context menu while keeping the left mouse button down,
+ then the drag operation will continue. This does not match the platform
+ conventions on Windows, Linux or Mac .
+
+ This change cancels the drag if the context menu is about to be displayed.
+
+ * fast/events/context-nodrag.html: Added.
+ * fast/events/context-nodrag-expected.txt: Added.
+
2012-11-21 Huang Dongsung <[email protected]>
REGRESSION(r135212): Fix crash due to an infinite rect.
Added: trunk/LayoutTests/fast/events/context-nodrag-expected.txt (0 => 135436)
--- trunk/LayoutTests/fast/events/context-nodrag-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/context-nodrag-expected.txt 2012-11-21 22:34:01 UTC (rev 135436)
@@ -0,0 +1,10 @@
+This tests to make sure that right clicking when the left-mouse button is pressed disables the drag.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getSelection().isCollapsed is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This is a test box. ABC 123
Added: trunk/LayoutTests/fast/events/context-nodrag.html (0 => 135436)
--- trunk/LayoutTests/fast/events/context-nodrag.html (rev 0)
+++ trunk/LayoutTests/fast/events/context-nodrag.html 2012-11-21 22:34:01 UTC (rev 135436)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="box">This is a test box. ABC 123</div>
+<script>
+if (window.testRunner) {
+ description("This tests to make sure that right clicking when the left-mouse button is pressed disables the drag.");
+ var box = document.getElementById("box");
+ var x = box.offsetLeft;
+ var y = box.offsetTop + box.offsetHeight / 2;
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(x, y);
+ // Start a mouse down with the left mouse button.
+ eventSender.mouseDown();
+ // On some platforms, the page only sees a right MouseDown before displaying the
+ // context menu. The context menu can also be dismissed via Esc and so there is
+ // no guarantee that a page will see MouseUp.
+ eventSender.contextClick();
+ x = x + 30;
+ // Move the mouse to initiate a drag.
+ eventSender.mouseMoveTo(x, y);
+ shouldBeTrue("window.getSelection().isCollapsed");
+}
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (135435 => 135436)
--- trunk/Source/WebCore/ChangeLog 2012-11-21 22:31:40 UTC (rev 135435)
+++ trunk/Source/WebCore/ChangeLog 2012-11-21 22:34:01 UTC (rev 135436)
@@ -1,3 +1,22 @@
+2012-11-21 Fady Samuel <[email protected]>
+
+ Clear MousePressed state on context menu to avoid initiating a drag
+ https://bugs.webkit.org/show_bug.cgi?id=101786
+
+ Reviewed by Ojan Vafai.
+
+ If a user initiates a drag via left mouse down, brings up the context menu,
+ and then cancels the context menu while keeping the left mouse button down,
+ then the drag operation will continue. This does not match the platform
+ conventions on Windows, Linux or Mac .
+
+ This change cancels the drag if the context menu is about to be displayed.
+
+ Test: fast/events/context-nodrag.html
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::sendContextMenuEvent):
+
2012-11-21 Patrick Gansterer <[email protected]>
Use MIMETypeRegistryWin for WinCE port too
Modified: trunk/Source/WebCore/page/EventHandler.cpp (135435 => 135436)
--- trunk/Source/WebCore/page/EventHandler.cpp 2012-11-21 22:31:40 UTC (rev 135435)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2012-11-21 22:34:01 UTC (rev 135436)
@@ -2780,6 +2780,8 @@
if (!v)
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());
HitTestRequest request(HitTestRequest::Active);
@@ -2810,6 +2812,9 @@
if (!doc)
return false;
+ // Clear mouse press state to avoid initiating a drag while context menu is up.
+ m_mousePressed = false;
+
static const int kContextMenuMargin = 1;
#if OS(WINDOWS) && !OS(WINCE)
Modified: trunk/Tools/ChangeLog (135435 => 135436)
--- trunk/Tools/ChangeLog 2012-11-21 22:31:40 UTC (rev 135435)
+++ trunk/Tools/ChangeLog 2012-11-21 22:34:01 UTC (rev 135436)
@@ -1,3 +1,17 @@
+2012-11-21 Fady Samuel <[email protected]>
+
+ Clear MousePressed state on context menu to avoid initiating a drag
+ https://bugs.webkit.org/show_bug.cgi?id=101786
+
+ Reviewed by Ojan Vafai.
+
+ * DumpRenderTree/chromium/TestRunner/src/EventSender.cpp:
+ (WebTestRunner):
+ (WebTestRunner::EventSender::EventSender):
+ (WebTestRunner::EventSender::contextClick):
+ Only send a MouseUp on Windows. Keep the current mouse pressed state when
+ calling up a context menu.
+
2012-11-21 Thiago Marcos P. Santos <[email protected]>
[EFL] KURL unit test crashing when tiled backing store is enabled on Release Bots
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp (135435 => 135436)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp 2012-11-21 22:31:40 UTC (rev 135435)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp 2012-11-21 22:34:01 UTC (rev 135436)
@@ -836,14 +836,19 @@
// Generate right mouse down and up.
WebMouseEvent event;
- pressedButton = WebMouseEvent::ButtonRight;
+ // This is a hack to work around only allowing a single pressed button since we want to
+ // test the case where both the left and right mouse buttons are pressed.
+ if (pressedButton == WebMouseEvent::ButtonNone)
+ pressedButton = WebMouseEvent::ButtonRight;
initMouseEvent(WebInputEvent::MouseDown, WebMouseEvent::ButtonRight, lastMousePos, &event, getCurrentEventTimeSec(m_delegate));
webview()->handleInputEvent(event);
+#if OS(WINDOWS)
initMouseEvent(WebInputEvent::MouseUp, WebMouseEvent::ButtonRight, lastMousePos, &event, getCurrentEventTimeSec(m_delegate));
webview()->handleInputEvent(event);
pressedButton = WebMouseEvent::ButtonNone;
+#endif
WebContextMenuData* lastContextMenu = m_delegate->lastContextMenuData();
result->set(WebBindings::makeStringArray(makeMenuItemStringsFor(lastContextMenu, m_delegate)));
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h (135435 => 135436)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h 2012-11-21 22:31:40 UTC (rev 135435)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.h 2012-11-21 22:34:01 UTC (rev 135436)
@@ -69,6 +69,7 @@
void dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*);
// JS callback methods.
+ void contextClick(const CppArgumentList&, CppVariant*);
void mouseDown(const CppArgumentList&, CppVariant*);
void mouseUp(const CppArgumentList&, CppVariant*);
void mouseMoveTo(const CppArgumentList&, CppVariant*);
@@ -114,7 +115,6 @@
void gestureEvent(WebKit::WebInputEvent::Type, const CppArgumentList&);
// Unimplemented stubs
- void contextClick(const CppArgumentList&, CppVariant*);
void enableDOMUIEventLogging(const CppArgumentList&, CppVariant*);
void fireKeyboardEventsToElement(const CppArgumentList&, CppVariant*);
void clearKillRing(const CppArgumentList&, CppVariant*);