diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 3d4be54ee808..504e7adfb512 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2954,9 +2954,12 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, // layer (for async animations), see // nsSVGIntegrationsUtils::PaintMaskAndClipPath or // nsSVGIntegrationsUtils::PaintFilter. + // Use MayNeedActiveLayer to decide, since we don't want to condition the wrapping + // display item on values that might change silently between paints (opacity activity + // can depend on the will-change budget). bool useOpacity = HasVisualOpacity(effectSet) && !nsSVGUtils::CanOptimizeOpacity(this) && - (!usingSVGEffects || nsDisplayOpacity::NeedsActiveLayer(aBuilder, this)); + (!usingSVGEffects || nsDisplayOpacity::MayNeedActiveLayer(this)); bool useBlendMode = effects->mMixBlendMode != NS_STYLE_BLEND_NORMAL; bool useStickyPosition = disp->mPosition == NS_STYLE_POSITION_STICKY && IsScrollFrameActive(aBuilder, diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 4fe1ecda4ee0..25bd9a426bf1 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -6526,6 +6526,12 @@ nsDisplayOpacity::NeedsActiveLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFr return false; } +/* static */ bool +nsDisplayOpacity::MayNeedActiveLayer(nsIFrame* aFrame) +{ + return ActiveLayerTracker::IsStyleMaybeAnimated(aFrame, eCSSProperty_opacity); +} + void nsDisplayOpacity::ApplyOpacity(nsDisplayListBuilder* aBuilder, float aOpacity, diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 616e00b629b9..b27f14fc7d88 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -5386,6 +5386,7 @@ public: bool OpacityAppliedToChildren() const { return mOpacityAppliedToChildren; } static bool NeedsActiveLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame); + static bool MayNeedActiveLayer(nsIFrame* aFrame); NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY) virtual void WriteDebugInfo(std::stringstream& aStream) override;