Bug 1521278 - Allow ScrollAnchorContainer to detach anchor frame even if pref is disabled. r=dholbert
authorRyan Hunt <rhunt@eqrion.net>
Sun, 20 Jan 2019 07:21:55 +0000
changeset 454631 60944b0fca8ffa2371774326101bffc9a1ed6ec5
parent 454630 2b62559fb02b566aa10476ea77169df02cee7807
child 454632 f1694d9e640bd1768178e121a5d6fb73565bd32c
push id35406
push userrmaries@mozilla.com
push dateMon, 21 Jan 2019 11:32:31 +0000
treeherdermozilla-central@f1694d9e640b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1521278
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 1521278 - Allow ScrollAnchorContainer to detach anchor frame even if pref is disabled. r=dholbert The important piece is just that we don't queue a selection for later. This code runs for each scroll, so we'd be wasting a lot of effort to do that. Differential Revision: https://phabricator.services.mozilla.com/D17050
layout/generic/ScrollAnchorContainer.cpp
--- a/layout/generic/ScrollAnchorContainer.cpp
+++ b/layout/generic/ScrollAnchorContainer.cpp
@@ -247,28 +247,28 @@ void ScrollAnchorContainer::UserScrolled
 }
 
 void ScrollAnchorContainer::SuppressAdjustments() {
   ANCHOR_LOG("Received a scroll anchor suppression for %p.\n", this);
   mSuppressAnchorAdjustment = true;
 }
 
 void ScrollAnchorContainer::InvalidateAnchor() {
-  if (!StaticPrefs::layout_css_scroll_anchoring_enabled()) {
-    return;
-  }
-
   ANCHOR_LOG("Invalidating scroll anchor %p for %p.\n", mAnchorNode, this);
 
   if (mAnchorNode) {
     SetAnchorFlags(mScrollFrame->mScrolledFrame, mAnchorNode, false);
   }
   mAnchorNode = nullptr;
   mAnchorNodeIsDirty = true;
   mLastAnchorOffset = 0;
+
+  if (!StaticPrefs::layout_css_scroll_anchoring_enabled()) {
+    return;
+  }
   Frame()->PresShell()->PostPendingScrollAnchorSelection(this);
 }
 
 void ScrollAnchorContainer::Destroy() {
   if (mAnchorNode) {
     SetAnchorFlags(mScrollFrame->mScrolledFrame, mAnchorNode, false);
   }
   mAnchorNode = nullptr;