Bug 1278268 - Ensure that no-op mousemove synthesizations on Windows still fire a mousemove event. r?jimm
MozReview-Commit-ID: EXZtvqy1BLu
--- a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
@@ -240,24 +240,18 @@ function synthesizeNativeClick(aElement,
utils.sendNativeMouseEvent(pt.x, pt.y, nativeMouseUpEventMsg(), 0, aElement, aObserver);
});
return true;
}
// 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);
});
}
-
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6032,16 +6032,22 @@ nsWindow::SynthesizeNativeKeyEvent(int32
nsresult
nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
uint32_t aNativeMessage,
uint32_t aModifierFlags,
nsIObserver* aObserver)
{
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;
memset(&input, 0, sizeof(input));
input.type = INPUT_MOUSE;
input.mi.dwFlags = aNativeMessage;
::SendInput(1, &input, sizeof(INPUT));