Bug 1517895 - Scroll the visual viewport in SessionStoreUtils::RestoreScrollPosition(). r=JanH
authorBotond Ballo <botond@mozilla.com>
Wed, 13 Mar 2019 23:07:24 +0000
changeset 521796 a0bf4a689da4
parent 521795 f41b081164d2
child 521797 f363798d6481
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJanH
bugs1517895
milestone67.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 1517895 - Scroll the visual viewport in SessionStoreUtils::RestoreScrollPosition(). r=JanH Differential Revision: https://phabricator.services.mozilla.com/D19876
toolkit/components/sessionstore/SessionStoreUtils.cpp
--- a/toolkit/components/sessionstore/SessionStoreUtils.cpp
+++ b/toolkit/components/sessionstore/SessionStoreUtils.cpp
@@ -282,16 +282,28 @@ void SessionStoreUtils::RestoreScrollPos
   }
 
   nsCCharSeparatedTokenizer tokenizer(aData.mScroll.Value(), ',');
   nsAutoCString token(tokenizer.nextToken());
   int pos_X = atoi(token.get());
   token = tokenizer.nextToken();
   int pos_Y = atoi(token.get());
   aWindow.ScrollTo(pos_X, pos_Y);
+
+  if (nsCOMPtr<Document> doc = aWindow.GetExtantDoc()) {
+    if (nsPresContext* presContext = doc->GetPresContext()) {
+      if (presContext->IsRootContentDocument()) {
+        // Use eMainThread so this takes precedence over session history
+        // (ScrollFrameHelper::ScrollToRestoredPosition()).
+        presContext->PresShell()->SetPendingVisualScrollUpdate(
+            CSSPoint::ToAppUnits(CSSPoint(pos_X, pos_Y)),
+            layers::FrameMetrics::eMainThread);
+      }
+    }
+  }
 }
 
 // Implements the Luhn checksum algorithm as described at
 // http://wikipedia.org/wiki/Luhn_algorithm
 // Number digit lengths vary with network, but should fall within 12-19 range.
 // [2] More details at https://en.wikipedia.org/wiki/Payment_card_number
 static bool IsValidCCNumber(nsAString& aValue) {
   uint32_t total = 0;