Bug 602759 part 11 - Update nsSVGTransformListParser to use new SVG transform types; r=jwatt

This commit is contained in:
Brian Birtles 2011-09-25 22:04:31 +01:00
Родитель 23a09913b7
Коммит 0aa10c2fb2
2 изменённых файлов: 19 добавлений и 40 удалений

Просмотреть файл

@ -36,24 +36,17 @@
* ***** 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"
#include "nsIAtom.h"
//----------------------------------------------------------------------
// public interface
nsSVGTransformListParser::nsSVGTransformListParser(nsCOMArray<nsIDOMSVGTransform>* aTransforms)
: mTransform(aTransforms)
{
}
using namespace mozilla;
//----------------------------------------------------------------------
// private methods
@ -61,6 +54,7 @@ nsSVGTransformListParser::nsSVGTransformListParser(nsCOMArray<nsIDOMSVGTransform
nsresult
nsSVGTransformListParser::Match()
{
mTransforms.Clear();
return MatchTransformList();
}
@ -232,17 +226,6 @@ nsSVGTransformListParser::MatchNumberArguments(float *aResult,
return NS_OK;
}
nsIDOMSVGTransform *
nsSVGTransformListParser::AppendTransform()
{
nsCOMPtr<nsIDOMSVGTransform> transform;
NS_NewSVGTransform(getter_AddRefs(transform));
if (transform) {
mTransform->AppendObject(transform);
}
return transform;
}
nsresult
nsSVGTransformListParser::MatchTranslate()
{
@ -259,7 +242,7 @@ nsSVGTransformListParser::MatchTranslate()
// 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;
@ -288,7 +271,7 @@ nsSVGTransformListParser::MatchScale()
// 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;
@ -317,7 +300,7 @@ nsSVGTransformListParser::MatchRotate()
// 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;
@ -344,7 +327,7 @@ nsSVGTransformListParser::MatchSkewX()
return NS_ERROR_FAILURE;
}
nsIDOMSVGTransform *transform = AppendTransform();
SVGTransform* transform = mTransforms.AppendElement();
NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
transform->SetSkewX(skew);
@ -366,7 +349,7 @@ nsSVGTransformListParser::MatchSkewY()
return NS_ERROR_FAILURE;
}
nsIDOMSVGTransform *transform = AppendTransform();
SVGTransform* transform = mTransforms.AppendElement();
NS_ENSURE_TRUE(transform, NS_ERROR_OUT_OF_MEMORY);
transform->SetSkewY(skew);
@ -388,14 +371,9 @@ nsSVGTransformListParser::MatchMatrix()
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;
}

Просмотреть файл

@ -39,10 +39,7 @@
#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
@ -51,13 +48,18 @@
// 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();
@ -65,7 +67,6 @@ private:
nsresult MatchNumberArguments(float *aResult,
PRUint32 aMaxNum,
PRUint32 *aParsedNum);
nsIDOMSVGTransform *AppendTransform();
nsresult MatchTransformList();