Bug 1232048 - Fix breakage in scroll snapping when snapping twice in a row to the same thing with non-smooth-scrolls in between. r=botond

This commit is contained in:
Kartikaya Gupta 2015-12-16 10:42:49 -05:00
parent b60330f131
commit 4a5b4ef145
2 changed files with 13 additions and 6 deletions

View File

@ -2093,6 +2093,12 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
nsRect range = aRange ? *aRange : nsRect(aScrollPosition, nsSize(0, 0));
if (aMode != nsIScrollableFrame::SMOOTH_MSD) {
// If we get a non-smooth-scroll, reset the cached APZ scroll destination,
// so that we know to process the next smooth-scroll destined for APZ.
mApzSmoothScrollDestination = Nothing();
}
if (aMode == nsIScrollableFrame::INSTANT) {
// Asynchronous scrolling is not allowed, so we'll kill any existing
// async-scrolling process and do an instant scroll.
@ -2122,7 +2128,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
}
if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) {
if (mApzSmoothScrollDestination == mDestination &&
if (mApzSmoothScrollDestination == Some(mDestination) &&
mScrollGeneration == sScrollGenerationCounter) {
// If we already sent APZ a smooth-scroll request to this
// destination with this generation (i.e. it was the last request
@ -2131,9 +2137,10 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
// calls, incrementing the generation counter, and blocking APZ from
// syncing the scroll offset back to the main thread.
// Note that if we get two smooth-scroll requests to the same
// destination with some other scroll in between, mDestination will
// get reset and so we shouldn't have the problem where this check
// discards a legitimate smooth-scroll.
// destination with some other scroll in between,
// mApzSmoothScrollDestination will get reset to Nothing() and so
// we shouldn't have the problem where this check discards a
// legitimate smooth-scroll.
// Note: if there are two separate scrollframes both getting smooth
// scrolled at the same time, sScrollGenerationCounter can get
// incremented and this early-exit won't get taken. Bug 1231177 is
@ -2145,7 +2152,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
// information needed to start the animation and skip the main-thread
// animation for this scroll.
mLastSmoothScrollOrigin = aOrigin;
mApzSmoothScrollDestination = mDestination;
mApzSmoothScrollDestination = Some(mDestination);
mScrollGeneration = ++sScrollGenerationCounter;
if (!nsLayoutUtils::GetDisplayPort(mOuter->GetContent())) {

View File

@ -432,7 +432,7 @@ public:
nsTArray<nsIScrollPositionListener*> mListeners;
nsIAtom* mLastScrollOrigin;
nsIAtom* mLastSmoothScrollOrigin;
nsPoint mApzSmoothScrollDestination;
Maybe<nsPoint> mApzSmoothScrollDestination;
uint32_t mScrollGeneration;
nsRect mScrollPort;
// Where we're currently scrolling to, if we're scrolling asynchronously.