Bug 1092626 - Don't try to restore the scroll position if the frame is still dirty or has dirty children. r=roc
authorMats Palmgren <mats@mozilla.com>
Wed, 11 Nov 2015 11:33:34 +0100
changeset 308254 f748eade3e29797dcbb5d2e0d0084027b3edbb37
parent 308253 d06197eaef0274dcdc6f1cc5d8d03b98aa950939
child 308255 92bbfb9abef905cc62f10b2bf3c885becc333528
push id7450
push userahalberstadt@mozilla.com
push dateWed, 11 Nov 2015 20:09:05 +0000
reviewersroc
bugs1092626
milestone45.0a1
Bug 1092626 - Don't try to restore the scroll position if the frame is still dirty or has dirty children. r=roc
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -4747,35 +4747,41 @@ ScrollFrameHelper::FinishReflowForScroll
   SetCoordAttribute(aContent, nsGkAtoms::maxpos, aMaxXY - aMinXY);
   SetCoordAttribute(aContent, nsGkAtoms::pageincrement, aPageIncrement);
   SetCoordAttribute(aContent, nsGkAtoms::increment, aIncrement);
 }
 
 bool
 ScrollFrameHelper::ReflowFinished()
 {
+  mPostedReflowCallback = false;
+
+  if (NS_SUBTREE_DIRTY(mOuter)) {
+    // We will get another call after the next reflow and scrolling
+    // later is less janky.
+    return false;
+  }
+
   nsAutoScriptBlocker scriptBlocker;
-  mPostedReflowCallback = false;
-
   ScrollToRestoredPosition();
 
   // Clamp current scroll position to new bounds. Normally this won't
   // do anything.
   nsPoint currentScrollPos = GetScrollPosition();
   ScrollToImpl(currentScrollPos, nsRect(currentScrollPos, nsSize(0, 0)));
   if (!mAsyncScroll && !mAsyncSmoothMSDScroll) {
     // We need to have mDestination track the current scroll position,
     // in case it falls outside the new reflow area. mDestination is used
     // by ScrollBy as its starting position.
     mDestination = GetScrollPosition();
   }
 
-  if (NS_SUBTREE_DIRTY(mOuter) || !mUpdateScrollbarAttributes)
+  if (!mUpdateScrollbarAttributes) {
     return false;
-
+  }
   mUpdateScrollbarAttributes = false;
 
   // Update scrollbar attributes.
   nsPresContext* presContext = mOuter->PresContext();
 
   if (mMayHaveDirtyFixedChildren) {
     mMayHaveDirtyFixedChildren = false;
     nsIFrame* parentFrame = mOuter->GetParent();