2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
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.
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.
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.
21 #ifndef SVGPathElement_h
22 #define SVGPathElement_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"
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;
54 class SVGPathElement FINAL : public SVGGeometryElement {
56 static PassRefPtr<SVGPathElement> create(Document&);
58 float getTotalLength();
59 PassRefPtr<SVGPointTearOff> getPointAtLength(float distance);
60 unsigned getPathSegAtLength(float distance);
62 SVGAnimatedNumber* pathLength() { return m_pathLength.get(); }
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);
84 // Used in the bindings only.
85 SVGPathSegListPropertyTearOff* pathSegList();
86 SVGPathSegListPropertyTearOff* animatedPathSegList();
87 SVGPathSegListPropertyTearOff* normalizedPathSegList();
88 SVGPathSegListPropertyTearOff* animatedNormalizedPathSegList();
90 SVGPathByteStream* pathByteStream() const;
92 void pathSegListChanged(SVGPathSegRole, ListModification = ListModificationUnknown);
94 virtual FloatRect getBBox() OVERRIDE;
96 static const SVGPropertyInfo* dPropertyInfo();
98 bool isAnimValObserved() const { return m_isAnimValObserved; }
101 explicit SVGPathElement(Document&);
103 virtual bool supportsFocus() const OVERRIDE { return hasFocusEventListeners(); }
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; }
110 // Custom 'd' property
111 static void synchronizeD(SVGElement* contextElement);
112 static PassRefPtr<SVGAnimatedProperty> lookupOrCreateDWrapper(SVGElement* contextElement);
114 virtual Node::InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
115 virtual void removedFrom(ContainerNode*) OVERRIDE;
117 void invalidateMPathDependencies();
119 OwnPtr<SVGPathByteStream> m_pathByteStream;
120 mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList;
121 bool m_isAnimValObserved;
123 RefPtr<SVGAnimatedNumber> m_pathLength;
124 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGPathElement)
125 END_DECLARE_ANIMATED_PROPERTIES
128 DEFINE_NODE_TYPE_CASTS(SVGPathElement, hasTagName(SVGNames::pathTag));
130 } // namespace WebCore