Bug 525363 - clipPath winding-mode is broken. r=roc,a=roc
authorRobert Longson <longsonr@gmail.com>
Fri, 30 Oct 2009 22:16:30 +0000
changeset 32670 251389c47d82309f9202283b861c5eabe5dcee9b
parent 32669 642185ee31d35f69ab63c03a277eef4cb075a31c
child 32671 cc13042643ca893e53846807a56c3688ee1e649b
push id523
push userlongsonr@gmail.com
push dateFri, 30 Oct 2009 22:16:32 +0000
reviewersroc, roc
bugs525363
milestone1.9.2b2pre
Bug 525363 - clipPath winding-mode is broken. r=roc,a=roc
layout/reftests/svg/clipPath-winding-01.svg
layout/reftests/svg/reftest.list
layout/svg/base/src/nsSVGPathGeometryFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/clipPath-winding-01.svg
@@ -0,0 +1,17 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
+
+  <title>Testcase for clipPath with evenodd winding</title>
+  
+  <!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=525363 -->
+
+  <defs>
+    <clipPath id="clip">
+      <path clip-rule="evenodd" d="M100,100 l 50,0 0,50 -50,0 0,-50 50,0 0,50 -50,0 0,-50z"/>
+    </clipPath>
+  </defs>
+
+  <rect width="100%" height="100%" fill="lime"/>
+
+  <rect width="100%" height="100%" fill="red" clip-path="url(#clip)"/>
+
+</svg>
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -14,16 +14,17 @@ include filters/reftest.list
 # Mozilla only tests (i.e. those containing XUL/XBL/etc.)
 include moz-only/reftest.list
 
 == clip-01.svg pass.svg
 == clip-02a.svg clip-02-ref.svg
 == clip-02b.svg clip-02-ref.svg
 == clipPath-and-shape-rendering-01.svg clipPath-and-shape-rendering-01-ref.svg
 == clipPath-basic-01.svg pass.svg
+== clipPath-winding-01.svg pass.svg
 == clip-surface-clone-01.svg clip-surface-clone-01-ref.svg
 == conditions-01.svg pass.svg
 == currentColor-01.svg pass.svg
 == currentColor-02.svg pass.svg
 == currentColor-03.svg pass.svg
 == dynamic-conditions-01.svg pass.svg
 == dynamic-clipPath-01.svg pass.svg
 == dynamic-feFlood-01.svg pass.svg
--- a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
@@ -419,43 +419,44 @@ nsSVGPathGeometryFrame::MarkerProperties
 
 void
 nsSVGPathGeometryFrame::Render(nsSVGRenderState *aContext)
 {
   gfxContext *gfx = aContext->GetGfxContext();
 
   PRUint16 renderMode = aContext->GetRenderMode();
 
-  /* save/restore the state so we don't screw up the xform */
-  gfx->Save();
-
-  GeneratePath(gfx);
-
   switch (GetStyleSVG()->mShapeRendering) {
   case NS_STYLE_SHAPE_RENDERING_OPTIMIZESPEED:
   case NS_STYLE_SHAPE_RENDERING_CRISPEDGES:
     gfx->SetAntialiasMode(gfxContext::MODE_ALIASED);
     break;
   default:
     gfx->SetAntialiasMode(gfxContext::MODE_COVERAGE);
     break;
   }
 
+  /* save/restore the state so we don't screw up the xform */
+  gfx->Save();
+
+  GeneratePath(gfx);
+
   if (renderMode != nsSVGRenderState::NORMAL) {
+    gfx->Restore();
+
     if (GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
       gfx->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
     else
       gfx->SetFillRule(gfxContext::FILL_RULE_WINDING);
 
     if (renderMode == nsSVGRenderState::CLIP_MASK) {
       gfx->SetColor(gfxRGBA(1.0f, 1.0f, 1.0f, 1.0f));
       gfx->Fill();
       gfx->NewPath();
     }
-    gfx->Restore();
 
     return;
   }
 
   if (SetupCairoFill(gfx)) {
     gfx->Fill();
   }