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 | |
33 | namespace WebCore { |
34 | |
35 | template<typename OwnerType> |
36 | class SVGAnimatedAngleAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedAngle> { |
37 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedAngle>; |
38 | |
39 | public: |
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 | |
45 | template<typename OwnerType> |
46 | class SVGAnimatedBooleanAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedBoolean> { |
47 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedBoolean>; |
48 | using Base::property; |
49 | |
50 | public: |
51 | using Base::Base; |
52 | template<Ref<SVGAnimatedBoolean> OwnerType::*property> |
53 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedBooleanAccessor, property>(); } |
54 | |
55 | private: |
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 | |
67 | template<typename OwnerType, typename EnumType> |
68 | class SVGAnimatedEnumerationAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedEnumeration> { |
69 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedEnumeration>; |
70 | using Base::property; |
71 | |
72 | public: |
73 | using Base::Base; |
74 | template<Ref<SVGAnimatedEnumeration> OwnerType::*property> |
75 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedEnumerationAccessor, property>(); } |
76 | |
77 | private: |
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 | |
89 | template<typename OwnerType> |
90 | class SVGAnimatedIntegerAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger> { |
91 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger>; |
92 | |
93 | public: |
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 | |
99 | private: |
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 | |
111 | template<typename OwnerType> |
112 | class SVGAnimatedLengthAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLength> { |
113 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLength>; |
114 | using Base::property; |
115 | |
116 | public: |
117 | using Base::Base; |
118 | template<Ref<SVGAnimatedLength> OwnerType::*property> |
119 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedLengthAccessor, property>(); } |
120 | |
121 | private: |
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 | |
136 | template<typename OwnerType> |
137 | class SVGAnimatedLengthListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLengthList> { |
138 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedLengthList>; |
139 | using Base::property; |
140 | |
141 | public: |
142 | using Base::Base; |
143 | template<Ref<SVGAnimatedLengthList> OwnerType::*property> |
144 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedLengthListAccessor, property>(); } |
145 | |
146 | private: |
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 | |
158 | template<typename OwnerType> |
159 | class SVGAnimatedNumberAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumber> { |
160 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumber>; |
161 | |
162 | public: |
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 | |
168 | private: |
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 | |
180 | template<typename OwnerType> |
181 | class SVGAnimatedNumberListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumberList> { |
182 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedNumberList>; |
183 | using Base::property; |
184 | |
185 | public: |
186 | using Base::Base; |
187 | template<Ref<SVGAnimatedNumberList> OwnerType::*property> |
188 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedNumberListAccessor, property>(); } |
189 | |
190 | private: |
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 | |
202 | template<typename OwnerType> |
203 | class SVGAnimatedPathSegListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPathSegList> { |
204 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPathSegList>; |
205 | using Base::property; |
206 | |
207 | public: |
208 | using Base::Base; |
209 | template<Ref<SVGAnimatedPathSegList> OwnerType::*property> |
210 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedPathSegListAccessor, property>(); } |
211 | |
212 | private: |
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 | |
224 | template<typename OwnerType> |
225 | class SVGAnimatedPointListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPointList> { |
226 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPointList>; |
227 | using Base::property; |
228 | |
229 | public: |
230 | using Base::Base; |
231 | template<Ref<SVGAnimatedPointList> OwnerType::*property> |
232 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedPointListAccessor, property>(); } |
233 | |
234 | private: |
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 | |
246 | template<typename OwnerType> |
247 | class SVGAnimatedOrientTypeAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedOrientType> { |
248 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedOrientType>; |
249 | |
250 | public: |
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 | |
256 | template<typename OwnerType> |
257 | class SVGAnimatedPreserveAspectRatioAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPreserveAspectRatio> { |
258 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedPreserveAspectRatio>; |
259 | using Base::property; |
260 | |
261 | public: |
262 | using Base::Base; |
263 | template<Ref<SVGAnimatedPreserveAspectRatio> OwnerType::*property> |
264 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedPreserveAspectRatioAccessor, property>(); } |
265 | |
266 | private: |
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 | |
278 | template<typename OwnerType> |
279 | class SVGAnimatedRectAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedRect> { |
280 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedRect>; |
281 | using Base::property; |
282 | |
283 | public: |
284 | using Base::Base; |
285 | template<Ref<SVGAnimatedRect> OwnerType::*property> |
286 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedRectAccessor, property>(); } |
287 | |
288 | private: |
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 | |
300 | template<typename OwnerType> |
301 | class SVGAnimatedStringAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedString> { |
302 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedString>; |
303 | using Base::property; |
304 | |
305 | public: |
306 | using Base::Base; |
307 | template<Ref<SVGAnimatedString> OwnerType::*property> |
308 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedStringAccessor, property>(); } |
309 | |
310 | private: |
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 | |
322 | template<typename OwnerType> |
323 | class SVGAnimatedTransformListAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedTransformList> { |
324 | using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedTransformList>; |
325 | using Base::property; |
326 | |
327 | public: |
328 | using Base::Base; |
329 | template<Ref<SVGAnimatedTransformList> OwnerType::*property> |
330 | constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedTransformListAccessor, property>(); } |
331 | |
332 | private: |
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 | |