Bug 952977: Switch GetViewBoxTransform to gfx::Matrix r=nical
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 30 Dec 2013 01:50:17 -0500
changeset 178864 0f2c1da63eeb1d289766cdb59447fe2437125dc2
parent 178863 19983d377f5845434608dbf30cdc30608000cf0c
child 178865 7fb529b7829a4ac09f504a3325d8d6c3b377eb4c
push id462
push userraliiev@mozilla.com
push dateTue, 22 Apr 2014 00:22:30 +0000
treeherdermozilla-release@ac5db8c74ac0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs952977
milestone29.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 952977: Switch GetViewBoxTransform to gfx::Matrix r=nical
content/svg/content/src/SVGContentUtils.cpp
content/svg/content/src/SVGContentUtils.h
content/svg/content/src/SVGFEImageElement.cpp
content/svg/content/src/SVGMarkerElement.cpp
content/svg/content/src/SVGMarkerElement.h
content/svg/content/src/SVGSVGElement.cpp
content/svg/content/src/SVGSVGElement.h
layout/svg/nsISVGChildFrame.h
layout/svg/nsSVGContainerFrame.h
layout/svg/nsSVGForeignObjectFrame.cpp
layout/svg/nsSVGForeignObjectFrame.h
layout/svg/nsSVGImageFrame.cpp
layout/svg/nsSVGInnerSVGFrame.cpp
layout/svg/nsSVGInnerSVGFrame.h
layout/svg/nsSVGMarkerFrame.cpp
layout/svg/nsSVGMarkerFrame.h
layout/svg/nsSVGOuterSVGFrame.h
layout/svg/nsSVGPathGeometryFrame.h
layout/svg/nsSVGPatternFrame.cpp
layout/svg/nsSVGPatternFrame.h
--- a/content/svg/content/src/SVGContentUtils.cpp
+++ b/content/svg/content/src/SVGContentUtils.cpp
@@ -267,29 +267,29 @@ SVGContentUtils::AngleBisect(float a1, f
   float r = a1 + delta/2;
   if (delta >= M_PI) {
     /* the arc from a2 to a1 is smaller, so use the ray on that side */
     r += static_cast<float>(M_PI);
   }
   return r;
 }
 
-gfxMatrix
+gfx::Matrix
 SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
                                      float aViewboxX, float aViewboxY,
                                      float aViewboxWidth, float aViewboxHeight,
                                      const SVGAnimatedPreserveAspectRatio &aPreserveAspectRatio)
 {
   return GetViewBoxTransform(aViewportWidth, aViewportHeight,
                              aViewboxX, aViewboxY,
                              aViewboxWidth, aViewboxHeight,
                              aPreserveAspectRatio.GetAnimValue());
 }
 
-gfxMatrix
+gfx::Matrix
 SVGContentUtils::GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
                                      float aViewboxX, float aViewboxY,
                                      float aViewboxWidth, float aViewboxHeight,
                                      const SVGPreserveAspectRatio &aPreserveAspectRatio)
 {
   NS_ASSERTION(aViewportWidth  >= 0, "viewport width must be nonnegative!");
   NS_ASSERTION(aViewportHeight >= 0, "viewport height must be nonnegative!");
   NS_ASSERTION(aViewboxWidth  > 0, "viewBox width must be greater than zero!");
@@ -356,21 +356,21 @@ SVGContentUtils::GetViewBoxTransform(flo
         e = aViewportWidth - a * aViewboxWidth;
         break;
       default:
         NS_NOTREACHED("Unknown value for align");
       }
     }
     else NS_NOTREACHED("Unknown value for meetOrSlice");
   }
-  
+
   if (aViewboxX) e += -a * aViewboxX;
   if (aViewboxY) f += -d * aViewboxY;
-  
-  return gfxMatrix(a, 0.0f, 0.0f, d, e, f);
+
+  return gfx::Matrix(a, 0.0f, 0.0f, d, e, f);
 }
 
 static bool
 ParseNumber(RangedPtr<const PRUnichar>& aIter,
             const RangedPtr<const PRUnichar>& aEnd,
             double& aValue)
 {
   int32_t sign;
--- a/content/svg/content/src/SVGContentUtils.h
+++ b/content/svg/content/src/SVGContentUtils.h
@@ -23,16 +23,20 @@ class nsSVGElement;
 
 namespace mozilla {
 class SVGAnimatedPreserveAspectRatio;
 class SVGPreserveAspectRatio;
 namespace dom {
 class Element;
 class SVGSVGElement;
 } // namespace dom
+
+namespace gfx {
+class Matrix;
+} // namespace gfx
 } // namespace mozilla
 
 inline bool
 IsSVGWhitespace(char aChar)
 {
   return aChar == '\x20' || aChar == '\x9' ||
          aChar == '\xD'  || aChar == '\xA';
 }
@@ -118,23 +122,23 @@ public:
   static double ComputeNormalizedHypotenuse(double aWidth, double aHeight);
 
   /* Returns the angle halfway between the two specified angles */
   static float
   AngleBisect(float a1, float a2);
 
   /* Generate a viewbox to viewport tranformation matrix */
 
-  static gfxMatrix
+  static mozilla::gfx::Matrix
   GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
                       float aViewboxX, float aViewboxY,
                       float aViewboxWidth, float aViewboxHeight,
                       const SVGAnimatedPreserveAspectRatio &aPreserveAspectRatio);
 
-  static gfxMatrix
+  static mozilla::gfx::Matrix
   GetViewBoxTransform(float aViewportWidth, float aViewportHeight,
                       float aViewboxX, float aViewboxY,
                       float aViewboxWidth, float aViewboxHeight,
                       const SVGPreserveAspectRatio &aPreserveAspectRatio);
 
   static mozilla::RangedPtr<const PRUnichar>
   GetStartRangedPtr(const nsAString& aString);
 
--- a/content/svg/content/src/SVGFEImageElement.cpp
+++ b/content/svg/content/src/SVGFEImageElement.cpp
@@ -224,22 +224,22 @@ SVGFEImageElement::GetPrimitiveDescripti
   DrawTarget* dt = platform->ScreenReferenceDrawTarget();
   RefPtr<SourceSurface> image =
     platform->GetSourceSurfaceForSurface(dt, currentFrame);
 
   IntSize nativeSize;
   imageContainer->GetWidth(&nativeSize.width);
   imageContainer->GetHeight(&nativeSize.height);
 
-  gfxMatrix viewBoxTM =
+  Matrix viewBoxTM =
     SVGContentUtils::GetViewBoxTransform(aFilterSubregion.width, aFilterSubregion.height,
                                          0, 0, nativeSize.width, nativeSize.height,
                                          mPreserveAspectRatio);
   Matrix xyTM = Matrix().Translate(aFilterSubregion.x, aFilterSubregion.y);
-  Matrix TM = ToMatrix(viewBoxTM) * xyTM;
+  Matrix TM = viewBoxTM * xyTM;
 
   Filter filter = ToFilter(nsLayoutUtils::GetGraphicsFilterForFrame(frame));
 
   FilterPrimitiveDescription descr(FilterPrimitiveDescription::eImage);
   descr.Attributes().Set(eImageFilter, (uint32_t)filter);
   descr.Attributes().Set(eImageTransform, TM);
 
   // Append the image to aInputImages and store its index in the description.
--- a/content/svg/content/src/SVGMarkerElement.cpp
+++ b/content/svg/content/src/SVGMarkerElement.cpp
@@ -8,17 +8,17 @@
 #include "nsGkAtoms.h"
 #include "nsCOMPtr.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 #include "nsError.h"
 #include "mozilla/dom/SVGAngle.h"
 #include "mozilla/dom/SVGMarkerElement.h"
 #include "mozilla/dom/SVGMarkerElementBinding.h"
 #include "mozilla/Preferences.h"
-#include "gfxMatrix.h"
+#include "mozilla/gfx/Matrix.h"
 #include "SVGContentUtils.h"
 
 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Marker)
 
 namespace mozilla {
 namespace dom {
 
 JSObject*
@@ -329,44 +329,44 @@ SVGMarkerElement::GetViewBoxRect()
     return mViewBox.GetAnimValue();
   }
   return nsSVGViewBoxRect(
            0, 0,
            mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx),
            mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx));
 }
 
-gfxMatrix
+gfx::Matrix
 SVGMarkerElement::GetViewBoxTransform()
 {
   if (!mViewBoxToViewportTransform) {
     float viewportWidth =
       mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx);
     float viewportHeight = 
       mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx);
-   
+
     nsSVGViewBoxRect viewbox = GetViewBoxRect();
 
     NS_ABORT_IF_FALSE(viewbox.width > 0.0f && viewbox.height > 0.0f,
                       "Rendering should be disabled");
 
-    gfxMatrix viewBoxTM =
+    gfx::Matrix viewBoxTM =
       SVGContentUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
                                            viewbox.x, viewbox.y,
                                            viewbox.width, viewbox.height,
                                            mPreserveAspectRatio);
 
     float refX = mLengthAttributes[REFX].GetAnimValue(mCoordCtx);
     float refY = mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
 
-    gfxPoint ref = viewBoxTM.Transform(gfxPoint(refX, refY));
+    gfx::Point ref = viewBoxTM * gfx::Point(refX, refY);
 
-    gfxMatrix TM = viewBoxTM * gfxMatrix().Translate(gfxPoint(-ref.x, -ref.y));
+    gfx::Matrix TM = viewBoxTM * gfx::Matrix().Translate(-ref.x, -ref.y);
 
-    mViewBoxToViewportTransform = new gfxMatrix(TM);
+    mViewBoxToViewportTransform = new gfx::Matrix(TM);
   }
 
   return *mViewBoxToViewportTransform;
 }
 
 /* static */ bool
 SVGMarkerElement::MarkerImprovementsPrefEnabled()
 {
--- a/content/svg/content/src/SVGMarkerElement.h
+++ b/content/svg/content/src/SVGMarkerElement.h
@@ -1,17 +1,16 @@
 /* -*- 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_dom_SVGMarkerElement_h
 #define mozilla_dom_SVGMarkerElement_h
 
-#include "gfxMatrix.h"
 #include "nsSVGAngle.h"
 #include "nsSVGEnum.h"
 #include "nsSVGLength2.h"
 #include "nsSVGViewBox.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
 #include "nsSVGElement.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/SVGAnimatedEnumeration.h"
@@ -116,21 +115,21 @@ public:
 
   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                              bool aNotify) MOZ_OVERRIDE;
 
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const MOZ_OVERRIDE;
 
   // public helpers
-  mozilla::gfx::Matrix GetMarkerTransform(float aStrokeWidth,
-                                          float aX, float aY, float aAutoAngle,
-                                          bool aIsStart);
+  gfx::Matrix GetMarkerTransform(float aStrokeWidth,
+                                 float aX, float aY, float aAutoAngle,
+                                 bool aIsStart);
   nsSVGViewBoxRect GetViewBoxRect();
-  gfxMatrix GetViewBoxTransform();
+  gfx::Matrix GetViewBoxTransform();
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
 
   nsSVGOrientType* GetOrientType() { return &mOrientType; }
 
   // Returns the value of svg.marker-improvements.enabled.
   static bool MarkerImprovementsPrefEnabled();
 
@@ -176,15 +175,15 @@ protected:
 
   nsSVGViewBox             mViewBox;
   SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
 
   // derived properties (from 'orient') handled separately
   nsSVGOrientType                        mOrientType;
 
   SVGSVGElement                         *mCoordCtx;
-  nsAutoPtr<gfxMatrix>                   mViewBoxToViewportTransform;
+  nsAutoPtr<gfx::Matrix>                 mViewBoxToViewportTransform;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_SVGMarkerElement_h
--- a/content/svg/content/src/SVGSVGElement.cpp
+++ b/content/svg/content/src/SVGSVGElement.cpp
@@ -37,16 +37,18 @@
 #include "nsSMILAnimationController.h"
 #include "nsSMILTypes.h"
 #include "SVGAngle.h"
 #include <algorithm>
 #include "prtime.h"
 
 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT_CHECK_PARSER(SVG)
 
+using namespace mozilla::gfx;
+
 namespace mozilla {
 namespace dom {
 
 class SVGAnimatedLength;
 
 JSObject*
 SVGSVGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
@@ -634,38 +636,38 @@ ComputeSynthesizedViewBoxDimension(const
   }
 
   return aLength.GetAnimValue(const_cast<SVGSVGElement*>(aSelf));
 }
 
 //----------------------------------------------------------------------
 // public helpers:
 
-gfxMatrix
+gfx::Matrix
 SVGSVGElement::GetViewBoxTransform() const
 {
   float viewportWidth, viewportHeight;
   if (IsInner()) {
     SVGSVGElement *ctx = GetCtx();
     viewportWidth = mLengthAttributes[ATTR_WIDTH].GetAnimValue(ctx);
     viewportHeight = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(ctx);
   } else {
     viewportWidth = mViewportWidth;
     viewportHeight = mViewportHeight;
   }
 
   if (viewportWidth <= 0.0f || viewportHeight <= 0.0f) {
-    return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
+    return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
   }
 
   nsSVGViewBoxRect viewBox =
     GetViewBoxWithSynthesis(viewportWidth, viewportHeight);
 
   if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
-    return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
+    return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
   }
 
   return SVGContentUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
                                               viewBox.x, viewBox.y,
                                               viewBox.width, viewBox.height,
                                               GetPreserveAspectRatioWithOverride());
 }
 
@@ -960,31 +962,31 @@ SVGSVGElement::PrependLocalTransformsTo(
     return fromUserSpace;
   }
 
   if (IsInner()) {
     float x, y;
     const_cast<SVGSVGElement*>(this)->GetAnimatedLengthValues(&x, &y, nullptr);
     if (aWhich == eAllTransforms) {
       // the common case
-      return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y)) * fromUserSpace;
+      return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix().Translate(gfxPoint(x, y)) * fromUserSpace;
     }
     NS_ABORT_IF_FALSE(aWhich == eChildToUserSpace, "Unknown TransformTypes");
-    return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y));
+    return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix().Translate(gfxPoint(x, y));
   }
 
   if (IsRoot()) {
     gfxMatrix zoomPanTM;
     zoomPanTM.Translate(gfxPoint(mCurrentTranslate.GetX(), mCurrentTranslate.GetY()));
     zoomPanTM.Scale(mCurrentScale, mCurrentScale);
-    return GetViewBoxTransform() * zoomPanTM * fromUserSpace;
+    return ThebesMatrix(GetViewBoxTransform()) * zoomPanTM * fromUserSpace;
   }
 
   // outer-<svg>, but inline in some other content:
-  return GetViewBoxTransform() * fromUserSpace;
+  return ThebesMatrix(GetViewBoxTransform()) * fromUserSpace;
 }
 
 /* virtual */ bool
 SVGSVGElement::HasValidDimensions() const
 {
   return !IsInner() ||
     ((!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
        mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
--- a/content/svg/content/src/SVGSVGElement.h
+++ b/content/svg/content/src/SVGSVGElement.h
@@ -163,17 +163,17 @@ public:
    * Only call this method if HasViewBoxRect() returns false.
    */
   bool ShouldSynthesizeViewBox() const;
 
   bool HasViewBoxOrSyntheticViewBox() const {
     return HasViewBoxRect() || ShouldSynthesizeViewBox();
   }
 
-  gfxMatrix GetViewBoxTransform() const;
+  gfx::Matrix GetViewBoxTransform() const;
 
   bool HasChildrenOnlyTransform() const {
     return mHasChildrenOnlyTransform;
   }
 
   void UpdateHasChildrenOnlyTransform();
 
   enum ChildrenOnlyTransformChangedFlags {
--- a/layout/svg/nsISVGChildFrame.h
+++ b/layout/svg/nsISVGChildFrame.h
@@ -128,17 +128,17 @@ public:
    * @param aToBBoxUserspace The transform from the userspace established by
    *   this element to the userspace established by the ancestor on which
    *   getBBox was called. This will be the identity matrix if we are the
    *   element on which getBBox was called.
    *
    * @param aFlags Flags indicating whether, stroke, for example, should be
    *   included in the bbox calculation.
    */
-  virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
+  virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
                                       uint32_t aFlags) = 0;
 
   // Are we a container frame?
   NS_IMETHOD_(bool) IsDisplayContainer()=0;
 };
 
 #endif // __NS_ISVGCHILDFRAME_H__
 
--- a/layout/svg/nsSVGContainerFrame.h
+++ b/layout/svg/nsSVGContainerFrame.h
@@ -63,17 +63,17 @@ public:
 
   /**
    * Returns true if the frame's content has a transform that applies only to
    * its children, and not to the frame itself. For example, an implicit
    * transform introduced by a 'viewBox' attribute, or an explicit transform
    * due to a root-<svg> having its currentScale/currentTransform properties
    * set. If aTransform is non-null, then it will be set to the transform.
    */
-  virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const {
+  virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const {
     return false;
   }
 
   // nsIFrame:
   NS_IMETHOD AppendFrames(ChildListID     aListID,
                           nsFrameList&    aFrameList) MOZ_OVERRIDE;
   NS_IMETHOD InsertFrames(ChildListID     aListID,
                           nsIFrame*       aPrevFrame,
@@ -136,25 +136,25 @@ public:
  virtual void Init(nsIContent*      aContent,
                    nsIFrame*        aParent,
                    nsIFrame*        aPrevInFlow) MOZ_OVERRIDE;
 
   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                 const nsRect&           aDirtyRect,
                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
 
-  virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform = nullptr,
-                                mozilla::gfx::Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
+  virtual bool IsSVGTransformed(Matrix *aOwnTransform = nullptr,
+                                Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
 
   // nsISVGChildFrame interface:
   NS_IMETHOD PaintSVG(nsRenderingContext* aContext,
                       const nsIntRect *aDirtyRect,
                       nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
   NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
   NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
   virtual void ReflowSVG() MOZ_OVERRIDE;
   virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
-  virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
+  virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
                                       uint32_t aFlags) MOZ_OVERRIDE;
   NS_IMETHOD_(bool) IsDisplayContainer() MOZ_OVERRIDE { return true; }
 };
 
 #endif
--- a/layout/svg/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/nsSVGForeignObjectFrame.cpp
@@ -160,18 +160,18 @@ nsSVGForeignObjectFrame::BuildDisplayLis
 {
   if (!static_cast<const nsSVGElement*>(mContent)->HasValidDimensions()) {
     return;
   }
   BuildDisplayListForNonBlockChildren(aBuilder, aDirtyRect, aLists);
 }
 
 bool
-nsSVGForeignObjectFrame::IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
-                                          mozilla::gfx::Matrix *aFromParentTransform) const
+nsSVGForeignObjectFrame::IsSVGTransformed(Matrix *aOwnTransform,
+                                          Matrix *aFromParentTransform) const
 {
   bool foundTransform = false;
 
   // Check if our parent has children-only transforms:
   nsIFrame *parent = GetParent();
   if (parent &&
       parent->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer)) {
     foundTransform = static_cast<nsSVGContainerFrame*>(parent)->
--- a/layout/svg/nsSVGForeignObjectFrame.h
+++ b/layout/svg/nsSVGForeignObjectFrame.h
@@ -60,18 +60,18 @@ public:
   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
 
   virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
   {
     return nsSVGForeignObjectFrameBase::IsFrameOfType(aFlags &
       ~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject));
   }
 
-  virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
-                                mozilla::gfx::Matrix *aFromParentTransform) const MOZ_OVERRIDE;
+  virtual bool IsSVGTransformed(Matrix *aOwnTransform,
+                                Matrix *aFromParentTransform) const MOZ_OVERRIDE;
 
 #ifdef DEBUG
   NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGForeignObject"), aResult);
   }
 #endif
 
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -228,22 +228,22 @@ nsSVGImageFrame::GetRasterImageTransform
                                          int32_t aNativeHeight,
                                          uint32_t aFor,
                                          nsIFrame* aTransformRoot)
 {
   float x, y, width, height;
   SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
   element->GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
 
-  gfxMatrix viewBoxTM =
+  Matrix viewBoxTM =
     SVGContentUtils::GetViewBoxTransform(width, height,
                                          0, 0, aNativeWidth, aNativeHeight,
                                          element->mPreserveAspectRatio);
 
-  return viewBoxTM *
+  return ThebesMatrix(viewBoxTM) *
          gfxMatrix().Translate(gfxPoint(x, y)) *
          GetCanvasTM(aFor, aTransformRoot);
 }
 
 gfxMatrix
 nsSVGImageFrame::GetVectorImageTransform(uint32_t aFor,
                                          nsIFrame* aTransformRoot)
 {
--- a/layout/svg/nsSVGInnerSVGFrame.cpp
+++ b/layout/svg/nsSVGInnerSVGFrame.cpp
@@ -295,14 +295,14 @@ nsSVGInnerSVGFrame::GetCanvasTM(uint32_t
 bool
 nsSVGInnerSVGFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) const
 {
   SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
 
   if (content->HasViewBoxOrSyntheticViewBox()) {
     // XXX Maybe return false if the transform is the identity transform?
     if (aTransform) {
-      *aTransform = gfx::ToMatrix(content->GetViewBoxTransform());
+      *aTransform = content->GetViewBoxTransform();
     }
     return true;
   }
   return false;
 }
--- a/layout/svg/nsSVGInnerSVGFrame.h
+++ b/layout/svg/nsSVGInnerSVGFrame.h
@@ -60,17 +60,17 @@ public:
   virtual void ReflowSVG() MOZ_OVERRIDE;
   virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
   NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
 
   // nsSVGContainerFrame methods:
   virtual gfxMatrix GetCanvasTM(uint32_t aFor,
                                 nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
 
-  virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE;
+  virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const MOZ_OVERRIDE;
 
   // nsISVGSVGFrame interface:
   virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) MOZ_OVERRIDE;
 
 protected:
 
   nsAutoPtr<gfxMatrix> mCanvasTM;
 };
--- a/layout/svg/nsSVGMarkerFrame.cpp
+++ b/layout/svg/nsSVGMarkerFrame.cpp
@@ -83,19 +83,19 @@ nsSVGMarkerFrame::GetCanvasTM(uint32_t a
   SVGMarkerElement *content = static_cast<SVGMarkerElement*>(mContent);
   
   mInUse2 = true;
   gfxMatrix markedTM = mMarkedFrame->GetCanvasTM(aFor, aTransformRoot);
   mInUse2 = false;
 
   Matrix markerTM = content->GetMarkerTransform(mStrokeWidth, mX, mY,
                                                 mAutoAngle, mIsStart);
-  gfxMatrix viewBoxTM = content->GetViewBoxTransform();
+  Matrix viewBoxTM = content->GetViewBoxTransform();
 
-  return viewBoxTM * ThebesMatrix(markerTM) * markedTM;
+  return ThebesMatrix(viewBoxTM * markerTM) * markedTM;
 }
 
 static nsIFrame*
 GetAnonymousChildFrame(nsIFrame* aFrame)
 {
   nsIFrame* kid = aFrame->GetFirstPrincipalChild();
   MOZ_ASSERT(kid && kid->GetType() == nsGkAtoms::svgMarkerAnonChildFrame,
              "expected to find anonymous child of marker frame");
@@ -181,19 +181,19 @@ nsSVGMarkerFrame::GetMarkBBoxContributio
   mStrokeWidth = aStrokeWidth;
   mX = aMark->x;
   mY = aMark->y;
   mAutoAngle = aMark->angle;
   mIsStart = aMark->type == nsSVGMark::eStart;
 
   Matrix markerTM =
     content->GetMarkerTransform(mStrokeWidth, mX, mY, mAutoAngle, mIsStart);
-  gfxMatrix viewBoxTM = content->GetViewBoxTransform();
+  Matrix viewBoxTM = content->GetViewBoxTransform();
 
-  Matrix tm = ToMatrix(viewBoxTM) * markerTM * aToBBoxUserspace;
+  Matrix tm = viewBoxTM * markerTM * aToBBoxUserspace;
 
   nsISVGChildFrame* child = do_QueryFrame(GetAnonymousChildFrame(this));
   // When we're being called to obtain the invalidation area, we need to
   // pass down all the flags so that stroke is included. However, once DOM
   // getBBox() accepts flags, maybe we should strip some of those here?
 
   // We need to include zero width/height vertical/horizontal lines, so we have
   // to use UnionEdges.
--- a/layout/svg/nsSVGMarkerFrame.h
+++ b/layout/svg/nsSVGMarkerFrame.h
@@ -89,17 +89,17 @@ public:
   }
 
   // nsSVGMarkerFrame methods:
   nsresult PaintMark(nsRenderingContext *aContext,
                      nsSVGPathGeometryFrame *aMarkedFrame,
                      nsSVGMark *aMark,
                      float aStrokeWidth);
 
-  SVGBBox GetMarkBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
+  SVGBBox GetMarkBBoxContribution(const Matrix &aToBBoxUserspace,
                                   uint32_t aFlags,
                                   nsSVGPathGeometryFrame *aMarkedFrame,
                                   const nsSVGMark *aMark,
                                   float aStrokeWidth);
 
 private:
   // stuff needed for callback
   nsSVGPathGeometryFrame *mMarkedFrame;
--- a/layout/svg/nsSVGOuterSVGFrame.h
+++ b/layout/svg/nsSVGOuterSVGFrame.h
@@ -92,18 +92,18 @@ public:
     // Any children must be added to our single anonymous inner frame kid.
     NS_ABORT_IF_FALSE(GetFirstPrincipalChild() &&
                       GetFirstPrincipalChild()->GetType() ==
                         nsGkAtoms::svgOuterSVGAnonChildFrame,
                       "Where is our anonymous child?");
     return GetFirstPrincipalChild()->GetContentInsertionFrame();
   }
 
-  virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
-                                mozilla::gfx::Matrix *aFromParentTransform) const MOZ_OVERRIDE {
+  virtual bool IsSVGTransformed(Matrix *aOwnTransform,
+                                Matrix *aFromParentTransform) const MOZ_OVERRIDE {
     // Our anonymous wrapper performs the transforms. We simply
     // return whether we are transformed here but don't apply the transforms
     // themselves.
     return GetFirstPrincipalChild()->IsSVGTransformed();
   }
 
   // nsISVGSVGFrame interface:
   virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) MOZ_OVERRIDE;
@@ -127,17 +127,17 @@ public:
    * them for areas that need to be invalidated, without having to also search
    * the SVG frame tree for foreignObjects. This is important so that bug 539356
    * does not slow down SVG in general (only foreignObjects, until bug 614732 is
    * fixed).
    */
   void RegisterForeignObject(nsSVGForeignObjectFrame* aFrame);
   void UnregisterForeignObject(nsSVGForeignObjectFrame* aFrame);
 
-  virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE {
+  virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const MOZ_OVERRIDE {
     // Our anonymous wrapper child must claim our children-only transforms as
     // its own so that our real children (the frames it wraps) are transformed
     // by them, and we must pretend we don't have any children-only transforms
     // so that our anonymous child is _not_ transformed by them.
     return false;
   }
 
   /**
@@ -265,12 +265,12 @@ public:
   virtual gfxMatrix GetCanvasTM(uint32_t aFor,
                                 nsIFrame* aTransformRoot) MOZ_OVERRIDE {
     // GetCanvasTM returns the transform from an SVG frame to the frame's
     // nsSVGOuterSVGFrame's content box, so we do not include any x/y offset
     // set on us for any CSS border or padding on our nsSVGOuterSVGFrame.
     return static_cast<nsSVGOuterSVGFrame*>(mParent)->GetCanvasTM(aFor, aTransformRoot);
   }
 
-  virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE;
+  virtual bool HasChildrenOnlyTransform(Matrix *aTransform) const MOZ_OVERRIDE;
 };
 
 #endif
--- a/layout/svg/nsSVGPathGeometryFrame.h
+++ b/layout/svg/nsSVGPathGeometryFrame.h
@@ -61,18 +61,18 @@ public:
 
   /**
    * Get the "type" of the frame
    *
    * @see nsGkAtoms::svgPathGeometryFrame
    */
   virtual nsIAtom* GetType() const MOZ_OVERRIDE;
 
-  virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransforms = nullptr,
-                                mozilla::gfx::Matrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
+  virtual bool IsSVGTransformed(Matrix *aOwnTransforms = nullptr,
+                                Matrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
 
 #ifdef DEBUG
   NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
   {
     return MakeFrameName(NS_LITERAL_STRING("SVGPathGeometry"), aResult);
   }
 #endif
 
@@ -88,17 +88,17 @@ protected:
   // nsISVGChildFrame interface:
   NS_IMETHOD PaintSVG(nsRenderingContext *aContext,
                       const nsIntRect *aDirtyRect,
                       nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
   NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint) MOZ_OVERRIDE;
   NS_IMETHOD_(nsRect) GetCoveredRegion() MOZ_OVERRIDE;
   virtual void ReflowSVG() MOZ_OVERRIDE;
   virtual void NotifySVGChanged(uint32_t aFlags) MOZ_OVERRIDE;
-  virtual SVGBBox GetBBoxContribution(const mozilla::gfx::Matrix &aToBBoxUserspace,
+  virtual SVGBBox GetBBoxContribution(const Matrix &aToBBoxUserspace,
                                       uint32_t aFlags) MOZ_OVERRIDE;
   NS_IMETHOD_(bool) IsDisplayContainer() MOZ_OVERRIDE { return false; }
 
 protected:
   void GeneratePath(gfxContext *aContext, const gfxMatrix &aTransform);
 
 private:
   enum { eRenderFill = 1, eRenderStroke = 2 };
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -674,23 +674,23 @@ nsSVGPatternFrame::ConstructCTM(const ns
     viewportHeight =
       GetLengthValue(SVGPatternElement::ATTR_HEIGHT)->GetAnimValue(aTarget);
   }
 
   if (viewportWidth <= 0.0f || viewportHeight <= 0.0f) {
     return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
   }
 
-  gfxMatrix tm = SVGContentUtils::GetViewBoxTransform(
+  Matrix tm = SVGContentUtils::GetViewBoxTransform(
     viewportWidth, viewportHeight,
     viewBoxRect.x, viewBoxRect.y,
     viewBoxRect.width, viewBoxRect.height,
     GetPreserveAspectRatio());
 
-  return tm * tCTM;
+  return ThebesMatrix(tm) * tCTM;
 }
 
 //----------------------------------------------------------------------
 // nsSVGPaintServerFrame methods:
 
 already_AddRefed<gfxPattern>
 nsSVGPatternFrame::GetPaintServerPattern(nsIFrame *aSource,
                                          const gfxMatrix& aContextMatrix,
--- a/layout/svg/nsSVGPatternFrame.h
+++ b/layout/svg/nsSVGPatternFrame.h
@@ -26,18 +26,16 @@ class nsSVGAnimatedTransformList;
 typedef nsSVGPaintServerFrame  nsSVGPatternFrameBase;
 
 /**
  * Patterns can refer to other patterns. We create an nsSVGPaintingProperty
  * with property type nsGkAtoms::href to track the referenced pattern.
  */
 class nsSVGPatternFrame : public nsSVGPatternFrameBase
 {
-  typedef mozilla::gfx::Matrix Matrix;
-
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   friend nsIFrame* NS_NewSVGPatternFrame(nsIPresShell* aPresShell,
                                          nsStyleContext* aContext);
 
   nsSVGPatternFrame(nsStyleContext* aContext);