Bug 1058040, part 1 - Move gfxTextContextPaint to a separate file to enable use in imagelib. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Fri, 22 Jul 2016 12:07:39 +0100
changeset 307903 0a536af3ebfadc7968b93cee2e765eef3d5364aa
parent 307902 3cda786e6bb64009cb5aadc0c285b82b585a3dd0
child 307904 c0404d1f3b47cee8284e4be54a79d3b01db6b961
push id31034
push usercbook@mozilla.com
push dateWed, 03 Aug 2016 15:09:36 +0000
treeherderautoland@8ceb6981305f [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 1 - Move gfxTextContextPaint to a separate file to enable use in imagelib. r=dholbert
dom/svg/SVGContentUtils.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxSVGGlyphs.cpp
gfx/thebes/gfxSVGGlyphs.h
layout/svg/SVGContextPaint.cpp
layout/svg/SVGContextPaint.h
layout/svg/SVGTextFrame.h
layout/svg/moz.build
layout/svg/nsSVGForeignObjectFrame.cpp
layout/svg/nsSVGPathGeometryFrame.cpp
layout/svg/nsSVGUtils.cpp
--- a/dom/svg/SVGContentUtils.cpp
+++ b/dom/svg/SVGContentUtils.cpp
@@ -7,20 +7,20 @@
 // Main header first:
 // This is also necessary to ensure our definition of M_SQRT1_2 is picked up
 #include "SVGContentUtils.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfx2DGlue.h"
 #include "gfxMatrix.h"
 #include "gfxPlatform.h"
-#include "gfxSVGGlyphs.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/dom/SVGSVGElement.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/SVGContextPaint.h"
 #include "nsComputedDOMStyle.h"
 #include "nsFontMetrics.h"
 #include "nsIFrame.h"
 #include "nsIScriptError.h"
 #include "nsLayoutUtils.h"
 #include "SVGAnimationElement.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 #include "nsContentUtils.h"
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxFont.h"
 
 #include "mozilla/BinarySearch.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/SVGContextPaint.h"
 
 #include "mozilla/Logging.h"
 
 #include "nsITimer.h"
 
 #include "gfxGlyphExtents.h"
 #include "gfxPlatform.h"
 #include "gfxTextRun.h"
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "gfxSVGGlyphs.h"
 
+#include "mozilla/SVGContextPaint.h"
 #include "nsError.h"
 #include "nsIDOMDocument.h"
 #include "nsString.h"
 #include "nsIDocument.h"
 #include "nsICategoryManager.h"
 #include "nsIDocumentLoaderFactory.h"
 #include "nsIContentViewer.h"
 #include "nsIStreamListener.h"
@@ -454,51 +455,8 @@ gfxSVGGlyphsDocument::InsertGlyphId(Elem
 size_t
 gfxSVGGlyphsDocument::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
 {
     return aMallocSizeOf(this)
            + mGlyphIdMap.ShallowSizeOfExcludingThis(aMallocSizeOf)
            + mSVGGlyphsDocumentURI.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
 
 }
-
-AutoSetRestoreSVGContextPaint::AutoSetRestoreSVGContextPaint(
-                                 gfxTextContextPaint* 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.
-
-  MOZ_ASSERT(aSVGDocument->IsBeingUsedAsImage(),
-             "nsSVGUtils::GetContextPaint assumes this");
-
-  if (mOuterContextPaint) {
-    mSVGDocument->UnsetProperty(nsGkAtoms::svgContextPaint);
-  }
-  DebugOnly<nsresult> res =
-    mSVGDocument->SetProperty(nsGkAtoms::svgContextPaint, aContextPaint);
-  NS_WARN_IF_FALSE(NS_SUCCEEDED(res), "Failed to set context paint");
-}
-
-AutoSetRestoreSVGContextPaint::~AutoSetRestoreSVGContextPaint()
-{
-  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");
-  }
-}
-
-void
-gfxTextContextPaint::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;
-}
--- a/gfx/thebes/gfxSVGGlyphs.h
+++ b/gfx/thebes/gfxSVGGlyphs.h
@@ -8,16 +8,17 @@
 #include "gfxFontUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "nsString.h"
 #include "nsClassHashtable.h"
 #include "nsBaseHashtable.h"
 #include "nsHashKeys.h"
 #include "gfxPattern.h"
 #include "mozilla/gfx/UserData.h"
+#include "mozilla/SVGContextPaint.h"
 #include "nsRefreshDriver.h"
 
 class nsIDocument;
 class nsIContentViewer;
 class nsIPresShell;
 class gfxSVGGlyphs;
 class gfxTextContextPaint;
 
@@ -158,117 +159,45 @@ private:
       mozilla::AutoSwap_PRUint16 mNumEntries;
       IndexEntry mEntries[1]; /* actual length = mNumEntries */
     } *mDocIndex;
 
     static int CompareIndexEntries(const void *_a, const void *_b);
 };
 
 /**
- * RAII class used to temporarily set and remove SVG context paint while
- * painting a piece of SVG.  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,
-                                nsIDocument* aSVGDocument);
-  ~AutoSetRestoreSVGContextPaint();
-private:
-  nsIDocument* mSVGDocument;
-  // The context paint that needs to be restored by our dtor after it removes
-  // aContextPaint:
-  void* mOuterContextPaint;
-};
-
-/**
- * Used for trickling down paint information through to SVG glyphs.
- */
-class gfxTextContextPaint
-{
-protected:
-    typedef mozilla::gfx::DrawTarget DrawTarget;
-
-    gfxTextContextPaint() { }
-
-public:
-    /*
-     * Get text context pattern with the specified opacity value.
-     * This lets us inherit paints and paint opacities (i.e. fill/stroke and
-     * fill-opacity/stroke-opacity) separately.
-     */
-    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() { return 1.0f; }
-    virtual float GetStrokeOpacity() { return 1.0f; }
-
-    void InitStrokeGeometry(gfxContext *aContext,
-                            float devUnitsPerSVGUnit);
-
-    FallibleTArray<gfxFloat>& GetStrokeDashArray() {
-        return mDashes;
-    }
-
-    gfxFloat GetStrokeDashOffset() {
-        return mDashOffset;
-    }
-
-    gfxFloat GetStrokeWidth() {
-        return mStrokeWidth;
-    }
-
-    already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
-                                                const gfxMatrix& aCTM) {
-        return GetFillPattern(aDrawTarget, GetFillOpacity(), aCTM);
-    }
-
-    already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
-                                                  const gfxMatrix& aCTM) {
-        return GetStrokePattern(aDrawTarget, GetStrokeOpacity(), aCTM);
-    }
-
-    virtual ~gfxTextContextPaint() { }
-
-private:
-    FallibleTArray<gfxFloat> mDashes;
-    gfxFloat mDashOffset;
-    gfxFloat mStrokeWidth;
-};
-
-/**
- * For passing in patterns where the text context has no separate pattern
- * opacity value.
+ * XXX This is a complete hack and should die (see bug 1291494).
+ *
+ * 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
 {
 private:
     static const mozilla::gfx::Color sZero;
 
-public:
     static gfxMatrix SetupDeviceToPatternMatrix(gfxPattern *aPattern,
                                                 const gfxMatrix& aCTM)
     {
         if (!aPattern) {
             return gfxMatrix();
         }
         gfxMatrix deviceToUser = aCTM;
         if (!deviceToUser.Invert()) {
             return gfxMatrix(0, 0, 0, 0, 0, 0); // singular
         }
         return deviceToUser * aPattern->GetMatrix();
     }
 
+public:
     SimpleTextContextPaint(gfxPattern *aFillPattern, gfxPattern *aStrokePattern,
                           const gfxMatrix& aCTM) :
         mFillPattern(aFillPattern ? aFillPattern : new gfxPattern(sZero)),
         mStrokePattern(aStrokePattern ? aStrokePattern : new gfxPattern(sZero))
     {
         mFillMatrix = SetupDeviceToPatternMatrix(aFillPattern, aCTM);
         mStrokeMatrix = SetupDeviceToPatternMatrix(aStrokePattern, aCTM);
     }
@@ -288,21 +217,21 @@ public:
                                                   const gfxMatrix& aCTM) {
         if (mStrokePattern) {
             mStrokePattern->SetMatrix(aCTM * mStrokeMatrix);
         }
         RefPtr<gfxPattern> strokePattern = mStrokePattern;
         return strokePattern.forget();
     }
 
-    float GetFillOpacity() {
+    float GetFillOpacity() const {
         return mFillPattern ? 1.0f : 0.0f;
     }
 
-    float GetStrokeOpacity() {
+    float GetStrokeOpacity() const {
         return mStrokePattern ? 1.0f : 0.0f;
     }
 
 private:
     RefPtr<gfxPattern> mFillPattern;
     RefPtr<gfxPattern> mStrokePattern;
 
     // Device space to pattern space transforms
new file mode 100644
--- /dev/null
+++ b/layout/svg/SVGContextPaint.cpp
@@ -0,0 +1,57 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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;
+
+void
+gfxTextContextPaint::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,
+                                 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.
+
+  MOZ_ASSERT(aContextPaint);
+  MOZ_ASSERT(aSVGDocument->IsBeingUsedAsImage(),
+             "nsSVGUtils::GetContextPaint assumes this");
+
+  if (mOuterContextPaint) {
+    mSVGDocument->UnsetProperty(nsGkAtoms::svgContextPaint);
+  }
+
+  DebugOnly<nsresult> res =
+    mSVGDocument->SetProperty(nsGkAtoms::svgContextPaint, aContextPaint);
+
+  NS_WARN_IF_FALSE(NS_SUCCEEDED(res), "Failed to set context paint");
+}
+
+AutoSetRestoreSVGContextPaint::~AutoSetRestoreSVGContextPaint()
+{
+  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");
+  }
+}
new file mode 100644
--- /dev/null
+++ b/layout/svg/SVGContextPaint.h
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifndef MOZILLA_SVGCONTEXTPAINT_H_
+#define MOZILLA_SVGCONTEXTPAINT_H_
+
+#include "gfxMatrix.h"
+#include "gfxPattern.h"
+#include "gfxTypes.h"
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/gfx/2D.h"
+#include "nsTArray.h"
+
+class gfxContext;
+class nsIDocument;
+
+/**
+ * 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
+{
+protected:
+  typedef mozilla::gfx::DrawTarget DrawTarget;
+
+  gfxTextContextPaint() {}
+
+public:
+  virtual ~gfxTextContextPaint() {}
+
+  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;
+  virtual float GetStrokeOpacity() const = 0;
+
+  already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
+                                              const gfxMatrix& aCTM) {
+    return GetFillPattern(aDrawTarget, GetFillOpacity(), aCTM);
+  }
+
+  already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
+                                                const gfxMatrix& aCTM) {
+    return GetStrokePattern(aDrawTarget, GetStrokeOpacity(), aCTM);
+  }
+
+  // XXX This gets the geometry params from the gfxContext.  We should get that
+  // information from the actual paint context!
+  void InitStrokeGeometry(gfxContext *aContext,
+                          float devUnitsPerSVGUnit);
+
+  FallibleTArray<gfxFloat>& GetStrokeDashArray() {
+    return mDashes;
+  }
+
+  gfxFloat GetStrokeDashOffset() {
+    return mDashOffset;
+  }
+
+  gfxFloat GetStrokeWidth() {
+    return mStrokeWidth;
+  }
+
+private:
+  FallibleTArray<gfxFloat> mDashes;
+  gfxFloat mDashOffset;
+  gfxFloat mStrokeWidth;
+};
+
+/**
+ * RAII class used to temporarily set and remove an SVGContextPaint while a
+ * 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,
+                                nsIDocument* aSVGDocument);
+  ~AutoSetRestoreSVGContextPaint();
+private:
+  nsIDocument* mSVGDocument;
+  // The context paint that needs to be restored by our dtor after it removes
+  // aContextPaint:
+  void* mOuterContextPaint;
+};
+
+#endif // MOZILLA_SVGCONTEXTPAINT_H_
+
--- a/layout/svg/SVGTextFrame.h
+++ b/layout/svg/SVGTextFrame.h
@@ -4,19 +4,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_SVGTEXTFRAME_H
 #define MOZILLA_SVGTEXTFRAME_H
 
 #include "mozilla/Attributes.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/gfx/2D.h"
+#include "mozilla/SVGContextPaint.h"
 #include "gfxMatrix.h"
 #include "gfxRect.h"
-#include "gfxSVGGlyphs.h"
 #include "gfxTextRun.h"
 #include "nsAutoPtr.h"
 #include "nsIContent.h" // for GetContent
 #include "nsStubMutationObserver.h"
 #include "nsSVGPaintServerFrame.h"
 
 class gfxContext;
 class nsDisplaySVGText;
@@ -146,20 +146,20 @@ public:
   already_AddRefed<gfxPattern> GetFillPattern(const DrawTarget* aDrawTarget,
                                               float aOpacity,
                                               const gfxMatrix& aCTM) override;
   already_AddRefed<gfxPattern> GetStrokePattern(const DrawTarget* aDrawTarget,
                                                 float aOpacity,
                                                 const gfxMatrix& aCTM) override;
 
   void SetFillOpacity(float aOpacity) { mFillOpacity = aOpacity; }
-  float GetFillOpacity() override { return mFillOpacity; }
+  float GetFillOpacity() const override { return mFillOpacity; }
 
   void SetStrokeOpacity(float aOpacity) { mStrokeOpacity = aOpacity; }
-  float GetStrokeOpacity() override { return mStrokeOpacity; }
+  float GetStrokeOpacity() const override { return mStrokeOpacity; }
 
   struct Paint {
     Paint() : mPaintType(eStyleSVGPaintType_None) {}
 
     void SetPaintServer(nsIFrame *aFrame, const gfxMatrix& aContextMatrix,
                         nsSVGPaintServerFrame *aPaintServerFrame) {
       mPaintType = eStyleSVGPaintType_Server;
       mPaintDefinition.mPaintServerFrame = aPaintServerFrame;
--- a/layout/svg/moz.build
+++ b/layout/svg/moz.build
@@ -12,16 +12,20 @@ EXPORTS += [
     'nsSVGEffects.h',
     'nsSVGFilterInstance.h',
     'nsSVGForeignObjectFrame.h',
     'nsSVGIntegrationUtils.h',
     'nsSVGUtils.h',
     'SVGImageContext.h',
 ]
 
+EXPORTS.mozilla += [
+    'SVGContextPaint.h',
+]
+
 UNIFIED_SOURCES += [
     'nsCSSClipPathInstance.cpp',
     'nsCSSFilterInstance.cpp',
     'nsFilterInstance.cpp',
     'nsSVGAFrame.cpp',
     'nsSVGClipPathFrame.cpp',
     'nsSVGContainerFrame.cpp',
     'nsSVGEffects.cpp',
@@ -38,16 +42,17 @@ UNIFIED_SOURCES += [
     'nsSVGMaskFrame.cpp',
     'nsSVGOuterSVGFrame.cpp',
     'nsSVGPathGeometryFrame.cpp',
     'nsSVGPatternFrame.cpp',
     'nsSVGStopFrame.cpp',
     'nsSVGSwitchFrame.cpp',
     'nsSVGUseFrame.cpp',
     'nsSVGUtils.cpp',
+    'SVGContextPaint.cpp',
     'SVGFEContainerFrame.cpp',
     'SVGFEImageFrame.cpp',
     'SVGFELeafFrame.cpp',
     'SVGFEUnstyledLeafFrame.cpp',
     'SVGTextFrame.cpp',
     'SVGViewFrame.cpp',
 ]
 
--- a/layout/svg/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/nsSVGForeignObjectFrame.cpp
@@ -2,32 +2,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 // Main header first:
 #include "nsSVGForeignObjectFrame.h"
 
 // Keep others in (case-insensitive) order:
+#include "DrawResult.h"
 #include "gfxContext.h"
+#include "nsDisplayList.h"
 #include "nsGkAtoms.h"
 #include "nsNameSpaceManager.h"
 #include "nsLayoutUtils.h"
 #include "nsRegion.h"
 #include "nsRenderingContext.h"
 #include "nsSVGContainerFrame.h"
 #include "nsSVGEffects.h"
 #include "mozilla/dom/SVGForeignObjectElement.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsSVGUtils.h"
 #include "mozilla/AutoRestore.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
+using namespace mozilla::image;
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsContainerFrame*
 NS_NewSVGForeignObjectFrame(nsIPresShell   *aPresShell,
                             nsStyleContext *aContext)
 {
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -5,21 +5,21 @@
 
 // Main header first:
 #include "nsSVGPathGeometryFrame.h"
 
 // Keep others in (case-insensitive) order:
 #include "gfx2DGlue.h"
 #include "gfxContext.h"
 #include "gfxPlatform.h"
-#include "gfxSVGGlyphs.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/Helpers.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/SVGContextPaint.h"
 #include "nsDisplayList.h"
 #include "nsGkAtoms.h"
 #include "nsLayoutUtils.h"
 #include "nsRenderingContext.h"
 #include "nsSVGEffects.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGMarkerFrame.h"
 #include "nsSVGPathGeometryElement.h"
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -13,16 +13,17 @@
 #include "gfxContext.h"
 #include "gfxMatrix.h"
 #include "gfxPlatform.h"
 #include "gfxRect.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PatternHelpers.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/SVGContextPaint.h"
 #include "nsCSSClipPathInstance.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsDisplayList.h"
 #include "nsFilterInstance.h"
 #include "nsFrameList.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
@@ -33,17 +34,16 @@
 #include "nsPresContext.h"
 #include "nsStyleCoord.h"
 #include "nsStyleStruct.h"
 #include "nsSVGClipPathFrame.h"
 #include "nsSVGContainerFrame.h"
 #include "nsSVGEffects.h"
 #include "nsSVGFilterPaintCallback.h"
 #include "nsSVGForeignObjectFrame.h"
-#include "gfxSVGGlyphs.h"
 #include "nsSVGInnerSVGFrame.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGLength2.h"
 #include "nsSVGMaskFrame.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "mozilla/dom/SVGClipPathElement.h"
 #include "mozilla/dom/SVGPathElement.h"
 #include "nsSVGPathGeometryElement.h"