Fixing mochitest to round, not truncate, coords when trying to dispatch mouse events relative to nodes which are positioned at fractional pixels. Reenabling the test that was failing because of the truncation

This commit is contained in:
Boris Zbarsky 2008-11-03 10:43:00 -05:00
parent 2b8cf3c2d4
commit 30a5c2b827
2 changed files with 10 additions and 7 deletions

View File

@ -78,8 +78,8 @@ addLoadEvent(function() {
submitForm(++pendingLoads);
submitForm(++pendingLoads);
submitForm(++pendingLoads);
/* submitFormMouse(++pendingLoads);
submitFormMouse(++pendingLoads);*/
submitFormMouse(++pendingLoads);
submitFormMouse(++pendingLoads);
}, 0);
});

View File

@ -211,15 +211,18 @@ function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
var modifiers = _parseModifiers(aEvent);
var rect = aTarget.getBoundingClientRect();
var left = rect.left;
var top = rect.top;
// Need to round, since rect could have non-integer coordinates, and sadly
// our event code can't deal with fractional pixel click coords.
var left = Math.round(rect.left + aOffsetX);
var top = Math.round(rect.top + aOffsetY);
if (aEvent.type) {
utils.sendMouseEvent(aEvent.type, left + aOffsetX, top + aOffsetY, button, clickCount, modifiers);
utils.sendMouseEvent(aEvent.type, left, top, button, clickCount, modifiers);
}
else {
utils.sendMouseEvent("mousedown", left + aOffsetX, top + aOffsetY, button, clickCount, modifiers);
utils.sendMouseEvent("mouseup", left + aOffsetX, top + aOffsetY, button, clickCount, modifiers);
utils.sendMouseEvent("mousedown", left, top, button, clickCount, modifiers);
utils.sendMouseEvent("mouseup", left, top, button, clickCount, modifiers);
}
}
}