Bug 602759 part 11 - Update nsSVGTransformListParser to use new SVG transform types; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Sun, 25 Sep 2011 22:04:31 +0100
changeset 78866 ec7fb3b6bbaf032e45f0052a9ed6918cf46d23c0
parent 78865 b8fcaa2794f3280d3d9bef13cee477470cf19acf
child 78867 af1b9b6267bfcb5e98caa903129fec1ae273e01c
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs602759
milestone9.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 602759 part 11 - Update nsSVGTransformListParser to use new SVG transform types; r=jwatt
content/svg/content/src/nsSVGTransformListParser.cpp
content/svg/content/src/nsSVGTransformListParser.h
--- a/content/svg/content/src/nsSVGTransformListParser.cpp
+++ b/content/svg/content/src/nsSVGTransformListParser.cpp
@@ -31,41 +31,35 @@
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsSVGTransformListParser.h"
+#include "SVGTransform.h"
 #include "prdtoa.h"
-#include "nsSVGTransform.h"
-#include "nsSVGMatrix.h"
 #include "nsDOMError.h"
 #include "nsGkAtoms.h"
 #include "nsReadableUtils.h"
 #include "nsCRT.h"
-#include "nsCOMArray.h"
 #include "nsContentUtils.h"
 #include "nsIDOMClassInfo.h"
-
-//----------------------------------------------------------------------
-// public interface
+#include "nsIAtom.h"
 
-nsSVGTransformListParser::nsSVGTransformListParser(nsCOMArray<nsIDOMSVGTransform>* aTransforms)
-    : mTransform(aTransforms)
-{
-}
+using namespace mozilla;
 
 //----------------------------------------------------------------------
 // private methods
 
 nsresult
 nsSVGTransformListParser::Match()
 {
+  mTransforms.Clear();
   return MatchTransformList();
 }
 
 
 nsresult
 nsSVGTransformListParser::MatchTransformList()
 {
   MatchWsp();
@@ -227,44 +221,33 @@ nsSVGTransformListParser::MatchNumberArg
 
   MatchWsp();
 
   ENSURE_MATCHED(MatchRightParen());
 
   return NS_OK;
 }
 
-nsIDOMSVGTransform *
-nsSVGTransformListParser::AppendTransform()
-{
-  nsCOMPtr<nsIDOMSVGTransform> transform;
-  NS_NewSVGTransform(getter_AddRefs(transform));
-  if (transform) {
-    mTransform->AppendObject(transform);
-  }
-  return transform;
-}
-
 nsresult
 nsSVGTransformListParser::MatchTranslate()
 {
   GetNextToken();
 
   float t[2];
   PRUint32 count;
 
   ENSURE_MATCHED(MatchNumberArguments(t, NS_ARRAY_LENGTH(t), &count));
 
   switch (count) {
     case 1:
       t[1] = 0.f;
       // fall-through
     case 2:
     {
-      nsIDOMSVGTransform *transform = AppendTransform();
+      SVGTransform* transform = mTransforms.AppendElement();
       NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
       transform->SetTranslate(t[0], t[1]);
       break;
     }
     default:
       return NS_ERROR_FAILURE;
   }
 
@@ -283,17 +266,17 @@ nsSVGTransformListParser::MatchScale()
   ENSURE_MATCHED(MatchNumberArguments(s, NS_ARRAY_LENGTH(s), &count));
 
   switch (count) {
     case 1:
       s[1] = s[0];
       // fall-through
     case 2:
     {
-      nsIDOMSVGTransform *transform = AppendTransform();
+      SVGTransform* transform = mTransforms.AppendElement();
       NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
       transform->SetScale(s[0], s[1]);
       break;
     }
     default:
       return NS_ERROR_FAILURE;
   }
 
@@ -312,17 +295,17 @@ nsSVGTransformListParser::MatchRotate()
   ENSURE_MATCHED(MatchNumberArguments(r, NS_ARRAY_LENGTH(r), &count));
 
   switch (count) {
     case 1:
       r[1] = r[2] = 0.f;
       // fall-through
     case 3:
     {
-      nsIDOMSVGTransform *transform = AppendTransform();
+      SVGTransform* transform = mTransforms.AppendElement();
       NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
       transform->SetRotate(r[0], r[1], r[2]);
       break;
     }
     default:
       return NS_ERROR_FAILURE;
   }
 
@@ -339,17 +322,17 @@ nsSVGTransformListParser::MatchSkewX()
   PRUint32 count;
 
   ENSURE_MATCHED(MatchNumberArguments(&skew, 1, &count));
 
   if (count != 1) {
     return NS_ERROR_FAILURE;
   }
 
-  nsIDOMSVGTransform *transform = AppendTransform();
+  SVGTransform* transform = mTransforms.AppendElement();
   NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
   transform->SetSkewX(skew);
 
   return NS_OK;
 }
 
 
 nsresult
@@ -361,17 +344,17 @@ nsSVGTransformListParser::MatchSkewY()
   PRUint32 count;
 
   ENSURE_MATCHED(MatchNumberArguments(&skew, 1, &count));
 
   if (count != 1) {
     return NS_ERROR_FAILURE;
   }
 
-  nsIDOMSVGTransform *transform = AppendTransform();
+  SVGTransform* transform = mTransforms.AppendElement();
   NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
   transform->SetSkewY(skew);
 
   return NS_OK;
 }
 
 
 nsresult
@@ -383,19 +366,14 @@ nsSVGTransformListParser::MatchMatrix()
   PRUint32 count;
 
   ENSURE_MATCHED(MatchNumberArguments(m, NS_ARRAY_LENGTH(m), &count));
 
   if (count != 6) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsIDOMSVGMatrix> matrix;
-  NS_NewSVGMatrix(getter_AddRefs(matrix),
-                  m[0], m[1], m[2], m[3], m[4], m[5]);
-  NS_ENSURE_TRUE(matrix, NS_ERROR_OUT_OF_MEMORY);
-
-  nsIDOMSVGTransform *transform = AppendTransform();
+  SVGTransform* transform = mTransforms.AppendElement();
   NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
-  transform->SetMatrix(matrix);
+  transform->SetMatrix(gfxMatrix(m[0], m[1], m[2], m[3], m[4], m[5]));
 
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGTransformListParser.h
+++ b/content/svg/content/src/nsSVGTransformListParser.h
@@ -34,43 +34,44 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef __NS_SVGTRANSFORMLISTPARSER_H__
 #define __NS_SVGTRANSFORMLISTPARSER_H__
 
 #include "nsSVGDataParser.h"
-#include "nsCOMPtr.h"
-#include "nsCOMArray.h"
-#include "nsIDOMSVGTransformList.h"
-#include "nsIAtom.h"
+#include "nsTArray.h"
 
 ////////////////////////////////////////////////////////////////////////
 // nsSVGTransformListParser: taken from nsSVGPathDataParser, a simple
 //  recursive descent parser that builds the transform lists from the
 //  transform attributes. The grammar for path data
 // can be found in SVG 1.1,  chapter 7.
 // http://www.w3.org/TR/SVG11/coords.html#TransformAttribute
 
+class nsIAtom;
+namespace mozilla { class SVGTransform; }
+
 class nsSVGTransformListParser : public nsSVGDataParser
 {
 public:
-  nsSVGTransformListParser(nsCOMArray<nsIDOMSVGTransform>* aTransforms);
+  const nsTArray<mozilla::SVGTransform>& GetTransformList() const {
+    return mTransforms;
+  }
 
 private:
-  nsCOMArray<nsIDOMSVGTransform> *mTransform;
+  nsTArray<mozilla::SVGTransform> mTransforms;
 
   // helpers
   virtual nsresult Match();
 
   nsresult MatchNumberArguments(float *aResult,
                                 PRUint32 aMaxNum,
                                 PRUint32 *aParsedNum);
-  nsIDOMSVGTransform *AppendTransform();
 
   nsresult MatchTransformList();
 
   nsresult GetTransformToken(nsIAtom** aKeyatom, PRBool aAdvancePos);
   nsresult MatchTransforms();
 
   nsresult MatchTransform();