Bug 459953 - Some path segments have the wrong pathSegTypeAsLetter. r+sr=roc
authorRobert Longson <longsonr@gmail.com>
Thu, 30 Oct 2008 14:05:33 +0000
changeset 21100 762df4556c17b1b64f2151f6a518f99cd6447e46
parent 21099 5a26c335a54b900dda22ec57ca4173e7f17cc430
child 21101 deed24924f5a3eb6cf282cc666ae48447ec09b0a
child 21109 f6a427e470ecee500ed454d89c567dcd514bf76a
push id3312
push userlongsonr@gmail.com
push dateThu, 30 Oct 2008 14:05:55 +0000
treeherdermozilla-central@762df4556c17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs459953
milestone1.9.1b2pre
Bug 459953 - Some path segments have the wrong pathSegTypeAsLetter. r+sr=roc
content/svg/content/src/nsSVGPathSeg.cpp
content/svg/content/src/nsSVGPathSeg.h
--- a/content/svg/content/src/nsSVGPathSeg.cpp
+++ b/content/svg/content/src/nsSVGPathSeg.cpp
@@ -49,16 +49,26 @@ struct PathPoint {
 
 //----------------------------------------------------------------------
 // Error threshold to use when calculating the length of Bezier curves
 static const float PATH_SEG_LENGTH_TOLERANCE = 0.0000001f;
 
 //----------------------------------------------------------------------
 // implementation helper macros
 
+#define NS_IMPL_SVGPATHSEG(type, letter)                      \
+NS_IMETHODIMP                                                 \
+GetPathSegType(PRUint16 *aPathSegType) {                      \
+  *aPathSegType = type; return NS_OK; }                       \
+                                                              \
+NS_IMETHODIMP                                                 \
+GetPathSegTypeAsLetter(nsAString & aPathSegTypeAsLetter) {    \
+  aPathSegTypeAsLetter.Assign(letter);                        \
+  return NS_OK; }
+
 #define NS_IMPL_NSISUPPORTS_SVGPATHSEG(basename)              \
 NS_IMPL_ADDREF(ns##basename)                                  \
 NS_IMPL_RELEASE(ns##basename)                                 \
                                                               \
 NS_INTERFACE_MAP_BEGIN(ns##basename)                          \
   NS_INTERFACE_MAP_ENTRY(nsIDOM##basename)                    \
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(basename)          \
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPathSeg)
@@ -128,21 +138,16 @@ static float CalcBezLength(PathPoint *cu
              CalcBezLength(right, numPts, split);
   }
   return length;
 }
 
 ////////////////////////////////////////////////////////////////////////
 // nsSVGPathSeg
 
-char nsSVGPathSeg::mTypeLetters[] = {
-  'X', 'z', 'M', 'm', 'L', 'l', 'C', 'c', 'S', 's',
-  'A', 'a', 'H', 'h', 'V', 'v', 'Q', 'q', 'T', 't'
-};
-
 nsQueryReferent
 nsSVGPathSeg::GetCurrentList() const
 {
   return do_QueryReferent(mCurrentList);
 }
 
 nsresult 
 nsSVGPathSeg::SetCurrentList(nsISVGValue* aList)
@@ -151,30 +156,16 @@ nsSVGPathSeg::SetCurrentList(nsISVGValue
     mCurrentList = nsnull;
     return NS_OK;
   }
   nsresult rv;
   mCurrentList = do_GetWeakReference(aList, &rv);
   return rv;
 }
 
-NS_IMETHODIMP
-nsSVGPathSeg::GetPathSegType(PRUint16 *aPathSegType)
-{
-  *aPathSegType = GetSegType();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsSVGPathSeg::GetPathSegTypeAsLetter(nsAString & aPathSegTypeAsLetter)
-{
-  aPathSegTypeAsLetter.AssignASCII(&mTypeLetters[GetSegType()], 1);
-  return NS_OK;
-}
-
 void
 nsSVGPathSeg::DidModify(void)
 {
   if (mCurrentList) {
     nsCOMPtr<nsISVGValue> val = do_QueryReferent(mCurrentList);
     if (val) {
       val->BeginBatchUpdate();
       val->EndBatchUpdate();
@@ -206,18 +197,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegClosePath interface:
   NS_DECL_NSIDOMSVGPATHSEGCLOSEPATH
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CLOSEPATH; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CLOSEPATH, 'z')
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsIDOMSVGPathSeg*
 NS_NewSVGPathSegClosePath()
 {
@@ -260,18 +250,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegMovetoAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGMOVETOABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_MOVETO_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_MOVETO_ABS, 'M')
 
 protected:
   float mX, mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -356,18 +345,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegMovetoRel interface:
   NS_DECL_NSIDOMSVGPATHSEGMOVETOREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_MOVETO_REL; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_MOVETO_REL, 'm')
 
 protected:
   float mX, mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -451,18 +439,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegLinetoAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGLINETOABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_LINETO_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_LINETO_ABS, 'L')
 
 protected:
   float mX, mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -549,18 +536,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegLinetoRel interface:
   NS_DECL_NSIDOMSVGPATHSEGLINETOREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_LINETO_REL; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_LINETO_REL, 'l')
 
 protected:
   float mX, mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -647,18 +633,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoCubicAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOCUBICABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_CUBIC_ABS, 'C')
 
 protected:
   float mX, mY, mX1, mY1, mX2, mY2;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -814,18 +799,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoCubicRel interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOCUBICREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_REL; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_CUBIC_REL, 'c')
 
 protected:
   float mX, mY, mX1, mY1, mX2, mY2;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -976,18 +960,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoQuadraticAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOQUADRATICABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_QUADRATIC_ABS, 'Q')
 
 protected:
   float mX, mY, mX1, mY1;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -1110,19 +1093,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoQuadraticRel interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOQUADRATICREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL; }
-
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_QUADRATIC_REL, 'q')
 
 protected:
   float mX, mY, mX1, mY1;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -1246,18 +1227,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegArcAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGARCABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_ARC_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_ARC_ABS, 'A')
 
 protected:
   float  mX, mY, mR1, mR2, mAngle;
   PRPackedBool mLargeArcFlag;
   PRPackedBool mSweepFlag;
 };
 
 //----------------------------------------------------------------------
@@ -1432,18 +1412,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegArcRel interface:
   NS_DECL_NSIDOMSVGPATHSEGARCREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_ARC_REL; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_ARC_REL, 'a')
 
 protected:
   float  mX, mY, mR1, mR2, mAngle;
   PRBool mLargeArcFlag, mSweepFlag;
 };
 
 //----------------------------------------------------------------------
 // Implementation
@@ -1616,18 +1595,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegLinetoHorizontalAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGLINETOHORIZONTALABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_LINETO_HORIZONTAL_ABS, 'H')
 
 protected:
   float mX;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -1699,18 +1677,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegLinetoHorizontalRel interface:
   NS_DECL_NSIDOMSVGPATHSEGLINETOHORIZONTALREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_LINETO_HORIZONTAL_REL, 'h')
 
 protected:
   float mX;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -1781,18 +1758,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegLinetoVerticalAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGLINETOVERTICALABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_LINETO_VERTICAL_ABS, 'V')
 
 protected:
   float mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -1864,19 +1840,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegLinetoVerticalRel interface:
   NS_DECL_NSIDOMSVGPATHSEGLINETOVERTICALREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_LINETO_VERTICAL_REL; }
-
+  NS_IMPL_SVGPATHSEG(PATHSEG_LINETO_VERTICAL_REL, 'v')
 
 protected:
   float mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -1948,18 +1922,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoCubicSmoothAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOCUBICSMOOTHABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S')
 
 protected:
   float mX, mY, mX2, mY2;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -2087,18 +2060,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoCubicSmoothRel interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOCUBICSMOOTHREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's')
 
 protected:
   float mX, mY, mX2, mY2;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -2223,18 +2195,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOQUADRATICSMOOTHABS
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; }
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T')
 
 protected:
   float mX, mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
@@ -2326,19 +2297,17 @@ public:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSegCurvetoQuadraticSmoothRel interface:
   NS_DECL_NSIDOMSVGPATHSEGCURVETOQUADRATICSMOOTHREL
 
   // nsSVGPathSeg methods:
   NS_IMETHOD GetValueString(nsAString& aValue);
   virtual float GetLength(nsSVGPathSegTraversalState *ts);
-  virtual PRUint16 GetSegType()
-    { return nsIDOMSVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; }
-
+  NS_IMPL_SVGPATHSEG(PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't')
 
 protected:
   float mX, mY;
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
--- a/content/svg/content/src/nsSVGPathSeg.h
+++ b/content/svg/content/src/nsSVGPathSeg.h
@@ -79,28 +79,27 @@ public:
   nsSVGPathSeg() : mCurrentList(nsnull) {}
   nsresult SetCurrentList(nsISVGValue* aList);
   nsQueryReferent GetCurrentList() const;
 
   // nsISupports interface:
   NS_DECL_ISUPPORTS
 
   // nsIDOMSVGPathSeg interface:
-  NS_DECL_NSIDOMSVGPATHSEG
-  NS_IMETHOD GetValueString(nsAString& aValue) = 0;
+  NS_IMETHOD GetPathSegType(PRUint16 *aPathSegType) = 0;
+  NS_IMETHOD GetPathSegTypeAsLetter(nsAString & aPathSegTypeAsLetter) = 0;
 
   // nsSVGPathSeg methods:
+  NS_IMETHOD GetValueString(nsAString& aValue) = 0;
   virtual float GetLength(nsSVGPathSegTraversalState *ts) = 0;
 
 protected:
-  virtual PRUint16 GetSegType() = 0;
   void DidModify();
 
 private:
-  static char mTypeLetters[];
   nsCOMPtr<nsIWeakReference> mCurrentList;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsSVGPathSeg, NS_SVGPATHSEG_IID)
 
 nsIDOMSVGPathSeg*
 NS_NewSVGPathSegClosePath();