Bug 944704, part 3 - Fix stroke dashing for SVG ellipses so that the dashing starts from the correct point and progresses in the correct direction. r=Bas

This commit is contained in:
Jonathan Watt 2013-12-13 12:14:37 +00:00
parent 35b8b77c8e
commit e6e89d5bf8
3 changed files with 34 additions and 1 deletions

View File

@ -95,6 +95,15 @@ SVGEllipseElement::GetLengthInfo()
void
SVGEllipseElement::ConstructPath(gfxContext *aCtx)
{
if (!aCtx->IsCairo()) {
RefPtr<Path> path = BuildPath();
if (path) {
gfxPath gfxpath(path);
aCtx->SetPath(&gfxpath);
}
return;
}
float x, y, rx, ry;
GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr);
@ -116,7 +125,7 @@ SVGEllipseElement::BuildPath()
RefPtr<PathBuilder> pathBuilder = CreatePathBuilder();
AppendEllipseToPath(pathBuilder, Point(x, y), Size(2.0*rx, 2.0*ry));
ArcToBezier(pathBuilder.get(), Point(x, y), Size(rx, ry), 0, Float(2*M_PI), false);
return pathBuilder->Finish();
}

View File

@ -319,6 +319,7 @@ HTTP(..) == text-scale-02.svg text-scale-02-ref.svg
HTTP(..) == text-scale-03.svg text-scale-03-ref.svg
== text-stroke-scaling-01.svg text-stroke-scaling-01-ref.svg
fails-if(OSX==10.8) == stroke-dasharray-01.svg stroke-dasharray-01-ref.svg # bug 896487
== stroke-dasharray-02.svg pass.svg
== stroke-dasharray-and-pathLength-01.svg pass.svg
== stroke-dasharray-and-text-01.svg stroke-dasharray-and-text-01-ref.svg
== stroke-dashoffset-01.svg pass.svg

View File

@ -0,0 +1,23 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<title>Test the start point and direction of dashing on circle and ellipse</title>
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=944704 -->
<rect width="100%" height="100%" fill="lime"/>
<!-- Test ellipse element dashes cover two red circles -->
<circle cx="95" cy="211" r="8" fill="red"/>
<circle cx="47" cy="225" r="8" fill="red"/>
<ellipse cx="50" cy="200" rx="50" ry="25" fill="none" stroke="lime" stroke-width="25" stroke-dasharray="25 25 25 100000"/>
<!-- Sanity test to check that two circles cover ellipse element dashes (i.e. that the previous check didn't pass because the stroke was solid) -->
<ellipse cx="200" cy="200" rx="50" ry="25" fill="none" stroke="red" stroke-width="10" stroke-dasharray="10 40 10 100000"/>
<circle cx="250" cy="205" r="11" fill="lime"/>
<circle cx="206" cy="225" r="11" fill="lime"/>
</svg>

After

Width:  |  Height:  |  Size: 1020 B