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