Back out e69ad50ec0d7 (bug 647914) for causing regression bug 736031. a=akeybl
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 20 Mar 2012 14:05:35 -0700
changeset 91859 9fb6ba8e053511463e8d7beda2b909a67eaa5be9
parent 91858 a0497708403af47dad57ddb35f629aaa0e912659
child 91860 0984ec812496580bc92e913265c16ecbe3465dac
push idunknown
push userunknown
push dateunknown
reviewersakeybl
bugs647914, 736031
milestone13.0a2
backs oute69ad50ec0d77ab7d42d9edede5653a110a3f320
Back out e69ad50ec0d7 (bug 647914) for causing regression bug 736031. a=akeybl
content/svg/content/test/bbox-helper.svg
content/svg/content/test/test_bbox.xhtml
layout/svg/base/src/nsSVGContainerFrame.cpp
layout/svg/base/src/nsSVGMarkerFrame.cpp
--- a/content/svg/content/test/bbox-helper.svg
+++ b/content/svg/content/test/bbox-helper.svg
@@ -1,17 +1,9 @@
 <?xml version="1.0"?>
 <svg xmlns="http://www.w3.org/2000/svg">
   <g transform="scale(0.5)">
     <foreignObject id="fO" x="10" y="10" width="100" height="100"/>
   </g>
   <text id="b" x="20" y="20">b</text>
   <text id="a" x="20" y="30">a</text>
   <text id="y" x="20" y="40">y</text>
-  <g id="v">
-    <circle cx="100" cy="50" r="5"/>
-    <path d="M 100,100 L 100,200"/>
-  </g>
-  <g id="h">
-    <circle cx="200" cy="50" r="5"/>
-    <path d="M 200,100 L 300,100"/>
-  </g>
 </svg>
--- a/content/svg/content/test/test_bbox.xhtml
+++ b/content/svg/content/test/test_bbox.xhtml
@@ -37,18 +37,16 @@ function run()
     var bbox1 = getBBox(id1);
     var bbox2 = getBBox(id2);
     is(bbox1.height, bbox2.height, id1 + ".getBBox().height");
   }
 
   checkBBox("fO", 10, 10, 100, 100);
   checkBBoxHeight("a", "b");
   checkBBoxHeight("a", "y");
-  checkBBox("v", 95, 45, 10, 155);
-  checkBBox("h", 195, 45, 105, 55);
   
   SimpleTest.finish();
 }
 
 window.addEventListener("load", run, false);
 </script>
 </pre>
 </body>
--- a/layout/svg/base/src/nsSVGContainerFrame.cpp
+++ b/layout/svg/base/src/nsSVGContainerFrame.cpp
@@ -249,37 +249,28 @@ nsSVGDisplayContainerFrame::NotifyRedraw
   nsSVGUtils::NotifyRedrawUnsuspended(this);
 }
 
 gfxRect
 nsSVGDisplayContainerFrame::GetBBoxContribution(
   const gfxMatrix &aToBBoxUserspace,
   PRUint32 aFlags)
 {
-  gfxRect bboxUnion;
-  bool firstChild = true;
+  gfxRect bboxUnion(0.0, 0.0, 0.0, 0.0);
 
   nsIFrame* kid = mFrames.FirstChild();
   while (kid) {
     nsISVGChildFrame* svgKid = do_QueryFrame(kid);
     if (svgKid) {
       gfxMatrix transform = aToBBoxUserspace;
       nsIContent *content = kid->GetContent();
       if (content->IsSVG() && !content->IsNodeOfType(nsINode::eTEXT)) {
         transform = static_cast<nsSVGElement*>(content)->
                       PrependLocalTransformsTo(aToBBoxUserspace);
       }
-      // We need to include zero width/height vertical/horizontal lines, so we have
-      // to use UnionEdges, but we must special case the first bbox so that we don't
-      // include the initial gfxRect(0,0,0,0).
-      gfxRect childBBox = svgKid->GetBBoxContribution(transform, aFlags);
-      if (firstChild) {
-        bboxUnion = childBBox;
-        firstChild = false;
-        continue;
-      }
-      bboxUnion = bboxUnion.UnionEdges(childBBox);
+      bboxUnion =
+        bboxUnion.Union(svgKid->GetBBoxContribution(transform, aFlags));
     }
     kid = kid->GetNextSibling();
   }
 
   return bboxUnion;
 }
--- a/layout/svg/base/src/nsSVGMarkerFrame.cpp
+++ b/layout/svg/base/src/nsSVGMarkerFrame.cpp
@@ -199,44 +199,33 @@ nsSVGMarkerFrame::GetMarkBBoxContributio
     return gfxRect();
   }
 
   mStrokeWidth = aStrokeWidth;
   mX = aMark->x;
   mY = aMark->y;
   mAutoAngle = aMark->angle;
 
+  gfxRect bbox;
+
   gfxMatrix markerTM =
     content->GetMarkerTransform(mStrokeWidth, mX, mY, mAutoAngle);
   gfxMatrix viewBoxTM = content->GetViewBoxTransform();
 
   gfxMatrix tm = viewBoxTM * markerTM * aToBBoxUserspace;
 
-  gfxRect bbox;
-  bool firstChild = true;
-
   for (nsIFrame* kid = mFrames.FirstChild();
        kid;
        kid = kid->GetNextSibling()) {
     nsISVGChildFrame* child = do_QueryFrame(kid);
     if (child) {
       // When we're being called to obtain the invalidation area, we need to
       // pass down all the flags so that stroke is included. However, once DOM
       // getBBox() accepts flags, maybe we should strip some of those here?
-
-      // We need to include zero width/height vertical/horizontal lines, so we have
-      // to use UnionEdges, but we must special case the first bbox so that we don't
-      // include the initial gfxRect(0,0,0,0).
-      gfxRect childBBox = child->GetBBoxContribution(tm, aFlags);
-      if (firstChild) {
-        bbox = childBBox;
-        firstChild = false;
-        continue;
-      }
-      bbox = bbox.UnionEdges(childBBox);
+      bbox.UnionRect(bbox, child->GetBBoxContribution(tm, aFlags));
     }
   }
 
   return bbox;
 }
 
 void
 nsSVGMarkerFrame::SetParentCoordCtxProvider(nsSVGSVGElement *aContext)