Bug 647914 - Horizontal and vertical SVG paths are omitted from bbox calculations if they have siblings. r=jwatt

This commit is contained in:
Robert Longson 2012-01-23 17:42:32 +00:00
Родитель 26a5795109
Коммит 05d3f21653
4 изменённых файлов: 36 добавлений и 6 удалений

Просмотреть файл

@ -6,4 +6,12 @@
<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>

До

Ширина:  |  Высота:  |  Размер: 273 B

После

Ширина:  |  Высота:  |  Размер: 459 B

Просмотреть файл

@ -42,6 +42,8 @@ function run()
checkBBox("f", 0, 0, 100, 100);
checkBBoxHeight("a", "b");
checkBBoxHeight("a", "y");
checkBBox("v", 95, 45, 10, 155);
checkBBox("h", 195, 45, 105, 55);
SimpleTest.finish();
}

Просмотреть файл

@ -265,7 +265,8 @@ nsSVGDisplayContainerFrame::GetBBoxContribution(
const gfxMatrix &aToBBoxUserspace,
PRUint32 aFlags)
{
gfxRect bboxUnion(0.0, 0.0, 0.0, 0.0);
gfxRect bboxUnion;
bool firstChild = true;
nsIFrame* kid = mFrames.FirstChild();
while (kid) {
@ -277,8 +278,16 @@ nsSVGDisplayContainerFrame::GetBBoxContribution(
transform = static_cast<nsSVGElement*>(content)->
PrependLocalTransformTo(aToBBoxUserspace);
}
bboxUnion =
bboxUnion.Union(svgKid->GetBBoxContribution(transform, aFlags));
// 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);
}
kid = kid->GetNextSibling();
}

Просмотреть файл

@ -203,14 +203,15 @@ nsSVGMarkerFrame::GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace,
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()) {
@ -219,7 +220,17 @@ nsSVGMarkerFrame::GetMarkBBoxContribution(const gfxMatrix &aToBBoxUserspace,
// 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?
bbox.UnionRect(bbox, child->GetBBoxContribution(tm, aFlags));
// 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);
}
}