Bug 806596 - Don't fire double tap if the delayed task to timeout the 1st tap fails to run in time. r=roc

This commit is contained in:
Cervantes Yu 2012-11-28 22:46:50 -05:00
parent 585436962e
commit f436443f50
2 changed files with 21 additions and 0 deletions

View File

@ -34,6 +34,7 @@ GestureEventListener::GestureEventListener(AsyncPanZoomController* aAsyncPanZoom
: mAsyncPanZoomController(aAsyncPanZoomController),
mState(GESTURE_NONE),
mSpanChange(0.0f),
mLastTapEndTime(0),
mLastTouchInput(MultiTouchInput::MULTITOUCH_START, 0)
{
}
@ -137,6 +138,17 @@ nsEventStatus GestureEventListener::HandleInputEvent(const InputData& aEvent)
NS_WARN_IF_FALSE(foundAlreadyExistingTouch, "Touch ended, but not in list");
if (event.mTime - mTapStartTime <= MAX_TAP_TIME) {
if (mState == GESTURE_WAITING_DOUBLE_TAP &&
event.mTime - mLastTapEndTime > MAX_TAP_TIME) {
// mDoubleTapTimeoutTask wasn't scheduled in time. We need to run the
// task synchronously to confirm the last tap.
mDoubleTapTimeoutTask->Cancel();
TimeoutDoubleTap();
// Change the state so we can proceed to process the current tap.
mState = GESTURE_WAITING_SINGLE_TAP;
}
if (mState == GESTURE_WAITING_DOUBLE_TAP) {
mDoubleTapTimeoutTask->Cancel();
@ -161,6 +173,8 @@ nsEventStatus GestureEventListener::HandleInputEvent(const InputData& aEvent)
mDoubleTapTimeoutTask,
MAX_TAP_TIME);
}
mLastTapEndTime = event.mTime;
}
if (mState == GESTURE_WAITING_SINGLE_TAP) {

View File

@ -178,6 +178,13 @@ protected:
*/
uint64_t mTapStartTime;
/**
* Stores the time the last tap ends (finger leaves the screen). This is used
* when mDoubleTapTimeoutTask cannot be scheduled in time and consecutive
* taps are falsely regarded as double taps.
*/
uint64_t mLastTapEndTime;
/**
* Cached copy of the last touch input, only valid when in the
* "GESTURE_WAITING_DOUBLE_TAP" state. This is used to forward along to