Bug 786216 - Fix evenodd fill-rule. r=jwatt
authorRobert Longson <longsonr@gmail.com>
Tue, 28 Aug 2012 15:47:01 +0100
changeset 105692 c4ceb6420c6089489bdc95bccc082c4aad7830b0
parent 105691 fc16f1c44039ecb90733417487fbed2bac1c0873
child 105693 145fedfb046af5a87956c24bf049efa9339e4d53
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjwatt
bugs786216
milestone18.0a1
Bug 786216 - Fix evenodd fill-rule. r=jwatt
layout/reftests/svg/reftest.list
layout/reftests/svg/winding-01.svg
layout/svg/base/src/nsSVGUtils.cpp
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -304,13 +304,14 @@ random-if(/^Windows\x20NT\x205\.1/.test(
 == userSpaceOnUse-and-pattern-01.svg userSpaceOnUse-and-pattern-01-ref.svg
 == viewBox-and-pattern-01.svg pass.svg
 == viewBox-and-pattern-02.svg pass.svg
 == viewBox-and-pattern-03.svg pass.svg
 == viewBox-invalid-01.svg pass.svg
 == viewBox-valid-01.svg pass.svg
 == viewBox-valid-02.xhtml pass.svg
 == viewport-percent-graphic-user-01.svg pass.svg
+== winding-01.svg pass.svg
 
 == svg-effects-area-unzoomed.xhtml svg-effects-area-unzoomed-ref.xhtml
 == svg-effects-area-zoomed-in.xhtml svg-effects-area-zoomed-in-ref.xhtml
 == svg-effects-area-zoomed-out.xhtml svg-effects-area-zoomed-out-ref.xhtml
 == href-attr-change-restyles.svg href-attr-change-restyles-ref.svg
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/winding-01.svg
@@ -0,0 +1,11 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+
+  <title>Testcase for path with evenodd winding</title>
+  
+  <!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=786216 -->
+
+  <rect width="100%" height="100%" fill="lime"/>
+
+  <path fill-rule="evenodd" fill="red" d="M100,100 l 50,0 0,50 -50,0 0,-50 50,0 0,50 -50,0 0,-50z"/>
+
+</svg>
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -1889,16 +1889,22 @@ MaybeOptimizeOpacity(nsIFrame *aFrame, f
 }
 
 bool
 nsSVGUtils::SetupCairoFillPaint(nsIFrame *aFrame, gfxContext* aContext)
 {
   const nsStyleSVG* style = aFrame->GetStyleSVG();
   if (style->mFill.mType == eStyleSVGPaintType_None)
     return false;
+
+  if (style->mFillRule == NS_STYLE_FILL_RULE_EVENODD)
+    aContext->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
+  else
+    aContext->SetFillRule(gfxContext::FILL_RULE_WINDING);
+
   float opacity = MaybeOptimizeOpacity(aFrame, style->mFillOpacity);
   nsSVGPaintServerFrame *ps =
     nsSVGEffects::GetPaintServer(aFrame, &style->mFill, nsSVGEffects::FillProperty());
   if (ps && ps->SetupPaintServer(aContext, aFrame, &nsStyleSVG::mFill, opacity))
     return true;
 
   // On failure, use the fallback colour in case we have an
   // objectBoundingBox where the width or height of the object is zero.