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