Bug 1058040, part 2 - Rename gfxTextContextPaint to SVGContextPaint and add some code comments. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Fri, 22 Jul 2016 14:56:09 +0100
changeset 307890 c0404d1f3b47cee8284e4be54a79d3b01db6b961
parent 307889 0a536af3ebfadc7968b93cee2e765eef3d5364aa
child 307891 ae7b718d8afa96ccd8552b142d46f06f37c953b5
push id30521
push usercbook@mozilla.com
push dateWed, 03 Aug 2016 15:04:18 +0000
treeherdermozilla-central@7f1b2e71efdc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1058040
milestone51.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 1058040, part 2 - Rename gfxTextContextPaint to SVGContextPaint and add some code comments. r=dholbert
dom/svg/SVGContentUtils.cpp
dom/svg/SVGContentUtils.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontEntry.cpp
gfx/thebes/gfxFontEntry.h
gfx/thebes/gfxSVGGlyphs.cpp
gfx/thebes/gfxSVGGlyphs.h
gfx/thebes/gfxTextRun.h
layout/generic/nsTextFrame.h
layout/svg/SVGContextPaint.cpp
layout/svg/SVGContextPaint.h
layout/svg/SVGTextFrame.cpp
layout/svg/SVGTextFrame.h
layout/svg/nsSVGPathGeometryFrame.cpp
layout/svg/nsSVGUtils.cpp
layout/svg/nsSVGUtils.h
--- a/dom/svg/SVGContentUtils.cpp
+++ b/dom/svg/SVGContentUtils.cpp
@@ -68,17 +68,17 @@ enum DashState {
   eContinuousStroke, //< all dashes, no gaps
   eNoStroke          //< all gaps, no dashes
 };
 
 static DashState
 GetStrokeDashData(SVGContentUtils::AutoStrokeOptions* aStrokeOptions,
                   nsSVGElement* aElement,
                   const nsStyleSVG* aStyleSVG,
-                  gfxTextContextPaint *aContextPaint)
+                  SVGContextPaint* aContextPaint)
 {
   size_t dashArrayLength;
   Float totalLengthOfDashes = 0.0, totalLengthOfGaps = 0.0;
   Float pathScale = 1.0;
 
   if (aContextPaint && aStyleSVG->StrokeDasharrayFromObject()) {
     const FallibleTArray<gfxFloat>& dashSrc = aContextPaint->GetStrokeDashArray();
     dashArrayLength = dashSrc.Length();
@@ -165,17 +165,17 @@ GetStrokeDashData(SVGContentUtils::AutoS
 
   return eDashedStroke;
 }
 
 void
 SVGContentUtils::GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
                                   nsSVGElement* aElement,
                                   nsStyleContext* aStyleContext,
-                                  gfxTextContextPaint *aContextPaint,
+                                  SVGContextPaint* aContextPaint,
                                   StrokeOptionFlags aFlags)
 {
   RefPtr<nsStyleContext> styleContext;
   if (aStyleContext) {
     styleContext = aStyleContext;
   } else {
     styleContext =
       nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr,
@@ -240,17 +240,17 @@ SVGContentUtils::GetStrokeOptions(AutoSt
         break;
     }
   }
 }
 
 Float
 SVGContentUtils::GetStrokeWidth(nsSVGElement* aElement,
                                 nsStyleContext* aStyleContext,
-                                gfxTextContextPaint *aContextPaint)
+                                SVGContextPaint* aContextPaint)
 {
   RefPtr<nsStyleContext> styleContext;
   if (aStyleContext) {
     styleContext = aStyleContext;
   } else {
     styleContext =
       nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr,
                                                            nullptr);
--- a/dom/svg/SVGContentUtils.h
+++ b/dom/svg/SVGContentUtils.h
@@ -12,27 +12,27 @@
 
 #include "mozilla/gfx/2D.h" // for StrokeOptions
 #include "mozilla/gfx/Matrix.h"
 #include "mozilla/RangedPtr.h"
 #include "nsError.h"
 #include "nsStringFwd.h"
 #include "gfx2DGlue.h"
 
-class gfxTextContextPaint;
 class nsIContent;
 class nsIDocument;
 class nsIFrame;
 class nsStyleContext;
 class nsStyleCoord;
 class nsSVGElement;
 
 namespace mozilla {
 class nsSVGAnimatedTransformList;
 class SVGAnimatedPreserveAspectRatio;
+class SVGContextPaint;
 class SVGPreserveAspectRatio;
 namespace dom {
 class Element;
 class SVGSVGElement;
 } // namespace dom
 
 namespace gfx {
 class Matrix;
@@ -167,31 +167,31 @@ public:
    * Note: the linecap style returned in aStrokeOptions is not valid when
    * ShapeTypeHasNoCorners(aElement) == true && aFlags == eIgnoreStrokeDashing,
    * since when aElement has no corners the rendered linecap style depends on
    * whether or not the stroke is dashed.
    */
   static void GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
                                nsSVGElement* aElement,
                                nsStyleContext* aStyleContext,
-                               gfxTextContextPaint *aContextPaint,
+                               mozilla::SVGContextPaint* aContextPaint,
                                StrokeOptionFlags aFlags = eAllStrokeOptions);
 
   /**
    * Returns the current computed value of the CSS property 'stroke-width' for
    * the given element. aStyleContext may be provided as an optimization. 
    * aContextPaint is also optional.
    *
    * Note that this function does NOT take account of the value of the 'stroke'
    * and 'stroke-opacity' properties to, say, return zero if they are "none" or
    * "0", respectively.
    */
   static Float GetStrokeWidth(nsSVGElement* aElement,
                               nsStyleContext* aStyleContext,
-                              gfxTextContextPaint *aContextPaint);
+                              mozilla::SVGContextPaint* aContextPaint);
 
   /*
    * Get the number of CSS px (user units) per em (i.e. the em-height in user
    * units) for an nsIContent
    *
    * XXX document the conditions under which these may fail, and what they
    * return in those cases.
    */
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2066,17 +2066,17 @@ gfxFont::Draw(const gfxTextRun *aTextRun
         if (aTextRun->UseCenterBaseline()) {
             gfxPoint baseAdj(0, (metrics.emAscent - metrics.emDescent) / 2);
             mat.Translate(baseAdj);
         }
 
         aRunParams.context->SetMatrix(mat);
     }
 
-    UniquePtr<gfxTextContextPaint> contextPaint;
+    UniquePtr<SVGContextPaint> contextPaint;
     if (fontParams.haveSVGGlyphs && !fontParams.contextPaint) {
         // If no pattern is specified for fill, use the current pattern
         NS_ASSERTION((int(aRunParams.drawMode) & int(DrawMode::GLYPH_STROKE)) == 0,
                      "no pattern supplied for stroking text");
         RefPtr<gfxPattern> fillPattern = aRunParams.context->GetPattern();
         contextPaint.reset(
             new SimpleTextContextPaint(fillPattern, nullptr,
                                        aRunParams.context->CurrentMatrix()));
@@ -2172,17 +2172,17 @@ gfxFont::Draw(const gfxTextRun *aTextRun
         } else {
             *aPt = gfxPoint(origPt.x, origPt.y + advance);
         }
     }
 }
 
 bool
 gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
-                        uint32_t aGlyphId, gfxTextContextPaint *aContextPaint) const
+                        uint32_t aGlyphId, SVGContextPaint* aContextPaint) const
 {
     if (!GetFontEntry()->HasSVGGlyph(aGlyphId)) {
         return false;
     }
 
     const gfxFloat devUnitsPerSVGUnit =
         GetAdjustedSize() / GetFontEntry()->UnitsPerEm();
     gfxContextMatrixAutoSaveRestore matrixRestore(aContext);
@@ -2198,17 +2198,17 @@ gfxFont::RenderSVGGlyph(gfxContext *aCon
                                              aContextPaint);
     aContext->Restore();
     aContext->NewPath();
     return rv;
 }
 
 bool
 gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
-                        uint32_t aGlyphId, gfxTextContextPaint *aContextPaint,
+                        uint32_t aGlyphId, SVGContextPaint* aContextPaint,
                         gfxTextRunDrawCallbacks *aCallbacks,
                         bool& aEmittedGlyphs) const
 {
     if (aCallbacks && aEmittedGlyphs) {
         aCallbacks->NotifyGlyphPathEmitted();
         aEmittedGlyphs = false;
     }
     return RenderSVGGlyph(aContext, aPoint, aGlyphId, aContextPaint);
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -41,17 +41,16 @@ typedef struct _cairo_scaled_font cairo_
 
 class gfxContext;
 class gfxTextRun;
 class gfxFont;
 class gfxGlyphExtents;
 class gfxShapedText;
 class gfxShapedWord;
 class gfxSkipChars;
-class gfxTextContextPaint;
 
 #define FONT_MAX_SIZE                  2000.0
 
 #define NO_FONT_LANGUAGE_OVERRIDE      0
 
 #define SMALL_CAPS_SCALE_FACTOR        0.8
 
 // The skew factor used for synthetic-italic [oblique] fonts;
@@ -62,16 +61,17 @@ class gfxTextContextPaint;
 #define OBLIQUE_SKEW_FACTOR  0.2
 #else
 #define OBLIQUE_SKEW_FACTOR  0.25
 #endif
 
 struct gfxTextRunDrawCallbacks;
 
 namespace mozilla {
+class SVGContextPaint;
 namespace gfx {
 class GlyphRenderingOptions;
 } // namespace gfx
 } // namespace mozilla
 
 struct gfxFontStyle {
     gfxFontStyle();
     gfxFontStyle(uint8_t aStyle, uint16_t aWeight, int16_t aStretch,
@@ -1332,16 +1332,17 @@ struct EmphasisMarkDrawParams;
 class gfxFont {
 
     friend class gfxHarfBuzzShaper;
     friend class gfxGraphiteShaper;
 
 protected:
     typedef mozilla::gfx::DrawTarget DrawTarget;
     typedef mozilla::unicode::Script Script;
+    typedef mozilla::SVGContextPaint SVGContextPaint;
 
 public:
     nsrefcnt AddRef(void) {
         NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
         if (mExpirationState.IsTracked()) {
             gfxFontCache::GetCache()->RemoveObject(this);
         }
         ++mRefCnt;
@@ -2145,19 +2146,19 @@ protected:
     // InitMetricsFromSfntTables or equivalent platform code
     void CalculateDerivedMetrics(Metrics& aMetrics);
 
     // some fonts have bad metrics, this method sanitize them.
     // if this font has bad underline offset, aIsBadUnderlineFont should be true.
     void SanitizeMetrics(Metrics *aMetrics, bool aIsBadUnderlineFont);
 
     bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
-                        uint32_t aGlyphId, gfxTextContextPaint *aContextPaint) const;
+                        uint32_t aGlyphId, SVGContextPaint* aContextPaint) const;
     bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
-                        uint32_t aGlyphId, gfxTextContextPaint *aContextPaint,
+                        uint32_t aGlyphId, SVGContextPaint* aContextPaint,
                         gfxTextRunDrawCallbacks *aCallbacks,
                         bool& aEmittedGlyphs) const;
 
     bool RenderColorGlyph(DrawTarget* aDrawTarget,
                           gfxContext* aContext,
                           mozilla::gfx::ScaledFont* scaledFont,
                           mozilla::gfx::GlyphRenderingOptions* renderingOptions,
                           mozilla::gfx::DrawOptions drawOptions,
@@ -2181,34 +2182,34 @@ protected:
 // The TextRunDrawParams are set up once per textrun; the FontDrawParams
 // are dependent on the specific font, so they are set per GlyphRun.
 
 struct TextRunDrawParams {
     RefPtr<mozilla::gfx::DrawTarget> dt;
     gfxContext              *context;
     gfxFont::Spacing        *spacing;
     gfxTextRunDrawCallbacks *callbacks;
-    gfxTextContextPaint     *runContextPaint;
+    mozilla::SVGContextPaint *runContextPaint;
     mozilla::gfx::Color      fontSmoothingBGColor;
     gfxFloat                 direction;
     double                   devPerApp;
     nscolor                  textStrokeColor;
     gfxPattern              *textStrokePattern;
     const mozilla::gfx::StrokeOptions *strokeOpts;
     const mozilla::gfx::DrawOptions   *drawOpts;
     DrawMode                 drawMode;
     bool                     isVerticalRun;
     bool                     isRTL;
     bool                     paintSVGGlyphs;
 };
 
 struct FontDrawParams {
     RefPtr<mozilla::gfx::ScaledFont>            scaledFont;
     RefPtr<mozilla::gfx::GlyphRenderingOptions> renderingOptions;
-    gfxTextContextPaint      *contextPaint;
+    mozilla::SVGContextPaint *contextPaint;
     mozilla::gfx::Matrix     *passedInvMatrix;
     mozilla::gfx::Matrix      matInv;
     double                    synBoldOnePixelOffset;
     int32_t                   extraStrikes;
     mozilla::gfx::DrawOptions drawOptions;
     bool                      isVerticalFont;
     bool                      haveSVGGlyphs;
     bool                      haveColorGlyphs;
--- a/gfx/thebes/gfxFontEntry.cpp
+++ b/gfx/thebes/gfxFontEntry.cpp
@@ -345,17 +345,17 @@ gfxFontEntry::GetSVGGlyphExtents(DrawTar
                             fontMatrix.x0, fontMatrix.y0);
     svgToAppSpace.Scale(1.0f / mUnitsPerEm, 1.0f / mUnitsPerEm);
 
     return mSVGGlyphs->GetGlyphExtents(aGlyphId, svgToAppSpace, aResult);
 }
 
 bool
 gfxFontEntry::RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId,
-                             gfxTextContextPaint *aContextPaint)
+                             SVGContextPaint* aContextPaint)
 {
     NS_ASSERTION(mSVGInitialized, "SVG data has not yet been loaded. TryGetSVGData() first.");
     return mSVGGlyphs->RenderGlyph(aContext, aGlyphId, aContextPaint);
 }
 
 bool
 gfxFontEntry::TryGetSVGData(gfxFont* aFont)
 {
--- a/gfx/thebes/gfxFontEntry.h
+++ b/gfx/thebes/gfxFontEntry.h
@@ -29,21 +29,24 @@ typedef struct gr_face gr_face;
 
 struct gfxFontStyle;
 class gfxContext;
 class gfxFont;
 class gfxFontFamily;
 class gfxUserFontData;
 class gfxSVGGlyphs;
 class gfxMathTable;
-class gfxTextContextPaint;
 class FontInfoData;
 struct FontListSizes;
 class nsIAtom;
 
+namespace mozilla {
+class SVGContextPaint;
+};
+
 class gfxCharacterMap : public gfxSparseBitSet {
 public:
     nsrefcnt AddRef() {
         NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
         ++mRefCnt;
         NS_LOG_ADDREF(this, mRefCnt, "gfxCharacterMap", sizeof(*this));
         return mRefCnt;
     }
@@ -180,17 +183,17 @@ public:
     // can be safely dereferenced.
     virtual nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr);
 
     bool TryGetSVGData(gfxFont* aFont);
     bool HasSVGGlyph(uint32_t aGlyphId);
     bool GetSVGGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphId,
                             gfxRect *aResult);
     bool RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId,
-                        gfxTextContextPaint *aContextPaint);
+                        mozilla::SVGContextPaint* aContextPaint);
     // Call this when glyph geometry or rendering has changed
     // (e.g. animated SVG glyphs)
     void NotifyGlyphsChanged();
 
     enum MathConstant {
         // The order of the constants must match the order of the fields
         // defined in the MATH table.
         ScriptPercentScaleDown,
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -208,17 +208,17 @@ gfxSVGGlyphsDocument::FindGlyphElements(
  * If there exists an SVG glyph with the specified glyph id, render it and return true
  * If no such glyph exists, or in the case of an error return false
  * @param aContext The thebes aContext to draw to
  * @param aGlyphId The glyph id
  * @return true iff rendering succeeded
  */
 bool
 gfxSVGGlyphs::RenderGlyph(gfxContext *aContext, uint32_t aGlyphId,
-                          gfxTextContextPaint *aContextPaint)
+                          SVGContextPaint* aContextPaint)
 {
     gfxContextAutoSaveRestore aContextRestorer(aContext);
 
     Element *glyph = mGlyphIdMap.Get(aGlyphId);
     NS_ASSERTION(glyph, "No glyph element. Should check with HasSVGGlyph() first!");
 
     AutoSetRestoreSVGContextPaint autoSetRestore(aContextPaint, glyph->OwnerDoc());
 
--- a/gfx/thebes/gfxSVGGlyphs.h
+++ b/gfx/thebes/gfxSVGGlyphs.h
@@ -15,19 +15,19 @@
 #include "mozilla/gfx/UserData.h"
 #include "mozilla/SVGContextPaint.h"
 #include "nsRefreshDriver.h"
 
 class nsIDocument;
 class nsIContentViewer;
 class nsIPresShell;
 class gfxSVGGlyphs;
-class gfxTextContextPaint;
 
 namespace mozilla {
+class SVGContextPaint;
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 /**
  * Wraps an SVG document contained in the SVG table of an OpenType font.
  * There may be multiple SVG documents in an SVG table which we lazily parse
@@ -113,20 +113,20 @@ public:
     /**
      * Return true iff there is an SVG glyph for |aGlyphId|
      */
     bool HasSVGGlyph(uint32_t aGlyphId);
 
     /**
      * Render the SVG glyph for |aGlyphId|
      * @param aContextPaint Information on text context paints.
-     *   See |gfxTextContextPaint|.
+     *   See |SVGContextPaint|.
      */
     bool RenderGlyph(gfxContext *aContext, uint32_t aGlyphId,
-                     gfxTextContextPaint *aContextPaint);
+                     mozilla::SVGContextPaint* aContextPaint);
 
     /**
      * Get the extents for the SVG glyph associated with |aGlyphId|
      * @param aSVGToAppSpace The matrix mapping the SVG glyph space to the
      *   target context space
      */
     bool GetGlyphExtents(uint32_t aGlyphId, const gfxMatrix& aSVGToAppSpace,
                          gfxRect *aResult);
@@ -169,17 +169,17 @@ private:
  * This class is used when code fails to pass through an SVGContextPaint from
  * the context in which we are painting.  In that case we create one of these
  * as a fallback and have it wrap the gfxContext's current gfxPattern and
  * pretend that that is the paint context's fill pattern.  In some contexts
  * that will be the case, in others it will not.  As we convert more code to
  * Moz2D the less likely it is that this hack will work.  It will also make
  * converting to Moz2D harder.
  */
-class SimpleTextContextPaint : public gfxTextContextPaint
+class SimpleTextContextPaint : public mozilla::SVGContextPaint
 {
 private:
     static const mozilla::gfx::Color sZero;
 
     static gfxMatrix SetupDeviceToPatternMatrix(gfxPattern *aPattern,
                                                 const gfxMatrix& aCTM)
     {
         if (!aPattern) {
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -24,21 +24,24 @@
 #ifdef DEBUG
 #include <stdio.h>
 #endif
 
 class gfxContext;
 class gfxFontGroup;
 class gfxUserFontEntry;
 class gfxUserFontSet;
-class gfxTextContextPaint;
 class nsIAtom;
 class nsILanguageAtomService;
 class gfxMissingFontRecorder;
 
+namespace mozilla {
+class SVGContextPaint;
+};
+
 /**
  * Callback for Draw() to use when drawing text with mode
  * DrawMode::GLYPH_PATH.
  */
 struct gfxTextRunDrawCallbacks {
 
     /**
      * Constructs a new DrawCallbacks object.
@@ -239,17 +242,17 @@ public:
         DrawMode drawMode = DrawMode::GLYPH_FILL;
         nscolor textStrokeColor = 0;
         gfxPattern* textStrokePattern = nullptr;
         const mozilla::gfx::StrokeOptions *strokeOpts = nullptr;
         const mozilla::gfx::DrawOptions *drawOpts = nullptr;
         PropertyProvider* provider = nullptr;
         // If non-null, the advance width of the substring is set.
         gfxFloat* advanceWidth = nullptr;
-        gfxTextContextPaint* contextPaint = nullptr;
+        mozilla::SVGContextPaint* contextPaint = nullptr;
         gfxTextRunDrawCallbacks* callbacks = nullptr;
         explicit DrawParams(gfxContext* aContext) : context(aContext) {}
     };
 
     /**
      * Draws a substring. Uses only GetSpacing from aBreakProvider.
      * The provided point is the baseline origin on the left of the string
      * for LTR, on the right of the string for RTL.
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -26,16 +26,20 @@
 class nsTextPaintStyle;
 class PropertyProvider;
 struct SelectionDetails;
 class nsTextFragment;
 
 class nsDisplayTextGeometry;
 class nsDisplayText;
 
+namespace mozilla {
+class SVGContextPaint;
+};
+
 class nsTextFrame : public nsFrame {
   typedef mozilla::LayoutDeviceRect LayoutDeviceRect;
   typedef mozilla::RawSelectionType RawSelectionType;
   typedef mozilla::SelectionType SelectionType;
   typedef mozilla::TextRangeStyle TextRangeStyle;
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::Point Point;
   typedef mozilla::gfx::Rect Rect;
@@ -388,17 +392,17 @@ public:
     virtual void NotifySelectionDecorationLinePathEmitted() { }
   };
 
   struct PaintTextParams
   {
     gfxContext* context;
     gfxPoint framePt;
     LayoutDeviceRect dirtyRect;
-    gfxTextContextPaint* contextPaint = nullptr;
+    mozilla::SVGContextPaint* contextPaint = nullptr;
     DrawPathCallbacks* callbacks = nullptr;
     enum {
       PaintText,           // Normal text painting.
       PaintTextBGColor,    // Only paint background color of the selected text
                            // range in this state.
       GenerateTextMask     // To generate a mask from a text frame. Should
                            // only paint text itself with opaque color.
                            // Text shadow, text selection color and text
@@ -422,17 +426,17 @@ public:
       : PaintTextParams(aParams) {}
   };
 
   struct DrawTextRunParams
   {
     gfxContext* context;
     PropertyProvider* provider = nullptr;
     gfxFloat* advanceWidth = nullptr;
-    gfxTextContextPaint* contextPaint = nullptr;
+    mozilla::SVGContextPaint* contextPaint = nullptr;
     DrawPathCallbacks* callbacks = nullptr;
     nscolor textColor = NS_RGBA(0, 0, 0, 0);
     nscolor textStrokeColor = NS_RGBA(0, 0, 0, 0);
     float textStrokeWidth = 0.0f;
     bool drawSoftHyphen = false;
     explicit DrawTextRunParams(gfxContext* aContext)
       : context(aContext) {}
   };
--- a/layout/svg/SVGContextPaint.cpp
+++ b/layout/svg/SVGContextPaint.cpp
@@ -2,32 +2,32 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SVGContextPaint.h"
 
 #include "gfxContext.h"
 #include "nsIDocument.h"
 
-using namespace mozilla;
+namespace mozilla {
 
 void
-gfxTextContextPaint::InitStrokeGeometry(gfxContext* aContext,
-                                        float devUnitsPerSVGUnit)
+SVGContextPaint::InitStrokeGeometry(gfxContext* aContext,
+                                    float devUnitsPerSVGUnit)
 {
   mStrokeWidth = aContext->CurrentLineWidth() / devUnitsPerSVGUnit;
   aContext->CurrentDash(mDashes, &mDashOffset);
   for (uint32_t i = 0; i < mDashes.Length(); i++) {
     mDashes[i] /= devUnitsPerSVGUnit;
   }
   mDashOffset /= devUnitsPerSVGUnit;
 }
 
 AutoSetRestoreSVGContextPaint::AutoSetRestoreSVGContextPaint(
-                                 gfxTextContextPaint* aContextPaint,
+                                 SVGContextPaint* aContextPaint,
                                  nsIDocument* aSVGDocument)
   : mSVGDocument(aSVGDocument)
   , mOuterContextPaint(aSVGDocument->GetProperty(nsGkAtoms::svgContextPaint))
 {
   // The way that we supply context paint is to temporarily set the context
   // paint on the owner document of the SVG that we're painting while it's
   // being painted.
 
@@ -50,8 +50,10 @@ AutoSetRestoreSVGContextPaint::~AutoSetR
   mSVGDocument->UnsetProperty(nsGkAtoms::svgContextPaint);
   if (mOuterContextPaint) {
     DebugOnly<nsresult> res =
       mSVGDocument->SetProperty(nsGkAtoms::svgContextPaint, mOuterContextPaint);
 
     NS_WARN_IF_FALSE(NS_SUCCEEDED(res), "Failed to restore context paint");
   }
 }
+
+} // namespace mozilla
--- a/layout/svg/SVGContextPaint.h
+++ b/layout/svg/SVGContextPaint.h
@@ -11,37 +11,39 @@
 #include "gfxTypes.h"
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/gfx/2D.h"
 #include "nsTArray.h"
 
 class gfxContext;
 class nsIDocument;
 
+namespace mozilla {
+
 /**
  * This class is used to pass information about a context element through to
  * SVG painting code in order to resolve the 'context-fill' and related
  * keywords. See:
  *
  *   https://www.w3.org/TR/SVG2/painting.html#context-paint
  *
  * This feature allows the color in an SVG-in-OpenType glyph to come from the
  * computed style for the text that is being drawn, for example, or for color
  * in an SVG embedded by an <img> element to come from the embedding <img>
  * element.
  */
-class gfxTextContextPaint
+class SVGContextPaint
 {
 protected:
   typedef mozilla::gfx::DrawTarget DrawTarget;
 
-  gfxTextContextPaint() {}
+  SVGContextPaint() {}
 
 public:
-  virtual ~gfxTextContextPaint() {}
+  virtual ~SVGContextPaint() {}
 
   virtual already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
                                                       float aOpacity,
                                                       const gfxMatrix& aCTM) = 0;
   virtual already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
                                                         float aOpacity,
                                                         const gfxMatrix& aCTM) = 0;
   virtual float GetFillOpacity() const = 0;
@@ -85,20 +87,22 @@ private:
  * piece of SVG is being painted.  The context paint is set on the SVG's owner
  * document, as expected by nsSVGUtils::GetContextPaint.  Any pre-existing
  * context paint is restored after this class removes the context paint that it
  * set.
  */
 class MOZ_RAII AutoSetRestoreSVGContextPaint
 {
 public:
-  AutoSetRestoreSVGContextPaint(gfxTextContextPaint* aContextPaint,
+  AutoSetRestoreSVGContextPaint(SVGContextPaint* aContextPaint,
                                 nsIDocument* aSVGDocument);
   ~AutoSetRestoreSVGContextPaint();
 private:
   nsIDocument* mSVGDocument;
   // The context paint that needs to be restored by our dtor after it removes
   // aContextPaint:
   void* mOuterContextPaint;
 };
 
+} // namespace mozilla
+
 #endif // MOZILLA_SVGCONTEXTPAINT_H_
 
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3719,17 +3719,17 @@ SVGTextFrame::PaintSVG(gfxContext& aCont
 
   RefPtr<nsCaret> caret = presContext->PresShell()->GetCaret();
   nsRect caretRect;
   nsIFrame* caretFrame = caret->GetPaintGeometry(&caretRect);
 
   TextRenderedRunIterator it(this, TextRenderedRunIterator::eVisibleFrames);
   TextRenderedRun run = it.Current();
 
-  gfxTextContextPaint* outerContextPaint = nsSVGUtils::GetContextPaint(mContent);
+  SVGContextPaint* outerContextPaint = nsSVGUtils::GetContextPaint(mContent);
 
   nsRenderingContext rendCtx(&aContext);
 
   while (run.mFrame) {
     nsTextFrame* frame = run.mFrame;
 
     // Determine how much of the left and right edges of the text frame we
     // need to ignore.
--- a/layout/svg/SVGTextFrame.h
+++ b/layout/svg/SVGTextFrame.h
@@ -134,17 +134,17 @@ public:
   explicit GlyphMetricsUpdater(SVGTextFrame* aFrame) : mFrame(aFrame) { }
   static void Run(SVGTextFrame* aFrame);
   void Revoke() { mFrame = nullptr; }
 private:
   SVGTextFrame* mFrame;
 };
 
 // Slightly horrible callback for deferring application of opacity
-struct SVGTextContextPaint : public gfxTextContextPaint {
+struct SVGTextContextPaint : public SVGContextPaint {
 protected:
   typedef mozilla::gfx::DrawTarget DrawTarget;
 public:
   already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
                                               float aOpacity,
                                               const gfxMatrix& aCTM) override;
   already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
                                                 float aOpacity,
@@ -167,28 +167,28 @@ public:
       mContextMatrix = aContextMatrix;
     }
 
     void SetColor(const nscolor &aColor) {
       mPaintType = eStyleSVGPaintType_Color;
       mPaintDefinition.mColor = aColor;
     }
 
-    void SetContextPaint(gfxTextContextPaint *aContextPaint,
+    void SetContextPaint(SVGContextPaint* aContextPaint,
                          nsStyleSVGPaintType aPaintType) {
       NS_ASSERTION(aPaintType == eStyleSVGPaintType_ContextFill ||
                    aPaintType == eStyleSVGPaintType_ContextStroke,
                    "Invalid context paint type");
       mPaintType = aPaintType;
       mPaintDefinition.mContextPaint = aContextPaint;
     }
 
     union {
       nsSVGPaintServerFrame *mPaintServerFrame;
-      gfxTextContextPaint *mContextPaint;
+      SVGContextPaint* mContextPaint;
       nscolor mColor;
     } mPaintDefinition;
 
     nsIFrame *mFrame;
     // CTM defining the user space for the pattern we will use.
     gfxMatrix mContextMatrix;
     nsStyleSVGPaintType mPaintType;
 
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -799,17 +799,17 @@ nsSVGPathGeometryFrame::Render(gfxContex
   element->GetAsSimplePath(&simplePath);
   if (!simplePath.IsPath()) {
     path = element->GetOrBuildPath(*drawTarget, fillRule);
     if (!path) {
       return;
     }
   }
 
-  gfxTextContextPaint* contextPaint = nsSVGUtils::GetContextPaint(mContent);
+  SVGContextPaint* contextPaint = nsSVGUtils::GetContextPaint(mContent);
 
   if (aRenderComponents & eRenderFill) {
     GeneralPattern fillPattern;
     nsSVGUtils::MakeFillPatternFor(this, aContext, &fillPattern, contextPaint);
     if (fillPattern.GetPattern()) {
       DrawOptions drawOptions(1.0f, CompositionOp::OP_OVER, aaMode);
       if (simplePath.IsRect()) {
         drawTarget->FillRect(simplePath.AsRect(), fillPattern, drawOptions);
@@ -867,17 +867,17 @@ nsSVGPathGeometryFrame::Render(gfxContex
     }
   }
 }
 
 void
 nsSVGPathGeometryFrame::PaintMarkers(gfxContext& aContext,
                                      const gfxMatrix& aTransform)
 {
-  gfxTextContextPaint* contextPaint = nsSVGUtils::GetContextPaint(mContent);
+  SVGContextPaint* contextPaint = nsSVGUtils::GetContextPaint(mContent);
 
   if (static_cast<nsSVGPathGeometryElement*>(mContent)->IsMarkable()) {
     MarkerProperties properties = GetMarkerProperties(this);
 
     if (properties.MarkersExist()) {
       float strokeWidth = nsSVGUtils::GetStrokeWidth(this, contextPaint);
 
       nsTArray<nsSVGMark> marks;
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1295,26 +1295,26 @@ nsSVGUtils::GetFallbackOrPaintColor(nsSt
       nscolor colors[2] = { color, paintIfVisited.mPaint.mColor };
       return nsStyleContext::CombineVisitedColors(
                colors, aStyleContext->RelevantLinkVisited());
     }
   }
   return color;
 }
 
-/* static */ gfxTextContextPaint*
+/* static */ SVGContextPaint*
 nsSVGUtils::GetContextPaint(nsIContent* aContent)
 {
   nsIDocument* ownerDoc = aContent->OwnerDoc();
 
   if (!ownerDoc->IsBeingUsedAsImage()) {
     return nullptr;
   }
 
-  return static_cast<gfxTextContextPaint*>(
+  return static_cast<SVGContextPaint*>(
            ownerDoc->GetProperty(nsGkAtoms::svgContextPaint));
 }
 
 /**
  * Stores in |aTargetPaint| information on how to reconstruct the current
  * fill or stroke pattern. Will also set the paint opacity to transparent if
  * the paint is set to "none".
  * @param aOuterContextPaint pattern information from the outer text context
@@ -1323,17 +1323,17 @@ nsSVGUtils::GetContextPaint(nsIContent* 
  * @param aProperty the frame property descriptor of the fill or stroke paint
  *   server frame
  */
 static void
 SetupInheritablePaint(const DrawTarget* aDrawTarget,
                       const gfxMatrix& aContextMatrix,
                       nsIFrame* aFrame,
                       float& aOpacity,
-                      gfxTextContextPaint* aOuterContextPaint,
+                      SVGContextPaint* aOuterContextPaint,
                       SVGTextContextPaint::Paint& aTargetPaint,
                       nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
                       nsSVGEffects::PaintingPropertyDescriptor aProperty)
 {
   const nsStyleSVG *style = aFrame->StyleSVG();
   nsSVGPaintServerFrame *ps =
     nsSVGEffects::GetPaintServer(aFrame, &(style->*aFillOrStroke), aProperty);
 
@@ -1369,17 +1369,17 @@ SetupInheritablePaint(const DrawTarget* 
     nsSVGUtils::GetFallbackOrPaintColor(aFrame->StyleContext(), aFillOrStroke);
   aTargetPaint.SetColor(color);
 }
 
 /* static */ DrawMode
 nsSVGUtils::SetupContextPaint(const DrawTarget* aDrawTarget,
                               const gfxMatrix& aContextMatrix,
                               nsIFrame* aFrame,
-                              gfxTextContextPaint* aOuterContextPaint,
+                              SVGContextPaint* aOuterContextPaint,
                               SVGTextContextPaint* aThisContextPaint)
 {
   DrawMode toDraw = DrawMode(0);
 
   const nsStyleSVG *style = aFrame->StyleSVG();
 
   // fill:
   if (style->mFill.mType == eStyleSVGPaintType_None) {
@@ -1419,17 +1419,17 @@ nsSVGUtils::SetupContextPaint(const Draw
 
   return toDraw;
 }
 
 /* static */ void
 nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame,
                                gfxContext* aContext,
                                GeneralPattern* aOutPattern,
-                               gfxTextContextPaint* aContextPaint)
+                               SVGContextPaint* aContextPaint)
 {
   const nsStyleSVG* style = aFrame->StyleSVG();
   if (style->mFill.mType == eStyleSVGPaintType_None) {
     return;
   }
 
   const float opacity = aFrame->StyleEffects()->mOpacity;
 
@@ -1487,17 +1487,17 @@ nsSVGUtils::MakeFillPatternFor(nsIFrame*
   color.a *= fillOpacity;
   aOutPattern->InitColorPattern(ToDeviceColor(color));
 }
 
 /* static */ void
 nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame,
                                  gfxContext* aContext,
                                  GeneralPattern* aOutPattern,
-                                 gfxTextContextPaint* aContextPaint)
+                                 SVGContextPaint* aContextPaint)
 {
   const nsStyleSVG* style = aFrame->StyleSVG();
   if (style->mStroke.mType == eStyleSVGPaintType_None) {
     return;
   }
 
   const float opacity = aFrame->StyleEffects()->mOpacity;
 
@@ -1554,17 +1554,17 @@ nsSVGUtils::MakeStrokePatternFor(nsIFram
                                                       &nsStyleSVG::mStroke)));
   color.a *= strokeOpacity;
   aOutPattern->InitColorPattern(ToDeviceColor(color));
 }
 
 /* static */ float
 nsSVGUtils::GetOpacity(nsStyleSVGOpacitySource aOpacityType,
                        const float& aOpacity,
-                       gfxTextContextPaint *aContextPaint)
+                       SVGContextPaint *aContextPaint)
 {
   float opacity = 1.0f;
   switch (aOpacityType) {
   case eStyleSVGOpacitySource_Normal:
     opacity = aOpacity;
     break;
   case eStyleSVGOpacitySource_ContextFillOpacity:
     if (aContextPaint) {
@@ -1582,24 +1582,24 @@ nsSVGUtils::GetOpacity(nsStyleSVGOpacity
     break;
   default:
     NS_NOTREACHED("Unknown object opacity inheritance type for SVG glyph");
   }
   return opacity;
 }
 
 bool
-nsSVGUtils::HasStroke(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
+nsSVGUtils::HasStroke(nsIFrame* aFrame, SVGContextPaint* aContextPaint)
 {
   const nsStyleSVG *style = aFrame->StyleSVG();
   return style->HasStroke() && GetStrokeWidth(aFrame, aContextPaint) > 0;
 }
 
 float
-nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
+nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, SVGContextPaint* aContextPaint)
 {
   const nsStyleSVG *style = aFrame->StyleSVG();
   if (aContextPaint && style->StrokeWidthFromObject()) {
     return aContextPaint->GetStrokeWidth();
   }
 
   nsIContent* content = aFrame->GetContent();
   if (content->IsNodeOfType(nsINode::eTEXT)) {
@@ -1610,17 +1610,17 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFr
 
   return SVGContentUtils::CoordToFloat(ctx, style->mStrokeWidth);
 }
 
 static bool
 GetStrokeDashData(nsIFrame* aFrame,
                   nsTArray<gfxFloat>& aDashes,
                   gfxFloat* aDashOffset,
-                  gfxTextContextPaint *aContextPaint)
+                  SVGContextPaint* aContextPaint)
 {
   const nsStyleSVG* style = aFrame->StyleSVG();
   nsIContent *content = aFrame->GetContent();
   nsSVGElement *ctx = static_cast<nsSVGElement*>
     (content->IsNodeOfType(nsINode::eTEXT) ?
      content->GetParent() : content);
 
   gfxFloat totalLength = 0.0;
@@ -1670,17 +1670,17 @@ GetStrokeDashData(nsIFrame* aFrame,
   }
 
   return (totalLength > 0.0);
 }
 
 void
 nsSVGUtils::SetupCairoStrokeGeometry(nsIFrame* aFrame,
                                      gfxContext *aContext,
-                                     gfxTextContextPaint *aContextPaint)
+                                     SVGContextPaint* aContextPaint)
 {
   float width = GetStrokeWidth(aFrame, aContextPaint);
   if (width <= 0)
     return;
   aContext->SetLineWidth(width);
 
   // Apply any stroke-specific transform
   gfxMatrix outerSVGToUser;
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -35,23 +35,23 @@ class nsPresContext;
 class nsStyleContext;
 class nsSVGDisplayContainerFrame;
 class nsSVGElement;
 class nsSVGEnum;
 class nsSVGLength2;
 class nsSVGOuterSVGFrame;
 class nsSVGPathGeometryFrame;
 class nsTextFrame;
-class gfxTextContextPaint;
 
 struct nsStyleSVG;
 struct nsStyleSVGPaint;
 struct nsRect;
 
 namespace mozilla {
+class SVGContextPaint;
 struct SVGTextContextPaint;
 namespace dom {
 class Element;
 class UserSpaceMetrics;
 } // namespace dom
 namespace gfx {
 class DrawTarget;
 class GeneralPattern;
@@ -179,16 +179,17 @@ class nsSVGUtils
 {
 public:
   typedef mozilla::dom::Element Element;
   typedef mozilla::gfx::AntialiasMode AntialiasMode;
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::FillRule FillRule;
   typedef mozilla::gfx::GeneralPattern GeneralPattern;
   typedef mozilla::gfx::Size Size;
+  typedef mozilla::SVGContextPaint SVGContextPaint;
   typedef mozilla::SVGTextContextPaint SVGTextContextPaint;
   typedef mozilla::image::DrawResult DrawResult;
 
   static void Init();
 
   NS_DECLARE_FRAME_PROPERTY_DELETABLE(ObjectBoundingBoxProperty, gfxRect)
 
   /**
@@ -492,56 +493,56 @@ public:
   {
     return NS_lround(std::max(double(INT32_MIN),
                             std::min(double(INT32_MAX), aVal)));
   }
 
   static nscolor GetFallbackOrPaintColor(nsStyleContext *aStyleContext,
                                          nsStyleSVGPaint nsStyleSVG::*aFillOrStroke);
 
-  static gfxTextContextPaint* GetContextPaint(nsIContent* aContent);
+  static SVGContextPaint* GetContextPaint(nsIContent* aContent);
 
   static DrawMode
   SetupContextPaint(const DrawTarget* aDrawTarget,
                     const gfxMatrix& aContextMatrix,
                     nsIFrame* aFrame,
-                    gfxTextContextPaint* aOuterContextPaint,
+                    SVGContextPaint* aOuterContextPaint,
                     SVGTextContextPaint* aThisContextPaint);
 
   static void
   MakeFillPatternFor(nsIFrame *aFrame,
                      gfxContext* aContext,
                      GeneralPattern* aOutPattern,
-                     gfxTextContextPaint *aContextPaint = nullptr);
+                     SVGContextPaint* aContextPaint = nullptr);
 
   static void
   MakeStrokePatternFor(nsIFrame* aFrame,
                        gfxContext* aContext,
                        GeneralPattern* aOutPattern,
-                       gfxTextContextPaint *aContextPaint = nullptr);
+                       SVGContextPaint* aContextPaint = nullptr);
 
   static float GetOpacity(nsStyleSVGOpacitySource aOpacityType,
                           const float& aOpacity,
-                          gfxTextContextPaint *aContextPaint);
+                          SVGContextPaint* aContextPaint);
 
   /*
    * @return false if there is no stroke
    */
   static bool HasStroke(nsIFrame* aFrame,
-                        gfxTextContextPaint *aContextPaint = nullptr);
+                        SVGContextPaint* aContextPaint = nullptr);
 
   static float GetStrokeWidth(nsIFrame* aFrame,
-                              gfxTextContextPaint *aContextPaint = nullptr);
+                              SVGContextPaint* aContextPaint = nullptr);
 
   /*
    * Set up a cairo context for a stroked path (including any dashing that
    * applies).
    */
   static void SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext,
-                                       gfxTextContextPaint *aContextPaint = nullptr);
+                                       SVGContextPaint* aContextPaint = nullptr);
 
   /**
    * This function returns a set of bit flags indicating which parts of the
    * element (fill, stroke, bounds) should intercept pointer events. It takes
    * into account the type of element and the value of the 'pointer-events'
    * property on the element.
    */
   static uint16_t GetGeometryHitTestFlags(nsIFrame* aFrame);