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

MozReview-Commit-ID: 6k3SaJ6X7Mr

--HG--
extra : histedit_source : 1b6842a2cd855dc04b1375c2c0f174005b1e0c75
This commit is contained in:
Markus Stange 2016-03-28 14:56:28 -04:00
parent aa9962666e
commit 0ab404928f
3 changed files with 23 additions and 0 deletions

View File

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

View File

@ -371,6 +371,7 @@ public:
mLineOrPageDeltaX(0),
mLineOrPageDeltaY(0),
mHandledByAPZ(false),
mFollowedByMomentum(false),
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false)
{
}
@ -398,6 +399,10 @@ public:
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
// 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

View File

@ -4941,6 +4941,20 @@ PanGestureTypeForEvent(NSEvent* aEvent)
panEvent.mLineOrPageDeltaX = lineOrPageDeltaX;
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];
panEvent.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection = canTriggerSwipe;
mGeckoChild->DispatchAPZWheelInputEvent(panEvent, canTriggerSwipe);