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 "SVGAnimatedBoolean.h"
26 #include "SVGAnimatedNumber.h"
27 #include "SVGExternalResourcesRequired.h"
28 #include "SVGGraphicsElement.h"
30 #include "SVGPathByteStream.h"
31 #include "SVGPathSegList.h"
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 class SVGPathSegListPropertyTearOff;
56 class SVGPathElement FINAL : public SVGGraphicsElement,
57 public SVGExternalResourcesRequired {
59 static PassRefPtr<SVGPathElement> create(const QualifiedName&, Document&);
61 float getTotalLength();
62 SVGPoint getPointAtLength(float distance);
63 unsigned getPathSegAtLength(float distance);
65 PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(SVGPathSegRole role = PathSegUndefinedRole);
66 PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
67 PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
68 PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
69 PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
70 PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
71 PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
72 PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1, SVGPathSegRole role = PathSegUndefinedRole);
73 PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1, SVGPathSegRole role = PathSegUndefinedRole);
74 PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role = PathSegUndefinedRole);
75 PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPathSegRole role = PathSegUndefinedRole);
76 PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x, SVGPathSegRole role = PathSegUndefinedRole);
77 PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x, SVGPathSegRole role = PathSegUndefinedRole);
78 PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y, SVGPathSegRole role = PathSegUndefinedRole);
79 PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y, SVGPathSegRole role = PathSegUndefinedRole);
80 PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
81 PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2, SVGPathSegRole role = PathSegUndefinedRole);
82 PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
83 PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y, SVGPathSegRole role = PathSegUndefinedRole);
85 // Used in the bindings only.
86 SVGPathSegListPropertyTearOff* pathSegList();
87 SVGPathSegListPropertyTearOff* animatedPathSegList();
88 SVGPathSegListPropertyTearOff* normalizedPathSegList();
89 SVGPathSegListPropertyTearOff* animatedNormalizedPathSegList();
91 SVGPathByteStream* pathByteStream() const;
93 void pathSegListChanged(SVGPathSegRole, ListModification = ListModificationUnknown);
95 virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate);
97 static const SVGPropertyInfo* dPropertyInfo();
99 bool isAnimValObserved() const { return m_isAnimValObserved; }
102 SVGPathElement(const QualifiedName&, Document&);
104 virtual bool isValid() const { return SVGTests::isValid(); }
105 virtual bool supportsFocus() const OVERRIDE { return true; }
107 bool isSupportedAttribute(const QualifiedName&);
108 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
109 virtual void svgAttributeChanged(const QualifiedName&);
110 virtual bool supportsMarkers() const { return true; }
112 // Custom 'd' property
113 static void synchronizeD(SVGElement* contextElement);
114 static PassRefPtr<SVGAnimatedProperty> lookupOrCreateDWrapper(SVGElement* contextElement);
116 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGPathElement)
117 DECLARE_ANIMATED_NUMBER(PathLength, pathLength)
118 DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired)
119 END_DECLARE_ANIMATED_PROPERTIES
121 virtual RenderElement* createRenderer(PassRef<RenderStyle>) OVERRIDE;
123 virtual Node::InsertionNotificationRequest insertedInto(ContainerNode&) OVERRIDE;
124 virtual void removedFrom(ContainerNode&) OVERRIDE;
126 void invalidateMPathDependencies();
129 std::unique_ptr<SVGPathByteStream> m_pathByteStream;
130 mutable SVGSynchronizableAnimatedProperty<SVGPathSegList> m_pathSegList;
131 bool m_isAnimValObserved;
134 NODE_TYPE_CASTS(SVGPathElement)
136 } // namespace WebCore
138 #endif // ENABLE(SVG)