1/*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef SVGPathStringSource_h
22#define SVGPathStringSource_h
23
24#include "core/svg/SVGPathSource.h"
25#include "wtf/PassOwnPtr.h"
26#include "wtf/text/WTFString.h"
27
28namespace WebCore {
29
30class SVGPathStringSource : public SVGPathSource {
31public:
32    static PassOwnPtr<SVGPathStringSource> create(const String& string)
33    {
34        return adoptPtr(new SVGPathStringSource(string));
35    }
36
37private:
38    SVGPathStringSource(const String&);
39
40    virtual bool hasMoreData() const;
41    virtual bool moveToNextToken();
42    virtual bool parseSVGSegmentType(SVGPathSegType&);
43    virtual SVGPathSegType nextCommand(SVGPathSegType previousCommand);
44
45    virtual bool parseMoveToSegment(FloatPoint&);
46    virtual bool parseLineToSegment(FloatPoint&);
47    virtual bool parseLineToHorizontalSegment(float&);
48    virtual bool parseLineToVerticalSegment(float&);
49    virtual bool parseCurveToCubicSegment(FloatPoint&, FloatPoint&, FloatPoint&);
50    virtual bool parseCurveToCubicSmoothSegment(FloatPoint&, FloatPoint&);
51    virtual bool parseCurveToQuadraticSegment(FloatPoint&, FloatPoint&);
52    virtual bool parseCurveToQuadraticSmoothSegment(FloatPoint&);
53    virtual bool parseArcToSegment(float&, float&, float&, bool&, bool&, FloatPoint&);
54
55    String m_string;
56    bool m_is8BitSource;
57
58    union {
59        const LChar* m_character8;
60        const UChar* m_character16;
61    } m_current;
62    union {
63        const LChar* m_character8;
64        const UChar* m_character16;
65    } m_end;
66};
67
68} // namespace WebCore
69
70#endif // SVGPathStringSource_h
71