Bug 1162648. When updating layout with the latest async values from the APZC do the scrolling last because it can flush layout. r=botond,kats
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 13 May 2015 15:52:09 -0500
changeset 243761 e0231e8d2cdf4028163f409f0df97aaa2b85cb5f
parent 243760 02c55409bb067ac74854b9cb34d8bee16bf3d82f
child 243762 74f120732c626337c9bfde5f70e8202e06d976ae
push id28753
push userkwierso@gmail.com
push dateThu, 14 May 2015 22:33:43 +0000
treeherdermozilla-central@07e2e15703cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond, kats
bugs1162648
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1162648. When updating layout with the latest async values from the APZC do the scrolling last because it can flush layout. r=botond,kats If we flush layout after the new scroll position clamping scroll port size but the old resolution then the scrollbars will be placed in the wrong spot.
gfx/layers/apz/util/APZCCallbackHelper.cpp
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -191,25 +191,27 @@ APZCCallbackHelper::UpdateRootFrame(nsIP
   // be 1000 pixels long but the frame would still be 100 pixels, and so the maximum
   // scroll range would be 900. Therefore this calculation depends on the zoom applied
   // to the content relative to the container.
   // Note that this needs to happen before scrolling the frame (in UpdateFrameCommon),
   // otherwise the scroll position may get clamped incorrectly.
   CSSSize scrollPort = aMetrics.CalculateCompositedSizeInCssPixels();
   nsLayoutUtils::SetScrollPositionClampingScrollPortSize(aPresShell, scrollPort);
 
-  nsIContent* content = nsLayoutUtils::FindContentFor(aMetrics.GetScrollId());
-  ScrollFrame(content, aMetrics);
-
   // The pres shell resolution is updated by the the async zoom since the
   // last paint.
   presShellResolution = aMetrics.GetPresShellResolution()
                       * aMetrics.GetAsyncZoom().scale;
   nsLayoutUtils::SetResolutionAndScaleTo(aPresShell, presShellResolution);
 
+  // Do this as late as possible since scrolling can flush layout. It also
+  // adjusts the display port margins, so do it before we set those.
+  nsIContent* content = nsLayoutUtils::FindContentFor(aMetrics.GetScrollId());
+  ScrollFrame(content, aMetrics);
+
   SetDisplayPortMargins(aPresShell, content, aMetrics);
 }
 
 static already_AddRefed<nsIPresShell>
 GetPresShell(const nsIContent* aContent)
 {
   nsCOMPtr<nsIPresShell> result;
   if (nsIDocument* doc = aContent->GetComposedDoc()) {