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
This commit is contained in:
Kartikaya Gupta 2016-06-09 09:06:58 -04:00
parent c96dfeb86e
commit bea6d03a52
2 changed files with 8 additions and 8 deletions

View File

@ -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);
});
}

View File

@ -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;