Bug 725918 patch 2: Fixed wrong assertion in nsSVGGlyphFrame. r=longsonr
authorEdwin Flores <eflores@mozilla.com>
Fri, 17 Feb 2012 16:33:23 -0800
changeset 87143 f89c186b8143099fa452fe900ca942f5cbc5690c
parent 87142 829fa4d266ac74d60ec7c099e2756999f4050b00
child 87144 4ab82ee636d69eacf62a890562a05e764536e7e2
push id22083
push userbmo@edmorley.co.uk
push dateSat, 18 Feb 2012 11:19:19 +0000
treeherdermozilla-central@20478b673212 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs725918
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 725918 patch 2: Fixed wrong assertion in nsSVGGlyphFrame. r=longsonr
layout/reftests/svg/reftest.list
layout/reftests/svg/text-layout-06-ref.svg
layout/reftests/svg/text-layout-06.svg
layout/svg/base/src/nsSVGGlyphFrame.cpp
layout/svg/crashtests/725918-1.svg
layout/svg/crashtests/crashtests.list
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -237,16 +237,17 @@ random-if(winWidget) == text-gradient-02
 # Tests for bug 546813: sanity-check using HTML text, then test SVG behavior.
 fails-if(Android) != text-language-00.xhtml text-language-00-ref.xhtml
 fails-if(Android) random-if(gtk2Widget) != text-language-01.xhtml text-language-01-ref.xhtml # Fails on Linux tryserver due to lack of CJK fonts.
 == text-layout-01.svg text-layout-01-ref.svg
 == text-layout-02.svg text-layout-02-ref.svg
 == text-layout-03.svg text-layout-03-ref.svg
 == text-layout-04.svg text-layout-04-ref.svg
 == text-layout-05.svg text-layout-05-ref.svg
+== text-layout-06.svg text-layout-06-ref.svg
 == text-scale-01.svg text-scale-01-ref.svg
 == text-stroke-scaling-01.svg text-stroke-scaling-01-ref.svg
 == stroke-dasharray-and-pathLength-01.svg pass.svg
 == stroke-dasharray-and-text-01.svg stroke-dasharray-and-text-01-ref.svg 
 == stroke-linecap-square-w-zero-length-segs-01.svg pass.svg
 == stroke-linecap-square-w-zero-length-segs-02.svg pass.svg
 == textPath-01.svg textPath-01-ref.svg
 == textPath-02.svg pass.svg
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/text-layout-06-ref.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <title>Reference to check fill and stroke handling</title>
+
+  <text x="50" y="80" font-size="80" fill="blue" stroke="none">A B</text>
+  <text x="50" y="80" font-size="80" fill="none" stroke="yellow" stroke-width="2">A B</text>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/text-layout-06.svg
@@ -0,0 +1,9 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <title>Testcase to check fill and stroke handling</title>
+
+  <text x="50" y="80" font-size="80" fill="blue" stroke="yellow" stroke-width="2">A B</text>
+</svg>
--- a/layout/svg/base/src/nsSVGGlyphFrame.cpp
+++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp
@@ -895,31 +895,35 @@ nsSVGGlyphFrame::SetupCairoState(gfxCont
 
     toDraw = DrawMode(toDraw | gfxFont::GLYPH_STROKE);
 
     SetupCairoStrokeHitGeometry(aContext);
     float opacity = style->mStrokeOpacity;
     nsSVGPaintServerFrame *ps = GetPaintServer(&style->mStroke,
                                                nsSVGEffects::StrokeProperty());
 
+    nsRefPtr<gfxPattern> strokePattern;
+
     if (ps) {
       // Gradient or Pattern: can get pattern directly from frame
-      *aStrokePattern = ps->GetPaintServerPattern(this, opacity);
+      strokePattern = ps->GetPaintServerPattern(this, opacity);
+    }
 
-      NS_ASSERTION(*aStrokePattern, "No pattern returned from paint server");
-    } else {
+    if (!strokePattern) {
       nscolor color;
       nsSVGUtils::GetFallbackOrPaintColor(aContext, GetStyleContext(),
                                           &nsStyleSVG::mStroke, &opacity,
                                           &color);
-      *aStrokePattern = new gfxPattern(gfxRGBA(NS_GET_R(color) / 255.0,
-                                              NS_GET_G(color) / 255.0,
-                                              NS_GET_B(color) / 255.0,
-                                              NS_GET_A(color) / 255.0 * opacity));
+      strokePattern = new gfxPattern(gfxRGBA(NS_GET_R(color) / 255.0,
+                                             NS_GET_G(color) / 255.0,
+                                             NS_GET_B(color) / 255.0,
+                                             NS_GET_A(color) / 255.0 * opacity));
     }
+
+    strokePattern.swap(*aStrokePattern);
   }
 
   if (SetupCairoFill(aContext)) {
     toDraw = DrawMode(toDraw | gfxFont::GLYPH_FILL);
   }
 
   return toDraw;
 }
new file mode 100644
--- /dev/null
+++ b/layout/svg/crashtests/725918-1.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+  <text stroke="url(#p)">t</text>
+  <pattern id="p"/>
+</svg>
--- a/layout/svg/crashtests/crashtests.list
+++ b/layout/svg/crashtests/crashtests.list
@@ -118,8 +118,9 @@ load 669025-2.svg
 load 682411-1.svg
 load 692203-1.svg
 load 692203-2.svg
 load 693424-1.svg
 load 709920-1.svg
 load 709920-2.svg
 load 713413-1.svg
 load 722003-1.svg
+load 725918-1.svg