• 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, 2008 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 SVGPathSeg_h
22 #define SVGPathSeg_h
23 
24 #include "bindings/v8/ScriptWrappable.h"
25 #include "wtf/RefCounted.h"
26 #include "wtf/text/WTFString.h"
27 
28 namespace WebCore {
29 
30 enum ListModification {
31     ListModificationUnknown = 0,
32     ListModificationInsert = 1,
33     ListModificationReplace = 2,
34     ListModificationRemove = 3,
35     ListModificationAppend = 4
36 };
37 
38 enum SVGPathSegType {
39     PathSegUnknown = 0,
40     PathSegClosePath = 1,
41     PathSegMoveToAbs = 2,
42     PathSegMoveToRel = 3,
43     PathSegLineToAbs = 4,
44     PathSegLineToRel = 5,
45     PathSegCurveToCubicAbs = 6,
46     PathSegCurveToCubicRel = 7,
47     PathSegCurveToQuadraticAbs = 8,
48     PathSegCurveToQuadraticRel = 9,
49     PathSegArcAbs = 10,
50     PathSegArcRel = 11,
51     PathSegLineToHorizontalAbs = 12,
52     PathSegLineToHorizontalRel = 13,
53     PathSegLineToVerticalAbs = 14,
54     PathSegLineToVerticalRel = 15,
55     PathSegCurveToCubicSmoothAbs = 16,
56     PathSegCurveToCubicSmoothRel = 17,
57     PathSegCurveToQuadraticSmoothAbs = 18,
58     PathSegCurveToQuadraticSmoothRel = 19
59 };
60 
61 enum SVGPathSegRole {
62     PathSegUnalteredRole = 0,
63     PathSegNormalizedRole = 1,
64     PathSegUndefinedRole = 2
65 };
66 
67 class SVGPropertyBase;
68 class SVGPathElement;
69 class SVGElement;
70 
71 class SVGPathSeg : public RefCounted<SVGPathSeg>, public ScriptWrappable {
72 public:
73     // SVGPathSeg itself is used as a tear-off type.
74     // FIXME: A tear-off type should be introduced to distinguish animVal/baseVal
75     typedef SVGPathSeg TearOffType;
76 
77     explicit SVGPathSeg(SVGPathElement* contextElement);
78 
~SVGPathSeg()79     virtual ~SVGPathSeg() { }
80 
81     // Forward declare these enums in the w3c naming scheme, for IDL generation
82     enum {
83         PATHSEG_UNKNOWN = PathSegUnknown,
84         PATHSEG_CLOSEPATH = PathSegClosePath,
85         PATHSEG_MOVETO_ABS = PathSegMoveToAbs,
86         PATHSEG_MOVETO_REL = PathSegMoveToRel,
87         PATHSEG_LINETO_ABS = PathSegLineToAbs,
88         PATHSEG_LINETO_REL = PathSegLineToRel,
89         PATHSEG_CURVETO_CUBIC_ABS = PathSegCurveToCubicAbs,
90         PATHSEG_CURVETO_CUBIC_REL = PathSegCurveToCubicRel,
91         PATHSEG_CURVETO_QUADRATIC_ABS = PathSegCurveToQuadraticAbs,
92         PATHSEG_CURVETO_QUADRATIC_REL = PathSegCurveToQuadraticRel,
93         PATHSEG_ARC_ABS = PathSegArcAbs,
94         PATHSEG_ARC_REL = PathSegArcRel,
95         PATHSEG_LINETO_HORIZONTAL_ABS = PathSegLineToHorizontalAbs,
96         PATHSEG_LINETO_HORIZONTAL_REL = PathSegLineToHorizontalRel,
97         PATHSEG_LINETO_VERTICAL_ABS = PathSegLineToVerticalAbs,
98         PATHSEG_LINETO_VERTICAL_REL = PathSegLineToVerticalRel,
99         PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = PathSegCurveToCubicSmoothAbs,
100         PATHSEG_CURVETO_CUBIC_SMOOTH_REL = PathSegCurveToCubicSmoothRel,
101         PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = PathSegCurveToQuadraticSmoothAbs,
102         PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = PathSegCurveToQuadraticSmoothRel
103     };
104 
105     virtual unsigned short pathSegType() const = 0;
106     virtual String pathSegTypeAsLetter() const = 0;
107 
ownerList()108     SVGPropertyBase* ownerList() const
109     {
110         return m_ownerList;
111     }
112 
setOwnerList(SVGPropertyBase * ownerList)113     void setOwnerList(SVGPropertyBase* ownerList)
114     {
115         // Previous owner list must be cleared before setting new owner list.
116         ASSERT((!ownerList && m_ownerList) || (ownerList && !m_ownerList));
117 
118         m_ownerList = ownerList;
119     }
120 
setContextElement(SVGElement * contextElement)121     void setContextElement(SVGElement* contextElement)
122     {
123         m_contextElement = contextElement;
124     }
125 
126 protected:
127     void commitChange();
128 
129 private:
130     // FIXME: oilpan: These are kept as raw ptrs to break reference cycle. Should be Member in oilpan.
131     SVGPropertyBase* m_ownerList;
132     SVGElement* m_contextElement;
133 };
134 
135 } // namespace WebCore
136 
137 #endif
138