Bug 552830 - Should not force rx=ry for a rect by clamping if one is omitted. r=jwatt

This commit is contained in:
Robert Longson 2010-03-18 12:14:38 +00:00
Родитель c78c824f17
Коммит d918498168
3 изменённых файлов: 26 добавлений и 18 удалений

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

@ -184,6 +184,15 @@ nsSVGRectElement::ConstructPath(gfxContext *aCtx)
return;
}
/* If either the 'rx' or the 'ry' attribute isn't set in the markup, then we
have to set it to the value of the other. */
PRBool hasRx = HasAttr(kNameSpaceID_None, nsGkAtoms::rx);
PRBool hasRy = HasAttr(kNameSpaceID_None, nsGkAtoms::ry);
if (hasRx && !hasRy)
ry = rx;
else if (hasRy && !hasRx)
rx = ry;
/* Clamp rx and ry to half the rect's width and height respectively. */
float halfWidth = width/2;
float halfHeight = height/2;
@ -192,24 +201,6 @@ nsSVGRectElement::ConstructPath(gfxContext *aCtx)
if (ry > halfHeight)
ry = halfHeight;
/* If either the 'rx' or the 'ry' attribute isn't set in the markup, then we
have to set it to the value of the other. We do this after clamping rx and
ry since omitting one of the attributes implicitly means they should both
be the same. */
PRBool hasRx = HasAttr(kNameSpaceID_None, nsGkAtoms::rx);
PRBool hasRy = HasAttr(kNameSpaceID_None, nsGkAtoms::ry);
if (hasRx && !hasRy)
ry = rx;
else if (hasRy && !hasRx)
rx = ry;
/* However, we may now have made rx > width/2 or else ry > height/2. (If this
is the case, we know we must be giving rx and ry the same value.) */
if (rx > halfWidth)
rx = ry = halfWidth;
else if (ry > halfHeight)
rx = ry = halfHeight;
gfxSize corner(rx, ry);
aCtx->RoundedRectangle(gfxRect(x, y, width, height),
gfxCornerSizes(corner, corner, corner, corner));

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

@ -0,0 +1,16 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg" >
<title>Testcase for rect with missing and clamped ry</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=552830s -->
<rect x1="0" y1="0" width="100%" height="100%" fill="lime"/>
<g shape-rendering="crispEdges">
<rect x="20" y="50" width="200" height="100" rx="100" fill="red" />
<rect x="20" y="50" width="200" height="100" rx="100" ry="50" fill="lime" />
</g>
</svg>

После

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

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

@ -123,6 +123,7 @@ fails == inline-in-xul-basic-01.xul pass.svg
== radialGradient-basic-02.svg pass.svg
== radialGradient-basic-03.svg radialGradient-basic-03-ref.svg
== rect-01.svg pass.svg
== rect-02.svg pass.svg
== rect-with-rx-and-ry-01.svg pass.svg
== rect-with-rx-or-ry-01.svg rect-with-rx-or-ry-01-ref.svg
== rootElement-null-01.svg pass.svg