Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPathSeg.h

Issue 1416273002: Remove SVGPathElement.pathSegList and related interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 "platform/geometry/FloatPoint.h"
26 #include "platform/heap/Handle.h"
27 #include "wtf/Allocator.h"
28 #include "wtf/RefCounted.h"
29 #include "wtf/text/WTFString.h"
30
31 namespace blink {
32
33 enum ListModification {
34 ListModificationUnknown = 0,
35 ListModificationInsert = 1,
36 ListModificationReplace = 2,
37 ListModificationRemove = 3,
38 ListModificationAppend = 4
39 };
40
41 enum SVGPathSegType {
42 PathSegUnknown = 0,
43 PathSegClosePath = 1,
44 PathSegMoveToAbs = 2,
45 PathSegMoveToRel = 3,
46 PathSegLineToAbs = 4,
47 PathSegLineToRel = 5,
48 PathSegCurveToCubicAbs = 6,
49 PathSegCurveToCubicRel = 7,
50 PathSegCurveToQuadraticAbs = 8,
51 PathSegCurveToQuadraticRel = 9,
52 PathSegArcAbs = 10,
53 PathSegArcRel = 11,
54 PathSegLineToHorizontalAbs = 12,
55 PathSegLineToHorizontalRel = 13,
56 PathSegLineToVerticalAbs = 14,
57 PathSegLineToVerticalRel = 15,
58 PathSegCurveToCubicSmoothAbs = 16,
59 PathSegCurveToCubicSmoothRel = 17,
60 PathSegCurveToQuadraticSmoothAbs = 18,
61 PathSegCurveToQuadraticSmoothRel = 19
62 };
63
64 static inline SVGPathSegType toAbsolutePathSegType(const SVGPathSegType type)
65 {
66 // Clear the LSB to get the absolute command.
67 return type >= PathSegMoveToAbs ? static_cast<SVGPathSegType>(type & ~1u) : type;
68 }
69
70 static inline bool isAbsolutePathSegType(const SVGPathSegType type)
71 {
72 // For commands with an ordinal >= PathSegMoveToAbs, and odd number => relat ive command.
73 return type < PathSegMoveToAbs || type % 2 == 0;
74 }
75
76 struct PathSegmentData {
77 STACK_ALLOCATED();
78 PathSegmentData()
79 : command(PathSegUnknown)
80 , arcSweep(false)
81 , arcLarge(false)
82 {
83 }
84
85 const FloatPoint& arcRadii() const { return point1; }
86 float arcAngle() const { return point2.x(); }
87
88 float r1() const { return arcRadii().x(); }
89 float r2() const { return arcRadii().y(); }
90
91 bool largeArcFlag() const { return arcLarge; }
92 bool sweepFlag() const { return arcSweep; }
93
94 float x() const { return targetPoint.x(); }
95 float y() const { return targetPoint.y(); }
96
97 float x1() const { return point1.x(); }
98 float y1() const { return point1.y(); }
99
100 float x2() const { return point2.x(); }
101 float y2() const { return point2.y(); }
102
103 SVGPathSegType command;
104 FloatPoint targetPoint;
105 FloatPoint point1;
106 FloatPoint point2;
107 bool arcSweep;
108 bool arcLarge;
109 };
110
111 class SVGPropertyBase;
112 class SVGPathElement;
113 class SVGElement;
114
115 class SVGPathSeg : public RefCountedWillBeGarbageCollectedFinalized<SVGPathSeg>, public ScriptWrappable {
116 DEFINE_WRAPPERTYPEINFO();
117 public:
118 // SVGPathSeg itself is used as a tear-off type.
119 // FIXME: A tear-off type should be introduced to distinguish animVal/baseVa l
120 typedef SVGPathSeg TearOffType;
121
122 explicit SVGPathSeg(SVGPathElement* contextElement);
123
124 virtual ~SVGPathSeg() { }
125
126 // Forward declare these enums in the w3c naming scheme, for IDL generation
127 enum {
128 PATHSEG_UNKNOWN = PathSegUnknown,
129 PATHSEG_CLOSEPATH = PathSegClosePath,
130 PATHSEG_MOVETO_ABS = PathSegMoveToAbs,
131 PATHSEG_MOVETO_REL = PathSegMoveToRel,
132 PATHSEG_LINETO_ABS = PathSegLineToAbs,
133 PATHSEG_LINETO_REL = PathSegLineToRel,
134 PATHSEG_CURVETO_CUBIC_ABS = PathSegCurveToCubicAbs,
135 PATHSEG_CURVETO_CUBIC_REL = PathSegCurveToCubicRel,
136 PATHSEG_CURVETO_QUADRATIC_ABS = PathSegCurveToQuadraticAbs,
137 PATHSEG_CURVETO_QUADRATIC_REL = PathSegCurveToQuadraticRel,
138 PATHSEG_ARC_ABS = PathSegArcAbs,
139 PATHSEG_ARC_REL = PathSegArcRel,
140 PATHSEG_LINETO_HORIZONTAL_ABS = PathSegLineToHorizontalAbs,
141 PATHSEG_LINETO_HORIZONTAL_REL = PathSegLineToHorizontalRel,
142 PATHSEG_LINETO_VERTICAL_ABS = PathSegLineToVerticalAbs,
143 PATHSEG_LINETO_VERTICAL_REL = PathSegLineToVerticalRel,
144 PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = PathSegCurveToCubicSmoothAbs,
145 PATHSEG_CURVETO_CUBIC_SMOOTH_REL = PathSegCurveToCubicSmoothRel,
146 PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = PathSegCurveToQuadraticSmoothAbs,
147 PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = PathSegCurveToQuadraticSmoothRel
148 };
149
150 virtual unsigned short pathSegType() const = 0;
151 virtual String pathSegTypeAsLetter() const = 0;
152
153 SVGPropertyBase* ownerList() const
154 {
155 return m_ownerList;
156 }
157
158 void setOwnerList(SVGPropertyBase* ownerList)
159 {
160 // Previous owner list must be cleared before setting new owner list.
161 ASSERT((!ownerList && m_ownerList) || (ownerList && !m_ownerList));
162
163 m_ownerList = ownerList;
164 }
165
166 void setContextElement(SVGElement* contextElement)
167 {
168 m_contextElement = contextElement;
169 }
170
171 static PassRefPtrWillBeRawPtr<SVGPathSeg> create() { ASSERT_NOT_REACHED(); r eturn nullptr; }
172 virtual PassRefPtrWillBeRawPtr<SVGPathSeg> clone() = 0;
173
174 DECLARE_VIRTUAL_TRACE();
175
176 protected:
177 void commitChange();
178
179 private:
180 RawPtrWillBeMember<SVGPropertyBase> m_ownerList;
181 GC_PLUGIN_IGNORE("528275")
182 SVGElement* m_contextElement;
183 };
184
185 class SVGPathSegSingleCoordinate : public SVGPathSeg {
186 public:
187 float x() const { return m_x; }
188 void setX(float x)
189 {
190 m_x = x;
191 commitChange();
192 }
193
194 float y() const { return m_y; }
195 void setY(float y)
196 {
197 m_y = y;
198 commitChange();
199 }
200
201 protected:
202 SVGPathSegSingleCoordinate(SVGPathElement* element, float x, float y)
203 : SVGPathSeg(element)
204 , m_x(x)
205 , m_y(y)
206 {
207 }
208
209 private:
210 float m_x;
211 float m_y;
212 };
213
214 } // namespace blink
215
216 #endif // SVGPathSeg_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathParser.h ('k') | third_party/WebKit/Source/core/svg/SVGPathSeg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698