Bug 1039979 - When cancelling animations based on user input, cancel animations on the entire handoff chain. r=botond

This commit is contained in:
Kartikaya Gupta 2014-07-17 13:41:53 -04:00
parent 6de071fb7b
commit 1eda27d75c
4 changed files with 36 additions and 7 deletions

View File

@ -888,16 +888,26 @@ bool
APZCTreeManager::FlushRepaintsForOverscrollHandoffChain()
{
MonitorAutoLock lock(mTreeLock); // to access mOverscrollHandoffChain
if (mOverscrollHandoffChain.length() == 0) {
return false;
}
for (uint32_t i = 0; i < mOverscrollHandoffChain.length(); i++) {
nsRefPtr<AsyncPanZoomController> item = mOverscrollHandoffChain[i];
if (item) {
item->FlushRepaintForOverscrollHandoff();
}
}
return true;
return mOverscrollHandoffChain.length() > 0;
}
bool
APZCTreeManager::CancelAnimationsForOverscrollHandoffChain()
{
MonitorAutoLock lock(mTreeLock); // to access mOverscrollHandoffChain
for (uint32_t i = 0; i < mOverscrollHandoffChain.length(); i++) {
nsRefPtr<AsyncPanZoomController> item = mOverscrollHandoffChain[i];
if (item) {
item->CancelAnimation();
}
}
return mOverscrollHandoffChain.length() > 0;
}
bool

View File

@ -293,6 +293,7 @@ public:
bool HandOffFling(AsyncPanZoomController* aApzc, ScreenPoint aVelocity);
bool FlushRepaintsForOverscrollHandoffChain();
bool CancelAnimationsForOverscrollHandoffChain();
/**
* Determine whether |aApzc|, or any APZC along its overscroll handoff chain,

View File

@ -813,6 +813,18 @@ AsyncPanZoomController::GetTouchStartTolerance()
return static_cast<AxisLockMode>(gfxPrefs::APZAxisLockMode());
}
void
AsyncPanZoomController::CancelAnimationForHandoffChain()
{
APZCTreeManager* treeManagerLocal = mTreeManager;
if (treeManagerLocal && treeManagerLocal->CancelAnimationsForOverscrollHandoffChain()) {
return;
}
NS_WARNING("Overscroll handoff chain was empty in CancelAnimationForHandoffChain! This should not be the case.");
// Graceful handling of error condition
CancelAnimation();
}
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
AssertOnControllerThread();
@ -830,7 +842,7 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent)
ScheduleContentResponseTimeout();
// However, we still want to cancel animations here because a finger has gone down
// and we don't want to keep moving the content under the finger.
CancelAnimation();
CancelAnimationForHandoffChain();
} else {
// Content won't prevent-default this, so we can just pretend like we scheduled
// a timeout and it expired. Note that we will still receive a ContentReceivedTouch
@ -967,7 +979,7 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent
}
// Fall through.
case ANIMATING_ZOOM:
CancelAnimation();
CancelAnimationForHandoffChain();
// Fall through.
case NOTHING: {
mX.StartTouch(point.x, aEvent.mTime);
@ -1293,7 +1305,7 @@ nsEventStatus AsyncPanZoomController::OnPanMayBegin(const PanGestureInput& aEven
mX.StartTouch(aEvent.mPanStartPoint.x, aEvent.mTime);
mY.StartTouch(aEvent.mPanStartPoint.y, aEvent.mTime);
CancelAnimation();
CancelAnimationForHandoffChain();
return nsEventStatus_eConsumeNoDefault;
}

View File

@ -536,6 +536,12 @@ protected:
void FireAsyncScrollOnTimeout();
private:
/**
* Cancel animations all the way up the overscroll handoff chain if possible,
* or just the local APZC if not.
*/
void CancelAnimationForHandoffChain();
/**
* Helper to set the current state. Holds the monitor before actually setting
* it and fires content controller events based on state changes. Always set