Bug 823964 - Wrong bounds for scaled images. r=longsonr

This commit is contained in:
Jonathan Kew 2012-12-22 10:07:00 +00:00
parent 0527db678b
commit a76332437f
5 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g transform="scale(0.5)">
<foreignObject id="fO" x="10" y="10" width="100" height="100"/>
<image id="i" 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>

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 782 B

View File

@ -21,6 +21,7 @@ text { font: 20px monospace; }
<rect id="rect3" x="25" y="80" width="50" height="50" fill="green"/>
<rect id="rect3a" x="25" y="80" width="50" height="50" fill="none" stroke-width="4" stroke="blue"/>
<rect id="rect3b" vector-effect="non-scaling-stroke" x="100" y="100" width="25" height="25" fill="orange" stroke-width="4" stroke="yellow"/>
<image id="i" x="10" y="10" width="100" height="100"/>
</g>
<g transform="scale(2) rotate(45 175 75)">
<rect id="rect4" x="150" y="50" width="50" height="50" fill="yellow"/>

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -48,6 +48,7 @@ function run()
}
checkBBox("fO", 10, 10, 100, 100);
checkBBox("i", 10, 10, 100, 100);
compareBBoxHeight("a", "b");
compareBBoxHeight("a", "y");
compareBBox("b", "tspan");

View File

@ -134,6 +134,13 @@ function runTest()
is(text2aBounds.left, text1aBounds.left + 100 - 3, "text2a.getBoundingClientRect().left");
is(text2aBounds.width, text1aBounds.width + 6, "text2a.getBoundingClientRect().width");
var i = doc.getElementById("i");
var iBounds = i.getBoundingClientRect();
is(iBounds.left, 20, "i.getBoundingClientRect().left");
is(iBounds.top, 20, "i.getBoundingClientRect().top");
is(iBounds.width, 200, "i.getBoundingClientRect().width");
is(iBounds.height, 200, "i.getBoundingClientRect().height");
SimpleTest.finish();
}

View File

@ -485,8 +485,10 @@ nsSVGImageFrame::ReflowSVG()
gfxMatrix scaling;
if (applyScaling) {
scaling.Scale(scaleFactors.width, scaleFactors.height);
}
}
tmpCtx.Save();
GeneratePath(&tmpCtx, scaling);
tmpCtx.Restore();
gfxRect extent = tmpCtx.GetUserPathExtent();
if (applyScaling) {
extent.Scale(1 / scaleFactors.width, 1 / scaleFactors.height);