Bug 916704 - Always initialize SVGTextContentPaint::Paint and check SetupCairoState return value in nsSVGTextFrame2::PaintSVG. r=longsonr
authorCameron McCormack <cam@mcc.id.au>
Wed, 25 Sep 2013 17:18:41 +1000
changeset 148642 28c74ba68af36c7e912294571642dd3f277a98c3
parent 148641 5312cc60f7b076a652c33827f1ef2f4dfad7e6cc
child 148643 e044880511db279e1bbe8b130fa6b9e49efff8ab
push id25349
push userryanvm@gmail.com
push dateWed, 25 Sep 2013 18:52:12 +0000
treeherdermozilla-central@39f30376058c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs916704
milestone27.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 916704 - Always initialize SVGTextContentPaint::Paint and check SetupCairoState return value in nsSVGTextFrame2::PaintSVG. r=longsonr
layout/svg/nsSVGGlyphFrame.cpp
layout/svg/nsSVGGlyphFrame.h
layout/svg/nsSVGTextFrame2.cpp
--- a/layout/svg/nsSVGGlyphFrame.cpp
+++ b/layout/svg/nsSVGGlyphFrame.cpp
@@ -1138,16 +1138,17 @@ mozilla::SVGTextContextPaint::Paint::Get
     // cache it, we'll have to compute mPatternMatrix, which is annoying.
     return pattern.forget();
   case eStyleSVGPaintType_ContextStroke:
     pattern = mPaintDefinition.mContextPaint->GetStrokePattern(aOpacity, aCTM);
     // Don't cache this. mContextPaint will have cached it anyway. If we
     // cache it, we'll have to compute mPatternMatrix, which is annoying.
     return pattern.forget();
   default:
+    MOZ_ASSERT(false, "invalid paint type");
     return nullptr;
   }
 
   mPatternCache.Put(aOpacity, pattern);
   return pattern.forget();
 }
 
 //----------------------------------------------------------------------
--- a/layout/svg/nsSVGGlyphFrame.h
+++ b/layout/svg/nsSVGGlyphFrame.h
@@ -41,17 +41,17 @@ struct SVGTextContextPaint : public gfxT
 
   void SetFillOpacity(float aOpacity) { mFillOpacity = aOpacity; }
   float GetFillOpacity() MOZ_OVERRIDE { return mFillOpacity; }
 
   void SetStrokeOpacity(float aOpacity) { mStrokeOpacity = aOpacity; }
   float GetStrokeOpacity() MOZ_OVERRIDE { return mStrokeOpacity; }
 
   struct Paint {
-    Paint() {}
+    Paint() : mPaintType(eStyleSVGPaintType_None) {}
 
     void SetPaintServer(nsIFrame *aFrame, const gfxMatrix& aContextMatrix,
                         nsSVGPaintServerFrame *aPaintServerFrame) {
       mPaintType = eStyleSVGPaintType_Server;
       mPaintDefinition.mPaintServerFrame = aPaintServerFrame;
       mFrame = aFrame;
       mContextMatrix = aContextMatrix;
     }
--- a/layout/svg/nsSVGTextFrame2.cpp
+++ b/layout/svg/nsSVGTextFrame2.cpp
@@ -3526,35 +3526,40 @@ nsSVGTextFrame2::PaintSVG(nsRenderingCon
 
     // Set up the fill and stroke so that SVG glyphs can get painted correctly
     // when they use context-fill etc.
     gfx->SetMatrix(initialMatrix);
     gfxTextContextPaint *outerContextPaint =
       (gfxTextContextPaint*)aContext->GetUserData(&gfxTextContextPaint::sUserDataKey);
 
     nsAutoPtr<gfxTextContextPaint> contextPaint;
-    SetupCairoState(gfx, frame, outerContextPaint, getter_Transfers(contextPaint));
+    gfxFont::DrawMode drawMode =
+      SetupCairoState(gfx, frame, outerContextPaint,
+                      getter_Transfers(contextPaint));
 
     // Set up the transform for painting the text frame for the substring
     // indicated by the run.
     gfxMatrix runTransform =
       run.GetTransformFromUserSpaceForPainting(presContext, item);
     runTransform.Multiply(currentMatrix);
     gfx->SetMatrix(runTransform);
 
-    nsRect frameRect = frame->GetVisualOverflowRect();
-    bool paintSVGGlyphs;
-    if (ShouldRenderAsPath(aContext, frame, paintSVGGlyphs)) {
-      SVGTextDrawPathCallbacks callbacks(aContext, frame, matrixForPaintServers,
-                                         paintSVGGlyphs);
-      frame->PaintText(aContext, nsPoint(), frameRect, item,
-                       contextPaint, &callbacks);
-    } else {
-      frame->PaintText(aContext, nsPoint(), frameRect, item,
-                       contextPaint, nullptr);
+    if (drawMode != gfxFont::DrawMode(0)) {
+      nsRect frameRect = frame->GetVisualOverflowRect();
+      bool paintSVGGlyphs;
+      if (ShouldRenderAsPath(aContext, frame, paintSVGGlyphs)) {
+        SVGTextDrawPathCallbacks callbacks(aContext, frame,
+                                           matrixForPaintServers,
+                                           paintSVGGlyphs);
+        frame->PaintText(aContext, nsPoint(), frameRect, item,
+                         contextPaint, &callbacks);
+      } else {
+        frame->PaintText(aContext, nsPoint(), frameRect, item,
+                         contextPaint, nullptr);
+      }
     }
 
     if (frame == caretFrame && ShouldPaintCaret(run, caret)) {
       // XXX Should we be looking at the fill/stroke colours to paint the
       // caret with, rather than using the color property?
       caret->PaintCaret(nullptr, aContext, frame, nsPoint());
       gfx->NewPath();
     }