Bug 929021. Skip calling GetFrameBoundsForTransform when we don't need it. r=heycam
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 22 Oct 2013 11:09:46 +0200
changeset 166899 c1578a4fc86d3d85fd2166947d55c078cc72391e
parent 166898 44de05b3239bac97f65da0d68462baa2a0ed3042
child 166900 9ef91147d327f319c8faac92ffe2ea42ddd685b6
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs929021
milestone27.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 929021. Skip calling GetFrameBoundsForTransform when we don't need it. r=heycam
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -3917,18 +3917,25 @@ nsDisplayTransform::GetDeltaToTransformO
   NS_PRECONDITION(aFrame->IsTransformed(),
                   "Shouldn't get a delta for an untransformed frame!");
 
   /* For both of the coordinates, if the value of -moz-transform is a
    * percentage, it's relative to the size of the frame.  Otherwise, if it's
    * a distance, it's already computed for us!
    */
   const nsStyleDisplay* display = aFrame->StyleDisplay();
-  nsRect boundingRect = (aBoundsOverride ? *aBoundsOverride :
-                         nsDisplayTransform::GetFrameBoundsForTransform(aFrame));
+  nsRect boundingRect;
+  if (aBoundsOverride) {
+    boundingRect = *aBoundsOverride;
+  } else if (display->mTransformOrigin[0].GetUnit() != eStyleUnit_Coord ||
+             display->mTransformOrigin[1].GetUnit() != eStyleUnit_Coord) {
+    // GetFrameBoundsForTransform is expensive for SVG frames and we don't need
+    // it if the origin is coords (which it is by default for SVG).
+    boundingRect = nsDisplayTransform::GetFrameBoundsForTransform(aFrame);
+  }
 
   /* Allows us to access named variables by index. */
   float coords[2];
   nscoord boundingOffsets[2] = {boundingRect.x, boundingRect.y};
   nscoord boundingDimensions[2] = {boundingRect.width, boundingRect.height};
   nscoord frameOffsets[2] = {aFrame->GetPosition().x, aFrame->GetPosition().y};
 
   for (uint8_t index = 0; index < 2; ++index) {