Bug 974177 - PointerCancel must trigger PointerOut event. r=smaug

--HG--
extra : rebase_source : cd88e856cbae08f21aed564899195f9697053f3a
This commit is contained in:
Oleg Romashin 2014-02-26 13:37:30 -08:00
parent 31d70123f1
commit c650e7620f
2 changed files with 36 additions and 0 deletions

View File

@ -1094,6 +1094,11 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
} }
break; break;
} }
case NS_POINTER_CANCEL:
{
GenerateMouseEnterExit(mouseEvent);
break;
}
case NS_MOUSE_EXIT: case NS_MOUSE_EXIT:
// If the event is not a top-level window exit, then it's not // If the event is not a top-level window exit, then it's not
// really an exit --- we may have traversed widget boundaries but // really an exit --- we may have traversed widget boundaries but
@ -4440,6 +4445,7 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
} }
break; break;
case NS_POINTER_LEAVE: case NS_POINTER_LEAVE:
case NS_POINTER_CANCEL:
case NS_MOUSE_EXIT: case NS_MOUSE_EXIT:
{ {
// This is actually the window mouse exit or pointer leave event. We're not moving // This is actually the window mouse exit or pointer leave event. We're not moving

View File

@ -263,6 +263,36 @@ function runTests() {
}; };
sendTouchEvent(cwu, "touchmove", getTouchEventForTarget(d1, cwu, 2), 0); sendTouchEvent(cwu, "touchmove", getTouchEventForTarget(d1, cwu, 2), 0);
// Test for cancel trigger pointerOut (Touch Pointer must be at d1 now)
pointerCancelTriggered = 0;
var pointerOutTriggeredForCancelEvent = 0;
var pointerLeaveTriggeredForCancelEvent = 0;
d1.onpointerout = function(e) {
if (pointerOutTriggeredForCancelEvent == 0) {
is(e.pointerId, 3, "Wrong Pointer type, should be id from Touch event");
is(e.pointerType, "touch", "Wrong Pointer type, should be touch type");
} else {
is(e.pointerId, 0, "Wrong Pointer type, should be id from mouse event");
is(e.pointerType, "mouse", "Wrong Pointer type, should be mouse type");
}
pointerOutTriggeredForCancelEvent = 1;
};
d1.onpointerleave = function(e) {
is(pointerOutTriggeredForCancelEvent, 1, "Pointer Out must be dispatched bedore Pointer leave");
if (pointerLeaveTriggeredForCancelEvent == 0) {
is(e.pointerId, 3, "Wrong Pointer type, should be id from Touch event");
is(e.pointerType, "touch", "Wrong Pointer type, should be touch type");
} else {
is(e.pointerId, 0, "Wrong Pointer type, should be id from mouse event");
is(e.pointerType, "mouse", "Wrong Pointer type, should be mouse type");
}
pointerLeaveTriggeredForCancelEvent = 1;
}
sendTouchEvent(cwu, "touchcancel", getTouchEventForTarget(d1, cwu, 3), 0);
is(pointerOutTriggeredForCancelEvent, 1, "Pointer Out not dispatched on PointerCancel");
is(pointerLeaveTriggeredForCancelEvent, 1, "Pointer Leave not dispatched on PointerCancel");
finishTest(); finishTest();
} }