Bug 1285619 - Introduce a ResetLayerStateForRecycling() helper function. r=mstange
MozReview-Commit-ID: DLktq4PYNba
--- 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;