From bea6d03a528cd59fa0920f3630df66b004894693 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 9 Jun 2016 09:06:58 -0400 Subject: [PATCH] Bug 1278268 - Ensure that no-op mousemove synthesizations on Windows still fire a mousemove event. r=jimm MozReview-Commit-ID: EXZtvqy1BLu --HG-- extra : rebase_source : 7dcaa9370c0733267940ad8374bf783cde65e9e7 --- .../apz/test/mochitest/apz_test_native_event_utils.js | 10 ++-------- widget/windows/nsWindow.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js index d0ec0d6100cd..e858738c62ed 100644 --- a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js +++ b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js @@ -245,19 +245,13 @@ function synthesizeNativeClick(aElement, aX, aY, aObserver = null) { // Move the mouse to (dx, dy) relative to |element|, and scroll the wheel // at that location. // Moving the mouse is necessary to avoid wheel events from two consecutive -// scrollWheelOver() calls on different elements being incorreclty considered -// as part of t he same wheel transaction. +// moveMouseAndScrollWheelOver() calls on different elements being incorrectly +// considered as part of the same wheel transaction. // We also wait for the mouse move event to be processed before sending the // wheel event, otherwise there is a chance they might get reordered, and // we have the transaction problem again. -// XXX FOOTGUN: On Windows, if the mouse cursor is already at the target -// position, the mouse-move event doesn't get dispatched, and -// we end up hanging waiting for it. As a result, care must -// be taken that the mouse isn't already at the target position -// when using this function. function moveMouseAndScrollWheelOver(element, dx, dy, testDriver) { return synthesizeNativeMouseMoveAndWaitForMoveEvent(element, dx, dy, function() { synthesizeNativeWheelAndWaitForScrollEvent(element, dx, dy, 0, -10, testDriver); }); } - diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 27128baaae41..3c54faebabb6 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -6041,6 +6041,12 @@ nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, { AutoObserverNotifier notifier(aObserver, "mouseevent"); + if (aNativeMessage == MOUSEEVENTF_MOVE) { + // Reset sLastMouseMovePoint so that even if we're moving the mouse + // to the position it's already at, we still dispatch a mousemove + // event, because the callers of this function expect that. + sLastMouseMovePoint = {0}; + } ::SetCursorPos(aPoint.x, aPoint.y); INPUT input;