Bug 1285619 - Introduce a ResetLayerStateForRecycling() helper function. r=mstange draft
authorBotond Ballo <botond@mozilla.com>
Fri, 08 Jul 2016 16:30:47 -0400
changeset 392636 ff9445f1d2593232b30d1ef643af5dd30c7e6375
parent 392445 251fccc1f62bf0eac569ef4f6717fea61ebadb27
child 392637 6ce3db9d7711a833b6385f531548f660fa6997ca
push id24066
push userbballo@mozilla.com
push dateMon, 25 Jul 2016 21:52:08 +0000
reviewersmstange
bugs1285619
milestone50.0a1
Bug 1285619 - Introduce a ResetLayerStateForRecycling() helper function. r=mstange MozReview-Commit-ID: DLktq4PYNba
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -2045,16 +2045,25 @@ FrameLayerBuilder::GetDebugSingleOldPain
       // More than one layer assigned, bail.
       return nullptr;
     }
     layer = data->mLayer;
   }
   return layer->AsPaintedLayer();
 }
 
+// Reset state that should not persist when a layer is recycled.
+static void
+ResetLayerStateForRecycling(Layer* aLayer) {
+  // Currently, this clears the mask layer and ancestor mask layers.
+  // Other cleanup may be added here.
+  aLayer->SetMaskLayer(nullptr);
+  aLayer->SetAncestorMaskLayers({});
+}
+
 already_AddRefed<ColorLayer>
 ContainerState::CreateOrRecycleColorLayer(PaintedLayer *aPainted)
 {
   PaintedDisplayItemLayerUserData* data =
       static_cast<PaintedDisplayItemLayerUserData*>(aPainted->GetUserData(&gPaintedDisplayItemLayerUserData));
   RefPtr<ColorLayer> layer = data->mColorLayer;
   if (layer) {
     layer->SetMaskLayer(nullptr);
@@ -2263,18 +2272,17 @@ ContainerState::CreatePaintedLayer(Paint
 
 PaintedDisplayItemLayerUserData*
 ContainerState::RecyclePaintedLayer(PaintedLayer* aLayer,
                                     AnimatedGeometryRoot* aAnimatedGeometryRoot,
                                     bool& didResetScrollPositionForLayerPixelAlignment)
 {
   // Clear clip rect and mask layer so we don't accidentally stay clipped.
   // We will reapply any necessary clipping.
-  aLayer->SetMaskLayer(nullptr);
-  aLayer->SetAncestorMaskLayers({});
+  ResetLayerStateForRecycling(aLayer);
   aLayer->ClearExtraDumpInfo();
 
   PaintedDisplayItemLayerUserData* data =
     static_cast<PaintedDisplayItemLayerUserData*>(
       aLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
   NS_ASSERTION(data, "Recycled PaintedLayers must have user data");
 
   // This gets called on recycled PaintedLayers that are going to be in the
@@ -5225,18 +5233,17 @@ FrameLayerBuilder::BuildContainerLayerFo
       if (oldLayer->HasUserData(&gPaintedDisplayItemLayerUserData)) {
         // The old layer for this item is actually our PaintedLayer
         // because we rendered its layer into that PaintedLayer. So we
         // don't actually have a retained container layer.
       } else {
         NS_ASSERTION(oldLayer->GetType() == Layer::TYPE_CONTAINER,
                      "Wrong layer type");
         containerLayer = static_cast<ContainerLayer*>(oldLayer);
-        containerLayer->SetMaskLayer(nullptr);
-        containerLayer->SetAncestorMaskLayers({});
+        ResetLayerStateForRecycling(containerLayer);
       }
     }
   }
   if (!containerLayer) {
     // No suitable existing layer was found.
     containerLayer = aManager->CreateContainerLayer();
     if (!containerLayer)
       return nullptr;