2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2006-09-14 13:48:36 +00:00
|
|
|
|
2011-09-25 21:04:32 +00:00
|
|
|
#ifndef MOZILLA_SVGTRANSFORMLISTPARSER_H__
|
|
|
|
#define MOZILLA_SVGTRANSFORMLISTPARSER_H__
|
2006-09-14 13:48:36 +00:00
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2006-09-14 13:48:36 +00:00
|
|
|
#include "nsSVGDataParser.h"
|
2011-09-25 21:04:31 +00:00
|
|
|
#include "nsTArray.h"
|
2006-09-14 13:48:36 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
2013-10-29 17:15:39 +00:00
|
|
|
// SVGTransformListParser: A simple recursive descent parser that builds
|
|
|
|
// transform lists from transform attributes. The grammar for path data
|
2006-09-14 13:48:36 +00:00
|
|
|
// can be found in SVG 1.1, chapter 7.
|
|
|
|
// http://www.w3.org/TR/SVG11/coords.html#TransformAttribute
|
|
|
|
|
2011-09-25 21:04:32 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
class nsSVGTransform;
|
2011-09-25 21:04:32 +00:00
|
|
|
|
|
|
|
class SVGTransformListParser : public nsSVGDataParser
|
2006-09-14 13:48:36 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 01:08:04 +00:00
|
|
|
explicit SVGTransformListParser(const nsAString& aValue)
|
2013-10-29 17:15:39 +00:00
|
|
|
: nsSVGDataParser(aValue) {}
|
|
|
|
|
|
|
|
bool Parse();
|
|
|
|
|
2013-04-02 19:17:41 +00:00
|
|
|
const nsTArray<nsSVGTransform>& GetTransformList() const {
|
2011-09-25 21:04:31 +00:00
|
|
|
return mTransforms;
|
|
|
|
}
|
2006-09-14 13:48:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// helpers
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParseArguments(float *aResult,
|
|
|
|
uint32_t aMaxCount,
|
|
|
|
uint32_t *aParsedCount);
|
2006-09-14 13:48:36 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParseTransforms();
|
2006-09-14 13:48:36 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParseTransform();
|
2006-09-14 13:48:36 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParseTranslate();
|
|
|
|
bool ParseScale();
|
|
|
|
bool ParseRotate();
|
|
|
|
bool ParseSkewX();
|
|
|
|
bool ParseSkewY();
|
|
|
|
bool ParseMatrix();
|
2006-09-14 13:48:36 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
FallibleTArray<nsSVGTransform> mTransforms;
|
2006-09-14 13:48:36 +00:00
|
|
|
};
|
|
|
|
|
2011-09-25 21:04:32 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_SVGTRANSFORMLISTPARSER_H__
|