diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 87edf368cbd5..eada8c7e3220 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -4378,23 +4378,23 @@ nsDisplayOpacity::BuildLayer(nsDisplayListBuilder* aBuilder, * size --- but this should be good enough. */ static bool -IsItemTooSmallForActiveLayer(nsDisplayItem* aItem) +IsItemTooSmallForActiveLayer(nsIFrame* aFrame) { - nsIntRect visibleDevPixels = aItem->Frame()->GetVisualOverflowRectRelativeToSelf().ToOutsidePixels( - aItem->Frame()->PresContext()->AppUnitsPerDevPixel()); + nsIntRect visibleDevPixels = aFrame->GetVisualOverflowRectRelativeToSelf().ToOutsidePixels( + aFrame->PresContext()->AppUnitsPerDevPixel()); static const int MIN_ACTIVE_LAYER_SIZE_DEV_PIXELS = 16; return visibleDevPixels.Size() < nsIntSize(MIN_ACTIVE_LAYER_SIZE_DEV_PIXELS, MIN_ACTIVE_LAYER_SIZE_DEV_PIXELS); } static void -SetAnimationPerformanceWarningForTooSmallItem(nsDisplayItem* aItem, +SetAnimationPerformanceWarningForTooSmallItem(nsIFrame* aFrame, nsCSSProperty aProperty) { // We use ToNearestPixels() here since ToOutsidePixels causes some sort of // errors. See https://bugzilla.mozilla.org/show_bug.cgi?id=1258904#c19 - nsIntRect visibleDevPixels = aItem->Frame()->GetVisualOverflowRectRelativeToSelf().ToNearestPixels( - aItem->Frame()->PresContext()->AppUnitsPerDevPixel()); + nsIntRect visibleDevPixels = aFrame->GetVisualOverflowRectRelativeToSelf().ToNearestPixels( + aFrame->PresContext()->AppUnitsPerDevPixel()); // Set performance warning only if the visible dev pixels is not empty // because dev pixels is empty if the frame has 'preserve-3d' style. @@ -4402,23 +4402,23 @@ SetAnimationPerformanceWarningForTooSmallItem(nsDisplayItem* aItem, return; } - EffectCompositor::SetPerformanceWarning(aItem->Frame(), aProperty, + EffectCompositor::SetPerformanceWarning(aFrame, aProperty, AnimationPerformanceWarning( AnimationPerformanceWarning::Type::ContentTooSmall, { visibleDevPixels.Width(), visibleDevPixels.Height() })); } -bool -nsDisplayOpacity::NeedsActiveLayer(nsDisplayListBuilder* aBuilder) +/* static */ bool +nsDisplayOpacity::NeedsActiveLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) { - if (ActiveLayerTracker::IsStyleAnimated(aBuilder, mFrame, + if (ActiveLayerTracker::IsStyleAnimated(aBuilder, aFrame, eCSSProperty_opacity) || - EffectCompositor::HasAnimationsForCompositor(mFrame, + EffectCompositor::HasAnimationsForCompositor(aFrame, eCSSProperty_opacity)) { - if (!IsItemTooSmallForActiveLayer(this)) { + if (!IsItemTooSmallForActiveLayer(aFrame)) { return true; } - SetAnimationPerformanceWarningForTooSmallItem(this, eCSSProperty_opacity); + SetAnimationPerformanceWarningForTooSmallItem(aFrame, eCSSProperty_opacity); } return false; } @@ -4444,7 +4444,7 @@ nsDisplayOpacity::CanApplyOpacity() const bool nsDisplayOpacity::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { - if (NeedsActiveLayer(aBuilder) || mOpacity == 0.0) { + if (NeedsActiveLayer(aBuilder, mFrame) || mOpacity == 0.0) { // If our opacity is zero then we'll discard all descendant display items // except for layer event regions, so there's no point in doing this // optimization (and if we do do it, then invalidations of those descendants @@ -4506,7 +4506,7 @@ nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder, return LAYER_INACTIVE; } - if (NeedsActiveLayer(aBuilder)) { + if (NeedsActiveLayer(aBuilder, mFrame)) { // Returns LAYER_ACTIVE_FORCE to avoid flatterning the layer for async // animations. return LAYER_ACTIVE_FORCE; @@ -6021,10 +6021,10 @@ nsDisplayTransform::MayBeAnimated(nsDisplayListBuilder* aBuilder) eCSSProperty_transform) || EffectCompositor::HasAnimationsForCompositor(mFrame, eCSSProperty_transform)) { - if (!IsItemTooSmallForActiveLayer(this)) { + if (!IsItemTooSmallForActiveLayer(mFrame)) { return true; } - SetAnimationPerformanceWarningForTooSmallItem(this, eCSSProperty_transform); + SetAnimationPerformanceWarningForTooSmallItem(mFrame, eCSSProperty_transform); } return false; } diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index a28d9156105b..5a0ac67d41b8 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -3391,7 +3391,7 @@ public: const DisplayItemClip* aClip) override; virtual bool CanApplyOpacity() const override; virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override; - bool NeedsActiveLayer(nsDisplayListBuilder* aBuilder); + static bool NeedsActiveLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame); NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY) virtual void WriteDebugInfo(std::stringstream& aStream) override;