Bug 602759 part 13 - Update layout to use new matrix and transform types; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Sun, 25 Sep 2011 22:04:32 +0100
changeset 77557 c9a9397f6db3e27cff0cf5ba8ed1fa4c3b9d85c2
parent 77556 af1b9b6267bfcb5e98caa903129fec1ae273e01c
child 77558 6e72c9d97a42e0b58e5136aeaca64d304a757a47
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjwatt
bugs602759
milestone9.0a1
Bug 602759 part 13 - Update layout to use new matrix and transform types; r=jwatt
layout/svg/base/src/nsSVGAFrame.cpp
layout/svg/base/src/nsSVGClipPathFrame.cpp
layout/svg/base/src/nsSVGClipPathFrame.h
layout/svg/base/src/nsSVGForeignObjectFrame.cpp
layout/svg/base/src/nsSVGForeignObjectFrame.h
layout/svg/base/src/nsSVGGFrame.cpp
layout/svg/base/src/nsSVGGFrame.h
layout/svg/base/src/nsSVGGlyphFrame.cpp
layout/svg/base/src/nsSVGGlyphFrame.h
layout/svg/base/src/nsSVGGradientFrame.cpp
layout/svg/base/src/nsSVGInnerSVGFrame.cpp
layout/svg/base/src/nsSVGInnerSVGFrame.h
layout/svg/base/src/nsSVGMaskFrame.cpp
layout/svg/base/src/nsSVGMaskFrame.h
layout/svg/base/src/nsSVGOuterSVGFrame.cpp
layout/svg/base/src/nsSVGOuterSVGFrame.h
layout/svg/base/src/nsSVGPatternFrame.cpp
layout/svg/base/src/nsSVGPatternFrame.h
layout/svg/base/src/nsSVGTextFrame.cpp
layout/svg/base/src/nsSVGTextFrame.h
layout/svg/base/src/nsSVGUtils.cpp
layout/svg/base/src/nsSVGUtils.h
--- a/layout/svg/base/src/nsSVGAFrame.cpp
+++ b/layout/svg/base/src/nsSVGAFrame.cpp
@@ -34,17 +34,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGTSpanFrame.h"
 #include "nsISVGGlyphFragmentNode.h"
 #include "nsSVGGraphicElement.h"
-#include "nsSVGMatrix.h"
 #include "nsSVGAElement.h"
 #include "nsSVGUtils.h"
 #include "gfxMatrix.h"
 #include "SVGLengthList.h"
 
 // <a> elements can contain text. nsSVGGlyphFrames expect to have
 // a class derived from nsSVGTextContainerFrame as a parent. We
 // also need something that implements nsISVGGlyphFragmentNode to get
@@ -98,17 +97,17 @@ public:
   // nsSVGTextContainerFrame methods:
   virtual void GetXY(mozilla::SVGUserUnitList *aX, mozilla::SVGUserUnitList *aY);
   virtual void GetDxDy(mozilla::SVGUserUnitList *aDx, mozilla::SVGUserUnitList *aDy);
   virtual const SVGNumberList* GetRotate() {
     return nsnull;
   }
 
 private:
-  nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
+  nsAutoPtr<gfxMatrix> mCanvasTM;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
@@ -183,20 +182,20 @@ nsSVGAFrame::GetCanvasTM()
   if (!mCanvasTM) {
     NS_ASSERTION(mParent, "null parent");
 
     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
     nsSVGAElement *content = static_cast<nsSVGAElement*>(mContent);
 
     gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
 
-    mCanvasTM = NS_NewSVGMatrix(tm);
+    mCanvasTM = new gfxMatrix(tm);
   }
 
-  return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
+  return *mCanvasTM;
 }
 
 //----------------------------------------------------------------------
 // nsSVGTextContainerFrame methods:
 
 void
 nsSVGAFrame::GetXY(SVGUserUnitList *aX, SVGUserUnitList *aY)
 {
--- a/layout/svg/base/src/nsSVGClipPathFrame.cpp
+++ b/layout/svg/base/src/nsSVGClipPathFrame.cpp
@@ -38,17 +38,16 @@
 #include "nsIDocument.h"
 #include "nsIDOMSVGClipPathElement.h"
 #include "nsSVGClipPathFrame.h"
 #include "nsGkAtoms.h"
 #include "nsSVGUtils.h"
 #include "nsSVGEffects.h"
 #include "nsSVGClipPathElement.h"
 #include "gfxContext.h"
-#include "nsSVGMatrix.h"
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsSVGClipPathFrame(aContext);
@@ -66,17 +65,21 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRende
   // has a clip reference loop.
   if (mInUse) {
     NS_WARNING("Clip loop detected!");
     return NS_OK;
   }
   AutoClipPathReferencer clipRef(this);
 
   mClipParent = aParent;
-  mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
+  if (mClipParentMatrix) {
+    *mClipParentMatrix = aMatrix;
+  } else {
+    mClipParentMatrix = new gfxMatrix(aMatrix);
+  }
 
   PRBool isTrivial = IsTrivial();
 
   nsAutoSVGRenderMode mode(aContext,
                            isTrivial ? nsSVGRenderState::CLIP
                                      : nsSVGRenderState::CLIP_MASK);
 
 
@@ -178,17 +181,21 @@ nsSVGClipPathFrame::ClipHitTest(nsIFrame
   // and the document has a clip reference loop.
   if (mInUse) {
     NS_WARNING("Clip loop detected!");
     return PR_FALSE;
   }
   AutoClipPathReferencer clipRef(this);
 
   mClipParent = aParent;
-  mClipParentMatrix = NS_NewSVGMatrix(aMatrix);
+  if (mClipParentMatrix) {
+    *mClipParentMatrix = aMatrix;
+  } else {
+    mClipParentMatrix = new gfxMatrix(aMatrix);
+  }
 
   nsSVGClipPathFrame *clipPathFrame =
     nsSVGEffects::GetEffectProperties(this).GetClipPathFrame(nsnull);
   if (clipPathFrame && !clipPathFrame->ClipHitTest(aParent, aMatrix, aPoint))
     return PR_FALSE;
 
   for (nsIFrame* kid = mFrames.FirstChild(); kid;
        kid = kid->GetNextSibling()) {
@@ -314,15 +321,16 @@ nsSVGClipPathFrame::GetType() const
   return nsGkAtoms::svgClipPathFrame;
 }
 
 gfxMatrix
 nsSVGClipPathFrame::GetCanvasTM()
 {
   nsSVGClipPathElement *content = static_cast<nsSVGClipPathElement*>(mContent);
 
-  gfxMatrix tm = content->PrependLocalTransformTo(
-    nsSVGUtils::ConvertSVGMatrixToThebes(mClipParentMatrix));
+  gfxMatrix tm =
+    content->PrependLocalTransformTo(mClipParentMatrix ?
+                                     *mClipParentMatrix : gfxMatrix());
 
   return nsSVGUtils::AdjustMatrixForUnits(tm,
                                           &content->mEnumAttributes[nsSVGClipPathElement::CLIPPATHUNITS],
                                           mClipParent);
 }
--- a/layout/svg/base/src/nsSVGClipPathFrame.h
+++ b/layout/svg/base/src/nsSVGClipPathFrame.h
@@ -44,17 +44,16 @@ typedef nsSVGContainerFrame nsSVGClipPat
 
 class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
 {
   friend nsIFrame*
   NS_NewSVGClipPathFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
 protected:
   nsSVGClipPathFrame(nsStyleContext* aContext) :
     nsSVGClipPathFrameBase(aContext),
-    mClipParentMatrix(nsnull),
     mInUse(PR_FALSE) {}
 
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsSVGClipPathFrame methods:
   nsresult ClipPaint(nsSVGRenderState* aContext,
                      nsIFrame* aParent,
@@ -110,17 +109,17 @@ public:
     ~AutoClipPathReferencer() {
       mFrame->mInUse = PR_FALSE;
     }
   private:
     nsSVGClipPathFrame *mFrame;
   };
 
   nsIFrame *mClipParent;
-  nsCOMPtr<nsIDOMSVGMatrix> mClipParentMatrix;
+  nsAutoPtr<gfxMatrix> mClipParentMatrix;
   // recursion prevention flag
   PRPackedBool mInUse;
 
   // nsSVGContainerFrame methods:
   virtual gfxMatrix GetCanvasTM();
 };
 
 #endif
--- a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp
+++ b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp
@@ -42,17 +42,16 @@
 #include "nsIDOMSVGSVGElement.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsRegion.h"
 #include "nsGkAtoms.h"
 #include "nsLayoutUtils.h"
 #include "nsSVGUtils.h"
 #include "nsIURI.h"
 #include "nsSVGRect.h"
-#include "nsSVGMatrix.h"
 #include "nsINameSpaceManager.h"
 #include "nsSVGForeignObjectElement.h"
 #include "nsSVGContainerFrame.h"
 #include "gfxContext.h"
 #include "gfxMatrix.h"
 
 //----------------------------------------------------------------------
 // Implementation
@@ -462,19 +461,19 @@ nsSVGForeignObjectFrame::GetCanvasTM()
     NS_ASSERTION(mParent, "null parent");
 
     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
     nsSVGForeignObjectElement *content =
       static_cast<nsSVGForeignObjectElement*>(mContent);
 
     gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
 
-    mCanvasTM = NS_NewSVGMatrix(tm);
+    mCanvasTM = new gfxMatrix(tm);
   }
-  return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
+  return *mCanvasTM;
 }
 
 //----------------------------------------------------------------------
 // Implementation helpers
 
 gfxMatrix
 nsSVGForeignObjectFrame::GetCanvasTMForChildren()
 {
--- a/layout/svg/base/src/nsSVGForeignObjectFrame.h
+++ b/layout/svg/base/src/nsSVGForeignObjectFrame.h
@@ -36,17 +36,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef NSSVGFOREIGNOBJECTFRAME_H__
 #define NSSVGFOREIGNOBJECTFRAME_H__
 
 #include "nsContainerFrame.h"
 #include "nsISVGChildFrame.h"
-#include "nsIDOMSVGMatrix.h"
 #include "nsRegion.h"
 #include "nsIPresShell.h"
 #include "gfxRect.h"
 #include "gfxMatrix.h"
 
 class nsSVGOuterSVGFrame;
 
 typedef nsContainerFrame nsSVGForeignObjectFrameBase;
@@ -148,17 +147,17 @@ protected:
   gfxMatrix GetCanvasTMForChildren();
   void InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter,
                            const nsRect& aRect, PRUint32 aFlags);
   void FlushDirtyRegion(PRUint32 aFlags);
 
   // If width or height is less than or equal to zero we must disable rendering
   PRBool IsDisabled() const { return mRect.width <= 0 || mRect.height <= 0; }
 
-  nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
+  nsAutoPtr<gfxMatrix> mCanvasTM;
 
   // Areas dirtied by changes to decendents that are in our document
   nsRegion mSameDocDirtyRegion;
 
   // Areas dirtied by changes to sub-documents embedded by our decendents
   nsRegion mSubDocDirtyRegion;
 
   PRPackedBool mInReflow;
--- a/layout/svg/base/src/nsSVGGFrame.cpp
+++ b/layout/svg/base/src/nsSVGGFrame.cpp
@@ -34,17 +34,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMSVGTransformable.h"
 #include "nsSVGGFrame.h"
 #include "nsIFrame.h"
-#include "nsSVGMatrix.h"
 #include "nsGkAtoms.h"
 #include "nsSVGUtils.h"
 #include "nsSVGGraphicElement.h"
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
@@ -95,19 +94,19 @@ nsSVGGFrame::GetCanvasTM()
   if (!mCanvasTM) {
     NS_ASSERTION(mParent, "null parent");
 
     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
     nsSVGGraphicElement *content = static_cast<nsSVGGraphicElement*>(mContent);
 
     gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
 
-    mCanvasTM = NS_NewSVGMatrix(tm);
+    mCanvasTM = new gfxMatrix(tm);
   }
-  return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
+  return *mCanvasTM;
 }
 
 NS_IMETHODIMP
 nsSVGGFrame::AttributeChanged(PRInt32         aNameSpaceID,
                               nsIAtom*        aAttribute,
                               PRInt32         aModType)
 {
   if (aNameSpaceID == kNameSpaceID_None &&
--- a/layout/svg/base/src/nsSVGGFrame.h
+++ b/layout/svg/base/src/nsSVGGFrame.h
@@ -81,12 +81,12 @@ public:
                               PRInt32         aModType);
 
   // nsISVGChildFrame interface:
   virtual void NotifySVGChanged(PRUint32 aFlags);
 
   // nsSVGContainerFrame methods:
   virtual gfxMatrix GetCanvasTM();
 
-  nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
+  nsAutoPtr<gfxMatrix> mCanvasTM;
 };
 
 #endif
--- a/layout/svg/base/src/nsSVGGlyphFrame.cpp
+++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp
@@ -634,17 +634,21 @@ nsSVGGlyphFrame::FillCharacters(Characte
     mTextRun->Draw(aContext, gfxPoint(0, 0), i, aIter->ClusterLength(),
                    nsnull, nsnull);
   }
 }
 
 gfxRect
 nsSVGGlyphFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
 {
-  mOverrideCanvasTM = NS_NewSVGMatrix(aToBBoxUserspace);
+  if (mOverrideCanvasTM) {
+    *mOverrideCanvasTM = aToBBoxUserspace;
+  } else {
+    mOverrideCanvasTM = new gfxMatrix(aToBBoxUserspace);
+  }
 
   nsRefPtr<gfxContext> tmpCtx = MakeTmpCtx();
   SetupGlobalTransform(tmpCtx);
   CharacterIterator iter(this, PR_TRUE);
   iter.SetInitialMatrix(tmpCtx);
   AddBoundingBoxesToPath(&iter, tmpCtx);
   tmpCtx->IdentityMatrix();
 
@@ -655,17 +659,17 @@ nsSVGGlyphFrame::GetBBoxContribution(con
 
 //----------------------------------------------------------------------
 // nsSVGGeometryFrame methods:
 
 gfxMatrix
 nsSVGGlyphFrame::GetCanvasTM()
 {
   if (mOverrideCanvasTM) {
-    return nsSVGUtils::ConvertSVGMatrixToThebes(mOverrideCanvasTM);
+    return *mOverrideCanvasTM;
   }
   NS_ASSERTION(mParent, "null parent");
   return static_cast<nsSVGContainerFrame*>(mParent)->GetCanvasTM();
 }
 
 //----------------------------------------------------------------------
 // nsSVGGlyphFrame methods:
 
--- a/layout/svg/base/src/nsSVGGlyphFrame.h
+++ b/layout/svg/base/src/nsSVGGlyphFrame.h
@@ -41,17 +41,16 @@
 
 #include "nsSVGGeometryFrame.h"
 #include "nsISVGGlyphFragmentNode.h"
 #include "nsISVGChildFrame.h"
 #include "gfxContext.h"
 #include "gfxFont.h"
 #include "gfxRect.h"
 #include "gfxMatrix.h"
-#include "nsSVGMatrix.h"
 #include "nsTextFragment.h"
 
 class nsSVGTextFrame;
 class nsSVGTextPathFrame;
 class nsSVGGlyphFrame;
 class CharacterIterator;
 struct CharacterPosition;
 
@@ -242,17 +241,17 @@ protected:
                             float aMetricsScale);
   gfxFloat GetBaselineOffset(float aMetricsScale);
 
   virtual void GetDxDy(SVGUserUnitList *aDx, SVGUserUnitList *aDy);
   virtual const SVGNumberList *GetRotate();
 
   // Used to support GetBBoxContribution by making GetConvasTM use this as the
   // parent transform instead of the real CanvasTM.
-  nsCOMPtr<nsIDOMSVGMatrix> mOverrideCanvasTM;
+  nsAutoPtr<gfxMatrix> mOverrideCanvasTM;
 
   // Owning pointer, must call gfxTextRunWordCache::RemoveTextRun before deleting
   gfxTextRun *mTextRun;
   gfxPoint mPosition;
   // The start index into the position and rotation data
   PRUint32 mStartIndex;
   PRPackedBool mCompressWhitespace;
   PRPackedBool mTrimLeadingWhitespace;
--- a/layout/svg/base/src/nsSVGGradientFrame.cpp
+++ b/layout/svg/base/src/nsSVGGradientFrame.cpp
@@ -34,27 +34,28 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMSVGAnimatedNumber.h"
 #include "nsIDOMSVGAnimTransformList.h"
-#include "nsSVGTransformList.h"
-#include "nsSVGMatrix.h"
+#include "SVGAnimatedTransformList.h"
 #include "nsSVGEffects.h"
 #include "nsIDOMSVGStopElement.h"
 #include "nsSVGGradientElement.h"
 #include "nsSVGGeometryFrame.h"
 #include "nsSVGGradientFrame.h"
 #include "gfxContext.h"
 #include "gfxPattern.h"
 #include "nsContentUtils.h"
 
+using mozilla::SVGAnimatedTransformList;
+
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGGradientFrame::nsSVGGradientFrame(nsStyleContext* aContext) :
   nsSVGGradientFrameBase(aContext),
   mLoopFlag(PR_FALSE),
   mNoHRefURI(PR_FALSE)
 {
@@ -155,28 +156,24 @@ nsSVGGradientFrame::GetGradientTransform
 
     gfxRect bbox = aOverrideBounds ? *aOverrideBounds : nsSVGUtils::GetBBox(aSource);
     bboxMatrix = gfxMatrix(bbox.Width(), 0, 0, bbox.Height(), bbox.X(), bbox.Y());
   }
 
   nsSVGGradientElement *element =
     GetGradientWithAttr(nsGkAtoms::gradientTransform, mContent);
 
-  if (!element->mGradientTransform)
+  SVGAnimatedTransformList* animTransformList =
+    element->GetAnimatedTransformList();
+  if (!animTransformList)
     return bboxMatrix;
 
-  nsCOMPtr<nsIDOMSVGTransformList> trans;
-  element->mGradientTransform->GetAnimVal(getter_AddRefs(trans));
-  nsCOMPtr<nsIDOMSVGMatrix> gradientTransform =
-    nsSVGTransformList::GetConsolidationMatrix(trans);
-
-  if (!gradientTransform)
-    return bboxMatrix;
-
-  return bboxMatrix.PreMultiply(nsSVGUtils::ConvertSVGMatrixToThebes(gradientTransform));
+  gfxMatrix gradientTransform =
+    animTransformList->GetAnimValue().GetConsolidationMatrix();
+  return bboxMatrix.PreMultiply(gradientTransform);
 }
 
 PRUint16
 nsSVGGradientFrame::GetSpreadMethod()
 {
   nsSVGGradientElement *element =
     GetGradientWithAttr(nsGkAtoms::spreadMethod, mContent);
 
--- a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp
+++ b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp
@@ -36,17 +36,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGInnerSVGFrame.h"
 #include "nsIFrame.h"
 #include "nsISVGChildFrame.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsIDOMSVGAnimatedRect.h"
-#include "nsSVGMatrix.h"
 #include "nsSVGSVGElement.h"
 #include "nsSVGContainerFrame.h"
 #include "gfxContext.h"
 
 nsIFrame*
 NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsSVGInnerSVGFrame(aContext);
@@ -267,13 +266,13 @@ nsSVGInnerSVGFrame::GetCanvasTM()
   if (!mCanvasTM) {
     NS_ASSERTION(mParent, "null parent");
 
     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
     nsSVGSVGElement *content = static_cast<nsSVGSVGElement*>(mContent);
 
     gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
 
-    mCanvasTM = NS_NewSVGMatrix(tm);
+    mCanvasTM = new gfxMatrix(tm);
   }
-  return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
+  return *mCanvasTM;
 }
 
--- a/layout/svg/base/src/nsSVGInnerSVGFrame.h
+++ b/layout/svg/base/src/nsSVGInnerSVGFrame.h
@@ -93,10 +93,10 @@ public:
 
   // nsISVGSVGFrame interface:
   NS_IMETHOD SuspendRedraw();
   NS_IMETHOD UnsuspendRedraw();
   NS_IMETHOD NotifyViewportChange();
 
 protected:
 
-  nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
+  nsAutoPtr<gfxMatrix> mCanvasTM;
 };
--- a/layout/svg/base/src/nsSVGMaskFrame.cpp
+++ b/layout/svg/base/src/nsSVGMaskFrame.cpp
@@ -34,20 +34,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDocument.h"
 #include "nsSVGMaskFrame.h"
 #include "nsSVGContainerFrame.h"
 #include "nsSVGMaskElement.h"
 #include "nsSVGEffects.h"
-#include "nsIDOMSVGMatrix.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
-#include "nsSVGMatrix.h"
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIFrame*
 NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsSVGMaskFrame(aContext);
@@ -113,17 +111,21 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRe
     new gfxImageSurface(surfaceSize, gfxASurface::ImageFormatARGB32);
   if (!image || image->CairoStatus())
     return nsnull;
   image->SetDeviceOffset(-clipExtents.TopLeft());
 
   nsSVGRenderState tmpState(image);
 
   mMaskParent = aParent;
-  mMaskParentMatrix = NS_NewSVGMatrix(aMatrix);
+  if (mMaskParentMatrix) {
+    *mMaskParentMatrix = aMatrix;
+  } else {
+    mMaskParentMatrix = new gfxMatrix(aMatrix);
+  }
 
   for (nsIFrame* kid = mFrames.FirstChild(); kid;
        kid = kid->GetNextSibling()) {
     // The CTM of each frame referencing us can be different
     nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
     if (SVGFrame) {
       SVGFrame->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION |
                                  nsISVGChildFrame::TRANSFORM_CHANGED);
@@ -198,13 +200,14 @@ nsSVGMaskFrame::GetType() const
 
 gfxMatrix
 nsSVGMaskFrame::GetCanvasTM()
 {
   NS_ASSERTION(mMaskParentMatrix, "null parent matrix");
 
   nsSVGMaskElement *mask = static_cast<nsSVGMaskElement*>(mContent);
 
-  return nsSVGUtils::AdjustMatrixForUnits(nsSVGUtils::ConvertSVGMatrixToThebes(mMaskParentMatrix),
-                                          &mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
-                                          mMaskParent);
+  return nsSVGUtils::AdjustMatrixForUnits(
+    mMaskParentMatrix ? *mMaskParentMatrix : gfxMatrix(),
+    &mask->mEnumAttributes[nsSVGMaskElement::MASKCONTENTUNITS],
+    mMaskParent);
 }
 
--- a/layout/svg/base/src/nsSVGMaskFrame.h
+++ b/layout/svg/base/src/nsSVGMaskFrame.h
@@ -47,17 +47,16 @@ typedef nsSVGContainerFrame nsSVGMaskFra
 
 class nsSVGMaskFrame : public nsSVGMaskFrameBase
 {
   friend nsIFrame*
   NS_NewSVGMaskFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
 protected:
   nsSVGMaskFrame(nsStyleContext* aContext) :
     nsSVGMaskFrameBase(aContext),
-    mMaskParentMatrix(nsnull),
     mInUse(PR_FALSE) {}
 
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsSVGMaskFrame method:
   already_AddRefed<gfxPattern> ComputeMaskAlpha(nsSVGRenderState *aContext,
                                                 nsIFrame* aParent,
@@ -104,17 +103,17 @@ private:
     ~AutoMaskReferencer() {
       mFrame->mInUse = PR_FALSE;
     }
   private:
     nsSVGMaskFrame *mFrame;
   };
 
   nsIFrame *mMaskParent;
-  nsCOMPtr<nsIDOMSVGMatrix> mMaskParentMatrix;
+  nsAutoPtr<gfxMatrix> mMaskParentMatrix;
   // recursion prevention flag
   PRPackedBool mInUse;
 
   // nsSVGContainerFrame methods:
   virtual gfxMatrix GetCanvasTM();
 };
 
 #endif
--- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
@@ -48,17 +48,16 @@
 #include "gfxRect.h"
 #include "nsIContentViewer.h"
 #include "nsIDocShell.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsSVGMatrix.h"
 
 namespace dom = mozilla::dom;
 
 class nsSVGMutationObserver : public nsStubMutationObserver
 {
 public:
   // nsIMutationObserver interface
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
@@ -788,19 +787,19 @@ nsSVGOuterSVGFrame::GetCanvasTM()
     gfxMatrix zoomPanTM;
     if (mIsRootContent) {
       const nsSVGTranslatePoint& translate = content->GetCurrentTranslate();
       zoomPanTM.Translate(gfxPoint(translate.GetX(), translate.GetY()));
       zoomPanTM.Scale(content->GetCurrentScale(), content->GetCurrentScale());
     }
 
     gfxMatrix TM = viewBoxTM * zoomPanTM * gfxMatrix().Scale(devPxPerCSSPx, devPxPerCSSPx);
-    mCanvasTM = NS_NewSVGMatrix(TM);
+    mCanvasTM = new gfxMatrix(TM);
   }
-  return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
+  return *mCanvasTM;
 }
 
 //----------------------------------------------------------------------
 // Implementation helpers
 
 void
 nsSVGOuterSVGFrame::RegisterForeignObject(nsSVGForeignObjectFrame* aFrame)
 {
--- a/layout/svg/base/src/nsSVGOuterSVGFrame.h
+++ b/layout/svg/base/src/nsSVGOuterSVGFrame.h
@@ -166,17 +166,17 @@ protected:
   PRBool IsRootOfImage();
 
   // A hash-set containing our nsSVGForeignObjectFrame descendants. Note we use
   // a hash-set to avoid the O(N^2) behavior we'd get tearing down an SVG frame
   // subtree if we were to use a list (see bug 381285 comment 20).
   nsTHashtable<nsVoidPtrHashKey> mForeignObjectHash;
 
   PRUint32 mRedrawSuspendCount;
-  nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
+  nsAutoPtr<gfxMatrix> mCanvasTM;
 
   float mFullZoom;
 
   PRPackedBool mViewportInitialized;
 #ifdef XP_MACOSX
   PRPackedBool mEnableBitmapFallback;
 #endif
   PRPackedBool mIsRootContent;
--- a/layout/svg/base/src/nsSVGPatternFrame.cpp
+++ b/layout/svg/base/src/nsSVGPatternFrame.cpp
@@ -35,28 +35,26 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSVGPatternFrame.h"
 
 #include "nsGkAtoms.h"
 #include "nsIDOMSVGAnimatedRect.h"
-#include "nsSVGTransformList.h"
+#include "SVGAnimatedTransformList.h"
 #include "nsStyleContext.h"
 #include "nsINameSpaceManager.h"
 #include "nsISVGChildFrame.h"
-#include "nsSVGMatrix.h"
 #include "nsSVGRect.h"
 #include "nsSVGUtils.h"
 #include "nsSVGEffects.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsSVGPatternElement.h"
 #include "nsSVGGeometryFrame.h"
-#include "nsSVGAnimatedTransformList.h"
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "gfxPattern.h"
 #include "gfxMatrix.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
@@ -159,17 +157,17 @@ nsSVGPatternFrame::GetType() const
 // If our GetCanvasTM is getting called, we
 // need to return *our current* transformation
 // matrix, which depends on our units parameters
 // and X, Y, Width, and Height
 gfxMatrix
 nsSVGPatternFrame::GetCanvasTM()
 {
   if (mCTM) {
-    return nsSVGUtils::ConvertSVGMatrixToThebes(mCTM);
+    return *mCTM;
   }
 
   // Do we know our rendering parent?
   if (mSource) {
     // Yes, use it!
     return mSource->GetCanvasTM();
   }
 
@@ -236,17 +234,21 @@ nsSVGPatternFrame::PaintPattern(gfxASurf
   gfxMatrix ctm = ConstructCTM(callerBBox, callerCTM, aSource);
   if (ctm.IsSingular()) {
     return NS_ERROR_FAILURE;
   }
 
   // Get the pattern we are going to render
   nsSVGPatternFrame *patternFrame =
     static_cast<nsSVGPatternFrame*>(firstKid->GetParent());
-  patternFrame->mCTM = NS_NewSVGMatrix(ctm);
+  if (patternFrame->mCTM) {
+    *patternFrame->mCTM = ctm;
+  } else {
+    patternFrame->mCTM = new gfxMatrix(ctm);
+  }
 
   // Get the bounding box of the pattern.  This will be used to determine
   // the size of the surface, and will also be used to define the bounding
   // box for the pattern tile.
   gfxRect bbox = GetPatternRect(callerBBox, callerCTM, aSource);
 
   // Get the transformation matrix that we will hand to the renderer's pattern
   // routine.
@@ -265,23 +267,21 @@ nsSVGPatternFrame::PaintPattern(gfxASurf
   // 0 disables rendering, < 0 is an error
   if (surfaceSize.width <= 0 || surfaceSize.height <= 0)
     return NS_ERROR_FAILURE;
 
   if (resultOverflows ||
       patternWidth != surfaceSize.width ||
       patternHeight != surfaceSize.height) {
     // scale drawing to pattern surface size
-    nsCOMPtr<nsIDOMSVGMatrix> tempTM, aCTM;
-    NS_NewSVGMatrix(getter_AddRefs(tempTM),
-                    surfaceSize.width / patternWidth, 0.0f,
-                    0.0f, surfaceSize.height / patternHeight,
-                    0.0f, 0.0f);
-    patternFrame->mCTM->Multiply(tempTM, getter_AddRefs(aCTM));
-    aCTM.swap(patternFrame->mCTM);
+    gfxMatrix tempTM =
+      gfxMatrix(surfaceSize.width / patternWidth, 0.0f,
+                0.0f, surfaceSize.height / patternHeight,
+                0.0f, 0.0f);
+    patternFrame->mCTM->PreMultiply(tempTM);
 
     // and rescale pattern to compensate
     patternMatrix->Scale(patternWidth / surfaceSize.width,
                          patternHeight / surfaceSize.height);
   }
 
   nsRefPtr<gfxASurface> tmpSurface =
     gfxPlatform::GetPlatform()->CreateOffscreenSurface(surfaceSize,
@@ -375,54 +375,41 @@ nsSVGPatternFrame::GetEnumValue(PRUint32
   AutoPatternReferencer patternRef(this);
 
   nsSVGPatternFrame *next = GetReferencedPatternIfNotInUse();
   return next ? next->GetEnumValue(aIndex, aDefault) :
     static_cast<nsSVGPatternElement *>(aDefault)->
       mEnumAttributes[aIndex].GetAnimValue();
 }
 
-nsIDOMSVGAnimatedTransformList*
+SVGAnimatedTransformList*
 nsSVGPatternFrame::GetPatternTransformList(nsIContent* aDefault)
 {
-  nsIDOMSVGAnimatedTransformList *thisTransformList =
-    static_cast<nsSVGPatternElement *>(mContent)->mPatternTransform.get();
+  SVGAnimatedTransformList *thisTransformList =
+    static_cast<nsSVGPatternElement *>(mContent)->GetAnimatedTransformList();
 
-  // XXX We should be able to do something cleaner than this casting once
-  // bug 602759 is fixed and we have a proper animated transform list class
-  const nsSVGAnimatedTransformList *thisListAsConcreteType =
-    static_cast<const nsSVGAnimatedTransformList *>(thisTransformList);
-  if (thisListAsConcreteType && thisListAsConcreteType->IsExplicitlySet())
+  if (thisTransformList->IsExplicitlySet())
     return thisTransformList;
 
   AutoPatternReferencer patternRef(this);
 
   nsSVGPatternFrame *next = GetReferencedPatternIfNotInUse();
   return next ? next->GetPatternTransformList(aDefault) :
     static_cast<nsSVGPatternElement *>(aDefault)->mPatternTransform.get();
 }
 
 gfxMatrix
 nsSVGPatternFrame::GetPatternTransform()
 {
-  nsIDOMSVGAnimatedTransformList* transformList = 
+  SVGAnimatedTransformList* animTransformList =
     GetPatternTransformList(mContent);
+  if (!animTransformList)
+    return gfxMatrix();
 
-  static const gfxMatrix identityMatrix;
-  if (!transformList) {
-    return identityMatrix;
-  }
-  nsCOMPtr<nsIDOMSVGTransformList> lTrans;
-  transformList->GetAnimVal(getter_AddRefs(lTrans));
-  nsCOMPtr<nsIDOMSVGMatrix> patternTransform =
-    nsSVGTransformList::GetConsolidationMatrix(lTrans);
-  if (!patternTransform) {
-    return identityMatrix;
-  }
-  return nsSVGUtils::ConvertSVGMatrixToThebes(patternTransform);
+  return animTransformList->GetAnimValue().GetConsolidationMatrix();
 }
 
 const nsSVGViewBox &
 nsSVGPatternFrame::GetViewBox(nsIContent* aDefault)
 {
   const nsSVGViewBox &thisViewBox =
     static_cast<nsSVGPatternElement *>(mContent)->mViewBox;
 
--- a/layout/svg/base/src/nsSVGPatternFrame.h
+++ b/layout/svg/base/src/nsSVGPatternFrame.h
@@ -34,29 +34,29 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef __NS_SVGPATTERNFRAME_H__
 #define __NS_SVGPATTERNFRAME_H__
 
-#include "nsIDOMSVGMatrix.h"
 #include "nsSVGPaintServerFrame.h"
 #include "gfxMatrix.h"
 #include "nsIDOMSVGAnimTransformList.h"
 
 class nsIFrame;
 class nsSVGLength2;
 class nsSVGElement;
 class gfxContext;
 class gfxASurface;
 
 namespace mozilla {
 class SVGAnimatedPreserveAspectRatio;
+class SVGAnimatedTransformList;
 } // namespace mozilla
 
 typedef nsSVGPaintServerFrame  nsSVGPatternFrameBase;
 
 /**
  * Patterns can refer to other patterns. We create an nsSVGPaintingProperty
  * with property type nsGkAtoms::href to track the referenced pattern.
  */
@@ -116,17 +116,18 @@ protected:
   nsSVGPatternFrame* GetReferencedPatternIfNotInUse();
 
   // Accessors to lookup pattern attributes
   PRUint16 GetEnumValue(PRUint32 aIndex, nsIContent *aDefault);
   PRUint16 GetEnumValue(PRUint32 aIndex)
   {
     return GetEnumValue(aIndex, mContent);
   }
-  nsIDOMSVGAnimatedTransformList* GetPatternTransformList(nsIContent* aDefault);
+  mozilla::SVGAnimatedTransformList* GetPatternTransformList(
+      nsIContent* aDefault);
   gfxMatrix GetPatternTransform();
   const nsSVGViewBox &GetViewBox(nsIContent *aDefault);
   const nsSVGViewBox &GetViewBox() { return GetViewBox(mContent); }
   const SVGAnimatedPreserveAspectRatio &GetPreserveAspectRatio(
       nsIContent *aDefault);
   const SVGAnimatedPreserveAspectRatio &GetPreserveAspectRatio()
   {
     return GetPreserveAspectRatio(mContent);
@@ -157,17 +158,17 @@ protected:
                                nsIFrame *aTarget,
                                const gfxRect *aOverrideBounds);
 
 private:
   // this is a *temporary* reference to the frame of the element currently
   // referencing our pattern.  This must be temporary because different
   // referencing frames will all reference this one frame
   nsSVGGeometryFrame               *mSource;
-  nsCOMPtr<nsIDOMSVGMatrix>         mCTM;
+  nsAutoPtr<gfxMatrix>              mCTM;
 
 protected:
   // This flag is used to detect loops in xlink:href processing
   PRPackedBool                      mLoopFlag;
   PRPackedBool                      mNoHRefURI;
 };
 
 #endif
--- a/layout/svg/base/src/nsSVGTextFrame.cpp
+++ b/layout/svg/base/src/nsSVGTextFrame.cpp
@@ -42,17 +42,16 @@
 #include "SVGLengthList.h"
 #include "nsIDOMSVGLength.h"
 #include "nsIDOMSVGAnimatedNumber.h"
 #include "nsISVGGlyphFragmentNode.h"
 #include "nsSVGGlyphFrame.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsIDOMSVGRect.h"
 #include "nsSVGRect.h"
-#include "nsSVGMatrix.h"
 #include "nsGkAtoms.h"
 #include "nsSVGTextPathFrame.h"
 #include "nsSVGPathElement.h"
 #include "nsSVGUtils.h"
 #include "nsSVGGraphicElement.h"
 
 using namespace mozilla;
 
@@ -273,20 +272,20 @@ nsSVGTextFrame::GetCanvasTM()
   if (!mCanvasTM) {
     NS_ASSERTION(mParent, "null parent");
 
     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
     nsSVGGraphicElement *content = static_cast<nsSVGGraphicElement*>(mContent);
 
     gfxMatrix tm = content->PrependLocalTransformTo(parent->GetCanvasTM());
 
-    mCanvasTM = NS_NewSVGMatrix(tm);
+    mCanvasTM = new gfxMatrix(tm);
   }
 
-  return nsSVGUtils::ConvertSVGMatrixToThebes(mCanvasTM);
+  return *mCanvasTM;
 }
 
 //----------------------------------------------------------------------
 //
 
 void
 nsSVGTextFrame::NotifyGlyphMetricsChange()
 {
--- a/layout/svg/base/src/nsSVGTextFrame.h
+++ b/layout/svg/base/src/nsSVGTextFrame.h
@@ -118,17 +118,17 @@ private:
    * @param aForceGlobalTransform passed down to nsSVGGlyphFrames to
    * control whether they should use the global transform even when
    * NS_STATE_NONDISPLAY_CHILD
    */
   void UpdateGlyphPositioning(PRBool aForceGlobalTransform);
 
   void SetWhitespaceHandling(nsSVGGlyphFrame *aFrame);
 
-  nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
+  nsAutoPtr<gfxMatrix> mCanvasTM;
 
   enum UpdateState { unsuspended, suspended };
   UpdateState mMetricsState;
 
   PRPackedBool mPositioningDirty;
 };
 
 #endif
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -55,17 +55,16 @@
 #include "nsContentDLF.h"
 #include "nsContentUtils.h"
 #include "nsSVGFilterFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsDOMError.h"
 #include "nsSVGOuterSVGFrame.h"
 #include "nsSVGInnerSVGFrame.h"
 #include "SVGAnimatedPreserveAspectRatio.h"
-#include "nsSVGMatrix.h"
 #include "nsSVGClipPathFrame.h"
 #include "nsSVGMaskFrame.h"
 #include "nsSVGContainerFrame.h"
 #include "nsSVGTextContainerFrame.h"
 #include "nsSVGLength2.h"
 #include "nsGenericElement.h"
 #include "nsSVGGraphicElement.h"
 #include "nsAttrValue.h"
@@ -1155,32 +1154,16 @@ nsSVGUtils::ConvertToSurfaceSize(const g
     surfaceSize.height = NS_MIN(NS_SVG_OFFSCREEN_MAX_DIMENSION,
                                 surfaceSize.height);
     *aResultOverflows = PR_TRUE;
   }
 
   return surfaceSize;
 }
 
-gfxMatrix
-nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
-{
-  if (!aMatrix) {
-    return gfxMatrix();
-  }
-  float A, B, C, D, E, F;
-  aMatrix->GetA(&A);
-  aMatrix->GetB(&B);
-  aMatrix->GetC(&C);
-  aMatrix->GetD(&D);
-  aMatrix->GetE(&E);
-  aMatrix->GetF(&F);
-  return gfxMatrix(A, B, C, D, E, F);
-}
-
 PRBool
 nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
                         float aRX, float aRY, float aRWidth, float aRHeight,
                         float aX, float aY)
 {
   if (aMatrix.IsSingular()) {
     return PR_FALSE;
   }
--- a/layout/svg/base/src/nsSVGUtils.h
+++ b/layout/svg/base/src/nsSVGUtils.h
@@ -43,17 +43,16 @@
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsRect.h"
 #include "gfxContext.h"
 #include "nsRenderingContext.h"
 #include "gfxRect.h"
 #include "gfxMatrix.h"
-#include "nsSVGMatrix.h"
 
 class nsIDocument;
 class nsPresContext;
 class nsIContent;
 class nsStyleContext;
 class nsStyleCoord;
 class nsFrameList;
 class nsIFrame;
@@ -449,22 +448,16 @@ public:
    * @param aSize the desired surface size
    * @param aResultOverflows true if the desired surface size is too big
    * @return the surface size to use
    */
   static gfxIntSize ConvertToSurfaceSize(const gfxSize& aSize,
                                          PRBool *aResultOverflows);
 
   /*
-   * Convert a nsIDOMSVGMatrix to a gfxMatrix.
-   */
-  static gfxMatrix
-  ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix);
-
-  /*
    * Hit test a given rectangle/matrix.
    */
   static PRBool
   HitTestRect(const gfxMatrix &aMatrix,
               float aRX, float aRY, float aRWidth, float aRHeight,
               float aX, float aY);