OSDN Git Service

Merge Webkit at r70949: Initial merge by git.
[android-x86/external-webkit.git] / WebCore / svg / SVGPathElement.h
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
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 SVGPathElement_h
22 #define SVGPathElement_h
23
24 #if ENABLE(SVG)
25 #include "SVGAnimatedPathData.h"
26 #include "SVGAnimatedPropertyMacros.h"
27 #include "SVGExternalResourcesRequired.h"
28 #include "SVGLangSpace.h"
29 #include "SVGStyledTransformableElement.h"
30 #include "SVGTests.h"
31
32 namespace WebCore {
33
34     class SVGPathSeg;
35     class SVGPathSegArcAbs;
36     class SVGPathSegArcRel;
37     class SVGPathSegClosePath;
38     class SVGPathSegLinetoAbs;
39     class SVGPathSegLinetoRel;
40     class SVGPathSegMovetoAbs;
41     class SVGPathSegMovetoRel;
42     class SVGPathSegCurvetoCubicAbs;
43     class SVGPathSegCurvetoCubicRel;
44     class SVGPathSegLinetoVerticalAbs;
45     class SVGPathSegLinetoVerticalRel;
46     class SVGPathSegLinetoHorizontalAbs;
47     class SVGPathSegLinetoHorizontalRel;
48     class SVGPathSegCurvetoQuadraticAbs;
49     class SVGPathSegCurvetoQuadraticRel;
50     class SVGPathSegCurvetoCubicSmoothAbs;
51     class SVGPathSegCurvetoCubicSmoothRel;
52     class SVGPathSegCurvetoQuadraticSmoothAbs;
53     class SVGPathSegCurvetoQuadraticSmoothRel;
54
55     class SVGPathElement : public SVGStyledTransformableElement,
56                            public SVGTests,
57                            public SVGLangSpace,
58                            public SVGExternalResourcesRequired,
59                            public SVGAnimatedPathData {
60     public:
61         static PassRefPtr<SVGPathElement> create(const QualifiedName&, Document*);
62         
63         float getTotalLength();
64         FloatPoint getPointAtLength(float distance);
65         unsigned long getPathSegAtLength(float distance);
66
67         static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath();
68         static PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y);
69         static PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y);
70         static PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y);
71         static PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y);
72         static PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
73         static PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2);
74         static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
75         static PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);
76         static PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
77         static PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
78         static PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x);
79         static PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x);
80         static PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y);
81         static PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y);
82         static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
83         static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);
84         static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
85         static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y);
86
87         // Derived from: 'SVGAnimatedPathData'
88         virtual SVGPathSegList* pathSegList() const;
89         virtual SVGPathSegList* normalizedPathSegList() const;
90         virtual SVGPathSegList* animatedPathSegList() const;
91         virtual SVGPathSegList* animatedNormalizedPathSegList() const;
92
93         virtual void toPathData(Path&) const;
94
95     private:
96         SVGPathElement(const QualifiedName&, Document*);
97
98         virtual bool isValid() const { return SVGTests::isValid(); }
99
100         virtual void parseMappedAttribute(Attribute*);
101         virtual void svgAttributeChanged(const QualifiedName&);
102         virtual void synchronizeProperty(const QualifiedName&);
103
104         virtual bool supportsMarkers() const { return true; }
105
106         mutable RefPtr<SVGPathSegList> m_pathSegList;
107
108         DECLARE_ANIMATED_PROPERTY(SVGPathElement, SVGNames::pathLengthAttr, float, PathLength, pathLength)
109
110         // SVGExternalResourcesRequired
111         DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGPathElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired)
112     };
113
114 } // namespace WebCore
115
116 #endif // ENABLE(SVG)
117 #endif