2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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
|
|
|
|
|
|
|
#ifndef __NS_SVGPATHDATAPARSER_H__
|
|
|
|
#define __NS_SVGPATHDATAPARSER_H__
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-24 05:46:38 -07:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2012-01-26 01:57:21 -08:00
|
|
|
#include "nsSVGDataParser.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-11-08 07:07:00 -08:00
|
|
|
namespace mozilla {
|
|
|
|
class SVGPathData;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsSVGPathDataParser: a simple recursive descent parser that builds
|
2012-12-22 20:54:22 -08:00
|
|
|
// DOMSVGPathSegs from path data strings. The grammar for path data
|
2007-03-22 10:30:00 -07:00
|
|
|
// can be found in SVG CR 20001102, chapter 8.
|
|
|
|
|
|
|
|
class nsSVGPathDataParser : public nsSVGDataParser
|
|
|
|
{
|
2013-10-29 10:15:39 -07:00
|
|
|
public:
|
|
|
|
nsSVGPathDataParser(const nsAString& aValue,
|
|
|
|
mozilla::SVGPathData* aList)
|
|
|
|
: nsSVGDataParser(aValue),
|
|
|
|
mPathSegList(aList)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aList, "null path data");
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-29 10:15:39 -07:00
|
|
|
bool Parse();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-29 10:15:39 -07:00
|
|
|
private:
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-29 10:15:39 -07:00
|
|
|
bool ParseCoordPair(float& aX, float& aY);
|
|
|
|
bool ParseFlag(bool& aFlag);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-29 10:15:39 -07:00
|
|
|
bool ParsePath();
|
|
|
|
bool IsStartOfSubPath() const;
|
|
|
|
bool ParseSubPath();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-29 10:15:39 -07:00
|
|
|
bool ParseSubPathElements();
|
2014-01-04 07:02:17 -08:00
|
|
|
bool ParseSubPathElement(char16_t aCommandType,
|
2013-10-29 10:15:39 -07:00
|
|
|
bool aAbsCoords);
|
|
|
|
|
|
|
|
bool ParseMoveto();
|
|
|
|
bool ParseClosePath();
|
|
|
|
bool ParseLineto(bool aAbsCoords);
|
|
|
|
bool ParseHorizontalLineto(bool aAbsCoords);
|
|
|
|
bool ParseVerticalLineto(bool aAbsCoords);
|
|
|
|
bool ParseCurveto(bool aAbsCoords);
|
|
|
|
bool ParseSmoothCurveto(bool aAbsCoords);
|
|
|
|
bool ParseQuadBezierCurveto(bool aAbsCoords);
|
|
|
|
bool ParseSmoothQuadBezierCurveto(bool aAbsCoords);
|
|
|
|
bool ParseEllipticalArc(bool aAbsCoords);
|
|
|
|
|
|
|
|
mozilla::SVGPathData * const mPathSegList;
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-11-08 07:07:00 -08:00
|
|
|
class nsSVGArcConverter
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-10-24 05:46:38 -07:00
|
|
|
typedef mozilla::gfx::Point Point;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2013-10-24 05:46:38 -07:00
|
|
|
nsSVGArcConverter(const Point& from,
|
|
|
|
const Point& to,
|
|
|
|
const Point& radii,
|
2010-11-08 07:07:00 -08:00
|
|
|
double angle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool largeArcFlag,
|
|
|
|
bool sweepFlag);
|
2013-10-24 05:46:38 -07:00
|
|
|
bool GetNextSegment(Point* cp1, Point* cp2, Point* to);
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mNumSegs, mSegIndex;
|
2010-11-08 07:07:00 -08:00
|
|
|
double mTheta, mDelta, mT;
|
|
|
|
double mSinPhi, mCosPhi;
|
|
|
|
double mRx, mRy;
|
2013-10-24 05:46:38 -07:00
|
|
|
Point mFrom, mC;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __NS_SVGPATHDATAPARSER_H__
|