Bug 519368 - pattern with viewBox not treated correctly. r=jwatt

This commit is contained in:
Robert Longson 2009-12-29 09:56:25 +00:00
parent fec8bc87e8
commit 0ef1acff76
3 changed files with 31 additions and 7 deletions

View File

@ -133,4 +133,5 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == text-font-weight-01.svg text-font-weigh
== text-style-01e.svg text-style-01-ref.svg
== thin-stroke-01.svg pass.svg
== userSpaceOnUse-and-pattern-01.svg userSpaceOnUse-and-pattern-01-ref.svg
== viewBox-and-pattern-01.svg pass.svg
== viewport-percent-graphic-user-01.svg pass.svg

View File

@ -0,0 +1,19 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<title>Testcase for elements referencing a viewBox pattern</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=519368 -->
<defs>
<pattern id="test" patternUnits="userSpaceOnUse" x="10" y="10" width="20%" height="20%" viewBox="10 10 10 10">
<rect x="10" y="10" width="10" height="10" fill="lime" />
</pattern>
</defs>
<rect width="100%" height="100%" fill="lime" />
<rect x="20" y="20" width="100" height="100" fill="red" />
<rect x="20" y="20" width="100" height="100" fill="url(#test)" />
</svg>

After

Width:  |  Height:  |  Size: 725 B

View File

@ -534,22 +534,26 @@ nsSVGPatternFrame::ConstructCTM(const gfxRect &callerBBox,
tCTM.Scale(scale, scale);
}
gfxMatrix viewBoxTM;
gfxMatrix tm;
const nsSVGViewBoxRect viewBox = GetViewBox().GetAnimValue();
if (viewBox.height > 0.0f && viewBox.width > 0.0f) {
nsSVGSVGElement *ctx = aTargetContent->GetCtx();
float viewportWidth = GetWidth()->GetAnimValue(ctx);
float viewportHeight = GetHeight()->GetAnimValue(ctx);
gfxMatrix viewBoxTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
viewBox.x, viewBox.y,
viewBox.width, viewBox.height,
GetPreserveAspectRatio(),
PR_TRUE);
float refX = GetX()->GetAnimValue(ctx);
float refY = GetY()->GetAnimValue(ctx);
viewBoxTM = nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
viewBox.x + refX, viewBox.y + refY,
viewBox.width, viewBox.height,
GetPreserveAspectRatio(),
PR_TRUE);
gfxPoint ref = viewBoxTM.Transform(gfxPoint(refX, refY));
tm = viewBoxTM * gfxMatrix().Translate(gfxPoint(-ref.x, -ref.y));
}
return viewBoxTM * tCTM;
return tm * tCTM;
}
gfxMatrix