Bug 862240 - Add null checking and reset the runnable member pointer when entering runnable method. r=drs

This commit is contained in:
Benjamin Chen 2013-04-25 03:58:10 +08:00
Родитель 24fa014fa3
Коммит cc0744c9bf
2 изменённых файлов: 26 добавлений и 6 удалений

Просмотреть файл

@ -142,7 +142,7 @@ nsEventStatus GestureEventListener::HandleInputEvent(const InputData& aEvent)
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();
CancelDoubleTapTimeoutTask();
TimeoutDoubleTap();
// Change the state so we can proceed to process the current tap.
@ -150,14 +150,12 @@ nsEventStatus GestureEventListener::HandleInputEvent(const InputData& aEvent)
}
if (mState == GESTURE_WAITING_DOUBLE_TAP) {
mDoubleTapTimeoutTask->Cancel();
CancelDoubleTapTimeoutTask();
// We were waiting for a double tap and it has arrived.
HandleDoubleTap(event);
mState = GESTURE_NONE;
} else if (mState == GESTURE_WAITING_SINGLE_TAP) {
mLongTapTimeoutTask->Cancel();
CancelLongTapTimeoutTask();
HandleSingleTapUpEvent(event);
// We were not waiting for anything but a single tap has happened that
@ -299,7 +297,7 @@ nsEventStatus GestureEventListener::HandleTapCancel(const MultiTouchInput& aEven
switch (mState)
{
case GESTURE_WAITING_SINGLE_TAP:
mLongTapTimeoutTask->Cancel();
CancelLongTapTimeoutTask();
mState = GESTURE_NONE;
break;
@ -321,6 +319,7 @@ nsEventStatus GestureEventListener::HandleDoubleTap(const MultiTouchInput& aEven
void GestureEventListener::TimeoutDoubleTap()
{
mDoubleTapTimeoutTask = nullptr;
// If we haven't gotten another tap by now, reset the state and treat it as a
// single tap. It couldn't have been a double tap.
if (mState == GESTURE_WAITING_DOUBLE_TAP) {
@ -330,8 +329,16 @@ void GestureEventListener::TimeoutDoubleTap()
}
}
void GestureEventListener::CancelDoubleTapTimeoutTask() {
if (mDoubleTapTimeoutTask) {
mDoubleTapTimeoutTask->Cancel();
mDoubleTapTimeoutTask = nullptr;
}
}
void GestureEventListener::TimeoutLongTap()
{
mLongTapTimeoutTask = nullptr;
// If the tap has not been released, this is a long press.
if (mState == GESTURE_WAITING_SINGLE_TAP) {
mState = GESTURE_NONE;
@ -340,6 +347,13 @@ void GestureEventListener::TimeoutLongTap()
}
}
void GestureEventListener::CancelLongTapTimeoutTask() {
if (mLongTapTimeoutTask) {
mLongTapTimeoutTask->Cancel();
mLongTapTimeoutTask = nullptr;
}
}
AsyncPanZoomController* GestureEventListener::GetAsyncPanZoomController() {
return mAsyncPanZoomController;
}

Просмотреть файл

@ -201,15 +201,21 @@ protected:
* Task used to timeout a double tap. This gets posted to the UI thread such
* that it runs a short time after a single tap happens. We cache it so that
* we can cancel it if a double tap actually comes in.
* CancelDoubleTapTimeoutTask: Cancel the mDoubleTapTimeoutTask and also set
* it to null.
*/
CancelableTask *mDoubleTapTimeoutTask;
inline void CancelDoubleTapTimeoutTask();
/**
* Task used to timeout a long tap. This gets posted to the UI thread such
* that it runs a time when a single tap happens. We cache it so that
* we can cancel it if any other touch event happens.
* CancelLongTapTimeoutTask: Cancel the mLongTapTimeoutTask and also set
* it to null.
*/
CancelableTask *mLongTapTimeoutTask;
inline void CancelLongTapTimeoutTask();
/**
* Position of the last touch starting. This is only valid during an attempt