Bug 1092626 - Don't try to restore the scroll position if the frame is still dirty or has dirty children. r=roc a=lizzard
authorMats Palmgren <mats@mozilla.com>
Wed, 11 Nov 2015 11:33:34 +0100
changeset 296708 c580b1ad0f23
parent 296707 decfff8497ce
child 296709 a59d9d8978ad
push id5300
push userkwierso@gmail.com
push date2015-11-12 18:55 +0000
treeherdermozilla-beta@26f64ca8f630 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lizzard
bugs1092626
milestone43.0
Bug 1092626 - Don't try to restore the scroll position if the frame is still dirty or has dirty children. r=roc a=lizzard
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -4642,35 +4642,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();