Bug 1254275 - Inspect the event queue to find out whether momentum events are following. r=kats a=ritu

MozReview-Commit-ID: 6k3SaJ6X7Mr
This commit is contained in:
Markus Stange 2016-03-28 14:56:28 -04:00
parent 1b1c5c5390
commit e6453f4c35
3 changed files with 23 additions and 0 deletions

View File

@ -1992,6 +1992,10 @@ nsEventStatus AsyncPanZoomController::OnPanEnd(const PanGestureInput& aEvent) {
SetState(NOTHING); SetState(NOTHING);
RequestContentRepaint(); RequestContentRepaint();
if (!aEvent.mFollowedByMomentum) {
RequestSnap();
}
return nsEventStatus_eConsumeNoDefault; return nsEventStatus_eConsumeNoDefault;
} }

View File

@ -358,6 +358,7 @@ public:
mLineOrPageDeltaX(0), mLineOrPageDeltaX(0),
mLineOrPageDeltaY(0), mLineOrPageDeltaY(0),
mHandledByAPZ(false), mHandledByAPZ(false),
mFollowedByMomentum(false),
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false) mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false)
{ {
} }
@ -385,6 +386,10 @@ public:
bool mHandledByAPZ; bool mHandledByAPZ;
// true if this is a PANGESTURE_END event that will be followed by a
// PANGESTURE_MOMENTUMSTART event.
bool mFollowedByMomentum;
// If this is true, and this event started a new input block that couldn't // If this is true, and this event started a new input block that couldn't
// find a scrollable target which is scrollable in the horizontal component // find a scrollable target which is scrollable in the horizontal component
// of the scroll start direction, then this input block needs to be put on // of the scroll start direction, then this input block needs to be put on

View File

@ -4963,6 +4963,20 @@ PanGestureTypeForEvent(NSEvent* aEvent)
panEvent.mLineOrPageDeltaX = lineOrPageDeltaX; panEvent.mLineOrPageDeltaX = lineOrPageDeltaX;
panEvent.mLineOrPageDeltaY = lineOrPageDeltaY; panEvent.mLineOrPageDeltaY = lineOrPageDeltaY;
if (panEvent.mType == PanGestureInput::PANGESTURE_END) {
// Check if there's a momentum start event in the event queue, so that we
// can annotate this event.
NSEvent* nextWheelEvent =
[NSApp nextEventMatchingMask:NSScrollWheelMask
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:NO];
if (nextWheelEvent &&
PanGestureTypeForEvent(nextWheelEvent) == PanGestureInput::PANGESTURE_MOMENTUMSTART) {
panEvent.mFollowedByMomentum = true;
}
}
bool canTriggerSwipe = [self shouldConsiderStartingSwipeFromEvent:theEvent]; bool canTriggerSwipe = [self shouldConsiderStartingSwipeFromEvent:theEvent];
panEvent.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection = canTriggerSwipe; panEvent.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection = canTriggerSwipe;
mGeckoChild->DispatchAPZWheelInputEvent(panEvent, canTriggerSwipe); mGeckoChild->DispatchAPZWheelInputEvent(panEvent, canTriggerSwipe);