2001-12-12 07:59:31 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2001-12-12 07:59:31 +00:00
|
|
|
|
|
|
|
#ifndef __NS_SVGPATHDATAPARSER_H__
|
|
|
|
#define __NS_SVGPATHDATAPARSER_H__
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-24 12:46:38 +00:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2012-01-26 09:57:21 +00:00
|
|
|
#include "nsSVGDataParser.h"
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
namespace mozilla {
|
|
|
|
class SVGPathData;
|
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
// nsSVGPathDataParser: a simple recursive descent parser that builds
|
2012-12-23 04:54:22 +00:00
|
|
|
// DOMSVGPathSegs from path data strings. The grammar for path data
|
2001-12-12 07:59:31 +00:00
|
|
|
// can be found in SVG CR 20001102, chapter 8.
|
|
|
|
|
2006-06-16 17:20:25 +00:00
|
|
|
class nsSVGPathDataParser : public nsSVGDataParser
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2013-10-29 17:15:39 +00:00
|
|
|
public:
|
|
|
|
nsSVGPathDataParser(const nsAString& aValue,
|
|
|
|
mozilla::SVGPathData* aList)
|
|
|
|
: nsSVGDataParser(aValue),
|
|
|
|
mPathSegList(aList)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aList, "null path data");
|
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool Parse();
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
private:
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParseCoordPair(float& aX, float& aY);
|
|
|
|
bool ParseFlag(bool& aFlag);
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParsePath();
|
|
|
|
bool IsStartOfSubPath() const;
|
|
|
|
bool ParseSubPath();
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-10-29 17:15:39 +00:00
|
|
|
bool ParseSubPathElements();
|
2014-01-04 15:02:17 +00:00
|
|
|
bool ParseSubPathElement(char16_t aCommandType,
|
2013-10-29 17:15:39 +00: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;
|
|
|
|
};
|
2006-05-03 17:01:28 +00:00
|
|
|
|
2010-11-08 15:07:00 +00:00
|
|
|
class nsSVGArcConverter
|
2006-05-03 17:01:28 +00:00
|
|
|
{
|
2013-10-24 12:46:38 +00:00
|
|
|
typedef mozilla::gfx::Point Point;
|
|
|
|
|
2006-05-03 17:01:28 +00:00
|
|
|
public:
|
2013-10-24 12:46:38 +00:00
|
|
|
nsSVGArcConverter(const Point& from,
|
|
|
|
const Point& to,
|
|
|
|
const Point& radii,
|
2010-11-08 15:07:00 +00:00
|
|
|
double angle,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool largeArcFlag,
|
|
|
|
bool sweepFlag);
|
2013-10-24 12:46:38 +00:00
|
|
|
bool GetNextSegment(Point* cp1, Point* cp2, Point* to);
|
2006-05-03 17:01:28 +00:00
|
|
|
protected:
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mNumSegs, mSegIndex;
|
2010-11-08 15:07:00 +00:00
|
|
|
double mTheta, mDelta, mT;
|
|
|
|
double mSinPhi, mCosPhi;
|
|
|
|
double mRx, mRy;
|
2013-10-24 12:46:38 +00:00
|
|
|
Point mFrom, mC;
|
2006-05-03 17:01:28 +00:00
|
|
|
};
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
#endif // __NS_SVGPATHDATAPARSER_H__
|