Bug 736031 - getBBox returns incorrect results with empty containers. r=jwatt

This commit is contained in:
Robert Longson 2012-03-15 11:42:54 +00:00
parent dd5260b15b
commit 9a7758d1f4
4 changed files with 9 additions and 3 deletions

View File

@ -14,4 +14,9 @@
<circle cx="200" cy="50" r="5"/>
<path d="M 200,100 L 300,100"/>
</g>
<g id="e">
<!-- empty container should not affect parent's bbox -->
<g/>
<circle cx="100" cy="100" r="5"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 602 B

View File

@ -44,6 +44,7 @@ function run()
checkBBoxHeight("a", "y");
checkBBox("v", 95, 45, 10, 155);
checkBBox("h", 195, 45, 105, 55);
checkBBox("e", 95, 95, 10, 10);
SimpleTest.finish();
}

View File

@ -263,7 +263,7 @@ nsSVGDisplayContainerFrame::GetBBoxContribution(
if (svgKid) {
gfxMatrix transform = aToBBoxUserspace;
nsIContent *content = kid->GetContent();
if (content->IsSVG() && !content->IsNodeOfType(nsINode::eTEXT)) {
if (content->IsSVG()) {
transform = static_cast<nsSVGElement*>(content)->
PrependLocalTransformsTo(aToBBoxUserspace);
}
@ -271,7 +271,7 @@ nsSVGDisplayContainerFrame::GetBBoxContribution(
// 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) {
if (firstChild && (childBBox.Width() > 0 || childBBox.Height() > 0)) {
bboxUnion = childBBox;
firstChild = false;
continue;

View File

@ -226,7 +226,7 @@ nsSVGMarkerFrame::GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace,
// 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) {
if (firstChild && (childBBox.Width() > 0 || childBBox.Height() > 0)) {
bbox = childBBox;
firstChild = false;
continue;