Bug 938388 - Convert all remaining code for calculating path lengths and position at an offset along a path in content/svg to Moz2D (kill off all uses of gfxPath). r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Mon, 18 Nov 2013 01:29:06 +0000
changeset 155118 af0931327e49e620b7a1ad6131afcc2c8bd03e00
parent 155117 4f086025350f6bdad1e216dc3fa31030d8ce156d
child 155119 116329598a6427e29fe1d701b46c9b3c65c40407
push id36242
push userjwatt@jwatt.org
push dateMon, 18 Nov 2013 01:30:24 +0000
treeherdermozilla-inbound@af0931327e49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs938388
milestone28.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 938388 - Convert all remaining code for calculating path lengths and position at an offset along a path in content/svg to Moz2D (kill off all uses of gfxPath). r=dholbert
content/svg/content/src/DOMSVGPoint.h
content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
content/svg/content/src/SVGMotionSMILAnimationFunction.h
content/svg/content/src/SVGMotionSMILPathUtils.cpp
content/svg/content/src/SVGMotionSMILPathUtils.h
content/svg/content/src/SVGMotionSMILType.cpp
content/svg/content/src/SVGMotionSMILType.h
content/svg/content/src/SVGPathData.h
content/svg/content/src/SVGPathElement.cpp
content/svg/content/src/nsSVGPathGeometryElement.h
--- a/content/svg/content/src/DOMSVGPoint.h
+++ b/content/svg/content/src/DOMSVGPoint.h
@@ -3,16 +3,17 @@
  * 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_DOMSVGPOINT_H__
 #define MOZILLA_DOMSVGPOINT_H__
 
 #include "DOMSVGPointList.h"
 #include "gfxPoint.h"
+#include "mozilla/gfx/2D.h"
 #include "nsAutoPtr.h"
 #include "nsDebug.h"
 #include "nsISVGPoint.h"
 #include "SVGPoint.h"
 #include "mozilla/Attributes.h"
 
 class nsSVGElement;
 
@@ -33,16 +34,18 @@ class SVGMatrix;
  * See the architecture comment in DOMSVGPointList.h for an overview of the
  * important points regarding these DOM wrapper structures.
  *
  * See the architecture comment in DOMSVGLength.h (yes, LENGTH) for an overview
  * of the important points regarding how this specific class works.
  */
 class DOMSVGPoint MOZ_FINAL : public nsISVGPoint
 {
+  typedef mozilla::gfx::Point Point;
+
 public:
   /**
    * Generic ctor for DOMSVGPoint objects that are created for an attribute.
    */
   DOMSVGPoint(DOMSVGPointList *aList,
               uint32_t aListIndex,
               bool aIsAnimValItem)
     : nsISVGPoint()
@@ -68,16 +71,25 @@ public:
 
   DOMSVGPoint(float aX, float aY)
     : nsISVGPoint()
   {
     mPt.mX = aX;
     mPt.mY = aY;
   }
 
+  explicit DOMSVGPoint(const Point& aPt)
+    : nsISVGPoint()
+  {
+    mPt.mX = aPt.x;
+    mPt.mY = aPt.y;
+    NS_ASSERTION(NS_finite(mPt.mX) && NS_finite(mPt.mX),
+                 "DOMSVGPoint coords are not finite");
+  }
+
   explicit DOMSVGPoint(const gfxPoint &aPt)
     : nsISVGPoint()
   {
     mPt.mX = float(aPt.x);
     mPt.mY = float(aPt.y);
     NS_ASSERTION(NS_finite(mPt.mX) && NS_finite(mPt.mX),
                  "DOMSVGPoint coords are not finite");
   }
--- a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
+++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp
@@ -224,44 +224,42 @@ SVGMotionSMILAnimationFunction::
   if (pathElem) {
     const SVGPathData &path = pathElem->GetAnimPathSegList()->GetAnimValue();
     // Path data must contain of at least one path segment (if the path data
     // doesn't begin with a valid "M", then it's invalid).
     if (path.Length()) {
       bool ok =
         path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
       if (ok && mPathVertices.Length()) {
-        RefPtr<Path> path = pathElem->GetPathForLengthOrPositionMeasuring();
-        mPath = new gfxPath(path);
+        mPath = pathElem->GetPathForLengthOrPositionMeasuring();
       }
     }
   }
 }
 
 void
 SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromPathAttr()
 {
   const nsAString& pathSpec = GetAttr(nsGkAtoms::path)->GetStringValue();
   mPathSourceType = ePathSourceType_PathAttr;
 
-  // Generate gfxPath from |path| attr
+  // Generate Path from |path| attr
   SVGPathData path;
   nsSVGPathDataParser pathParser(pathSpec, &path);
 
   // We ignore any failure returned from Parse() since the SVG spec says to
   // accept all segments up to the first invalid token. Instead we must
   // explicitly check that the parse produces at least one path segment (if
   // the path data doesn't begin with a valid "M", then it's invalid).
   pathParser.Parse();
   if (!path.Length()) {
     return;
   }
 
-  RefPtr<Path> moz2dpath = path.ToPathForLengthOrPositionMeasuring();
-  mPath = new gfxPath(moz2dpath);
+  mPath = path.ToPathForLengthOrPositionMeasuring();
   bool ok = path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
   if (!ok || !mPathVertices.Length()) {
     mPath = nullptr;
   }
 }
 
 // Helper to regenerate our path representation & its list of vertices
 void
@@ -291,26 +289,26 @@ SVGMotionSMILAnimationFunction::
     RebuildPathAndVerticesFromBasicAttrs(aTargetElement);
     mValueNeedsReparsingEverySample = true;
   }
   mIsPathStale = false;
 }
 
 bool
 SVGMotionSMILAnimationFunction::
-  GenerateValuesForPathAndPoints(gfxPath* aPath,
+  GenerateValuesForPathAndPoints(Path* aPath,
                                  bool aIsKeyPoints,
                                  nsTArray<double>& aPointDistances,
                                  nsTArray<nsSMILValue>& aResult)
 {
   NS_ABORT_IF_FALSE(aResult.IsEmpty(), "outparam is non-empty");
 
   // If we're using "keyPoints" as our list of input distances, then we need
   // to de-normalize from the [0, 1] scale to the [0, totalPathLen] scale.
-  double distanceMultiplier = aIsKeyPoints ? aPath->GetLength() : 1.0;
+  double distanceMultiplier = aIsKeyPoints ? aPath->ComputeLength() : 1.0;
   const uint32_t numPoints = aPointDistances.Length();
   for (uint32_t i = 0; i < numPoints; ++i) {
     double curDist = aPointDistances[i] * distanceMultiplier;
     if (!aResult.AppendElement(
           SVGMotionSMILType::ConstructSMILValue(aPath, curDist,
                                                 mRotateType, mRotateAngle))) {
       return false;
     }
--- a/content/svg/content/src/SVGMotionSMILAnimationFunction.h
+++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.h
@@ -1,17 +1,18 @@
 /* -*- 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_SVGMOTIONSMILANIMATIONFUNCTION_H_
 #define MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
 
-#include "gfxPath.h"  // for gfxPath
+#include "mozilla/gfx/2D.h"
+#include "mozilla/RefPtr.h"
 #include "nsAutoPtr.h"
 #include "nsSMILAnimationFunction.h"
 #include "nsTArray.h"
 #include "SVGMotionSMILType.h"  // for RotateType
 
 class nsAttrValue;
 class nsIAtom;
 class nsIContent;
@@ -27,16 +28,18 @@ class SVGMPathElement;
 //----------------------------------------------------------------------
 // SVGMotionSMILAnimationFunction
 //
 // Subclass of nsSMILAnimationFunction to support a few extra features offered
 // by the <animateMotion> element.
 //
 class SVGMotionSMILAnimationFunction : public nsSMILAnimationFunction
 {
+  typedef mozilla::gfx::Path Path;
+
 public:
   SVGMotionSMILAnimationFunction();
   virtual bool SetAttr(nsIAtom* aAttribute,
                        const nsAString& aValue,
                        nsAttrValue& aResult,
                        nsresult* aParseResult = nullptr) MOZ_OVERRIDE;
   virtual bool UnsetAttr(nsIAtom* aAttribute) MOZ_OVERRIDE;
 
@@ -73,30 +76,30 @@ protected:
   void     UnsetRotate();
 
   // Helpers for GetValues
   void     MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute);
   void     RebuildPathAndVertices(const nsIContent* aContextElem);
   void     RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem);
   void     RebuildPathAndVerticesFromPathAttr();
   void     RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
-  bool     GenerateValuesForPathAndPoints(gfxPath* aPath,
+  bool     GenerateValuesForPathAndPoints(Path* aPath,
                                           bool aIsKeyPoints,
                                           nsTArray<double>& aPointDistances,
                                           nsTArray<nsSMILValue>& aResult);
 
   // Members
   // -------
   nsTArray<double>           mKeyPoints; // parsed from "keyPoints" attribute.
 
   RotateType                 mRotateType;  // auto, auto-reverse, or explicit.
   float                      mRotateAngle; // the angle value, if explicit.
 
-  PathSourceType             mPathSourceType; // source of our gfxPath.
-  nsRefPtr<gfxPath> mPath;           // representation of motion path.
+  PathSourceType             mPathSourceType; // source of our Path.
+  RefPtr<Path>               mPath;           // representation of motion path.
   nsTArray<double>           mPathVertices; // distances of vertices along path.
 
   bool                       mIsPathStale;
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
--- a/content/svg/content/src/SVGMotionSMILPathUtils.cpp
+++ b/content/svg/content/src/SVGMotionSMILPathUtils.cpp
@@ -1,16 +1,15 @@
 /* -*- 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/. */
 
 #include "SVGMotionSMILPathUtils.h"
 
-#include "gfxPath.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentUtils.h" // for NS_ENSURE_FINITE2
 #include "SVGContentUtils.h"
 #include "SVGLength.h"
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
@@ -75,22 +74,20 @@ SVGMotionSMILPathUtils::PathGenerator::
   if (!ParseCoordinatePair(aCoordPairStr, xVal, yVal)) {
     return false;
   }
   mPathBuilder->LineTo(mPathBuilder->CurrentPoint() + Point(xVal, yVal));
   aSegmentDistance = NS_hypot(xVal, yVal);
   return true;
 }
 
-already_AddRefed<gfxPath>
+TemporaryRef<Path>
 SVGMotionSMILPathUtils::PathGenerator::GetResultingPath()
 {
-  RefPtr<Path> path = mPathBuilder->Finish();
-  nsRefPtr<gfxPath> thebesPath = new gfxPath(path);
-  return thebesPath.forget();
+  return mPathBuilder->Finish();
 }
 
 //----------------------------------------------------------------------
 // Helper / protected methods
 
 bool
 SVGMotionSMILPathUtils::PathGenerator::
   ParseCoordinatePair(const nsAString& aCoordPairStr,
--- a/content/svg/content/src/SVGMotionSMILPathUtils.h
+++ b/content/svg/content/src/SVGMotionSMILPathUtils.h
@@ -12,29 +12,29 @@
 #include "mozilla/Attributes.h"
 #include "gfxPlatform.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "nsDebug.h"
 #include "nsSMILParserUtils.h"
 #include "nsTArray.h"
 
-class gfxPath;
 class nsAString;
 class nsSVGElement;
 
 namespace mozilla {
 
 class SVGMotionSMILPathUtils
 {
   typedef mozilla::gfx::DrawTarget DrawTarget;
+  typedef mozilla::gfx::Path Path;
   typedef mozilla::gfx::PathBuilder PathBuilder;
 
 public:
-  // Class to assist in generating a gfxPath, based on
+  // Class to assist in generating a Path, based on
   // coordinates in the <animateMotion> from/by/to/values attributes.
   class PathGenerator {
   public:
     PathGenerator(const nsSVGElement* aSVGElement)
       : mSVGElement(aSVGElement),
         mHaveReceivedCommands(false)
     {
       RefPtr<DrawTarget> drawTarget =
@@ -56,31 +56,31 @@ public:
     bool LineToAbsolute(const nsAString& aCoordPairStr,
                           double& aSegmentDistance);
     bool LineToRelative(const nsAString& aCoordPairStr,
                           double& aSegmentDistance);
 
     // Accessor to let clients check if we've received any commands yet.
     inline bool HaveReceivedCommands() { return mHaveReceivedCommands; }
     // Accessor to get the finalized path
-    already_AddRefed<gfxPath> GetResultingPath();
+    mozilla::TemporaryRef<Path> GetResultingPath();
 
   protected:
     // Helper methods
     bool ParseCoordinatePair(const nsAString& aStr,
                                float& aXVal, float& aYVal);
 
     // Member data
     const nsSVGElement* mSVGElement; // context for converting to user units
     RefPtr<PathBuilder> mPathBuilder;
     bool          mHaveReceivedCommands;
   };
 
   // Class to assist in passing each subcomponent of a |values| attribute to
-  // a PathGenerator, for generating a corresponding gfxPath.
+  // a PathGenerator, for generating a corresponding Path.
   class MotionValueParser : public nsSMILParserUtils::GenericValueParser
   {
   public:
     MotionValueParser(PathGenerator* aPathGenerator,
                       nsTArray<double>* aPointDistances)
       : mPathGenerator(aPathGenerator),
         mPointDistances(aPointDistances),
         mDistanceSoFar(0.0)
--- a/content/svg/content/src/SVGMotionSMILType.cpp
+++ b/content/svg/content/src/SVGMotionSMILType.cpp
@@ -1,24 +1,27 @@
 /* -*- 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/. */
 
 /* implementation of nsISMILType for use by <animateMotion> element */
 
 #include "SVGMotionSMILType.h"
+
+#include "gfx2DGlue.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include "nsMathUtils.h"
 #include "nsISupportsUtils.h"
-#include "gfxPath.h"
 #include "nsTArray.h"
 #include <math.h>
 
+using namespace mozilla::gfx;
+
 namespace mozilla {
 
 /*static*/ SVGMotionSMILType SVGMotionSMILType::sSingleton;
 
 
 // Helper enum, for distinguishing between types of MotionSegment structs
 enum SegmentType {
   eSegmentType_Translation,
@@ -27,17 +30,17 @@ enum SegmentType {
 
 // Helper Structs: containers for params to define our MotionSegment
 // (either simple translation or point-on-a-path)
 struct TranslationParams {  // Simple translation
   float mX;
   float mY;
 };
 struct PathPointParams {  // Point along a path
-  gfxPath* mPath; // NOTE: Refcounted; need to AddRef/Release.
+  Path* mPath; // NOTE: Refcounted; need to AddRef/Release.
   float mDistToPoint; // Distance from path start to the point on the path that
                       // we're interested in.
 };
 
 /**
  * Helper Struct: MotionSegment
  *
  * Instances of this class represent the points that we move between during
@@ -65,17 +68,17 @@ struct MotionSegment
     : mRotateType(eRotateType_Explicit), mRotateAngle(aRotateAngle),
       mSegmentType(eSegmentType_Translation)
   {
     mU.mTranslationParams.mX = aX;
     mU.mTranslationParams.mY = aY;
   }
 
   // Constructor for a point on a path (NOTE: AddRef's)
-  MotionSegment(gfxPath* aPath, float aDistToPoint,
+  MotionSegment(Path* aPath, float aDistToPoint,
                 RotateType aRotateType, float aRotateAngle)
     : mRotateType(aRotateType), mRotateAngle(aRotateAngle),
       mSegmentType(eSegmentType_PathPoint)
   {
     mU.mPathPointParams.mPath = aPath;
     mU.mPathPointParams.mDistToPoint = aDistToPoint;
 
     NS_ADDREF(mU.mPathPointParams.mPath); // Retain a reference to path
@@ -223,36 +226,34 @@ SVGMotionSMILType::IsEqual(const nsSMILV
     }
   }
 
   return true; // If we get here, we found no differences.
 }
 
 // Helper method for Add & CreateMatrix
 inline static void
-GetAngleAndPointAtDistance(gfxPath* aPath, float aDistance,
+GetAngleAndPointAtDistance(Path* aPath, float aDistance,
                            RotateType aRotateType,
                            gfxFloat& aRotateAngle, // in & out-param.
                            gfxPoint& aPoint)       // out-param.
 {
-  gfxFloat tangentAngle;
-  // NOTE: "0.0" below is distance-off-the-path. (see FindPoint documentation)
-  aPoint = aPath->FindPoint(gfxPoint(aDistance, 0.0), &tangentAngle);
-
-  // Update aRotateAngle if it's auto/auto-reverse
-  switch (aRotateType) {
-    case eRotateType_Explicit:
-      // Leave aRotateAngle as-is.
-      break;
-    case eRotateType_Auto:
+  if (aRotateType == eRotateType_Explicit) {
+    // Leave aRotateAngle as-is.
+    aPoint = ThebesPoint(aPath->ComputePointAtLength(aDistance));
+  } else {
+    Point tangent; // Unit vector tangent to the point we find.
+    aPoint = ThebesPoint(aPath->ComputePointAtLength(aDistance, &tangent));
+    gfxFloat tangentAngle = atan2(tangent.y, tangent.x);
+    if (aRotateType == eRotateType_Auto) {
       aRotateAngle = tangentAngle;
-      break;
-    case eRotateType_AutoReverse:
+    } else {
+      MOZ_ASSERT(aRotateType == eRotateType_AutoReverse);
       aRotateAngle = M_PI + tangentAngle;
-      break;
+    }
   }
 }
 
 nsresult
 SVGMotionSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                        uint32_t aCount) const
 {
   NS_ABORT_IF_FALSE(aDest.mType == aValueToAdd.mType,
@@ -282,26 +283,25 @@ SVGMotionSMILType::Add(nsSMILValue& aDes
   const PathPointParams& srcParams = srcSeg.mU.mPathPointParams;
   const PathPointParams& dstParams = dstSeg.mU.mPathPointParams;
 
   NS_ABORT_IF_FALSE(srcSeg.mRotateType  == dstSeg.mRotateType &&
                     srcSeg.mRotateAngle == dstSeg.mRotateAngle,
                     "unexpected angle mismatch");
   NS_ABORT_IF_FALSE(srcParams.mPath == dstParams.mPath,
                     "unexpected path mismatch");
-  gfxPath* path = srcParams.mPath;
+  Path* path = srcParams.mPath;
 
   // Use destination to get our rotate angle.
   gfxFloat rotateAngle = dstSeg.mRotateAngle;
   gfxPoint dstPt;
   GetAngleAndPointAtDistance(path, dstParams.mDistToPoint, dstSeg.mRotateType,
                              rotateAngle, dstPt);
 
-  // NOTE: "0.0" below is distance-off-the-path. (see FindPoint documentation)
-  gfxPoint srcPt = path->FindPoint(gfxPoint(srcParams.mDistToPoint, 0.0));
+  Point srcPt = path->ComputePointAtLength(srcParams.mDistToPoint);
 
   float newX = dstPt.x + srcPt.x * aCount;
   float newY = dstPt.y + srcPt.y * aCount;
 
   // Replace destination's current value -- a point-on-a-path -- with the
   // translation that results from our addition.
   dstArr.Clear();
   dstArr.AppendElement(MotionSegment(newX, newY, rotateAngle));
@@ -406,17 +406,17 @@ SVGMotionSMILType::Interpolate(const nsS
   const MotionSegment& endSeg = endArr[0];
   NS_ABORT_IF_FALSE(endSeg.mSegmentType == eSegmentType_PathPoint,
                     "Expecting to be interpolating along a path");
 
   const PathPointParams& endParams = endSeg.mU.mPathPointParams;
   // NOTE: path & angle should match between start & end (since presumably
   // start & end came from the same <animateMotion> element), unless start is
   // empty. (as it would be for pure 'to' animation)
-  gfxPath* path = endParams.mPath;
+  Path* path = endParams.mPath;
   RotateType rotateType  = endSeg.mRotateType;
   float rotateAngle      = endSeg.mRotateAngle;
 
   float startDist;
   if (startArr.IsEmpty()) {
     startDist = 0.0f;
   } else {
     const MotionSegment& startSeg = startArr[0];
@@ -466,17 +466,17 @@ SVGMotionSMILType::CreateMatrix(const ns
     }
     matrix.Translate(point);
     matrix.Rotate(rotateAngle);
   }
   return matrix;
 }
 
 /* static */ nsSMILValue
-SVGMotionSMILType::ConstructSMILValue(gfxPath* aPath,
+SVGMotionSMILType::ConstructSMILValue(Path* aPath,
                                       float aDist,
                                       RotateType aRotateType,
                                       float aRotateAngle)
 {
   nsSMILValue smilVal(&SVGMotionSMILType::sSingleton);
   MotionSegmentArray& arr = ExtractMotionSegmentArray(smilVal);
 
   // AppendElement has guaranteed success here, since Init() allocates 1 slot.
--- a/content/svg/content/src/SVGMotionSMILType.h
+++ b/content/svg/content/src/SVGMotionSMILType.h
@@ -3,21 +3,21 @@
  * 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/. */
 
 /* implementation of nsISMILType for use by <animateMotion> element */
 
 #ifndef MOZILLA_SVGMOTIONSMILTYPE_H_
 #define MOZILLA_SVGMOTIONSMILTYPE_H_
 
+#include "mozilla/gfx/2D.h"
 #include "mozilla/Attributes.h"
 #include "gfxMatrix.h"
 #include "nsISMILType.h"
 
-class gfxPath;
 class nsSMILValue;
 
 namespace mozilla {
 
 /**
  * MotionRotateType: Enum to indicate the type of our "rotate" attribute.
  */
 enum RotateType {
@@ -30,16 +30,18 @@ enum RotateType {
  * SVGMotionSMILType: Implements the nsISMILType interface for SMIL animations
  * from <animateMotion>.
  *
  * NOTE: Even though there's technically no "motion" attribute, we behave in
  * many ways as if there were, for simplicity.
  */
 class SVGMotionSMILType : public nsISMILType
 {
+  typedef mozilla::gfx::Path Path;
+
 public:
   // Singleton for nsSMILValue objects to hold onto.
   static SVGMotionSMILType sSingleton;
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
@@ -60,17 +62,17 @@ protected:
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 public:
   // Used to generate a transform matrix from an <animateMotion> nsSMILValue.
   static gfxMatrix CreateMatrix(const nsSMILValue& aSMILVal);
 
   // Used to generate a nsSMILValue for the point at the given distance along
   // the given path.
-  static nsSMILValue ConstructSMILValue(gfxPath* aPath,
+  static nsSMILValue ConstructSMILValue(Path* aPath,
                                         float aDist,
                                         RotateType aRotateType,
                                         float aRotateAngle);
 
 private:
   // Private constructor: prevent instances beyond my singleton.
   MOZ_CONSTEXPR SVGMotionSMILType() {}
 };
--- a/content/svg/content/src/SVGPathData.h
+++ b/content/svg/content/src/SVGPathData.h
@@ -15,17 +15,16 @@
 #include "mozilla/gfx/Types.h"
 #include "mozilla/RefPtr.h"
 #include "nsSVGElement.h"
 #include "nsTArray.h"
 
 #include <string.h>
 
 class gfxContext;
-class gfxPath;
 class nsSVGPathDataParser; // IWYU pragma: keep
 
 struct gfxMatrix;
 struct nsSVGMark;
 
 namespace mozilla {
 
 /**
--- a/content/svg/content/src/SVGPathElement.cpp
+++ b/content/svg/content/src/SVGPathElement.cpp
@@ -5,17 +5,16 @@
 
 #include "mozilla/dom/SVGPathElement.h"
 
 #include <algorithm>
 
 #include "DOMSVGPathSeg.h"
 #include "DOMSVGPathSegList.h"
 #include "DOMSVGPoint.h"
-#include "gfxPath.h"
 #include "gfx2DGlue.h"
 #include "mozilla/dom/SVGPathElementBinding.h"
 #include "mozilla/gfx/2D.h"
 #include "nsCOMPtr.h"
 #include "nsComputedDOMStyle.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsStyleStruct.h"
@@ -75,31 +74,30 @@ already_AddRefed<nsISVGPoint>
 SVGPathElement::GetPointAtLength(float distance, ErrorResult& rv)
 {
   RefPtr<Path> path = GetPathForLengthOrPositionMeasuring();
   if (!path) {
     rv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<gfxPath> flat = new gfxPath(path);
-
-  float totalLength = flat->GetLength();
+  float totalLength = path->ComputeLength();
   if (mPathLength.IsExplicitlySet()) {
     float pathLength = mPathLength.GetAnimValue();
     if (pathLength <= 0) {
       rv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
     distance *= totalLength / pathLength;
   }
   distance = std::max(0.f,         distance);
   distance = std::min(totalLength, distance);
 
-  nsCOMPtr<nsISVGPoint> point = new DOMSVGPoint(flat->FindPoint(gfxPoint(distance, 0)));
+  nsCOMPtr<nsISVGPoint> point =
+    new DOMSVGPoint(path->ComputePointAtLength(distance));
   return point.forget();
 }
 
 uint32_t
 SVGPathElement::GetPathSegAtLength(float distance)
 {
   return mD.GetAnimValue().GetPathSegAtLength(distance);
 }
--- a/content/svg/content/src/nsSVGPathGeometryElement.h
+++ b/content/svg/content/src/nsSVGPathGeometryElement.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __NS_SVGPATHGEOMETRYELEMENT_H__
 #define __NS_SVGPATHGEOMETRYELEMENT_H__
 
 #include "mozilla/gfx/2D.h"
 #include "SVGGraphicsElement.h"
 
-class gfxPath;
 struct gfxMatrix;
 template <class E> class nsTArray;
 
 struct nsSVGMark {
   enum Type {
     eStart,
     eMid,
     eEnd,