Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / 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 #include "SVGNames.h"
25 #include "core/svg/SVGAnimatedBoolean.h"
26 #include "core/svg/SVGAnimatedNumber.h"
27 #include "core/svg/SVGGeometryElement.h"
28 #include "core/svg/SVGPathByteStream.h"
29 #include "core/svg/SVGPathSegList.h"
30
31 namespace WebCore {
32
33 class SVGPathSegArcAbs;
34 class SVGPathSegArcRel;
35 class SVGPathSegClosePath;
36 class SVGPathSegLinetoAbs;
37 class SVGPathSegLinetoRel;
38 class SVGPathSegMovetoAbs;
39 class SVGPathSegMovetoRel;
40 class SVGPathSegCurvetoCubicAbs;
41 class SVGPathSegCurvetoCubicRel;
42 class SVGPathSegLinetoVerticalAbs;
43 class SVGPathSegLinetoVerticalRel;
44 class SVGPathSegLinetoHorizontalAbs;
45 class SVGPathSegLinetoHorizontalRel;
46 class SVGPathSegCurvetoQuadraticAbs;
47 class SVGPathSegCurvetoQuadraticRel;
48 class SVGPathSegCurvetoCubicSmoothAbs;
49 class SVGPathSegCurvetoCubicSmoothRel;
50 class SVGPathSegCurvetoQuadraticSmoothAbs;
51 class SVGPathSegCurvetoQuadraticSmoothRel;
52 class SVGPathSegListPropertyTearOff;
53
54 class SVGPathElement FINAL : public SVGGeometryElement {
55 public:
56     static PassRefPtr<SVGPathElement> create(Document&);
57
58     float getTotalLength();
59     PassRefPtr<SVGPointTearOff> getPointAtLength(float distance);
60     unsigned getPathSegAtLength(float distance);
61
62     SVGAnimatedNumber* pathLength() { return m_pathLength.get(); }
63
64     PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(SVGPathSegRole role = PathSegUndefinedRole);
65     PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
66     PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
67     PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
68     PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
69     PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
70     PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
71     PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, SVGPathSegRole role = PathSegUndefinedRole);
72     PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, SVGPathSegRole role = PathSegUndefinedRole);
73     PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role = PathSegUndefinedRole);
74     PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role = PathSegUndefinedRole);
75     PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x, SVGPathSegRole role = PathSegUndefinedRole);
76     PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x, SVGPathSegRole role = PathSegUndefinedRole);
77     PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y, SVGPathSegRole role = PathSegUndefinedRole);
78     PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y, SVGPathSegRole role = PathSegUndefinedRole);
79     PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
80     PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
81     PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
82     PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
83
84     // Used in the bindings only.
85     SVGPathSegListPropertyTearOff* pathSegList();
86     SVGPathSegListPropertyTearOff* animatedPathSegList();
87     SVGPathSegListPropertyTearOff* normalizedPathSegList();
88     SVGPathSegListPropertyTearOff* animatedNormalizedPathSegList();
89
90     SVGPathByteStream* pathByteStream() const;
91
92     void pathSegListChanged(SVGPathSegRole, ListModification = ListModificationUnknown);
93
94     virtual FloatRect getBBox() OVERRIDE;
95
96     static const SVGPropertyInfo* dPropertyInfo();
97
98     bool isAnimValObserved() const { return m_isAnimValObserved; }
99
100 private:
101     explicit SVGPathElement(Document&);
102
103     virtual bool supportsFocus() const OVERRIDE { return hasFocusEventListeners(); }
104
105     bool isSupportedAttribute(const QualifiedName&);
106     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
107     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
108     virtual bool supportsMarkers() const OVERRIDE { return true; }
109
110     // Custom 'd' property
111     static void synchronizeD(SVGElement* contextElement);
112     static PassRefPtr<SVGAnimatedProperty> lookupOrCreateDWrapper(SVGElement* contextElement);
113
114     virtual Node::InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
115     virtual void removedFrom(ContainerNode*) OVERRIDE;
116
117     void invalidateMPathDependencies();
118
119     OwnPtr<SVGPathByteStream> m_pathByteStream;
120     mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList;
121     bool m_isAnimValObserved;
122
123     RefPtr<SVGAnimatedNumber> m_pathLength;
124     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGPathElement)
125     END_DECLARE_ANIMATED_PROPERTIES
126 };
127
128 DEFINE_NODE_TYPE_CASTS(SVGPathElement, hasTagName(SVGNames::pathTag));
129
130 } // namespace WebCore
131
132 #endif