Backed out 2 changesets (bug 1547624) for causing crashes (bug 1348503). a=backout
authorJulien Cristau <jcristau@mozilla.com>
Wed, 12 Jun 2019 15:39:13 +0200
changeset 536866 34a9ba95e9085caa5dd46f7aa78b6a7c43897fcb
parent 536865 00a108b014dac0f3ee308bbc0a7cb097236ed79e
child 536867 458469ed6f7e96118c0dd7224ce01f9f1a5f22bb
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1547624, 1348503
milestone68.0
backs oute8341f537323e62da5a165e1fd914367ff0576ec
e2f092d47d0327d2bcd8bcb20fbc7a4de941a9f2
Backed out 2 changesets (bug 1547624) for causing crashes (bug 1348503). a=backout Backed out changeset e8341f537323 (bug 1547624) Backed out changeset e2f092d47d03 (bug 1547624)
layout/painting/FrameLayerBuilder.cpp
layout/painting/FrameLayerBuilder.h
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -563,18 +563,16 @@ class PaintedLayerData {
         mNewChildLayersIndex(-1)
 #ifdef DEBUG
         ,
         mTransformLevel(0)
 #endif
   {
   }
 
-  PaintedLayerData(PaintedLayerData&& aRhs) = default;
-
   ~PaintedLayerData() { MOZ_ASSERT(mTransformLevel == 0); }
 
 #ifdef MOZ_DUMP_PAINTING
   /**
    * Keep track of important decisions for debugging.
    */
   nsCString mLog;
 
@@ -605,20 +603,16 @@ class PaintedLayerData {
    */
   void Accumulate(ContainerState* aState, nsPaintedDisplayItem* aItem,
                   const nsIntRect& aVisibleRect, const nsRect& aContentRect,
                   const DisplayItemClip& aClip, LayerState aLayerState,
                   nsDisplayList* aList, DisplayItemEntryType aType,
                   nsTArray<size_t>& aOpacityIndices,
                   const RefPtr<TransformClipNode>& aTransform);
 
-  UniquePtr<InactiveLayerData> CreateInactiveLayerData(
-      ContainerState* aState, nsPaintedDisplayItem* aItem,
-      DisplayItemData* aData);
-
   /**
    * Updates the status of |mTransform| and |aOpacityIndices|, based on |aType|.
    */
   void UpdateEffectStatus(DisplayItemEntryType aType,
                           nsTArray<size_t>& aOpacityIndices);
 
   AnimatedGeometryRoot* GetAnimatedGeometryRoot() {
     return mAnimatedGeometryRoot;
@@ -631,18 +625,16 @@ class PaintedLayerData {
 
   /**
    * Add the given hit test info to the hit regions for this PaintedLayer.
    */
   void AccumulateHitTestItem(ContainerState* aState, nsDisplayItem* aItem,
                              const DisplayItemClip& aClip,
                              TransformClipNode* aTransform);
 
-  void HitRegionsUpdated();
-
   /**
    * If this represents only a nsDisplayImage, and the image type supports being
    * optimized to an ImageLayer, returns true.
    */
   bool CanOptimizeToImageLayer(nsDisplayListBuilder* aBuilder);
 
   /**
    * If this represents only a nsDisplayImage, and the image type supports being
@@ -655,21 +647,16 @@ class PaintedLayerData {
   bool VisibleAboveRegionIntersects(const nsIntRegion& aRegion) const {
     return !mVisibleAboveRegion.Intersect(aRegion).IsEmpty();
   }
   bool VisibleRegionIntersects(const nsIntRegion& aRegion) const {
     return !mVisibleRegion.Intersect(aRegion).IsEmpty();
   }
 
   /**
-   * The owning ContainerState that created this PaintedLayerData.
-   */
-  ContainerState* mState;
-
-  /**
    * The region of visible content in the layer, relative to the
    * container layer (which is at the snapped top-left of the display
    * list reference frame).
    */
   nsIntRegion mVisibleRegion;
   /**
    * The region of visible content in the layer that is opaque.
    * Same coordinate system as mVisibleRegion.
@@ -1312,17 +1299,16 @@ class ContainerState {
       return ScaleRegionToNearestPixels(aRegion);
     }
     return aRegion.ScaleToOutsidePixels(
         mParameters.mXScale, mParameters.mYScale, mAppUnitsPerDevPixel);
   }
 
   nsIFrame* GetContainerFrame() const { return mContainerFrame; }
   nsDisplayListBuilder* Builder() const { return mBuilder; }
-  FrameLayerBuilder* LayerBuilder() const { return mLayerBuilder; }
 
   /**
    * Check if we are currently inside an inactive layer.
    */
   bool IsInInactiveLayer() const {
     return mLayerBuilder->GetContainingPaintedLayerData();
   }
 
@@ -3469,17 +3455,17 @@ void ContainerState::FinishPaintedLayerD
                DisplayItemType::TYPE_COMPOSITOR_HITTEST_INFO);
 
     if (IsEffectEndMarker(item.mType)) {
       // Do not invalidate for end markers.
       continue;
     }
 
     InvalidateForLayerChange(item.mItem, data->mLayer, item.mDisplayItemData);
-    mLayerBuilder->AddPaintedDisplayItem(data, item, layer);
+    mLayerBuilder->AddPaintedDisplayItem(data, item, *this, layer);
     item.mDisplayItemData = nullptr;
   }
 
   if (mLayerBuilder->IsBuildingRetainedLayers()) {
     newLayerEntry->mVisibleRegion = data->mVisibleRegion;
     newLayerEntry->mOpaqueRegion = data->mOpaqueRegion;
     newLayerEntry->mHideAllLayersBelow = data->mHideAllLayersBelow;
     newLayerEntry->mOpaqueForAnimatedGeometryRootParent =
@@ -3626,17 +3612,16 @@ void ContainerState::FinishPaintedLayerD
         containingPaintedLayerData->mReferenceFrame,
         &containingPaintedLayerData->mVerticalPanRegion,
         &containingPaintedLayerData->mDispatchToContentHitRegion, &matrixCache,
         inactiveLayerClip);
     if (alreadyHadRegions) {
       containingPaintedLayerData->mDispatchToContentHitRegion.OrWith(
           containingPaintedLayerData->CombinedTouchActionRegion());
     }
-    containingPaintedLayerData->HitRegionsUpdated();
   } else {
     EventRegions regions(
         ScaleRegionToOutsidePixels(data->mHitRegion),
         ScaleRegionToOutsidePixels(data->mMaybeHitRegion),
         ScaleRegionToOutsidePixels(data->mDispatchToContentHitRegion),
         ScaleRegionToOutsidePixels(data->mNoActionRegion),
         ScaleRegionToOutsidePixels(data->mHorizontalPanRegion),
         ScaleRegionToOutsidePixels(data->mVerticalPanRegion),
@@ -3736,44 +3721,16 @@ bool PaintedLayerData::SetupComponentAlp
       aItem->DisableComponentAlpha();
       return false;
     }
   }
 
   return true;
 }
 
-UniquePtr<InactiveLayerData> PaintedLayerData::CreateInactiveLayerData(
-    ContainerState* aState, nsPaintedDisplayItem* aItem,
-    DisplayItemData* aData) {
-  RefPtr<BasicLayerManager> tempManager;
-  if (aData) {
-    tempManager = aData->InactiveManager();
-  }
-  if (!tempManager) {
-    tempManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
-  }
-  UniquePtr<InactiveLayerData> data = MakeUnique<InactiveLayerData>();
-  data->mLayerManager = tempManager;
-
-  data->mLayerBuilder = new FrameLayerBuilder();
-  data->mLayerBuilder->Init(aState->Builder(), tempManager, this, true,
-                            &aItem->GetClip());
-
-  tempManager->BeginTransaction();
-  if (aState->LayerBuilder()->GetRetainingLayerManager()) {
-    data->mLayerBuilder->DidBeginRetainedLayerTransaction(tempManager);
-  }
-
-  data->mProps = LayerProperties::CloneFrom(tempManager->GetRoot());
-  data->mLayer = aItem->BuildLayer(aState->Builder(), tempManager,
-                                   ContainerLayerParameters());
-  return data;
-}
-
 void PaintedLayerData::Accumulate(
     ContainerState* aState, nsPaintedDisplayItem* aItem,
     const nsIntRect& aVisibleRect, const nsRect& aContentRect,
     const DisplayItemClip& aClip, LayerState aLayerState, nsDisplayList* aList,
     DisplayItemEntryType aType, nsTArray<size_t>& aOpacityIndices,
     const RefPtr<TransformClipNode>& aTransform) {
   // If aItem is nullptr, the cast to nsPaintedDisplayItem failed.
   MOZ_ASSERT(aItem, "Can only accumulate display items that are painted!");
@@ -3806,23 +3763,16 @@ void PaintedLayerData::Accumulate(
 
   DisplayItemData* oldData = aState->mLayerBuilder->GetOldLayerForFrame(
       aItem->Frame(), aItem->GetPerFrameKey(), currentData,
       aItem->GetDisplayItemDataLayerManager());
 
   mAssignedDisplayItems.emplace_back(aItem, aLayerState, oldData, aContentRect,
                                      aType, hasOpacity, aTransform, isMerged);
 
-  if (aLayerState != LayerState::LAYER_NONE) {
-    FLB_LOG_PAINTED_LAYER_DECISION(this, "Creating nested FLB for item %p\n",
-                                   aItem);
-    mAssignedDisplayItems.back().mInactiveLayerData =
-        CreateInactiveLayerData(aState, aItem, oldData);
-  }
-
   if (aState->mBuilder->NeedToForceTransparentSurfaceForItem(aItem)) {
     mForceTransparentSurface = true;
   }
 
   if (aState->mParameters.mDisableSubpixelAntialiasingInDescendants) {
     // Disable component alpha.
     // Note that the transform (if any) on the PaintedLayer is always an integer
     // translation so we don't have to factor that in here.
@@ -4092,33 +4042,28 @@ void PaintedLayerData::AccumulateHitTest
     }
   }
 
   // Avoid quadratic performance as a result of the region growing to include
   // and arbitrarily large number of rects, which can happen on some pages.
   mMaybeHitRegion.SimplifyOutward(8);
   mDispatchToContentHitRegion.SimplifyOutward(8);
 
-  HitRegionsUpdated();
-}
-
-void PaintedLayerData::HitRegionsUpdated() {
   // Calculate scaled versions of the bounds of mHitRegion and mMaybeHitRegion
   // for quick access in FindPaintedLayerFor().
-  mScaledHitRegionBounds = mState->ScaleToOutsidePixels(mHitRegion.GetBounds());
+  mScaledHitRegionBounds = aState->ScaleToOutsidePixels(mHitRegion.GetBounds());
   mScaledMaybeHitRegionBounds =
-      mState->ScaleToOutsidePixels(mMaybeHitRegion.GetBounds());
+      aState->ScaleToOutsidePixels(mMaybeHitRegion.GetBounds());
 }
 
 void ContainerState::NewPaintedLayerData(
     PaintedLayerData* aData, AnimatedGeometryRoot* aAnimatedGeometryRoot,
     const ActiveScrolledRoot* aASR, const DisplayItemClipChain* aClipChain,
     const ActiveScrolledRoot* aScrollMetadataASR, const nsPoint& aTopLeft,
     const nsIFrame* aReferenceFrame, const bool aBackfaceHidden) {
-  aData->mState = this;
   aData->mAnimatedGeometryRoot = aAnimatedGeometryRoot;
   aData->mASR = aASR;
   aData->mClipChain = aClipChain;
   aData->mAnimatedGeometryRootOffset = aTopLeft;
   aData->mReferenceFrame = aReferenceFrame;
   aData->mBackfaceHidden = aBackfaceHidden;
 
   aData->mNewChildLayersIndex = mNewChildLayers.Length();
@@ -5331,55 +5276,87 @@ void FrameLayerBuilder::ComputeGeometryC
                                   layerData->mTranslation);
   }
 
   aData->EndUpdate(geometry);
 }
 
 void FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
                                               AssignedDisplayItem& aItem,
+                                              ContainerState& aContainerState,
                                               Layer* aLayer) {
   PaintedLayer* layer = aLayerData->mLayer;
   PaintedDisplayItemLayerUserData* paintedData =
       static_cast<PaintedDisplayItemLayerUserData*>(
           layer->GetUserData(&gPaintedDisplayItemLayerUserData));
+  RefPtr<BasicLayerManager> tempManager;
+  nsIntRect intClip;
+  if (aItem.mLayerState != LayerState::LAYER_NONE) {
+    if (aItem.mDisplayItemData) {
+      tempManager = aItem.mDisplayItemData->mInactiveManager;
+
+      // We need to grab these before updating the DisplayItemData because it
+      // will overwrite them.
+      nsRegion clip;
+      if (aItem.mItem->GetClip().ComputeRegionInClips(
+              &aItem.mDisplayItemData->GetClip(),
+              aLayerData->mAnimatedGeometryRootOffset -
+                  paintedData->mLastAnimatedGeometryRootOrigin,
+              &clip)) {
+        intClip = clip.GetBounds().ScaleToOutsidePixels(
+            paintedData->mXScale, paintedData->mYScale,
+            paintedData->mAppUnitsPerDevPixel);
+      }
+    }
+    if (!tempManager) {
+      tempManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
+    }
+  }
 
   if (layer->Manager() == mRetainingManager) {
     DisplayItemData* data = aItem.mDisplayItemData;
     if (data && !data->mUsed) {
       data->BeginUpdate(layer, aItem.mLayerState, aItem.mItem, aItem.mReused,
                         aItem.mMerged);
     } else {
       if (data && data->mUsed) {
         // If the DID has already been used (by a previously merged frame,
         // which is not merged this paint) we must create a new DID for the
         // item.
         aItem.mItem->SetDisplayItemData(nullptr, nullptr);
       }
       data = StoreDataForFrame(aItem.mItem, layer, aItem.mLayerState, nullptr);
     }
-    data->mInactiveManager = aItem.mInactiveLayerData
-                                 ? aItem.mInactiveLayerData->mLayerManager
-                                 : nullptr;
+    data->mInactiveManager = tempManager;
     // We optimized this PaintedLayer into a ColorLayer/ImageLayer. Store the
     // optimized layer here.
     if (aLayer != layer) {
       data->mOptLayer = aLayer;
     }
 
     data->mOldTransform = data->mTransform;
     data->mTransform = aItem.mTransform;
   }
 
-  if (aItem.mInactiveLayerData) {
-    RefPtr<BasicLayerManager> tempManager =
-        aItem.mInactiveLayerData->mLayerManager;
-    FrameLayerBuilder* layerBuilder = aItem.mInactiveLayerData->mLayerBuilder;
-    Layer* tmpLayer = aItem.mInactiveLayerData->mLayer;
-
+  if (tempManager) {
+    FLB_LOG_PAINTED_LAYER_DECISION(
+        aLayerData, "Creating nested FLB for item %p\n", aItem.mItem);
+    FrameLayerBuilder* layerBuilder = new FrameLayerBuilder();
+    layerBuilder->Init(mDisplayListBuilder, tempManager, aLayerData, true,
+                       &aItem.mItem->GetClip());
+
+    tempManager->BeginTransaction();
+    if (mRetainingManager) {
+      layerBuilder->DidBeginRetainedLayerTransaction(tempManager);
+    }
+
+    UniquePtr<LayerProperties> props(
+        LayerProperties::CloneFrom(tempManager->GetRoot()));
+    RefPtr<Layer> tmpLayer = aItem.mItem->BuildLayer(
+        mDisplayListBuilder, tempManager, ContainerLayerParameters());
     // We have no easy way of detecting if this transaction will ever actually
     // get finished. For now, I've just silenced the warning with nested
     // transactions in BasicLayers.cpp
     if (!tmpLayer) {
       tempManager->EndTransaction(nullptr, nullptr);
       tempManager->SetUserData(&gLayerManagerLayerBuilder, nullptr);
       aItem.mItem = nullptr;
       return;
@@ -5433,22 +5410,21 @@ void FrameLayerBuilder::AddPaintedDispla
       tempManager->Dump(stream, "", gfxEnv::DumpPaintToFile());
       fprint_stderr(
           gfxUtils::sDumpPaintFile,
           stream);  // not a typo, fprint_stderr declared in LayersLogging.h
     }
 
     nsIntPoint offset =
         GetLastPaintOffset(layer) - GetTranslationForPaintedLayer(layer);
-    aItem.mInactiveLayerData->mProps->MoveBy(-offset);
+    props->MoveBy(-offset);
     // Effective transforms are needed by ComputeDifferences().
     tmpLayer->ComputeEffectiveTransforms(Matrix4x4());
     nsIntRegion invalid;
-    if (!aItem.mInactiveLayerData->mProps->ComputeDifferences(tmpLayer, invalid,
-                                                              nullptr)) {
+    if (!props->ComputeDifferences(tmpLayer, invalid, nullptr)) {
       nsRect visible = aItem.mItem->Frame()->GetVisualOverflowRect();
       invalid = visible.ToOutsidePixels(paintedData->mAppUnitsPerDevPixel);
     }
     if (aItem.mLayerState == LayerState::LAYER_SVG_EFFECTS) {
       invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(
           aItem.mItem->Frame(), aItem.mItem->ToReferenceFrame(), invalid);
     }
     if (!invalid.IsEmpty()) {
@@ -5467,16 +5443,17 @@ void FrameLayerBuilder::AddPaintedDispla
       }
 
       invalid.ScaleRoundOut(paintedData->mXScale, paintedData->mYScale);
 
       InvalidatePostTransformRegion(layer, invalid,
                                     GetTranslationForPaintedLayer(layer));
     }
   }
+  aItem.mInactiveLayerManager = tempManager;
 }
 
 DisplayItemData* FrameLayerBuilder::StoreDataForFrame(
     nsPaintedDisplayItem* aItem, Layer* aLayer, LayerState aState,
     DisplayItemData* aData) {
   MOZ_ASSERT(aItem);
 
   if (aData) {
@@ -5529,19 +5506,19 @@ AssignedDisplayItem::AssignedDisplayItem
       mContentRect(aContentRect),
       mLayerState(aLayerState),
       mType(aType),
       mReused(aItem->IsReused()),
       mMerged(aIsMerged),
       mHasOpacity(aHasOpacity),
       mHasPaintRect(aItem->HasPaintRect()) {}
 
-InactiveLayerData::~InactiveLayerData() {
-  if (mLayerManager) {
-    mLayerManager->SetUserData(&gLayerManagerLayerBuilder, nullptr);
+AssignedDisplayItem::~AssignedDisplayItem() {
+  if (mInactiveLayerManager) {
+    mInactiveLayerManager->SetUserData(&gLayerManagerLayerBuilder, nullptr);
   }
 }
 
 nsIntPoint FrameLayerBuilder::GetLastPaintOffset(PaintedLayer* aLayer) {
   PaintedDisplayItemLayerUserData* layerData =
       GetPaintedDisplayItemLayerUserData(aLayer);
   MOZ_ASSERT(layerData);
   if (layerData->mHasExplicitLastPaintOffset) {
@@ -7026,17 +7003,17 @@ void FrameLayerBuilder::PaintItems(std::
     if (cdi.mType != DisplayItemEntryType::Item) {
 #ifdef DEBUG
       UpdateEffectTracking(opacityLevel, transformLevel, cdi.mType);
 #endif
       // Nothing more to do with effect markers.
       continue;
     }
 
-    const bool paintAsLayer = cdi.mInactiveLayerData.get();
+    const bool paintAsLayer = cdi.mInactiveLayerManager;
     nsPaintedDisplayItem* paintedItem = item->AsPaintedDisplayItem();
     MOZ_ASSERT(paintAsLayer || paintedItem,
                "The display item does not support painting");
 
     const DisplayItemClip* itemClip = GetItemClip(item, temporaryClip);
     bool itemPaintsOwnClip = false;
 
     if (itemClip && !itemClipTracker.HasClip(itemClip)) {
@@ -7055,18 +7032,18 @@ void FrameLayerBuilder::PaintItems(std::
 
     if (!itemClip) {
       // Item does not need clipping, remove the clip if there is one.
       itemClipTracker.Restore();
     }
 
     if (paintAsLayer) {
       bool saved = aDrawTarget.GetPermitSubpixelAA();
-      PaintInactiveLayer(aBuilder, cdi.mInactiveLayerData->mLayerManager, item,
-                         aContext, aContext);
+      PaintInactiveLayer(aBuilder, cdi.mInactiveLayerManager, item, aContext,
+                         aContext);
       aDrawTarget.SetPermitSubpixelAA(saved);
       continue;
     }
 
     nsIFrame* frame = item->Frame();
     if (aBuilder->IsPaintingToWindow()) {
       frame->AddStateBits(NS_FRAME_PAINTED_THEBES);
     }
@@ -7284,37 +7261,26 @@ void FrameLayerBuilder::DumpRetainedLaye
   aManager->Dump(aStream, "", aDumpHtml);
 }
 
 nsDisplayItemGeometry* FrameLayerBuilder::GetMostRecentGeometry(
     nsDisplayItem* aItem) {
   typedef SmallPointerArray<DisplayItemData> DataArray;
 
   // Retrieve the array of DisplayItemData associated with our frame.
-  DataArray& dataArray = aItem->Frame()->DisplayItemData();
+  const DataArray& dataArray = aItem->Frame()->DisplayItemData();
 
   // Find our display item data, if it exists, and return its geometry.
-  // We first check for ones with an inactive manager, since items that
-  // create inactive layers will create two DisplayItemData entries,
-  // and we want the outer one.
-  DisplayItemData* firstMatching = nullptr;
   uint32_t itemPerFrameKey = aItem->GetPerFrameKey();
-  for (DisplayItemData* data : dataArray) {
-    DisplayItemData::AssertDisplayItemData(data);
+  for (uint32_t i = 0; i < dataArray.Length(); i++) {
+    DisplayItemData* data =
+        DisplayItemData::AssertDisplayItemData(dataArray.ElementAt(i));
     if (data->GetDisplayItemKey() == itemPerFrameKey) {
-      if (data->InactiveManager()) {
-        return data->GetGeometry();
-      }
-      if (!firstMatching) {
-        firstMatching = data;
-      }
-    }
-  }
-  if (firstMatching) {
-    return firstMatching->GetGeometry();
+      return data->GetGeometry();
+    }
   }
   if (RefPtr<WebRenderFallbackData> data =
           GetWebRenderUserData<WebRenderFallbackData>(aItem->Frame(),
                                                       itemPerFrameKey)) {
     return data->GetGeometry();
   }
 
   return nullptr;
--- a/layout/painting/FrameLayerBuilder.h
+++ b/layout/painting/FrameLayerBuilder.h
@@ -35,17 +35,16 @@ namespace mozilla {
 struct ActiveScrolledRoot;
 struct DisplayItemClipChain;
 namespace layers {
 class ContainerLayer;
 class LayerManager;
 class BasicLayerManager;
 class PaintedLayer;
 class ImageLayer;
-struct LayerProperties;
 }  // namespace layers
 
 class FrameLayerBuilder;
 class LayerManagerData;
 class PaintedLayerData;
 class ContainerState;
 class PaintedDisplayItemLayerUserData;
 
@@ -85,19 +84,16 @@ class DisplayItemData final {
   layers::Layer* GetLayer() const { return mLayer; }
   nsDisplayItemGeometry* GetGeometry() const { return mGeometry.get(); }
   const DisplayItemClip& GetClip() const { return mClip; }
   void Invalidate() { mIsInvalid = true; }
   void ClearAnimationCompositorState();
   void SetItem(nsPaintedDisplayItem* aItem) { mItem = aItem; }
   nsPaintedDisplayItem* GetItem() const { return mItem; }
   nsIFrame* FirstFrame() const { return mFrameList[0]; }
-  layers::BasicLayerManager* InactiveManager() const {
-    return mInactiveManager;
-  }
 
   bool HasMergedFrames() const { return mFrameList.Length() > 1; }
 
   static DisplayItemData* AssertDisplayItemData(DisplayItemData* aData);
 
   void* operator new(size_t sz, nsPresContext* aPresContext) {
     // Check the recycle list first.
     return aPresContext->PresShell()->AllocateByObjectID(
@@ -222,46 +218,37 @@ class RefCountedRegion {
  public:
   NS_INLINE_DECL_REFCOUNTING(RefCountedRegion)
 
   RefCountedRegion() : mIsInfinite(false) {}
   nsRegion mRegion;
   bool mIsInfinite;
 };
 
-struct InactiveLayerData {
-  RefPtr<layers::BasicLayerManager> mLayerManager;
-  FrameLayerBuilder* mLayerBuilder;
-  RefPtr<layers::Layer> mLayer;
-  UniquePtr<layers::LayerProperties> mProps;
-
-  ~InactiveLayerData();
-};
-
 struct AssignedDisplayItem {
   AssignedDisplayItem(nsPaintedDisplayItem* aItem, LayerState aLayerState,
                       DisplayItemData* aData, const nsRect& aContentRect,
                       DisplayItemEntryType aType, const bool aHasOpacity,
                       const RefPtr<TransformClipNode>& aTransform,
                       const bool aIsMerged);
-  AssignedDisplayItem(AssignedDisplayItem&& aRhs) = default;
+  ~AssignedDisplayItem();
 
   bool HasOpacity() const { return mHasOpacity; }
 
   bool HasTransform() const { return mTransform; }
 
   nsPaintedDisplayItem* mItem;
   DisplayItemData* mDisplayItemData;
 
   /**
    * If the display item is being rendered as an inactive
    * layer, then this stores the layer manager being
    * used for the inactive transaction.
    */
-  UniquePtr<InactiveLayerData> mInactiveLayerData;
+  RefPtr<layers::LayerManager> mInactiveLayerManager;
   RefPtr<TransformClipNode> mTransform;
 
   nsRect mContentRect;
   LayerState mLayerState;
   DisplayItemEntryType mType;
 
   bool mReused;
   bool mMerged;
@@ -551,17 +538,17 @@ class FrameLayerBuilder : public layers:
    * Record aItem as a display item that is rendered by the PaintedLayer
    * aLayer, with aClipRect, where aContainerLayerFrame is the frame
    * for the container layer this ThebesItem belongs to.
    * aItem must have an underlying frame.
    * @param aTopLeft offset from active scrolled root to reference frame
    */
   void AddPaintedDisplayItem(PaintedLayerData* aLayerData,
                              AssignedDisplayItem& aAssignedDisplayItem,
-                             Layer* aLayer);
+                             ContainerState& aContainerState, Layer* aLayer);
 
   /**
    * Calls GetOldLayerForFrame on the underlying frame of the display item,
    * and each subsequent merged frame if no layer is found for the underlying
    * frame.
    */
   Layer* GetOldLayerFor(nsDisplayItem* aItem,
                         nsDisplayItemGeometry** aOldGeometry = nullptr,