mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1228407 - Avoid a scenario where content floods APZ with smooth-scroll requests and blocks it from syncing a new scroll offset back to the main thread. r=botond
--HG-- extra : commitid : LdMBKbQQw7V
This commit is contained in:
parent
d66458bcdc
commit
56e9023bca
@ -2121,10 +2121,30 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) {
|
||||
if (mApzSmoothScrollDestination == 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
|
||||
// we sent), then don't send another one because it is redundant.
|
||||
// This is to avoid a scenario where pages do repeated scrollBy
|
||||
// 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.
|
||||
// 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
|
||||
// on file for this.
|
||||
return;
|
||||
}
|
||||
|
||||
// The animation will be handled in the compositor, pass the
|
||||
// information needed to start the animation and skip the main-thread
|
||||
// animation for this scroll.
|
||||
mLastSmoothScrollOrigin = aOrigin;
|
||||
mApzSmoothScrollDestination = mDestination;
|
||||
mScrollGeneration = ++sScrollGenerationCounter;
|
||||
|
||||
if (!nsLayoutUtils::GetDisplayPort(mOuter->GetContent())) {
|
||||
|
@ -432,6 +432,7 @@ public:
|
||||
nsTArray<nsIScrollPositionListener*> mListeners;
|
||||
nsIAtom* mLastScrollOrigin;
|
||||
nsIAtom* mLastSmoothScrollOrigin;
|
||||
nsPoint mApzSmoothScrollDestination;
|
||||
uint32_t mScrollGeneration;
|
||||
nsRect mScrollPort;
|
||||
// Where we're currently scrolling to, if we're scrolling asynchronously.
|
||||
|
Loading…
Reference in New Issue
Block a user