12017-02-21 Said Abou-Hallawa <sabouhallawa@apple.com>
2
3 Make SVGAnimatedType holds RefCounted objects instead of holding a union of raw pointers
4 https://bugs.webkit.org/show_bug.cgi?id=168586
5
6 Reviewed by NOBODY (OOPS!).
7
8 This is a step towards changing the raw pointers which is held by
9 SVGAnimatedType and the SVGAnimatedPropertyTearOff object to be RefCounted
10 pointers.
11
12 This patch changes SVGAnimatedType which holds a union of raw pointers to
13 hold RefCounted Variant objects. It makes the SVGAnimatedType holds a pair
14 SVGAnimatedValue. The SVGAnimatedValue is a RefCounted Variant which holds
15 a single data type. SVGAnimatedType can hold one or two SVGAnimatedValues.
16 The data pair have to be stored in separate objects not in the same Variant
17 because they are held by two different SVGAnimatedPropertyTearOff objects.
18
19 The plan is to change the property raw pointer in SVGAnimatedPropertyTearOff
20 to be be a SVGAnimatedValue which is a RefCounted pointer initiated in
21 SVGAnimatedType.
22
23 * WebCore.xcodeproj/project.pbxproj: Add SVGMarkerTypes.h and SVGAnimatedValue.h
24 and delete SVGRectTraits.h from the project. Make ParserUtilities.h private because
25 it is included in SVGPropertyTraits.h.
26
27 * svg/SVGAnimateElementBase.cpp:
28 (WebCore::SVGAnimateElementBase::resetAnimatedType): Replace the call to
29 SVGAnimatedType::setValueAsString() by SVGAnimatedType::parse().
30 (WebCore::SVGAnimateElementBase::applyResultsToTarget): Replace the call
31 to SVGAnimatedType::valueAsString() by SVGAnimatedType::toString().
32
33 * svg/SVGAnimatedAngle.cpp:
34 (WebCore::SVGAnimatedAngleAnimator::constructFromString):Use
35 SVGPropertyTraits<std::pair<SVGAngleValue, unsigned>>::fromString() to get
36 the angle value form a string.
37 (WebCore::SVGAnimatedAngleAnimator::startAnimValAnimation): Don't construct
38 an SVGAnimatedType from the return of constructFromBaseValues() since it now
39 returns an SVGAnimatedType.
40 (WebCore::SVGAnimatedAngleAnimator::resetAnimValToBaseVal): Don't pass a getter
41 to resetFromBaseValues since the ContentType of the TearOff object can be used
42 to get the property from the SVGAnimatedType.
43 (WebCore::SVGAnimatedAngleAnimator::addAnimatedTypes): Replace the call to
44 SVGAnimatedType::angleAndEnumeration() by SVGAnimatedType::properties<>().
45 (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue): Ditto.
46
47 * svg/SVGAnimatedBoolean.cpp:
48 (WebCore::SVGAnimatedBooleanAnimator::constructFromString):
49 (WebCore::SVGAnimatedBooleanAnimator::startAnimValAnimation):
50 (WebCore::SVGAnimatedBooleanAnimator::resetAnimValToBaseVal):
51 (WebCore::SVGAnimatedBooleanAnimator::calculateAnimatedValue):
52 Ditto.
53
54 * svg/SVGAnimatedColor.cpp:
55 (WebCore::SVGAnimatedColorAnimator::constructFromString):
56 (WebCore::SVGAnimatedColorAnimator::addAnimatedTypes):
57 (WebCore::SVGAnimatedColorAnimator::calculateAnimatedValue):
58 Ditto.
59
60 * svg/SVGAnimatedEnumeration.cpp:
61 (WebCore::SVGAnimatedEnumerationAnimator::constructFromString):
62 (WebCore::SVGAnimatedEnumerationAnimator::startAnimValAnimation):
63 (WebCore::SVGAnimatedEnumerationAnimator::resetAnimValToBaseVal):
64 (WebCore::SVGAnimatedEnumerationAnimator::calculateAnimatedValue):
65 Ditto.
66
67 * svg/SVGAnimatedInteger.cpp:
68 (WebCore::SVGAnimatedIntegerAnimator::constructFromString):
69 (WebCore::SVGAnimatedIntegerAnimator::startAnimValAnimation):
70 (WebCore::SVGAnimatedIntegerAnimator::resetAnimValToBaseVal):
71 (WebCore::SVGAnimatedIntegerAnimator::addAnimatedTypes):
72 (WebCore::SVGAnimatedIntegerAnimator::calculateAnimatedValue):
73 Ditto.
74
75 * svg/SVGAnimatedIntegerOptionalInteger.cpp:
76 (WebCore::SVGAnimatedIntegerOptionalIntegerAnimator::constructFromString):
77 (WebCore::SVGAnimatedIntegerOptionalIntegerAnimator::startAnimValAnimation):
78 (WebCore::SVGAnimatedIntegerOptionalIntegerAnimator::resetAnimValToBaseVal):
79 (WebCore::SVGAnimatedIntegerOptionalIntegerAnimator::addAnimatedTypes):
80 (WebCore::SVGAnimatedIntegerOptionalIntegerAnimator::calculateAnimatedValue):
81 Ditto.
82
83 * svg/SVGAnimatedLength.cpp:
84 (WebCore::SVGAnimatedLengthAnimator::constructFromString):
85 (WebCore::SVGAnimatedLengthAnimator::startAnimValAnimation):
86 (WebCore::SVGAnimatedLengthAnimator::resetAnimValToBaseVal):
87 (WebCore::SVGAnimatedLengthAnimator::addAnimatedTypes):
88 (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue):
89 Ditto.
90
91 * svg/SVGAnimatedLengthList.cpp:
92 (WebCore::SVGAnimatedLengthListAnimator::constructFromString):
93 (WebCore::SVGAnimatedLengthListAnimator::startAnimValAnimation):
94 (WebCore::SVGAnimatedLengthListAnimator::resetAnimValToBaseVal):
95 (WebCore::SVGAnimatedLengthListAnimator::addAnimatedTypes):
96 (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
97 Ditto.
98
99 * svg/SVGAnimatedNumber.cpp:
100 (WebCore::SVGAnimatedNumberAnimator::constructFromString):
101 (WebCore::SVGAnimatedNumberAnimator::startAnimValAnimation):
102 (WebCore::SVGAnimatedNumberAnimator::resetAnimValToBaseVal):
103 (WebCore::SVGAnimatedNumberAnimator::addAnimatedTypes):
104 (WebCore::parseNumberFromString):
105 (WebCore::SVGAnimatedNumberAnimator::calculateAnimatedValue):
106 Ditto.
107
108 * svg/SVGAnimatedNumberList.cpp:
109 (WebCore::SVGAnimatedNumberListAnimator::constructFromString):
110 (WebCore::SVGAnimatedNumberListAnimator::startAnimValAnimation):
111 (WebCore::SVGAnimatedNumberListAnimator::resetAnimValToBaseVal):
112 (WebCore::SVGAnimatedNumberListAnimator::addAnimatedTypes):
113 (WebCore::SVGAnimatedNumberListAnimator::calculateAnimatedValue):
114 Ditto.
115
116 * svg/SVGAnimatedNumberOptionalNumber.cpp:
117 (WebCore::SVGAnimatedNumberOptionalNumberAnimator::constructFromString):
118 (WebCore::SVGAnimatedNumberOptionalNumberAnimator::startAnimValAnimation):
119 (WebCore::SVGAnimatedNumberOptionalNumberAnimator::resetAnimValToBaseVal):
120 (WebCore::SVGAnimatedNumberOptionalNumberAnimator::addAnimatedTypes):
121 (WebCore::SVGAnimatedNumberOptionalNumberAnimator::calculateAnimatedValue):
122 Ditto.
123
124 * svg/SVGAnimatedPath.cpp:
125 (WebCore::SVGAnimatedPathAnimator::constructFromString):
126 (WebCore::SVGAnimatedPathAnimator::startAnimValAnimation):
127 (WebCore::SVGAnimatedPathAnimator::resetAnimValToBaseVal):
128 (WebCore::SVGAnimatedPathAnimator::addAnimatedTypes):
129 (WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
130 Ditto.
131
132 * svg/SVGAnimatedPointList.cpp:
133 (WebCore::SVGAnimatedPointListAnimator::constructFromString):
134 (WebCore::SVGAnimatedPointListAnimator::startAnimValAnimation):
135 (WebCore::SVGAnimatedPointListAnimator::resetAnimValToBaseVal):
136 (WebCore::SVGAnimatedPointListAnimator::addAnimatedTypes):
137 (WebCore::SVGAnimatedPointListAnimator::calculateAnimatedValue):
138 Ditto.
139
140 * svg/SVGAnimatedPreserveAspectRatio.cpp:
141 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString):
142 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::startAnimValAnimation):
143 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::resetAnimValToBaseVal):
144 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue):
145 Ditto.
146
147 * svg/SVGAnimatedRect.cpp:
148 (WebCore::SVGAnimatedRectAnimator::constructFromString):
149 (WebCore::SVGAnimatedRectAnimator::startAnimValAnimation):
150 (WebCore::SVGAnimatedRectAnimator::resetAnimValToBaseVal):
151 (WebCore::SVGAnimatedRectAnimator::addAnimatedTypes):
152 (WebCore::SVGAnimatedRectAnimator::calculateAnimatedValue):
153 Ditto.
154
155 * svg/SVGAnimatedString.cpp:
156 (WebCore::SVGAnimatedStringAnimator::constructFromString):
157 (WebCore::SVGAnimatedStringAnimator::startAnimValAnimation):
158 (WebCore::SVGAnimatedStringAnimator::resetAnimValToBaseVal):
159 (WebCore::SVGAnimatedStringAnimator::calculateAnimatedValue):
160 Ditto.
161
162 * svg/SVGAnimatedTransformList.cpp:
163 (WebCore::SVGAnimatedTransformListAnimator::constructFromString):
164 (WebCore::SVGAnimatedTransformListAnimator::startAnimValAnimation):
165 (WebCore::SVGAnimatedTransformListAnimator::resetAnimValToBaseVal):
166 (WebCore::SVGAnimatedTransformListAnimator::addAnimatedTypes):
167 (WebCore::SVGAnimatedTransformListAnimator::calculateAnimatedValue):
168 (WebCore::SVGAnimatedTransformListAnimator::calculateDistance):
169 Ditto.
170
171 * svg/SVGAnimatedType.cpp:
172 (WebCore::SVGAnimatedType::type): The type of the SVGAnimatedType can be
173 deduced from the type of the SVGAnimatedValues.
174 (WebCore::SVGAnimatedType::toString): Rename valueAsString() to toString().
175 (WebCore::SVGAnimatedType::parse): Rename setValueAsString() to parse().
176 (WebCore::SVGAnimatedType::SVGAnimatedType): Deleted.
177 (WebCore::SVGAnimatedType::~SVGAnimatedType): Deleted.
178 (WebCore::SVGAnimatedType::createAngleAndEnumeration): Deleted.
179 (WebCore::SVGAnimatedType::createBoolean): Deleted.
180 (WebCore::SVGAnimatedType::createColor): Deleted.
181 (WebCore::SVGAnimatedType::createEnumeration): Deleted.
182 (WebCore::SVGAnimatedType::createInteger): Deleted.
183 (WebCore::SVGAnimatedType::createIntegerOptionalInteger): Deleted.
184 (WebCore::SVGAnimatedType::createLength): Deleted.
185 (WebCore::SVGAnimatedType::createLengthList): Deleted.
186 (WebCore::SVGAnimatedType::createNumber): Deleted.
187 (WebCore::SVGAnimatedType::createNumberList): Deleted.
188 (WebCore::SVGAnimatedType::createNumberOptionalNumber): Deleted.
189 (WebCore::SVGAnimatedType::createPath): Deleted.
190 (WebCore::SVGAnimatedType::createPointList): Deleted.
191 (WebCore::SVGAnimatedType::createPreserveAspectRatio): Deleted.
192 (WebCore::SVGAnimatedType::createRect): Deleted.
193 (WebCore::SVGAnimatedType::createString): Deleted.
194 (WebCore::SVGAnimatedType::createTransformList): Deleted.
195 (WebCore::SVGAnimatedType::valueAsString): Deleted.
196 (WebCore::SVGAnimatedType::setValueAsString): Deleted.
197
198 * svg/SVGAnimatedType.h:
199 (WebCore::SVGAnimatedType::SVGAnimatedType): Template constructors to construct a SVGAnimatedType.
200 (WebCore::SVGAnimatedType::create): Template functions to create a SVGAnimatedType.
201 (WebCore::SVGAnimatedType::property): Template functions to return the stored property.
202 (WebCore::SVGAnimatedType::properties): Template functions to return the stored pair properties.
203 (WebCore::SVGAnimatedType::type): Deleted.
204 (WebCore::SVGAnimatedType::angleAndEnumeration): Deleted.
205 (WebCore::SVGAnimatedType::boolean): Deleted.
206 (WebCore::SVGAnimatedType::color): Deleted.
207 (WebCore::SVGAnimatedType::enumeration): Deleted.
208 (WebCore::SVGAnimatedType::integer): Deleted.
209 (WebCore::SVGAnimatedType::integerOptionalInteger): Deleted.
210 (WebCore::SVGAnimatedType::length): Deleted.
211 (WebCore::SVGAnimatedType::lengthList): Deleted.
212 (WebCore::SVGAnimatedType::number): Deleted.
213 (WebCore::SVGAnimatedType::numberList): Deleted.
214 (WebCore::SVGAnimatedType::numberOptionalNumber): Deleted.
215 (WebCore::SVGAnimatedType::path): Deleted.
216 (WebCore::SVGAnimatedType::pointList): Deleted.
217 (WebCore::SVGAnimatedType::preserveAspectRatio): Deleted.
218 (WebCore::SVGAnimatedType::rect): Deleted.
219 (WebCore::SVGAnimatedType::string): Deleted.
220 (WebCore::SVGAnimatedType::transformList): Deleted.
221
222 * svg/SVGAnimatedTypeAnimator.h:
223 (WebCore::SVGAnimatedTypeAnimator::constructFromBaseValue): Create a RefPtr<SVGAnimatedValue> from
224 the currentBaseValue and use this pointer to create an std::unique_ptr<SVGAnimatedType>.
225 (WebCore::SVGAnimatedTypeAnimator::resetFromBaseValue): No need for the SVGAnimatedType getter
226 because the ContentType of the TearOff object can be used to get the property from the SVGAnimatedType.
227 (WebCore::SVGAnimatedTypeAnimator::constructFromBaseValues): Create two RefPtr<SVGAnimatedValue>
228 from the currentBaseValues and use these pair pointers to create an std::unique_ptr<SVGAnimatedType>.
229 (WebCore::SVGAnimatedTypeAnimator::resetFromBaseValues): No need for the SVGAnimatedType getter
230 because the ContentType of the TearOff object can be used to get the properties from the SVGAnimatedType.
231 (WebCore::SVGAnimatedTypeAnimator::executeAction): Rename the argument name.
232
233 * svg/SVGAnimatedValue.h: Added.
234 (WebCore::SVGAnimatedValue::create): Template functions to create an SVGAnimatedValue.
235 (WebCore::SVGAnimatedValue::is): A template function to return the data type of an SVGAnimatedValue.
236 (WebCore::SVGAnimatedValue::property): Template functions to return the data of an SVGAnimatedValue.
237 (WebCore::SVGAnimatedValue::toString): A template function to return value an SVGAnimatedValue as an String.
238 (WebCore::SVGAnimatedValue::parse): A template function to change value an SVGAnimatedValue.
239 (WebCore::SVGAnimatedValue::SVGAnimatedValue): Template constructors to construct an SVGAnimatedValue.
240
241 * svg/SVGLengthListValues.h:
242 (WebCore::SVGPropertyTraits<SVGLengthListValues>::fromString):
243 (WebCore::SVGPropertyTraits<SVGLengthListValues>::parse):
244 Add functions to SVGPropertyTraits<SVGLengthListValues>.
245
246 * svg/SVGLengthValue.h:
247 (WebCore::SVGPropertyTraits<SVGLengthValue>::parse):
248 (WebCore::SVGPropertyTraits<SVGLengthValue>::toString):
249 Add functions to SVGPropertyTraits<SVGLengthValue>.
250
251 * svg/SVGMarkerElement.h:
252 (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::highestEnumValue): Deleted.
253 (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::toString): Deleted.
254 (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::fromString): Deleted.
255 (WebCore::SVGIDLEnumLimits<SVGMarkerOrientType>::highestExposedEnumValue): Deleted.
256 (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::highestEnumValue): Deleted.
257 (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::fromString): Deleted.
258 * svg/SVGMarkerTypes.h: Added.
259 (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::highestEnumValue):
260 (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::toString):
261 (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::fromString):
262 (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::highestEnumValue):
263 (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::fromString):
264 (WebCore::SVGIDLEnumLimits<SVGMarkerOrientType>::highestExposedEnumValue):
265 Move these SVGPropertyTraits to a separate file because we want to add a new
266 SVGPropertyTraits for the pair <SVGAngleValue, unsigned>.
267
268 * svg/SVGNumberListValues.h:
269 (WebCore::SVGPropertyTraits<SVGNumberListValues>::fromString):
270 (WebCore::SVGPropertyTraits<SVGNumberListValues>::toString):
271 Add functions to SVGPropertyTraits<SVGNumberListValues>.
272
273 * svg/SVGPathByteStream.h:
274 (WebCore::SVGPathByteStream::SVGPathByteStream):
275 (WebCore::SVGPathByteStream::operator=):
276 Add copy and move semantics.
277
278 (WebCore::SVGPathByteStream::operator==):
279 (WebCore::SVGPathByteStream::operator!=):
280 (WebCore::SVGPathByteStream::copy):
281 (WebCore::SVGPathByteStream::append):
282 (WebCore::SVGPathByteStream::clear):
283 (WebCore::SVGPathByteStream::isEmpty):
284 Minor clean-up.
285
286 (WebCore::SVGPropertyTraits<SVGPathByteStream>::initialValue):
287 (WebCore::SVGPropertyTraits<SVGPathByteStream>::fromString):
288 Add functions to SVGPropertyTraits<SVGPathByteStream>.
289
290 * svg/SVGPathUtilities.cpp:
291 (WebCore::addToSVGPathByteStream): Use SVGPathByteStream move semantics.
292
293 * svg/SVGPointListValues.h:
294 (WebCore::SVGPropertyTraits<SVGPointListValues>::fromString):
295 Add functions to SVGPropertyTraits<SVGPointListValues>.
296
297 * svg/SVGPreserveAspectRatioValue.cpp:
298 (WebCore::SVGPreserveAspectRatioValue::SVGPreserveAspectRatioValue):
299 Add a constructor which takes a string to be used by
300 SVGPropertyTraits<SVGPreserveAspectRatioValue>.
301
302 * svg/SVGPreserveAspectRatioValue.h:
303 (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::fromString):
304 Add functions to SVGPropertyTraits<SVGPreserveAspectRatioValue>.
305
306 * svg/SVGRect.h:
307 * svg/SVGRectTraits.h: Removed.
308 Move SVGPropertyTraits<FloatRect> from SVGRectTraits.h to SVGPropertyTraits.h
309 since it includes the SVGPropertyTraits for the non SVG types.
310
311 * svg/SVGTransformListValues.h:
312 (WebCore::SVGPropertyTraits<SVGTransformListValues>::fromString):
313 Add functions to SVGPropertyTraits<SVGTransformListValues>.
314
315 * svg/properties/SVGPropertyTraits.h:
316 (WebCore::SVGPropertyTraits<bool>::fromString):
317 (WebCore::SVGPropertyTraits<Color>::initialValue):
318 (WebCore::SVGPropertyTraits<Color>::fromString):
319 (WebCore::SVGPropertyTraits<Color>::parse):
320 (WebCore::SVGPropertyTraits<Color>::toString):
321 (WebCore::SVGPropertyTraits<int>::fromString):
322 (WebCore::SVGPropertyTraits<float>::fromString):
323 (WebCore::SVGPropertyTraits<float>::parse):
324 (WebCore::SVGPropertyTraits<FloatRect>::initialValue):
325 (WebCore::SVGPropertyTraits<FloatRect>::fromString):
326 (WebCore::SVGPropertyTraits<FloatRect>::parse):
327 (WebCore::SVGPropertyTraits<FloatRect>::toString):
328 (WebCore::SVGPropertyTraits<String>::fromString):
329 (WebCore::SVGPropertyTraits<String>::parse):
330 (WebCore::SVGPropertyTraits<String>::toString):
331 Add functions to the SVGPropertyTraits for non SVG types.
332