1/*
2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "SVGAnimatedPropertyAccessor.h"
29#include "SVGAnimatedPropertyAnimatorImpl.h"
30#include "SVGAnimatedPropertyImpl.h"
31#include "SVGNames.h"
32
33namespace WebCore {
34
35template<typename OwnerType>
36class SVGAnimatedAngleAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedAngle> {
37 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedAngle>;
38
39public:
40 using Base::Base;
41 template<Ref<SVGAnimatedAngle> OwnerType::*property>
42 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedAngleAccessor, property>(); }
43};
44
45template<typename OwnerType>
46class SVGAnimatedBooleanAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedBoolean> {
47 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedBoolean>;
48 using Base::property;
49
50public:
51 using Base::Base;
52 template<Ref<SVGAnimatedBoolean> OwnerType::*property>
53 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedBooleanAccessor, property>(); }
54
55private:
56 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
57 {
58 return SVGAnimatedBooleanAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
59 }
60
61 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
62 {
63 static_cast<SVGAnimatedBooleanAnimator&>(animator).appendAnimatedInstance(property(owner));
64 }
65};
66
67template<typename OwnerType, typename EnumType>
68class SVGAnimatedEnumerationAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedEnumeration> {
69 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedEnumeration>;
70 using Base::property;
71
72public:
73 using Base::Base;
74 template<Ref<SVGAnimatedEnumeration> OwnerType::*property>
75 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedEnumerationAccessor, property>(); }
76
77private:
78 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
79 {
80 return SVGAnimatedEnumerationAnimator<EnumType>::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
81 }
82
83 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
84 {
85 static_cast<SVGAnimatedEnumerationAnimator<EnumType>&>(animator).appendAnimatedInstance(property(owner));
86 }
87};
88
89template<typename OwnerType>
90class SVGAnimatedIntegerAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger> {
91 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger>;
92
93public:
94 using Base::Base;
95 using Base::property;
96 template<Ref<SVGAnimatedInteger> OwnerType::*property>
97 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedIntegerAccessor, property>(); }
98
99private:
100 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
101 {
102 return SVGAnimatedIntegerAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
103 }
104
105 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
106 {
107 static_cast<SVGAnimatedIntegerAnimator&>(animator).appendAnimatedInstance(property(owner));
108 }
109};
110
111template<typename OwnerType>
112class SVGAnimatedLengthAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLength> {
113 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLength>;
114 using Base::property;
115
116public:
117 using Base::Base;
118 template<Ref<SVGAnimatedLength> OwnerType::*property>
119 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedLengthAccessor, property>(); }
120
121private:
122 bool isAnimatedLength() const override { return true; }
123
124 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
125 {
126 SVGLengthMode lengthMode = property(owner)->baseVal()->value().unitMode();
127 return SVGAnimatedLengthAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, lengthMode);
128 }
129
130 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
131 {
132 static_cast<SVGAnimatedLengthAnimator&>(animator).appendAnimatedInstance(property(owner));
133 }
134};
135
136template<typename OwnerType>
137class SVGAnimatedLengthListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLengthList> {
138 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLengthList>;
139 using Base::property;
140
141public:
142 using Base::Base;
143 template<Ref<SVGAnimatedLengthList> OwnerType::*property>
144 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedLengthListAccessor, property>(); }
145
146private:
147 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
148 {
149 return SVGAnimatedLengthListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, LengthModeWidth);
150 }
151
152 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
153 {
154 static_cast<SVGAnimatedLengthListAnimator&>(animator).appendAnimatedInstance(property(owner));
155 }
156};
157
158template<typename OwnerType>
159class SVGAnimatedNumberAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumber> {
160 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumber>;
161
162public:
163 using Base::Base;
164 using Base::property;
165 template<Ref<SVGAnimatedNumber> OwnerType::*property>
166 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedNumberAccessor, property>(); }
167
168private:
169 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
170 {
171 return SVGAnimatedNumberAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
172 }
173
174 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
175 {
176 static_cast<SVGAnimatedNumberAnimator&>(animator).appendAnimatedInstance(property(owner));
177 }
178};
179
180template<typename OwnerType>
181class SVGAnimatedNumberListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumberList> {
182 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumberList>;
183 using Base::property;
184
185public:
186 using Base::Base;
187 template<Ref<SVGAnimatedNumberList> OwnerType::*property>
188 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedNumberListAccessor, property>(); }
189
190private:
191 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
192 {
193 return SVGAnimatedNumberListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
194 }
195
196 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
197 {
198 static_cast<SVGAnimatedNumberListAnimator&>(animator).appendAnimatedInstance(property(owner));
199 }
200};
201
202template<typename OwnerType>
203class SVGAnimatedPathSegListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPathSegList> {
204 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPathSegList>;
205 using Base::property;
206
207public:
208 using Base::Base;
209 template<Ref<SVGAnimatedPathSegList> OwnerType::*property>
210 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedPathSegListAccessor, property>(); }
211
212private:
213 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
214 {
215 return SVGAnimatedPathSegListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
216 }
217
218 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
219 {
220 static_cast<SVGAnimatedPathSegListAnimator&>(animator).appendAnimatedInstance(property(owner));
221 }
222};
223
224template<typename OwnerType>
225class SVGAnimatedPointListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPointList> {
226 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPointList>;
227 using Base::property;
228
229public:
230 using Base::Base;
231 template<Ref<SVGAnimatedPointList> OwnerType::*property>
232 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedPointListAccessor, property>(); }
233
234private:
235 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
236 {
237 return SVGAnimatedPointListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
238 }
239
240 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
241 {
242 static_cast<SVGAnimatedPointListAnimator&>(animator).appendAnimatedInstance(property(owner));
243 }
244};
245
246template<typename OwnerType>
247class SVGAnimatedOrientTypeAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedOrientType> {
248 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedOrientType>;
249
250public:
251 using Base::Base;
252 template<Ref<SVGAnimatedOrientType> OwnerType::*property>
253 constexpr static const SVGMemberAccessor<OwnerType>& singleton() {return Base::template singleton<SVGAnimatedOrientTypeAccessor, property>(); }
254};
255
256template<typename OwnerType>
257class SVGAnimatedPreserveAspectRatioAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPreserveAspectRatio> {
258 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPreserveAspectRatio>;
259 using Base::property;
260
261public:
262 using Base::Base;
263 template<Ref<SVGAnimatedPreserveAspectRatio> OwnerType::*property>
264 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedPreserveAspectRatioAccessor, property>(); }
265
266private:
267 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
268 {
269 return SVGAnimatedPreserveAspectRatioAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
270 }
271
272 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
273 {
274 static_cast<SVGAnimatedPreserveAspectRatioAnimator&>(animator).appendAnimatedInstance(property(owner));
275 }
276};
277
278template<typename OwnerType>
279class SVGAnimatedRectAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedRect> {
280 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedRect>;
281 using Base::property;
282
283public:
284 using Base::Base;
285 template<Ref<SVGAnimatedRect> OwnerType::*property>
286 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedRectAccessor, property>(); }
287
288private:
289 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
290 {
291 return SVGAnimatedRectAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
292 }
293
294 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
295 {
296 static_cast<SVGAnimatedRectAnimator&>(animator).appendAnimatedInstance(property(owner));
297 }
298};
299
300template<typename OwnerType>
301class SVGAnimatedStringAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedString> {
302 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedString>;
303 using Base::property;
304
305public:
306 using Base::Base;
307 template<Ref<SVGAnimatedString> OwnerType::*property>
308 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedStringAccessor, property>(); }
309
310private:
311 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
312 {
313 return SVGAnimatedStringAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
314 }
315
316 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
317 {
318 static_cast<SVGAnimatedStringAnimator&>(animator).appendAnimatedInstance(property(owner));
319 }
320};
321
322template<typename OwnerType>
323class SVGAnimatedTransformListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedTransformList> {
324 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedTransformList>;
325 using Base::property;
326
327public:
328 using Base::Base;
329 template<Ref<SVGAnimatedTransformList> OwnerType::*property>
330 constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedTransformListAccessor, property>(); }
331
332private:
333 std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
334 {
335 return SVGAnimatedTransformListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
336 }
337
338 void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
339 {
340 static_cast<SVGAnimatedTransformListAnimator&>(animator).appendAnimatedInstance(property(owner));
341 }
342};
343
344}
345