Bug 923193. Make transform-origin on SVG elements use the SVG bbox as the reference rectangle. r=heycam

--HG--
extra : rebase_source : 7c8d1b42a09b9389d082195edd0c683e2dc7e12e
This commit is contained in:
Robert O'Callahan 2013-10-03 08:34:24 -04:00
parent d7e61cc28c
commit 944645a6ad
5 changed files with 24 additions and 4 deletions

View File

@ -3829,8 +3829,9 @@ nsDisplayTransform::GetFrameBoundsForTransform(const nsIFrame* aFrame)
NS_PRECONDITION(aFrame, "Can't get the bounds of a nonexistent frame!");
if (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
// TODO: SVG needs to define what percentage translations resolve against.
return nsRect();
gfxRect bbox = nsSVGUtils::GetBBox(const_cast<nsIFrame*>(aFrame));
return nsLayoutUtils::RoundGfxRectToAppRect(bbox,
aFrame->PresContext()->AppUnitsPerCSSPixel()) - aFrame->GetPosition();
}
return nsRect(nsPoint(0, 0), aFrame->GetSize());
@ -3846,8 +3847,9 @@ nsDisplayTransform::GetFrameBoundsForTransform(const nsIFrame* aFrame)
nsRect result;
if (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
// TODO: SVG needs to define what percentage translations resolve against.
return result;
gfxRect bbox = nsSVGUtils::GetBBox(const_cast<nsIFrame*>(aFrame));
return nsLayoutUtils::RoundGfxRectToAppRect(bbox,
aFrame->PresContext()->AppUnitsPerCSSPixel()) - aFrame->GetPosition();
}
/* Iterate through the continuation list, unioning together all the

View File

@ -124,3 +124,5 @@ skip-if(B2G) fails-if(Android) fuzzy-if(cocoaWidget,1,2) == stresstest-1.html st
== table-2b.html table-2-ref.html
# Bug 722463
== inline-1a.html inline-1-ref.html
== transform-origin-svg-1a.svg transform-origin-svg-1-ref.svg
== transform-origin-svg-1b.svg transform-origin-svg-1-ref.svg

View File

@ -0,0 +1,3 @@
<svg xmlns='http://www.w3.org/2000/svg'>
<rect x='40' y='140' width='100' height='100' fill='lime'/>
</svg>

After

Width:  |  Height:  |  Size: 108 B

View File

@ -0,0 +1,6 @@
<svg xmlns='http://www.w3.org/2000/svg'>
<g transform="translate(30,30)">
<rect x='10' y='10' width='100' height='100' fill='lime'
style="transform:rotate(90deg); transform-origin:left bottom;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 218 B

View File

@ -0,0 +1,7 @@
<svg xmlns='http://www.w3.org/2000/svg'>
<g transform="translate(30,30)">
<rect x='10' y='10' width='100' height='100' fill='lime'
style="transform:rotate(90deg); transform-origin:10px 110px;
-webkit-transform:rotate(90deg); -webkit-transform-origin:10px 110px;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 302 B