Bug 1714138 - Remove AnimatedGeometryRoot. r=mstange
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 15 Sep 2021 08:31:05 +0000
changeset 592028 00f891318c3aa052957840cac009546fdbc9e20f
parent 592027 14f05ffa9f78e7acf213138ecac786c3562fa38c
child 592029 361b4938c21265618e08498c781edefb86f60c4b
push id149771
push usermwoodrow@mozilla.com
push dateWed, 15 Sep 2021 08:33:33 +0000
treeherderautoland@00f891318c3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1714138
milestone94.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 1714138 - Remove AnimatedGeometryRoot. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D124154
layout/base/nsLayoutDebugger.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/painting/RetainedDisplayListBuilder.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/layout/base/nsLayoutDebugger.cpp
+++ b/layout/base/nsLayoutDebugger.cpp
@@ -72,27 +72,25 @@ static void PrintDisplayItemTo(nsDisplay
     string.AppendInt((uint64_t)aItem);
     aStream << nsPrintfCString("<a href=\"javascript:ViewImage('%s')\">",
                                string.BeginReading());
   }
 #endif
 
   aStream << nsPrintfCString(
       "%s p=0x%p f=0x%p(%s) key=%d %sbounds(%d,%d,%d,%d) "
-      "componentAlpha(%d,%d,%d,%d) clip(%s) asr(%s) clipChain(%s)%s "
-      "agr=0x%p",
+      "componentAlpha(%d,%d,%d,%d) clip(%s) asr(%s) clipChain(%s)%s ",
       aItem->Name(), aItem, (void*)f, NS_ConvertUTF16toUTF8(contentData).get(),
       aItem->GetPerFrameKey(),
       (aItem->ZIndex() ? nsPrintfCString("z=%d ", aItem->ZIndex()).get() : ""),
       rect.x, rect.y, rect.width, rect.height, component.x, component.y,
       component.width, component.height, clip.ToString().get(),
       ActiveScrolledRoot::ToString(aItem->GetActiveScrolledRoot()).get(),
       DisplayItemClipChain::ToString(aItem->GetClipChain()).get(),
-      aItem->IsUniform(aBuilder) ? " uniform" : "",
-      aItem->GetAnimatedGeometryRoot()->mFrame);
+      aItem->IsUniform(aBuilder) ? " uniform" : "");
 
   for (auto iter = opaque.RectIter(); !iter.Done(); iter.Next()) {
     const nsRect& r = iter.Get();
     aStream << nsPrintfCString(" (opaque %d,%d,%d,%d)", r.x, r.y, r.width,
                                r.height);
   }
 
   const auto& willChange = aItem->Frame()->StyleDisplay()->mWillChange;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -4339,19 +4339,16 @@ nsRect ScrollFrameHelper::RestrictToRoot
             (StaticPrefs::apz_nonwr_activate_all_scroll_frames_when_fission() &&
              FissionAutostart()));
   }
 }
 
 bool ScrollFrameHelper::DecideScrollableLayer(
     nsDisplayListBuilder* aBuilder, nsRect* aVisibleRect, nsRect* aDirtyRect,
     bool aSetBase, bool* aDirtyRectHasBeenOverriden) {
-  // Save and check if this changes so we can recompute the current agr.
-  bool oldWillBuildScrollableLayer = mWillBuildScrollableLayer;
-
   nsIContent* content = mOuter->GetContent();
   // For hit testing purposes with fission we want to create a
   // minimal display port for every scroll frame that could be active. (We only
   // do this when aSetBase is true because we only want to do this the first
   // time this function is called for the same scroll frame.)
   if (ShouldActivateAllScrollFrames() &&
       !DisplayPortUtils::HasDisplayPort(content) &&
       nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && WantAsyncScroll() &&
@@ -4462,23 +4459,16 @@ bool ScrollFrameHelper::DecideScrollable
   // for some scroll frames.
   // When a displayport is being used, force building of a layer so that
   // the compositor can find the scrollable layer for async scrolling.
   // If the element is marked 'scrollgrab', also force building of a layer
   // so that APZ can implement scroll grabbing.
   mWillBuildScrollableLayer = usingDisplayPort ||
                               nsContentUtils::HasScrollgrab(content) ||
                               mZoomableByAPZ;
-
-  // The cached animated geometry root for the display builder is out of
-  // date if we just introduced a new animated geometry root.
-  if (oldWillBuildScrollableLayer != mWillBuildScrollableLayer) {
-    aBuilder->RecomputeCurrentAnimatedGeometryRoot();
-  }
-
   return mWillBuildScrollableLayer;
 }
 
 void ScrollFrameHelper::NotifyApzTransaction() {
   mAllowScrollOriginDowngrade = true;
   mApzScrollPos = GetScrollPosition();
   mApzAnimationRequested = IsLastScrollUpdateAnimating();
   mScrollUpdates.Clear();
--- a/layout/painting/RetainedDisplayListBuilder.cpp
+++ b/layout/painting/RetainedDisplayListBuilder.cpp
@@ -1169,19 +1169,17 @@ bool RetainedDisplayListBuilder::Process
   }
 
   if (aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP)) {
     return true;
   }
 
   // TODO: There is almost certainly a faster way of doing this, probably can be
   // combined with the ancestor walk for TransformFrameRectToAncestor.
-  AnimatedGeometryRoot* agr =
-      aBuilder->FindAnimatedGeometryRootFor(aFrame)->GetAsyncAGR();
-  nsIFrame* agrFrame = agr ? agr->mFrame : nullptr;
+  nsIFrame* agrFrame = aBuilder->FindAnimatedGeometryRootFrameFor(aFrame);
 
   CRR_LOG("Processing frame %p with agr %p\n", aFrame, agr->mFrame);
 
   // Convert the frame's overflow rect into the coordinate space
   // of the nearest stacking context that has an existing display item.
   // We store that as a dirty rect on that stacking context so that we build
   // all items that intersect the changed frame within the stacking context,
   // and then we use MarkFrameForDisplayIfVisible to make sure the stacking
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -614,21 +614,17 @@ nsDisplayListBuilder::nsDisplayListBuild
                                            bool aBuildCaret,
                                            bool aRetainingDisplayList)
     : mReferenceFrame(aReferenceFrame),
       mIgnoreScrollFrame(nullptr),
       mCurrentActiveScrolledRoot(nullptr),
       mCurrentContainerASR(nullptr),
       mCurrentFrame(aReferenceFrame),
       mCurrentReferenceFrame(aReferenceFrame),
-      mRootAGR(AnimatedGeometryRoot::CreateAGRForFrame(
-          aReferenceFrame, nullptr, true, aRetainingDisplayList)),
-      mCurrentAGR(mRootAGR),
       mBuildingExtraPagesForPageNum(0),
-      mUsedAGRBudget(0),
       mDirtyRect(-1, -1, -1, -1),
       mGlassDisplayItem(nullptr),
       mHasGlassItemDuringPartial(false),
       mCaretFrame(nullptr),
       mScrollInfoItemsForHoisting(nullptr),
       mFirstClipChainToDestroy(nullptr),
       mMode(aMode),
       mTableBackgroundSet(nullptr),
@@ -703,19 +699,16 @@ static PresShell* GetFocusedPresShell() 
     return nullptr;
   }
 
   return focusedDocShell->GetPresShell();
 }
 
 void nsDisplayListBuilder::BeginFrame() {
   nsCSSRendering::BeginFrameTreesLocked();
-  mCurrentAGR = mRootAGR;
-  mFrameToAnimatedGeometryRootMap.InsertOrUpdate(mReferenceFrame,
-                                                 RefPtr{mRootAGR});
 
   mIsPaintingToWindow = false;
   mUseHighQualityScaling = false;
   mIgnoreSuppression = false;
   mInTransform = false;
   mInFilter = false;
   mSyncDecodeImages = false;
 
@@ -738,18 +731,16 @@ void nsDisplayListBuilder::BeginFrame() 
       mCaretFrame = nullptr;
     }
   }
 }
 
 void nsDisplayListBuilder::EndFrame() {
   NS_ASSERTION(!mInInvalidSubtree,
                "Someone forgot to cleanup mInInvalidSubtree!");
-  mFrameToAnimatedGeometryRootMap.Clear();
-  mAGRBudgetSet.Clear();
   mActiveScrolledRoots.Clear();
   mEffectsUpdates.Clear();
   FreeClipChains();
   FreeTemporaryItems();
   nsCSSRendering::EndFrameTreesLocked();
   mCaretFrame = nullptr;
 }
 
@@ -823,93 +814,16 @@ void nsDisplayListBuilder::SetGlassDispl
   }
 }
 
 bool nsDisplayListBuilder::NeedToForceTransparentSurfaceForItem(
     nsDisplayItem* aItem) {
   return aItem == mGlassDisplayItem;
 }
 
-AnimatedGeometryRoot* nsDisplayListBuilder::WrapAGRForFrame(
-    nsIFrame* aAnimatedGeometryRoot, bool aIsAsync,
-    AnimatedGeometryRoot* aParent /* = nullptr */) {
-  DebugOnly<bool> dummy;
-  MOZ_ASSERT(IsAnimatedGeometryRoot(aAnimatedGeometryRoot, dummy) == AGR_YES);
-
-  RefPtr<AnimatedGeometryRoot> result =
-      mFrameToAnimatedGeometryRootMap.Get(aAnimatedGeometryRoot);
-  if (!result) {
-    MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDocInProcess(
-        RootReferenceFrame(), aAnimatedGeometryRoot));
-    RefPtr<AnimatedGeometryRoot> parent = aParent;
-    if (!parent) {
-      nsIFrame* parentFrame =
-          nsLayoutUtils::GetCrossDocParentFrameInProcess(aAnimatedGeometryRoot);
-      if (parentFrame) {
-        bool isAsync;
-        nsIFrame* parentAGRFrame =
-            FindAnimatedGeometryRootFrameFor(parentFrame, isAsync);
-        parent = WrapAGRForFrame(parentAGRFrame, isAsync);
-      }
-    }
-    result = AnimatedGeometryRoot::CreateAGRForFrame(
-        aAnimatedGeometryRoot, parent, aIsAsync, IsRetainingDisplayList());
-    mFrameToAnimatedGeometryRootMap.InsertOrUpdate(aAnimatedGeometryRoot,
-                                                   RefPtr{result});
-  }
-  MOZ_ASSERT(!aParent || result->mParentAGR == aParent);
-  return result;
-}
-
-AnimatedGeometryRoot* nsDisplayListBuilder::AnimatedGeometryRootForASR(
-    const ActiveScrolledRoot* aASR) {
-  if (!aASR) {
-    return GetRootAnimatedGeometryRoot();
-  }
-  nsIFrame* scrolledFrame = aASR->mScrollableFrame->GetScrolledFrame();
-  return FindAnimatedGeometryRootFor(scrolledFrame);
-}
-
-AnimatedGeometryRoot* nsDisplayListBuilder::FindAnimatedGeometryRootFor(
-    nsIFrame* aFrame) {
-  if (!IsPaintingToWindow()) {
-    return mRootAGR;
-  }
-  if (aFrame == mCurrentFrame) {
-    return mCurrentAGR;
-  }
-
-  RefPtr<AnimatedGeometryRoot> result =
-      mFrameToAnimatedGeometryRootMap.Get(aFrame);
-  if (result) {
-    return result;
-  }
-
-  bool isAsync;
-  nsIFrame* agrFrame = FindAnimatedGeometryRootFrameFor(aFrame, isAsync);
-  result = WrapAGRForFrame(agrFrame, isAsync);
-  return result;
-}
-
-AnimatedGeometryRoot* nsDisplayListBuilder::FindAnimatedGeometryRootFor(
-    nsDisplayItem* aItem) {
-  if (aItem->ShouldFixToViewport(this)) {
-    // Make its active scrolled root be the active scrolled root of
-    // the enclosing viewport, since it shouldn't be scrolled by scrolled
-    // frames in its document. InvalidateFixedBackgroundFramesFromList in
-    // nsGfxScrollFrame will not repaint this item when scrolling occurs.
-    nsIFrame* viewportFrame = nsLayoutUtils::GetClosestFrameOfType(
-        aItem->Frame(), LayoutFrameType::Viewport, RootReferenceFrame());
-    if (viewportFrame) {
-      return FindAnimatedGeometryRootFor(viewportFrame);
-    }
-  }
-  return FindAnimatedGeometryRootFor(aItem->Frame());
-}
-
 void nsDisplayListBuilder::SetIsRelativeToLayoutViewport() {
   mIsRelativeToLayoutViewport = true;
   UpdateShouldBuildAsyncZoomContainer();
 }
 
 void nsDisplayListBuilder::UpdateShouldBuildAsyncZoomContainer() {
   const Document* document = mReferenceFrame->PresContext()->Document();
   mBuildAsyncZoomContainer = !mIsRelativeToLayoutViewport &&
@@ -1261,18 +1175,16 @@ void nsDisplayListBuilder::LeavePresShel
   if (!mPresShellStates.IsEmpty()) {
     nsPresContext* pc = CurrentPresContext();
     nsIDocShell* docShell = pc->GetDocShell();
     if (docShell) {
       docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
     }
     mIsInChromePresContext = pc->IsChrome();
   } else {
-    mCurrentAGR = mRootAGR;
-
     for (uint32_t i = 0; i < mFramesMarkedForDisplayIfVisible.Length(); ++i) {
       UnmarkFrameForDisplayIfVisible(mFramesMarkedForDisplayIfVisible[i]);
     }
     mFramesMarkedForDisplayIfVisible.SetLength(0);
   }
 }
 
 void nsDisplayListBuilder::FreeClipChains() {
@@ -1609,147 +1521,75 @@ static bool IsStickyFrameActive(nsDispla
                                nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
   if (!sf) {
     return false;
   }
 
   return sf->IsScrollingActive();
 }
 
-nsDisplayListBuilder::AGRState nsDisplayListBuilder::IsAnimatedGeometryRoot(
-    nsIFrame* aFrame, bool& aIsAsync, nsIFrame** aParent) {
-  // We can return once we know that this frame is an AGR, and we're either
-  // async, or sure that none of the later conditions might make us async.
-  // The exception to this is when IsPaintingToWindow() == false.
-  aIsAsync = false;
+bool nsDisplayListBuilder::IsAnimatedGeometryRoot(nsIFrame* aFrame,
+                                                  nsIFrame** aParent) {
   if (aFrame == mReferenceFrame) {
-    aIsAsync = true;
-    return AGR_YES;
+    return true;
   }
 
   if (!IsPaintingToWindow()) {
     if (aParent) {
       *aParent = nsLayoutUtils::GetCrossDocParentFrameInProcess(aFrame);
     }
-    return AGR_NO;
+    return false;
   }
 
   nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrameInProcess(aFrame);
   if (!parent) {
-    aIsAsync = true;
-    return AGR_YES;
-  }
+    return true;
+  }
+  *aParent = parent;
 
   if (aFrame->StyleDisplay()->mPosition == StylePositionProperty::Sticky &&
       IsStickyFrameActive(this, aFrame, parent)) {
-    aIsAsync = true;
-    return AGR_YES;
+    return true;
   }
 
   if (aFrame->IsTransformed()) {
-    aIsAsync = EffectCompositor::HasAnimationsForCompositor(
-        aFrame, DisplayItemType::TYPE_TRANSFORM);
-    return AGR_YES;
+    if (EffectCompositor::HasAnimationsForCompositor(
+            aFrame, DisplayItemType::TYPE_TRANSFORM)) {
+      return true;
+    }
   }
 
   LayoutFrameType parentType = parent->Type();
   if (parentType == LayoutFrameType::Scroll ||
       parentType == LayoutFrameType::ListControl) {
     nsIScrollableFrame* sf = do_QueryFrame(parent);
     if (sf->GetScrolledFrame() == aFrame && sf->IsScrollingActive()) {
       MOZ_ASSERT(!aFrame->IsTransformed());
-      aIsAsync = sf->IsMaybeAsynchronouslyScrolled();
-      return AGR_YES;
-    }
-  }
-
-  // Treat the slider thumb as being as an active scrolled root when it wants
-  // its own layer so that it can move without repainting.
-  if (parentType == LayoutFrameType::Slider) {
-    auto* sf = static_cast<nsSliderFrame*>(parent)->GetScrollFrame();
-    if (sf && sf->IsScrollingActive()) {
-      return AGR_YES;
-    }
-  }
-
-  if (nsLayoutUtils::IsPopup(aFrame)) {
-    return AGR_YES;
-  }
-
-  if (ActiveLayerTracker::IsOffsetStyleAnimated(aFrame)) {
-    const bool inBudget = AddToAGRBudget(aFrame);
-    if (inBudget) {
-      return AGR_YES;
-    }
-  }
-
-  if (!aFrame->GetParent() &&
-      DisplayPortUtils::ViewportHasDisplayPort(aFrame->PresContext())) {
-    // Viewport frames in a display port need to be animated geometry roots
-    // for background-attachment:fixed elements.
-    return AGR_YES;
-  }
-
-  // Fixed-pos frames are parented by the viewport frame, which has no parent.
-  if (DisplayPortUtils::IsFixedPosFrameInDisplayPort(aFrame)) {
-    return AGR_YES;
-  }
-
-  if (aParent) {
-    *aParent = parent;
-  }
-
-  return AGR_NO;
+      return sf->IsMaybeAsynchronouslyScrolled();
+    }
+  }
+
+  return false;
 }
 
 nsIFrame* nsDisplayListBuilder::FindAnimatedGeometryRootFrameFor(
-    nsIFrame* aFrame, bool& aIsAsync) {
+    nsIFrame* aFrame) {
   MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDocInProcess(
       RootReferenceFrame(), aFrame));
   nsIFrame* cursor = aFrame;
   while (cursor != RootReferenceFrame()) {
     nsIFrame* next;
-    if (IsAnimatedGeometryRoot(cursor, aIsAsync, &next) == AGR_YES) {
+    if (IsAnimatedGeometryRoot(cursor, &next)) {
       return cursor;
     }
     cursor = next;
   }
-  // Root frame is always an async agr.
-  aIsAsync = true;
   return cursor;
 }
 
-void nsDisplayListBuilder::RecomputeCurrentAnimatedGeometryRoot() {
-  bool isAsync;
-  if (*mCurrentAGR != mCurrentFrame &&
-      IsAnimatedGeometryRoot(const_cast<nsIFrame*>(mCurrentFrame), isAsync) ==
-          AGR_YES) {
-    AnimatedGeometryRoot* oldAGR = mCurrentAGR;
-    mCurrentAGR = WrapAGRForFrame(const_cast<nsIFrame*>(mCurrentFrame), isAsync,
-                                  mCurrentAGR);
-
-    // Iterate the AGR cache and look for any objects that reference the old AGR
-    // and check to see if they need to be updated. AGRs can be in the cache
-    // multiple times, so we may end up doing the work multiple times for AGRs
-    // that don't change.
-    for (const RefPtr<AnimatedGeometryRoot>& cached :
-         mFrameToAnimatedGeometryRootMap.Values()) {
-      if (cached->mParentAGR == oldAGR && cached != mCurrentAGR) {
-        // It's possible that this cached AGR struct that has the old AGR as a
-        // parent should instead have mCurrentFrame has a parent.
-        nsIFrame* parent = FindAnimatedGeometryRootFrameFor(*cached, isAsync);
-        MOZ_ASSERT(parent == mCurrentFrame || parent == *oldAGR);
-        if (parent == mCurrentFrame) {
-          cached->mParentAGR = mCurrentAGR;
-        }
-      }
-    }
-  }
-}
-
 static nsRect ApplyAllClipNonRoundedIntersection(
     const DisplayItemClipChain* aClipChain, const nsRect& aRect) {
   nsRect result = aRect;
   while (aClipChain) {
     result = aClipChain->mClip.ApplyNonRoundedIntersection(result);
     aClipChain = aClipChain->mParent;
   }
   return result;
@@ -1871,17 +1711,16 @@ void nsDisplayTransform::AddSizeOfExclud
 
 void nsDisplayListBuilder::AddSizeOfExcludingThis(nsWindowSizes& aSizes) const {
   mPool.AddSizeOfExcludingThis(aSizes, Arena::ArenaKind::DisplayList);
 
   size_t n = 0;
   MallocSizeOf mallocSizeOf = aSizes.mState.mMallocSizeOf;
   n += mDocumentWillChangeBudgets.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mFrameWillChangeBudgets.ShallowSizeOfExcludingThis(mallocSizeOf);
-  n += mAGRBudgetSet.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mEffectsUpdates.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mWindowExcludeGlassRegion.SizeOfExcludingThis(mallocSizeOf);
   n += mRetainedWindowDraggingRegion.SizeOfExcludingThis(mallocSizeOf);
   n += mRetainedWindowNoDraggingRegion.SizeOfExcludingThis(mallocSizeOf);
   n += mRetainedWindowOpaqueRegion.SizeOfExcludingThis(mallocSizeOf);
   // XXX can't measure mClipDeduplicator since it uses std::unordered_set.
 
   aSizes.mLayoutRetainedDisplayListSize += n;
@@ -2066,50 +1905,16 @@ void nsDisplayListBuilder::RemoveFromWil
   }
 }
 
 void nsDisplayListBuilder::ClearWillChangeBudgets() {
   mFrameWillChangeBudgets.Clear();
   mDocumentWillChangeBudgets.Clear();
 }
 
-#ifdef MOZ_GFX_OPTIMIZE_MOBILE
-const float gAGRBudgetAreaMultiplier = 0.3;
-#else
-const float gAGRBudgetAreaMultiplier = 3.0;
-#endif
-
-bool nsDisplayListBuilder::AddToAGRBudget(nsIFrame* aFrame) {
-  if (mAGRBudgetSet.Contains(aFrame)) {
-    return true;
-  }
-
-  const nsPresContext* presContext =
-      aFrame->PresContext()->GetRootPresContext();
-  if (!presContext) {
-    return false;
-  }
-
-  const nsRect area = presContext->GetVisibleArea();
-  const uint32_t budgetLimit =
-      gAGRBudgetAreaMultiplier *
-      nsPresContext::AppUnitsToIntCSSPixels(area.width) *
-      nsPresContext::AppUnitsToIntCSSPixels(area.height);
-
-  const uint32_t cost = GetLayerizationCost(aFrame->GetSize());
-  const bool onBudget = mUsedAGRBudget + cost < budgetLimit;
-
-  if (onBudget) {
-    mUsedAGRBudget += cost;
-    mAGRBudgetSet.Insert(aFrame);
-  }
-
-  return onBudget;
-}
-
 void nsDisplayListBuilder::EnterSVGEffectsContents(
     nsIFrame* aEffectsFrame, nsDisplayList* aHoistedItemsStorage) {
   MOZ_ASSERT(aHoistedItemsStorage);
   if (mSVGEffectsFrames.IsEmpty()) {
     MOZ_ASSERT(!mScrollInfoItemsForHoisting);
     mScrollInfoItemsForHoisting = aHoistedItemsStorage;
   }
   mSVGEffectsFrames.AppendElement(aEffectsFrame);
@@ -2741,22 +2546,16 @@ nsDisplayItem::nsDisplayItem(nsDisplayLi
     : mFrame(aFrame), mActiveScrolledRoot(aActiveScrolledRoot) {
   MOZ_COUNT_CTOR(nsDisplayItem);
   MOZ_ASSERT(mFrame);
   if (aBuilder->IsRetainingDisplayList()) {
     mFrame->AddDisplayItem(this);
   }
 
   aBuilder->FindReferenceFrameFor(aFrame, &mToReferenceFrame);
-  // This can return the wrong result if the item override
-  // ShouldFixToViewport(), the item needs to set it again in its constructor.
-  mAnimatedGeometryRoot = aBuilder->FindAnimatedGeometryRootFor(aFrame);
-  MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDocInProcess(
-                 aBuilder->RootReferenceFrame(), *mAnimatedGeometryRoot),
-             "Bad");
   NS_ASSERTION(
       aBuilder->GetVisibleRect().width >= 0 || !aBuilder->IsForPainting(),
       "visible rect not set");
 
   mClipChain = aBuilder->ClipState().GetCurrentCombinedClipChain(aBuilder);
 
   // The visible rect is for mCurrentFrame, so we have to use
   // mCurrentOffsetToReferenceFrame
@@ -3075,19 +2874,16 @@ nsDisplayBackgroundImage::nsDisplayBackg
     // invalidate mFrame as needed.
     MOZ_ASSERT(mFrame->IsCanvasFrame() ||
                mFrame->IsFrameOfType(nsIFrame::eTablePart));
   }
 #endif
 
   mBounds = GetBoundsInternal(aInitData.builder, aFrameForBounds);
   if (mShouldFixToViewport) {
-    mAnimatedGeometryRoot =
-        aInitData.builder->FindAnimatedGeometryRootFor(this);
-
     // Expand the item's visible rect to cover the entire bounds, limited to the
     // viewport rect. This is necessary because the background's clip can move
     // asynchronously.
     if (Maybe<nsRect> viewportRect = GetViewportRectRelativeToReferenceFrame(
             aInitData.builder, mFrame)) {
       SetBuildingRect(mBounds.Intersect(*viewportRect));
     }
   }
@@ -5400,24 +5196,16 @@ nsDisplayOwnLayer::nsDisplayOwnLayer(
     bool aForceActive, bool aClearClipChain)
     : nsDisplayWrapList(aBuilder, aFrame, aList, aActiveScrolledRoot,
                         aClearClipChain),
       mFlags(aFlags),
       mScrollbarData(aScrollbarData),
       mForceActive(aForceActive),
       mWrAnimationId(0) {
   MOZ_COUNT_CTOR(nsDisplayOwnLayer);
-
-  // For scroll thumb layers, override the AGR to be the thumb's AGR rather
-  // than the AGR for mFrame (which is the slider frame).
-  if (IsScrollThumbLayer()) {
-    if (nsIFrame* thumbFrame = nsIFrame::GetChildXULBox(mFrame)) {
-      mAnimatedGeometryRoot = aBuilder->FindAnimatedGeometryRootFor(thumbFrame);
-    }
-  }
 }
 
 bool nsDisplayOwnLayer::IsScrollThumbLayer() const {
   return mScrollbarData.mScrollbarLayerType == ScrollbarLayerType::Thumb;
 }
 
 bool nsDisplayOwnLayer::IsScrollbarContainer() const {
   return mScrollbarData.mScrollbarLayerType == ScrollbarLayerType::Container;
@@ -5574,23 +5362,16 @@ nsDisplaySubDocument::nsDisplaySubDocume
                                            nsDisplayOwnLayerFlags aFlags)
     : nsDisplayOwnLayer(aBuilder, aFrame, aList,
                         aBuilder->CurrentActiveScrolledRoot(), aFlags),
       mScrollParentId(aBuilder->GetCurrentScrollParentId()),
       mShouldFlatten(false),
       mSubDocFrame(aSubDocFrame) {
   MOZ_COUNT_CTOR(nsDisplaySubDocument);
 
-  // The SubDocument display item is conceptually outside the viewport frame,
-  // so in cases where the viewport frame is an AGR, the SubDocument's AGR
-  // should be not the viewport frame itself, but its parent AGR.
-  if (*mAnimatedGeometryRoot == mFrame && mAnimatedGeometryRoot->mParentAGR) {
-    mAnimatedGeometryRoot = mAnimatedGeometryRoot->mParentAGR;
-  }
-
   if (mSubDocFrame && mSubDocFrame != mFrame) {
     mSubDocFrame->AddDisplayItem(this);
   }
 }
 
 nsDisplaySubDocument::~nsDisplaySubDocument() {
   MOZ_COUNT_DTOR(nsDisplaySubDocument);
   if (mSubDocFrame) {
@@ -5674,35 +5455,26 @@ nsDisplayFixedPosition* nsDisplayFixedPo
 nsDisplayFixedPosition::nsDisplayFixedPosition(
     nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList,
     const ActiveScrolledRoot* aActiveScrolledRoot,
     const ActiveScrolledRoot* aContainerASR)
     : nsDisplayOwnLayer(aBuilder, aFrame, aList, aActiveScrolledRoot),
       mContainerASR(aContainerASR),
       mIsFixedBackground(false) {
   MOZ_COUNT_CTOR(nsDisplayFixedPosition);
-  Init(aBuilder);
 }
 
 nsDisplayFixedPosition::nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder,
                                                nsIFrame* aFrame,
                                                nsDisplayList* aList)
     : nsDisplayOwnLayer(aBuilder, aFrame, aList,
                         aBuilder->CurrentActiveScrolledRoot()),
       mContainerASR(nullptr),  // XXX maybe this should be something?
       mIsFixedBackground(true) {
   MOZ_COUNT_CTOR(nsDisplayFixedPosition);
-  Init(aBuilder);
-}
-
-void nsDisplayFixedPosition::Init(nsDisplayListBuilder* aBuilder) {
-  mAnimatedGeometryRootForScrollMetadata = mAnimatedGeometryRoot;
-  if (ShouldFixToViewport(aBuilder)) {
-    mAnimatedGeometryRoot = aBuilder->FindAnimatedGeometryRootFor(this);
-  }
 }
 
 ScrollableLayerGuid::ViewID nsDisplayFixedPosition::GetScrollTargetId() {
   if (mContainerASR && !nsLayoutUtils::IsReallyFixedPos(mFrame)) {
     return mContainerASR->GetViewId();
   }
   return nsLayoutUtils::ScrollIdForRootScrollFrame(mFrame->PresContext());
 }
@@ -6230,51 +6002,45 @@ static_assert(sizeof(nsDisplayTransform)
               "nsDisplayTransform has grown");
 #endif
 
 nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
                                        nsIFrame* aFrame, nsDisplayList* aList,
                                        const nsRect& aChildrenBuildingRect)
     : nsPaintedDisplayItem(aBuilder, aFrame),
       mTransform(Some(Matrix4x4())),
-      mAnimatedGeometryRootForChildren(mAnimatedGeometryRoot),
-      mAnimatedGeometryRootForScrollMetadata(mAnimatedGeometryRoot),
       mChildrenBuildingRect(aChildrenBuildingRect),
       mPrerenderDecision(PrerenderDecision::No),
       mIsTransformSeparator(true),
       mHasTransformGetter(false) {
   MOZ_COUNT_CTOR(nsDisplayTransform);
   MOZ_ASSERT(aFrame, "Must have a frame!");
   Init(aBuilder, aList);
 }
 
 nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
                                        nsIFrame* aFrame, nsDisplayList* aList,
                                        const nsRect& aChildrenBuildingRect,
                                        PrerenderDecision aPrerenderDecision)
     : nsPaintedDisplayItem(aBuilder, aFrame),
-      mAnimatedGeometryRootForChildren(mAnimatedGeometryRoot),
-      mAnimatedGeometryRootForScrollMetadata(mAnimatedGeometryRoot),
       mChildrenBuildingRect(aChildrenBuildingRect),
       mPrerenderDecision(aPrerenderDecision),
       mIsTransformSeparator(false),
       mHasTransformGetter(false) {
   MOZ_COUNT_CTOR(nsDisplayTransform);
   MOZ_ASSERT(aFrame, "Must have a frame!");
   SetReferenceFrameToAncestor(aBuilder);
   Init(aBuilder, aList);
 }
 
 nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
                                        nsIFrame* aFrame, nsDisplayList* aList,
                                        const nsRect& aChildrenBuildingRect,
                                        decltype(WithTransformGetter))
     : nsPaintedDisplayItem(aBuilder, aFrame),
-      mAnimatedGeometryRootForChildren(mAnimatedGeometryRoot),
-      mAnimatedGeometryRootForScrollMetadata(mAnimatedGeometryRoot),
       mChildrenBuildingRect(aChildrenBuildingRect),
       mPrerenderDecision(PrerenderDecision::No),
       mIsTransformSeparator(false),
       mHasTransformGetter(true) {
   MOZ_COUNT_CTOR(nsDisplayTransform);
   MOZ_ASSERT(aFrame, "Must have a frame!");
   MOZ_ASSERT(aFrame->GetTransformGetter());
   Init(aBuilder, aList);
@@ -6295,42 +6061,16 @@ void nsDisplayTransform::SetReferenceFra
   // have the additional offset applied? Should we instead just manually remove
   // the offset from our transform instead of this more general value?
   // Can we instead apply the additional offset to us and not our children, like
   // we do for all other offsets (and how reference frames are supposed to
   // work)?
   nsIFrame* outerFrame = nsLayoutUtils::GetCrossDocParentFrameInProcess(mFrame);
   const nsIFrame* referenceFrame = aBuilder->FindReferenceFrameFor(outerFrame);
   mToReferenceFrame = mFrame->GetOffsetToCrossDoc(referenceFrame);
-
-  if (DisplayPortUtils::IsFixedPosFrameInDisplayPort(mFrame)) {
-    // This is an odd special case. If we are both IsFixedPosFrameInDisplayPort
-    // and transformed that we are our own AGR parent.
-    // We want our frame to be our AGR because FrameLayerBuilder uses our AGR to
-    // determine if we are inside a fixed pos subtree. If we use the outer AGR
-    // from outside the fixed pos subtree FLB can't tell that we are fixed pos.
-    mAnimatedGeometryRoot = mAnimatedGeometryRootForChildren;
-  } else if (mFrame->StyleDisplay()->mPosition ==
-                 StylePositionProperty::Sticky &&
-             IsStickyFrameActive(aBuilder, mFrame, nullptr)) {
-    // Similar to the IsFixedPosFrameInDisplayPort case we are our own AGR.
-    // We are inside the sticky position, so our AGR is the sticky positioned
-    // frame, which is our AGR, not the parent AGR.
-    mAnimatedGeometryRoot = mAnimatedGeometryRootForChildren;
-  } else if (mAnimatedGeometryRoot->mParentAGR) {
-    mAnimatedGeometryRootForScrollMetadata = mAnimatedGeometryRoot->mParentAGR;
-    if (!MayBeAnimated(aBuilder)) {
-      // If we're an animated transform then we want the same AGR as our
-      // children so that FrameLayerBuilder knows that this layer moves with the
-      // transform and won't compute occlusions. If we're not animated then use
-      // our parent AGR so that inactive transform layers can go in the same
-      // PaintedLayer as surrounding content.
-      mAnimatedGeometryRoot = mAnimatedGeometryRoot->mParentAGR;
-    }
-  }
 }
 
 void nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder,
                               nsDisplayList* aChildren) {
   mChildren.AppendToTop(aChildren);
   UpdateBounds(aBuilder);
 }
 
@@ -7589,18 +7329,16 @@ void nsDisplayTransform::WriteDebugInfo(
 
 nsDisplayPerspective::nsDisplayPerspective(nsDisplayListBuilder* aBuilder,
                                            nsIFrame* aFrame,
                                            nsDisplayList* aList)
     : nsPaintedDisplayItem(aBuilder, aFrame) {
   mList.AppendToTop(aList);
   MOZ_ASSERT(mList.Count() == 1);
   MOZ_ASSERT(mList.GetTop()->GetType() == DisplayItemType::TYPE_TRANSFORM);
-  mAnimatedGeometryRoot = aBuilder->FindAnimatedGeometryRootFor(
-      mFrame->GetClosestFlattenedTreeAncestorPrimaryFrame());
 }
 
 void nsDisplayPerspective::Paint(nsDisplayListBuilder* aBuilder,
                                  gfxContext* aCtx) {
   // Just directly recurse into children, since we'll include the persepctive
   // value in any nsDisplayTransform children.
   GetChildren()->Paint(aBuilder, aCtx,
                        mFrame->PresContext()->AppUnitsPerDevPixel());
@@ -8893,48 +8631,32 @@ nsDisplayListBuilder::AutoBuildingDispla
     const bool aIsTransformed)
     : mBuilder(aBuilder),
       mPrevFrame(aBuilder->mCurrentFrame),
       mPrevReferenceFrame(aBuilder->mCurrentReferenceFrame),
       mPrevOffset(aBuilder->mCurrentOffsetToReferenceFrame),
       mPrevAdditionalOffset(aBuilder->mAdditionalOffset),
       mPrevVisibleRect(aBuilder->mVisibleRect),
       mPrevDirtyRect(aBuilder->mDirtyRect),
-      mPrevAGR(aBuilder->mCurrentAGR),
       mPrevCompositorHitTestInfo(aBuilder->mCompositorHitTestInfo),
       mPrevAncestorHasApzAwareEventHandler(
           aBuilder->mAncestorHasApzAwareEventHandler),
       mPrevBuildingInvisibleItems(aBuilder->mBuildingInvisibleItems),
       mPrevInInvalidSubtree(aBuilder->mInInvalidSubtree) {
   if (aIsTransformed) {
     aBuilder->mCurrentOffsetToReferenceFrame =
         aBuilder->AdditionalOffset().refOr(nsPoint());
     aBuilder->mCurrentReferenceFrame = aForChild;
   } else if (aBuilder->mCurrentFrame == aForChild->GetParent()) {
     aBuilder->mCurrentOffsetToReferenceFrame += aForChild->GetPosition();
   } else {
     aBuilder->mCurrentReferenceFrame = aBuilder->FindReferenceFrameFor(
         aForChild, &aBuilder->mCurrentOffsetToReferenceFrame);
   }
 
-  bool isAsync;
-  mCurrentAGRState = aBuilder->IsAnimatedGeometryRoot(aForChild, isAsync);
-
-  if (aBuilder->mCurrentFrame == aForChild->GetParent()) {
-    if (mCurrentAGRState == AGR_YES) {
-      aBuilder->mCurrentAGR =
-          aBuilder->WrapAGRForFrame(aForChild, isAsync, aBuilder->mCurrentAGR);
-    }
-  } else if (aBuilder->mCurrentFrame != aForChild) {
-    aBuilder->mCurrentAGR = aBuilder->FindAnimatedGeometryRootFor(aForChild);
-  }
-
-  MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDocInProcess(
-      aBuilder->RootReferenceFrame(), *aBuilder->mCurrentAGR));
-
   // If aForChild is being visited from a frame other than it's ancestor frame,
   // mInInvalidSubtree will need to be recalculated the slow way.
   if (aForChild == mPrevFrame || GetAncestorFor(aForChild) == mPrevFrame) {
     aBuilder->mInInvalidSubtree =
         aBuilder->mInInvalidSubtree || aForChild->IsFrameModified();
   } else {
     aBuilder->mInInvalidSubtree = AnyContentAncestorModified(aForChild);
   }
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -148,107 +148,16 @@ enum class DisplayListArenaObjectId {
  * the subdocuments.
  *
  * Display item's coordinates are relative to their nearest reference frame
  * ancestor. Both the display root and any frame with a transform act as a
  * reference frame for their frame subtrees.
  */
 
 /**
- * Represents a frame that is considered to have (or will have) "animated
- * geometry" for itself and descendant frames.
- *
- * For example the scrolled frames of scrollframes which are actively being
- * scrolled fall into this category. Frames with certain CSS properties that are
- * being animated (e.g. 'left'/'top' etc) are also placed in this category.
- * Frames with different active geometry roots are in different PaintedLayers,
- * so that we can animate the geometry root by changing its transform (either on
- * the main thread or in the compositor).
- *
- * nsDisplayListBuilder constructs a tree of these (for fast traversals) and
- * assigns one for each display item.
- *
- * The animated geometry root for a display item is required to be a descendant
- * (or equal to) the item's ReferenceFrame(), which means that we will fall back
- * to returning aItem->ReferenceFrame() when we can't find another animated
- * geometry root.
- *
- * The animated geometry root isn't strongly defined for a frame as transforms
- * and background-attachment:fixed can cause it to vary between display items
- * for a given frame.
- */
-struct AnimatedGeometryRoot {
-  static already_AddRefed<AnimatedGeometryRoot> CreateAGRForFrame(
-      nsIFrame* aFrame, AnimatedGeometryRoot* aParent, bool aIsAsync,
-      bool aIsRetained) {
-    RefPtr<AnimatedGeometryRoot> result;
-    if (aIsRetained) {
-      result = aFrame->GetProperty(AnimatedGeometryRootCache());
-    }
-
-    if (result) {
-      result->mParentAGR = aParent;
-      result->mIsAsync = aIsAsync;
-    } else {
-      result = new AnimatedGeometryRoot(aFrame, aParent, aIsAsync, aIsRetained);
-    }
-    return result.forget();
-  }
-
-  operator nsIFrame*() { return mFrame; }
-
-  nsIFrame* operator->() const { return mFrame; }
-
-  AnimatedGeometryRoot* GetAsyncAGR() {
-    AnimatedGeometryRoot* agr = this;
-    while (!agr->mIsAsync && agr->mParentAGR) {
-      agr = agr->mParentAGR;
-    }
-    return agr;
-  }
-
-  NS_INLINE_DECL_REFCOUNTING(AnimatedGeometryRoot)
-
-  nsIFrame* mFrame;
-  RefPtr<AnimatedGeometryRoot> mParentAGR;
-  bool mIsAsync;
-  bool mIsRetained;
-
- protected:
-  static void DetachAGR(AnimatedGeometryRoot* aAGR) {
-    aAGR->mFrame = nullptr;
-    aAGR->mParentAGR = nullptr;
-    NS_RELEASE(aAGR);
-  }
-
-  NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(AnimatedGeometryRootCache,
-                                      AnimatedGeometryRoot, DetachAGR)
-
-  AnimatedGeometryRoot(nsIFrame* aFrame, AnimatedGeometryRoot* aParent,
-                       bool aIsAsync, bool aIsRetained)
-      : mFrame(aFrame),
-        mParentAGR(aParent),
-        mIsAsync(aIsAsync),
-        mIsRetained(aIsRetained) {
-    MOZ_ASSERT(mParentAGR || mIsAsync,
-               "The root AGR should always be treated as an async AGR.");
-    if (mIsRetained) {
-      NS_ADDREF(this);
-      aFrame->SetProperty(AnimatedGeometryRootCache(), this);
-    }
-  }
-
-  ~AnimatedGeometryRoot() {
-    if (mFrame && mIsRetained) {
-      mFrame->RemoveProperty(AnimatedGeometryRootCache());
-    }
-  }
-};
-
-/**
  * An active scrolled root (ASR) is similar to an animated geometry root (AGR).
  * The differences are:
  *  - ASRs are only created for async-scrollable scroll frames. This is a
  *    (hopefully) temporary restriction. In the future we will want to create
  *    ASRs for all the things that are currently creating AGRs, and then
  *    replace AGRs with ASRs and rename them from "active scrolled root" to
  *    "animated geometry root".
  *  - ASR objects are created during display list construction by the nsIFrames
@@ -390,23 +299,16 @@ class nsDisplayListBuilder {
     nsRect mAccumulatedRect;
     // How far this frame is from the root of the current 3d context.
     int mAccumulatedRectLevels;
     nsRect mVisibleRect;
     // Allow async animation for this 3D context.
     bool mAllowAsyncAnimation;
   };
 
-  /**
-   * A frame can be in one of three states of AGR.
-   * AGR_NO     means the frame is not an AGR for now.
-   * AGR_YES    means the frame is an AGR for now.
-   */
-  enum AGRState { AGR_NO, AGR_YES };
-
  public:
   using ViewID = layers::ScrollableLayerGuid::ViewID;
 
   /**
    * @param aReferenceFrame the frame at the root of the subtree; its origin
    * is the origin of the reference coordinate system for this display list
    * @param aMode encodes what the builder is being used for.
    * @param aBuildCaret whether or not we should include the caret in any
@@ -650,21 +552,16 @@ class nsDisplayListBuilder {
 
   const nsIFrame* GetCurrentFrame() { return mCurrentFrame; }
   const nsIFrame* GetCurrentReferenceFrame() { return mCurrentReferenceFrame; }
 
   const nsPoint& GetCurrentFrameOffsetToReferenceFrame() const {
     return mCurrentOffsetToReferenceFrame;
   }
 
-  AnimatedGeometryRoot* GetCurrentAnimatedGeometryRoot() { return mCurrentAGR; }
-  AnimatedGeometryRoot* GetRootAnimatedGeometryRoot() { return mRootAGR; }
-
-  void RecomputeCurrentAnimatedGeometryRoot();
-
   void Check() { mPool.Check(); }
 
   /**
    * Returns true if merging and flattening of display lists should be
    * performed while computing visibility.
    */
   bool AllowMergingAndFlattening() { return mAllowMergingAndFlattening; }
   void SetAllowMergingAndFlattening(bool aAllow) {
@@ -1073,47 +970,42 @@ class nsDisplayListBuilder {
 
     void SetAdditionalOffset(const nsPoint& aOffset) {
       MOZ_ASSERT(!mBuilder->mAdditionalOffset);
       mBuilder->mAdditionalOffset = Some(aOffset);
 
       mBuilder->mCurrentOffsetToReferenceFrame += aOffset;
     }
 
-    bool IsAnimatedGeometryRoot() const { return mCurrentAGRState == AGR_YES; }
-
     void RestoreBuildingInvisibleItemsValue() {
       mBuilder->mBuildingInvisibleItems = mPrevBuildingInvisibleItems;
     }
 
     ~AutoBuildingDisplayList() {
       mBuilder->mCurrentFrame = mPrevFrame;
       mBuilder->mCurrentReferenceFrame = mPrevReferenceFrame;
       mBuilder->mCurrentOffsetToReferenceFrame = mPrevOffset;
       mBuilder->mVisibleRect = mPrevVisibleRect;
       mBuilder->mDirtyRect = mPrevDirtyRect;
-      mBuilder->mCurrentAGR = mPrevAGR;
       mBuilder->mAncestorHasApzAwareEventHandler =
           mPrevAncestorHasApzAwareEventHandler;
       mBuilder->mBuildingInvisibleItems = mPrevBuildingInvisibleItems;
       mBuilder->mInInvalidSubtree = mPrevInInvalidSubtree;
       mBuilder->mAdditionalOffset = mPrevAdditionalOffset;
       mBuilder->mCompositorHitTestInfo = mPrevCompositorHitTestInfo;
     }
 
    private:
     nsDisplayListBuilder* mBuilder;
-    AGRState mCurrentAGRState;
     const nsIFrame* mPrevFrame;
     const nsIFrame* mPrevReferenceFrame;
     nsPoint mPrevOffset;
     Maybe<nsPoint> mPrevAdditionalOffset;
     nsRect mPrevVisibleRect;
     nsRect mPrevDirtyRect;
-    RefPtr<AnimatedGeometryRoot> mPrevAGR;
     gfx::CompositorHitTestInfo mPrevCompositorHitTestInfo;
     bool mPrevAncestorHasApzAwareEventHandler;
     bool mPrevBuildingInvisibleItems;
     bool mPrevInInvalidSubtree;
   };
 
   /**
    * A helper class to temporarily set the value of mInTransform.
@@ -1680,23 +1572,16 @@ class nsDisplayListBuilder {
 
   void SetBuildingExtraPagesForPageNum(uint8_t aPageNum) {
     mBuildingExtraPagesForPageNum = aPageNum;
   }
   uint8_t GetBuildingExtraPagesForPageNum() const {
     return mBuildingExtraPagesForPageNum;
   }
 
-  /**
-   * This is a convenience function to ease the transition until AGRs and ASRs
-   * are unified.
-   */
-  AnimatedGeometryRoot* AnimatedGeometryRootForASR(
-      const ActiveScrolledRoot* aASR);
-
   bool HitTestIsForVisibility() const { return mVisibleThreshold.isSome(); }
 
   float VisibilityThreshold() const {
     MOZ_DIAGNOSTIC_ASSERT(HitTestIsForVisibility());
     return mVisibleThreshold.valueOr(1.0f);
   }
 
   void SetHitTestIsForVisibility(float aVisibleThreshold) {
@@ -1785,58 +1670,35 @@ class nsDisplayListBuilder {
 
     void MaybeAppendLink(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame);
 
    private:
     nsDisplayListBuilder* mBuilderToReset = nullptr;
     nsDisplayList* mList;
   };
 
+  /**
+   * Returns the nearest ancestor frame to aFrame that is considered to have
+   * (or will have) animated geometry. This can return aFrame.
+   */
+  nsIFrame* FindAnimatedGeometryRootFrameFor(nsIFrame* aFrame);
+
  private:
   bool MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame, nsIFrame* aFrame,
                                     const nsRect& aVisibleRect,
                                     const nsRect& aDirtyRect);
 
+  friend class nsDisplayBackgroundImage;
+  friend struct RetainedDisplayListBuilder;
+
   /**
    * Returns whether a frame acts as an animated geometry root, optionally
    * returning the next ancestor to check.
    */
-  AGRState IsAnimatedGeometryRoot(nsIFrame* aFrame, bool& aIsAsync,
-                                  nsIFrame** aParent = nullptr);
-
-  /**
-   * Returns the nearest ancestor frame to aFrame that is considered to have
-   * (or will have) animated geometry. This can return aFrame.
-   */
-  nsIFrame* FindAnimatedGeometryRootFrameFor(nsIFrame* aFrame, bool& aIsAsync);
-
-  friend class nsDisplayCanvasBackgroundImage;
-  friend class nsDisplayBackgroundImage;
-  friend class nsDisplayFixedPosition;
-  friend class nsDisplayPerspective;
-  AnimatedGeometryRoot* FindAnimatedGeometryRootFor(nsDisplayItem* aItem);
-
-  friend class nsDisplayItem;
-  friend class nsDisplayOwnLayer;
-  friend struct RetainedDisplayListBuilder;
-  AnimatedGeometryRoot* FindAnimatedGeometryRootFor(nsIFrame* aFrame);
-
-  AnimatedGeometryRoot* WrapAGRForFrame(
-      nsIFrame* aAnimatedGeometryRoot, bool aIsAsync,
-      AnimatedGeometryRoot* aParent = nullptr);
-
-  nsTHashMap<nsIFrame*, RefPtr<AnimatedGeometryRoot>>
-      mFrameToAnimatedGeometryRootMap;
-
-  /**
-   * Add the current frame to the AGR budget if possible and remember
-   * the outcome. Subsequent calls will return the same value as
-   * returned here.
-   */
-  bool AddToAGRBudget(nsIFrame* aFrame);
+  bool IsAnimatedGeometryRoot(nsIFrame* aFrame, nsIFrame** aParent = nullptr);
 
   struct PresShellState {
     PresShell* mPresShell;
 #ifdef DEBUG
     Maybe<nsAutoLayoutPhase> mAutoLayoutPhase;
 #endif
     Maybe<OutOfFlowDisplayData> mFixedBackgroundDisplayData;
     uint32_t mFirstFrameMarkedForDisplay;
@@ -1890,36 +1752,28 @@ class nsDisplayListBuilder {
   const nsIFrame* mCurrentFrame;
   // The reference frame for mCurrentFrame.
   const nsIFrame* mCurrentReferenceFrame;
   // The offset from mCurrentFrame to mCurrentReferenceFrame.
   nsPoint mCurrentOffsetToReferenceFrame;
 
   Maybe<nsPoint> mAdditionalOffset;
 
-  RefPtr<AnimatedGeometryRoot> mRootAGR;
-  RefPtr<AnimatedGeometryRoot> mCurrentAGR;
-
   // will-change budget tracker
   typedef uint32_t DocumentWillChangeBudget;
   nsTHashMap<nsPtrHashKey<const nsPresContext>, DocumentWillChangeBudget>
       mDocumentWillChangeBudgets;
 
   // Any frame listed in this set is already counted in the budget
   // and thus is in-budget.
   nsTHashMap<nsPtrHashKey<const nsIFrame>, FrameWillChangeBudget>
       mFrameWillChangeBudgets;
 
   uint8_t mBuildingExtraPagesForPageNum;
 
-  // Area of animated geometry root budget already allocated
-  uint32_t mUsedAGRBudget;
-  // Set of frames already counted in budget
-  nsTHashSet<nsIFrame*> mAGRBudgetSet;
-
   nsTHashMap<nsPtrHashKey<dom::RemoteBrowser>, dom::EffectsInfo>
       mEffectsUpdates;
 
   // Relative to mCurrentFrame.
   nsRect mVisibleRect;
   nsRect mDirtyRect;
 
   // Tracked regions used for retained display list.
@@ -2378,17 +2232,16 @@ class nsDisplayItem : public nsDisplayIt
   nsDisplayItem(nsDisplayListBuilder* aBuilder, const nsDisplayItem& aOther)
       : mFrame(aOther.mFrame),
         mItemFlags(aOther.mItemFlags),
         mType(aOther.mType),
         mExtraPageForPageNum(aOther.mExtraPageForPageNum),
         mPerFrameIndex(aOther.mPerFrameIndex),
         mBuildingRect(aOther.mBuildingRect),
         mToReferenceFrame(aOther.mToReferenceFrame),
-        mAnimatedGeometryRoot(aOther.mAnimatedGeometryRoot),
         mActiveScrolledRoot(aOther.mActiveScrolledRoot),
         mClipChain(aOther.mClipChain) {
     MOZ_COUNT_CTOR(nsDisplayItem);
     // TODO: It might be better to remove the flags that aren't copied.
     if (aOther.ForceNotVisible()) {
       mItemFlags += ItemFlag::ForceNotVisible;
     }
     if (mFrame->In3DContextAndBackfaceIsHidden()) {
@@ -2796,27 +2649,16 @@ class nsDisplayItem : public nsDisplayIt
     return mToReferenceFrame;
   }
 
   /**
    * Returns the reference frame for display item children of this item.
    */
   virtual const nsIFrame* ReferenceFrameForChildren() const { return nullptr; }
 
-  AnimatedGeometryRoot* GetAnimatedGeometryRoot() const {
-    MOZ_ASSERT(mAnimatedGeometryRoot,
-               "Must have cached AGR before accessing it!");
-    return mAnimatedGeometryRoot;
-  }
-
-  virtual struct AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata()
-      const {
-    return GetAnimatedGeometryRoot();
-  }
-
   /**
    * Checks if this display item (or any children) contains content that might
    * be rendered with component alpha (e.g. subpixel antialiasing). Returns the
    * bounds of the area that needs component alpha, or an empty rect if nothing
    * in the item does.
    */
   virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) const {
     return nsRect();
@@ -2939,17 +2781,16 @@ class nsDisplayItem : public nsDisplayIt
     }
   }
 
   void SetHasHitTestInfo() { mItemFlags += ItemFlag::HasHitTestInfo; }
 
   // Result of ToReferenceFrame(mFrame), if mFrame is non-null
   nsPoint mToReferenceFrame;
 
-  RefPtr<AnimatedGeometryRoot> mAnimatedGeometryRoot;
   RefPtr<const ActiveScrolledRoot> mActiveScrolledRoot;
   RefPtr<const DisplayItemClipChain> mClipChain;
 
 #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
  public:
   bool IsMergedItem() const {
     return mItemFlags.contains(ItemFlag::MergedItem);
   }
@@ -5646,18 +5487,16 @@ class nsDisplayFixedPosition : public ns
  public:
   nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
                          nsDisplayList* aList,
                          const ActiveScrolledRoot* aActiveScrolledRoot,
                          const ActiveScrolledRoot* aContainerASR);
   nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder,
                          const nsDisplayFixedPosition& aOther)
       : nsDisplayOwnLayer(aBuilder, aOther),
-        mAnimatedGeometryRootForScrollMetadata(
-            aOther.mAnimatedGeometryRootForScrollMetadata),
         mContainerASR(aOther.mContainerASR),
         mIsFixedBackground(aOther.mIsFixedBackground) {
     MOZ_COUNT_CTOR(nsDisplayFixedPosition);
   }
 
   static nsDisplayFixedPosition* CreateForFixedBackground(
       nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
       nsIFrame* aSecondaryFrame, nsDisplayBackgroundImage* aImage,
@@ -5671,37 +5510,31 @@ class nsDisplayFixedPosition : public ns
     GetChildren()->Paint(aBuilder, aCtx,
                          mFrame->PresContext()->AppUnitsPerDevPixel());
   }
 
   bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) const override {
     return mIsFixedBackground;
   }
 
-  AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata() const override {
-    return mAnimatedGeometryRootForScrollMetadata;
-  }
-
   bool CreateWebRenderCommands(
       wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources,
       const StackingContextHelper& aSc,
       layers::RenderRootStateManager* aManager,
       nsDisplayListBuilder* aDisplayListBuilder) override;
   bool UpdateScrollData(layers::WebRenderScrollData* aData,
                         layers::WebRenderLayerScrollData* aLayerData) override;
   void WriteDebugInfo(std::stringstream& aStream) override;
 
  protected:
   // For background-attachment:fixed
   nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
                          nsDisplayList* aList);
-  void Init(nsDisplayListBuilder* aBuilder);
   ViewID GetScrollTargetId();
 
-  RefPtr<AnimatedGeometryRoot> mAnimatedGeometryRootForScrollMetadata;
   RefPtr<const ActiveScrolledRoot> mContainerASR;
   bool mIsFixedBackground;
 
  private:
   NS_DISPLAY_ALLOW_CLONING()
 };
 
 class nsDisplayTableFixedPosition : public nsDisplayFixedPosition {
@@ -6255,20 +6088,16 @@ class nsDisplayTransform : public nsPain
     // belong to a transformed frame, and aren't a reference frame
     // for our children.
     if (!mHasTransformGetter) {
       return mFrame;
     }
     return nsPaintedDisplayItem::ReferenceFrameForChildren();
   }
 
-  AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata() const override {
-    return mAnimatedGeometryRootForScrollMetadata;
-  }
-
   const nsRect& GetBuildingRectForChildren() const override {
     return mChildrenBuildingRect;
   }
 
   enum { INDEX_MAX = UINT32_MAX >> TYPE_BITS };
 
   /**
    * We include the perspective matrix from our containing block for the
@@ -6492,18 +6321,16 @@ class nsDisplayTransform : public nsPain
   using TransformPolygon = layers::BSPPolygon<nsDisplayTransform>;
   void CollectSorted3DTransformLeaves(nsDisplayListBuilder* aBuilder,
                                       nsTArray<TransformPolygon>& aLeaves);
 
   mutable Maybe<Matrix4x4Flagged> mTransform;
   mutable Maybe<Matrix4x4Flagged> mInverseTransform;
   // Accumulated transform of ancestors on the preserves-3d chain.
   UniquePtr<Matrix4x4> mTransformPreserves3D;
-  RefPtr<AnimatedGeometryRoot> mAnimatedGeometryRootForChildren;
-  RefPtr<AnimatedGeometryRoot> mAnimatedGeometryRootForScrollMetadata;
   nsRect mChildrenBuildingRect;
   mutable RetainedDisplayList mChildren;
 
   // The untransformed bounds of |mChildren|.
   nsRect mChildBounds;
   // The transformed bounds of this display item.
   nsRect mBounds;
   PrerenderDecision mPrerenderDecision : 8;