Bug 915645 - Allow single taps to occur longer than MAX_TAP_TIME. r=kats

This commit is contained in:
Dale Harvey 2013-10-28 15:46:40 +00:00
parent eff07313ae
commit b764e71eec

View File

@ -149,47 +149,46 @@ 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.
CancelDoubleTapTimeoutTask();
if (mState == GESTURE_WAITING_DOUBLE_TAP) {
CancelDoubleTapTimeoutTask();
if (mTapStartTime - mLastTapEndTime > MAX_TAP_TIME ||
event.mTime - mTapStartTime > MAX_TAP_TIME) {
// Either the time between taps or the last tap took too long
// confirm previous tap and handle current tap seperately
TimeoutDoubleTap();
// Change the state so we can proceed to process the current tap.
mState = GESTURE_WAITING_SINGLE_TAP;
}
if (mState == GESTURE_WAITING_DOUBLE_TAP) {
CancelDoubleTapTimeoutTask();
} else {
// We were waiting for a double tap and it has arrived.
HandleDoubleTap(event);
mState = GESTURE_NONE;
} else if (mState == GESTURE_WAITING_SINGLE_TAP) {
CancelLongTapTimeoutTask();
HandleSingleTapUpEvent(event);
// We were not waiting for anything but a single tap has happened that
// may turn into a double tap. Wait a while and if it doesn't turn into
// a double tap, send a single tap instead.
mState = GESTURE_WAITING_DOUBLE_TAP;
mDoubleTapTimeoutTask =
NewRunnableMethod(this, &GestureEventListener::TimeoutDoubleTap);
mAsyncPanZoomController->PostDelayedTask(
mDoubleTapTimeoutTask,
MAX_TAP_TIME);
}
mLastTapEndTime = event.mTime;
}
if (mState == GESTURE_WAITING_SINGLE_TAP) {
if (mState == GESTURE_WAITING_SINGLE_TAP &&
event.mTime - mTapStartTime > MAX_TAP_TIME) {
// Extended taps are immediately dispatched as single taps
CancelLongTapTimeoutTask();
HandleSingleTapConfirmedEvent(event);
mState = GESTURE_NONE;
} else if (mState == GESTURE_WAITING_SINGLE_TAP) {
CancelLongTapTimeoutTask();
HandleSingleTapUpEvent(event);
// We were not waiting for anything but a single tap has happened that
// may turn into a double tap. Wait a while and if it doesn't turn into
// a double tap, send a single tap instead.
mState = GESTURE_WAITING_DOUBLE_TAP;
mDoubleTapTimeoutTask =
NewRunnableMethod(this, &GestureEventListener::TimeoutDoubleTap);
mAsyncPanZoomController->PostDelayedTask(
mDoubleTapTimeoutTask,
MAX_TAP_TIME);
}
mLastTapEndTime = event.mTime;
if (!mTouches.Length()) {
mSpanChange = 0.0f;
}