Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGPathSeg.h
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/core/v8/ScriptWrappable.h"
25 #include "wtf/RefCounted.h"
26 #include "wtf/text/WTFString.h"
27
28 namespace blink {
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 class SVGPropertyBase;
62 class SVGPathElement;
63 class SVGElement;
64
65 class SVGPathSeg : public RefCounted<SVGPathSeg>, public ScriptWrappable {
66 public:
67     // SVGPathSeg itself is used as a tear-off type.
68     // FIXME: A tear-off type should be introduced to distinguish animVal/baseVal
69     typedef SVGPathSeg TearOffType;
70
71     explicit SVGPathSeg(SVGPathElement* contextElement);
72
73     virtual ~SVGPathSeg() { }
74
75     // Forward declare these enums in the w3c naming scheme, for IDL generation
76     enum {
77         PATHSEG_UNKNOWN = PathSegUnknown,
78         PATHSEG_CLOSEPATH = PathSegClosePath,
79         PATHSEG_MOVETO_ABS = PathSegMoveToAbs,
80         PATHSEG_MOVETO_REL = PathSegMoveToRel,
81         PATHSEG_LINETO_ABS = PathSegLineToAbs,
82         PATHSEG_LINETO_REL = PathSegLineToRel,
83         PATHSEG_CURVETO_CUBIC_ABS = PathSegCurveToCubicAbs,
84         PATHSEG_CURVETO_CUBIC_REL = PathSegCurveToCubicRel,
85         PATHSEG_CURVETO_QUADRATIC_ABS = PathSegCurveToQuadraticAbs,
86         PATHSEG_CURVETO_QUADRATIC_REL = PathSegCurveToQuadraticRel,
87         PATHSEG_ARC_ABS = PathSegArcAbs,
88         PATHSEG_ARC_REL = PathSegArcRel,
89         PATHSEG_LINETO_HORIZONTAL_ABS = PathSegLineToHorizontalAbs,
90         PATHSEG_LINETO_HORIZONTAL_REL = PathSegLineToHorizontalRel,
91         PATHSEG_LINETO_VERTICAL_ABS = PathSegLineToVerticalAbs,
92         PATHSEG_LINETO_VERTICAL_REL = PathSegLineToVerticalRel,
93         PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = PathSegCurveToCubicSmoothAbs,
94         PATHSEG_CURVETO_CUBIC_SMOOTH_REL = PathSegCurveToCubicSmoothRel,
95         PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = PathSegCurveToQuadraticSmoothAbs,
96         PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = PathSegCurveToQuadraticSmoothRel
97     };
98
99     virtual unsigned short pathSegType() const = 0;
100     virtual String pathSegTypeAsLetter() const = 0;
101
102     SVGPropertyBase* ownerList() const
103     {
104         return m_ownerList;
105     }
106
107     void setOwnerList(SVGPropertyBase* ownerList)
108     {
109         // Previous owner list must be cleared before setting new owner list.
110         ASSERT((!ownerList && m_ownerList) || (ownerList && !m_ownerList));
111
112         m_ownerList = ownerList;
113     }
114
115     void setContextElement(SVGElement* contextElement)
116     {
117         m_contextElement = contextElement;
118     }
119
120     static PassRefPtr<SVGPathSeg> create() { ASSERT_NOT_REACHED(); return nullptr; }
121     PassRefPtr<SVGPathSeg> clone() { ASSERT_NOT_REACHED(); return nullptr; }
122
123 protected:
124     void commitChange();
125
126 private:
127     // FIXME: oilpan: These are kept as raw ptrs to break reference cycle. Should be Member in oilpan.
128     SVGPropertyBase* m_ownerList;
129     SVGElement* m_contextElement;
130 };
131
132 } // namespace blink
133
134 #endif