Bug 1509575 - Restore the visual viewport offset from the main thread during a first paint. r=kats
☠☠ backed out by c908cdfffe30 ☠ ☠
authorBotond Ballo <botond@mozilla.com>
Fri, 11 Jan 2019 04:21:29 +0000
changeset 510546 245d6855cd3bcb4ff5afd2ab9cc90ce2cedf8a00
parent 510545 7dcfa876f76cd181cb7f8d482770c09b32f6a849
child 510547 65511e8d7a7e0df5df7c4b7c96ffc3cbd2590db3
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1509575
milestone66.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 1509575 - Restore the visual viewport offset from the main thread during a first paint. r=kats During a "first paint" transaction, compositor-side state such as APZ's copy of the visual viewport offset is overwritten. However, the scroll frame may persist on the main thread, and in such a case we want to restore the visual viewport offset stored in the scroll frame. This comes into play during e.g. navigation back to a page. Differential Revision: https://phabricator.services.mozilla.com/D16238
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8703,16 +8703,23 @@ static void MaybeReflowForInflationScree
     CSSPoint scrollPosition =
         CSSPoint::FromAppUnits(scrollableFrame->GetScrollPosition());
     CSSPoint apzScrollPosition =
         CSSPoint::FromAppUnits(scrollableFrame->GetApzScrollPosition());
     metrics.SetScrollOffset(scrollPosition);
     metrics.SetBaseScrollOffset(apzScrollPosition);
 
     if (aIsRootContent) {
+      if (aLayerManager->GetIsFirstPaint()) {
+        // Restore the visual viewport offset to the copy stored on the
+        // main thread.
+        presShell->SetPendingVisualViewportOffset(
+            Some(presShell->GetVisualViewportOffset()));
+      }
+
       if (const Maybe<nsPoint>& visualOffset =
               presShell->GetPendingVisualViewportOffset()) {
         metrics.SetVisualViewportOffset(CSSPoint::FromAppUnits(*visualOffset));
         metrics.SetVisualScrollUpdateType(FrameMetrics::eMainThread);
         presShell->SetPendingVisualViewportOffset(Nothing());
       }
     }