Bug 717521 - Limit pre-rendering to max 4096 x 4096 pixels (post-transform) to avoid hang. r=tnikkel
authorMats Palmgren <matspal@gmail.com>
Thu, 01 Mar 2012 13:34:20 +0100
changeset 88083 391ac2bb95bdb9c818e066720d14b668a17cca97
parent 88082 45d47d37a2b4994dae1610fba1c3dcc967bfc09c
child 88084 f50254fe891267904b58c4a38e95ad765fafc78c
push id22171
push usermak77@bonardo.net
push dateFri, 02 Mar 2012 13:56:30 +0000
treeherdermozilla-central@343ec916dfd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs717521
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 717521 - Limit pre-rendering to max 4096 x 4096 pixels (post-transform) to avoid hang. r=tnikkel
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -2597,17 +2597,24 @@ nsDisplayTransform::ShouldPrerenderTrans
                                                       nsIFrame* aFrame)
 {
   if (aFrame->AreLayersMarkedActive(nsChangeHint_UpdateTransformLayer)) {
     nsSize refSize = aBuilder->ReferenceFrame()->GetSize();
     // Only prerender if the transformed frame's size is <= the
     // reference frame size (~viewport), allowing a 1/8th fuzz factor
     // for shadows, borders, etc.
     refSize += nsSize(refSize.width / 8, refSize.height / 8);
-    return aFrame->GetVisualOverflowRectRelativeToSelf().Size() <= refSize;
+    if (aFrame->GetVisualOverflowRectRelativeToSelf().Size() <= refSize) {
+      // Bug 717521 - pre-render max 4096 x 4096 device pixels.
+      nscoord max = aFrame->PresContext()->DevPixelsToAppUnits(4096);
+      nsRect visual = aFrame->GetVisualOverflowRect();
+      if (visual.width <= max && visual.height <= max) {
+        return true;
+      }
+    }
   }
   return false;
 }
 
 /* If the matrix is singular, or a hidden backface is shown, the frame won't be visible or hit. */
 static bool IsFrameVisible(nsIFrame* aFrame, const gfx3DMatrix& aMatrix) 
 {
   if (aMatrix.IsSingular()) {