• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "core/SVGNames.h"
25 #include "core/svg/SVGAnimatedBoolean.h"
26 #include "core/svg/SVGAnimatedNumber.h"
27 #include "core/svg/SVGAnimatedPath.h"
28 #include "core/svg/SVGGeometryElement.h"
29 #include "core/svg/SVGPathByteStream.h"
30 #include "wtf/WeakPtr.h"
31 
32 namespace WebCore {
33 
34 class SVGPathSegArcAbs;
35 class SVGPathSegArcRel;
36 class SVGPathSegClosePath;
37 class SVGPathSegLinetoAbs;
38 class SVGPathSegLinetoRel;
39 class SVGPathSegMovetoAbs;
40 class SVGPathSegMovetoRel;
41 class SVGPathSegCurvetoCubicAbs;
42 class SVGPathSegCurvetoCubicRel;
43 class SVGPathSegLinetoVerticalAbs;
44 class SVGPathSegLinetoVerticalRel;
45 class SVGPathSegLinetoHorizontalAbs;
46 class SVGPathSegLinetoHorizontalRel;
47 class SVGPathSegCurvetoQuadraticAbs;
48 class SVGPathSegCurvetoQuadraticRel;
49 class SVGPathSegCurvetoCubicSmoothAbs;
50 class SVGPathSegCurvetoCubicSmoothRel;
51 class SVGPathSegCurvetoQuadraticSmoothAbs;
52 class SVGPathSegCurvetoQuadraticSmoothRel;
53 
54 class SVGPathElement FINAL : public SVGGeometryElement {
55 public:
56     DECLARE_NODE_FACTORY(SVGPathElement);
57 
58     float getTotalLength();
59     PassRefPtr<SVGPointTearOff> getPointAtLength(float distance);
60     unsigned getPathSegAtLength(float distance);
61 
pathLength()62     SVGAnimatedNumber* pathLength() { return m_pathLength.get(); }
63 
64     PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath();
65     PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y);
66     PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y);
67     PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y);
68     PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y);
69     PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2);
70     PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2);
71     PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1);
72     PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1);
73     PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
74     PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag);
75     PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x);
76     PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x);
77     PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y);
78     PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y);
79     PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2);
80     PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2);
81     PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y);
82     PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y);
83 
84     // Used in the bindings only.
pathSegList()85     SVGPathSegListTearOff* pathSegList() { return m_pathSegList->baseVal(); }
animatedPathSegList()86     SVGPathSegListTearOff* animatedPathSegList() { return m_pathSegList->animVal(); }
87 
88     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists!
normalizedPathSegList()89     SVGPathSegListTearOff* normalizedPathSegList() { return 0; }
animatedNormalizedPathSegList()90     SVGPathSegListTearOff* animatedNormalizedPathSegList() { return 0; }
91 
pathByteStream()92     const SVGPathByteStream* pathByteStream() const { return m_pathSegList->currentValue()->byteStream(); }
93 
94     void pathSegListChanged(ListModification = ListModificationUnknown);
95 
96     virtual FloatRect getBBox() OVERRIDE;
97 
98 private:
99     explicit SVGPathElement(Document&);
100 
101     bool isSupportedAttribute(const QualifiedName&);
102     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
103     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
104 
105     virtual Node::InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
106     virtual void removedFrom(ContainerNode*) OVERRIDE;
107 
108     void invalidateMPathDependencies();
109 
110     RefPtr<SVGAnimatedNumber> m_pathLength;
111     RefPtr<SVGAnimatedPath> m_pathSegList;
112 };
113 
114 } // namespace WebCore
115 
116 #endif
117