Bug 1278268 - Ensure that no-op mousemove synthesizations on Windows still fire a mousemove event. r?jimm draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 09 Jun 2016 09:06:58 -0400
changeset 377018 106b271f3d301ad99f0b1339a01eeb9af8c857a9
parent 377017 d19d7ccdee5419b5908fc0ec741698be358a47a2
child 377019 bde228551aac6734cc57fdf8f28b2cc5b3cd351a
push id20730
push userkgupta@mozilla.com
push dateThu, 09 Jun 2016 13:07:25 +0000
reviewersjimm
bugs1278268
milestone50.0a1
Bug 1278268 - Ensure that no-op mousemove synthesizations on Windows still fire a mousemove event. r?jimm MozReview-Commit-ID: EXZtvqy1BLu
gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
widget/windows/nsWindow.cpp
--- 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));