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
Родитель 2ddc154612
Коммит b3ed04ff30
2 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

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

Просмотреть файл

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