Bug 1431778 - Take 3D transforms in to account when deciding whether content is small enough to be prerendered. r?mattwoodrow draft
authorJamie Nicol <jnicol@mozilla.com>
Fri, 06 Apr 2018 18:34:13 +0100
changeset 781059 f402d00154279a246cd7419044095419f2a3f059
parent 781042 ee1d1bf1dc8a83eec16967ddb61dd5024c8d6058
push id106194
push userbmo:jnicol@mozilla.com
push dateThu, 12 Apr 2018 13:24:01 +0000
reviewersmattwoodrow
bugs1431778
milestone61.0a1
Bug 1431778 - Take 3D transforms in to account when deciding whether content is small enough to be prerendered. r?mattwoodrow MozReview-Commit-ID: 1eV04BMYy97
layout/painting/nsDisplayList.cpp
--- 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;