diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index ded6f7336754..2e6517c578b3 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2209,10 +2209,9 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder, if (isTransformed) { const nsRect overflow = GetVisualOverflowRectRelativeToSelf(); nsDisplayTransform::PrerenderDecision decision = - nsDisplayTransform::ShouldPrerenderTransformedContent(aBuilder, this); + nsDisplayTransform::ShouldPrerenderTransformedContent(aBuilder, this, &dirtyRect); switch (decision) { case nsDisplayTransform::FullPrerender: - dirtyRect = overflow; allowAsyncAnimation = true; break; case nsDisplayTransform::NoPrerender: diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index e442ecaa8f61..fa8150bcde64 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -6228,7 +6228,8 @@ nsDisplayTransform::CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) /* static */ auto nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder, - nsIFrame* aFrame) -> PrerenderDecision + nsIFrame* aFrame, + nsRect* aDirtyRect) -> PrerenderDecision { // Elements whose transform has been modified recently, or which // have a compositor-animated transform, can be prerendered. An element @@ -6251,13 +6252,14 @@ nsDisplayTransform::ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBui // for shadows, borders, etc. refSize += nsSize(refSize.width / 8, refSize.height / 8); gfxSize scale = nsLayoutUtils::GetTransformToAncestorScale(aFrame); - nsSize frameSize = nsSize( - aFrame->GetVisualOverflowRectRelativeToSelf().Size().width * scale.width, - aFrame->GetVisualOverflowRectRelativeToSelf().Size().height * scale.height); + nsRect overflow = aFrame->GetVisualOverflowRectRelativeToSelf(); + nsSize frameSize = nsSize(overflow.Size().width * scale.width, + overflow.Size().height * scale.height); nscoord maxInAppUnits = nscoord_MAX; if (frameSize <= refSize) { maxInAppUnits = aFrame->PresContext()->DevPixelsToAppUnits(4096); if (frameSize <= nsSize(maxInAppUnits, maxInAppUnits)) { + *aDirtyRect = overflow; return FullPrerender; } } diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index e37ceb3d3614..e283641654ad 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -4283,9 +4283,11 @@ public: /** * Return FullPrerender when we should try to prerender the entire contents of the * transformed frame even when it's not completely visible (yet). + * |aDirtyRect| is updated to the area that should be prerendered. */ static PrerenderDecision ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder, - nsIFrame* aFrame); + nsIFrame* aFrame, + nsRect* aDirtyRect); bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) override; bool MayBeAnimated(nsDisplayListBuilder* aBuilder);