Bug 1431778 - Take 3D transforms in to account when deciding whether content is small enough to be prerendered. r?mattwoodrow
MozReview-Commit-ID: 1eV04BMYy97
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8331,19 +8331,24 @@ nsDisplayTransform::ShouldPrerenderTrans
// Only prerender if the transformed frame's size is <= a multiple of the
// reference frame size (~viewport), and less than an absolute limit.
// Both the ratio and the absolute limit are configurable.
nsSize relativeLimit(nscoord(refSize.width * viewportRatioX),
nscoord(refSize.height * viewportRatioY));
nsSize absoluteLimit(aFrame->PresContext()->DevPixelsToAppUnits(absoluteLimitX),
aFrame->PresContext()->DevPixelsToAppUnits(absoluteLimitY));
nsSize maxSize = Min(relativeLimit, absoluteLimit);
- gfxSize scale = nsLayoutUtils::GetTransformToAncestorScale(aFrame);
- nsSize frameSize(overflow.Size().width * scale.width,
- overflow.Size().height * scale.height);
+
+ const auto transform = nsLayoutUtils::GetTransformToAncestor(aFrame,
+ nsLayoutUtils::GetDisplayRootFrame(aFrame));
+ const gfxRect transformedBounds = transform.TransformAndClipBounds(
+ gfxRect(overflow.x, overflow.y, overflow.width, overflow.height),
+ gfxRect::MaxIntRect());
+ const nsSize frameSize = nsSize(transformedBounds.width, transformedBounds.height);
+
uint64_t maxLimitArea = uint64_t(maxSize.width) * maxSize.height;
uint64_t frameArea = uint64_t(frameSize.width) * frameSize.height;
if (frameArea <= maxLimitArea && frameSize <= absoluteLimit) {
*aDirtyRect = overflow;
return FullPrerender;
} else if (gfxPrefs::PartiallyPrerenderAnimatedContent()) {
*aDirtyRect = nsLayoutUtils::ComputePartialPrerenderArea(*aDirtyRect, overflow, maxSize);
return PartialPrerender;