OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/StringKeyframe.h" | 6 #include "core/animation/StringKeyframe.h" |
7 | 7 |
8 #include "core/animation/AngleSVGInterpolation.h" | 8 #include "core/animation/AngleSVGInterpolation.h" |
9 #include "core/animation/ColorStyleInterpolation.h" | 9 #include "core/animation/ColorStyleInterpolation.h" |
10 #include "core/animation/CompositorAnimations.h" | 10 #include "core/animation/CompositorAnimations.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 PropertyHandleSet properties; | 76 PropertyHandleSet properties; |
77 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) | 77 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) |
78 properties.add(PropertyHandle(m_propertySet->propertyAt(i).id())); | 78 properties.add(PropertyHandle(m_propertySet->propertyAt(i).id())); |
79 | 79 |
80 for (const auto& key: m_svgPropertyMap.keys()) | 80 for (const auto& key: m_svgPropertyMap.keys()) |
81 properties.add(PropertyHandle(*key)); | 81 properties.add(PropertyHandle(*key)); |
82 | 82 |
83 return properties; | 83 return properties; |
84 } | 84 } |
85 | 85 |
86 PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const | 86 Keyframe* StringKeyframe::clone() const |
87 { | 87 { |
88 return adoptRefWillBeNoop(new StringKeyframe(*this)); | 88 return new StringKeyframe(*this); |
89 } | 89 } |
90 | 90 |
91 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::creat
ePropertySpecificKeyframe(PropertyHandle property) const | 91 Keyframe::PropertySpecificKeyframe* StringKeyframe::createPropertySpecificKeyfra
me(PropertyHandle property) const |
92 { | 92 { |
93 if (property.isCSSProperty()) | 93 if (property.isCSSProperty()) |
94 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset(), &eas
ing(), cssPropertyValue(property.cssProperty()), composite())); | 94 return new CSSPropertySpecificKeyframe(offset(), &easing(), cssPropertyV
alue(property.cssProperty()), composite()); |
95 | 95 |
96 ASSERT(property.isSVGAttribute()); | 96 ASSERT(property.isSVGAttribute()); |
97 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset(), &easing(
), svgPropertyValue(*property.svgAttribute()), composite())); | 97 return new SVGPropertySpecificKeyframe(offset(), &easing(), svgPropertyValue
(*property.svgAttribute()), composite()); |
98 } | 98 } |
99 | 99 |
100 DEFINE_TRACE(StringKeyframe) | 100 DEFINE_TRACE(StringKeyframe) |
101 { | 101 { |
102 visitor->trace(m_propertySet); | 102 visitor->trace(m_propertySet); |
103 Keyframe::trace(visitor); | 103 Keyframe::trace(visitor); |
104 } | 104 } |
105 | 105 |
106 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::Com
positeOperation op) | 106 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::Com
positeOperation op) |
107 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 107 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 case CSSPropertyFontSizeAdjust: | 145 case CSSPropertyFontSizeAdjust: |
146 return RangeNonNegative; | 146 return RangeNonNegative; |
147 default: | 147 default: |
148 ASSERT_NOT_REACHED(); | 148 ASSERT_NOT_REACHED(); |
149 return RangeAll; | 149 return RangeAll; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 } // namespace | 153 } // namespace |
154 | 154 |
155 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram
e::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpe
cificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const | 155 Interpolation* StringKeyframe::CSSPropertySpecificKeyframe::maybeCreateInterpola
tion(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Ele
ment* element, const ComputedStyle* baseStyle) const |
156 { | 156 { |
157 CSSPropertyID property = propertyHandle.cssProperty(); | 157 CSSPropertyID property = propertyHandle.cssProperty(); |
158 | 158 |
159 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe
ct, and a template parameter specific converter. | 159 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe
ct, and a template parameter specific converter. |
160 CSSValue* fromCSSValue = m_value.get(); | 160 CSSValue* fromCSSValue = m_value.get(); |
161 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value(); | 161 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value(); |
162 InterpolationRange range = RangeAll; | 162 InterpolationRange range = RangeAll; |
163 bool fallBackToLegacy = false; | 163 bool fallBackToLegacy = false; |
164 | 164 |
165 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. | 165 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 case CSSPropertyFontSizeAdjust: | 264 case CSSPropertyFontSizeAdjust: |
265 case CSSPropertyOpacity: | 265 case CSSPropertyOpacity: |
266 case CSSPropertyStopOpacity: | 266 case CSSPropertyStopOpacity: |
267 case CSSPropertyStrokeOpacity: | 267 case CSSPropertyStrokeOpacity: |
268 case CSSPropertyStrokeMiterlimit: | 268 case CSSPropertyStrokeMiterlimit: |
269 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl
eInterpolation::canCreateFrom(*toCSSValue)) | 269 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl
eInterpolation::canCreateFrom(*toCSSValue)) |
270 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue,
property, toCSSPrimitiveValue(fromCSSValue)->primitiveType(), setRange(property)
); | 270 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue,
property, toCSSPrimitiveValue(fromCSSValue)->primitiveType(), setRange(property)
); |
271 break; | 271 break; |
272 | 272 |
273 case CSSPropertyMotionRotation: { | 273 case CSSPropertyMotionRotation: { |
274 RefPtrWillBeRawPtr<Interpolation> interpolation = DoubleStyleInterpolati
on::maybeCreateFromMotionRotation(*fromCSSValue, *toCSSValue, property); | 274 Interpolation* interpolation = DoubleStyleInterpolation::maybeCreateFrom
MotionRotation(*fromCSSValue, *toCSSValue, property); |
275 if (interpolation) | 275 if (interpolation) |
276 return interpolation.release(); | 276 return interpolation; |
277 break; | 277 break; |
278 } | 278 } |
279 case CSSPropertyVisibility: | 279 case CSSPropertyVisibility: |
280 if (VisibilityStyleInterpolation::canCreateFrom(*fromCSSValue) && Visibi
lityStyleInterpolation::canCreateFrom(*toCSSValue) && (VisibilityStyleInterpolat
ion::isVisible(*fromCSSValue) || VisibilityStyleInterpolation::isVisible(*toCSSV
alue))) | 280 if (VisibilityStyleInterpolation::canCreateFrom(*fromCSSValue) && Visibi
lityStyleInterpolation::canCreateFrom(*toCSSValue) && (VisibilityStyleInterpolat
ion::isVisible(*fromCSSValue) || VisibilityStyleInterpolation::isVisible(*toCSSV
alue))) |
281 return VisibilityStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property); | 281 return VisibilityStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property); |
282 | 282 |
283 break; | 283 break; |
284 | 284 |
285 case CSSPropertyBackgroundColor: | 285 case CSSPropertyBackgroundColor: |
286 case CSSPropertyBorderBottomColor: | 286 case CSSPropertyBorderBottomColor: |
287 case CSSPropertyBorderLeftColor: | 287 case CSSPropertyBorderLeftColor: |
288 case CSSPropertyBorderRightColor: | 288 case CSSPropertyBorderRightColor: |
289 case CSSPropertyBorderTopColor: | 289 case CSSPropertyBorderTopColor: |
290 case CSSPropertyColor: | 290 case CSSPropertyColor: |
291 case CSSPropertyFill: | 291 case CSSPropertyFill: |
292 case CSSPropertyFloodColor: | 292 case CSSPropertyFloodColor: |
293 case CSSPropertyLightingColor: | 293 case CSSPropertyLightingColor: |
294 case CSSPropertyOutlineColor: | 294 case CSSPropertyOutlineColor: |
295 case CSSPropertyStopColor: | 295 case CSSPropertyStopColor: |
296 case CSSPropertyStroke: | 296 case CSSPropertyStroke: |
297 case CSSPropertyTextDecorationColor: | 297 case CSSPropertyTextDecorationColor: |
298 case CSSPropertyWebkitColumnRuleColor: | 298 case CSSPropertyWebkitColumnRuleColor: |
299 case CSSPropertyWebkitTextStrokeColor: | 299 case CSSPropertyWebkitTextStrokeColor: |
300 { | 300 { |
301 RefPtrWillBeRawPtr<Interpolation> interpolation = ColorStyleInterpol
ation::maybeCreateFromColor(*fromCSSValue, *toCSSValue, property); | 301 Interpolation* interpolation = ColorStyleInterpolation::maybeCreateF
romColor(*fromCSSValue, *toCSSValue, property); |
302 if (interpolation) | 302 if (interpolation) |
303 return interpolation.release(); | 303 return interpolation; |
304 | 304 |
305 // Current color should use LegacyStyleInterpolation | 305 // Current color should use LegacyStyleInterpolation |
306 if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*from
CSSValue, *toCSSValue)) | 306 if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*from
CSSValue, *toCSSValue)) |
307 fallBackToLegacy = true; | 307 fallBackToLegacy = true; |
308 | 308 |
309 break; | 309 break; |
310 } | 310 } |
311 | 311 |
312 case CSSPropertyBorderImageSource: | 312 case CSSPropertyBorderImageSource: |
313 case CSSPropertyListStyleImage: | 313 case CSSPropertyListStyleImage: |
(...skipping 12 matching lines...) Expand all Loading... |
326 case CSSPropertyBorderTopRightRadius: | 326 case CSSPropertyBorderTopRightRadius: |
327 range = RangeNonNegative; | 327 range = RangeNonNegative; |
328 // Fall through | 328 // Fall through |
329 case CSSPropertyObjectPosition: | 329 case CSSPropertyObjectPosition: |
330 if (LengthPairStyleInterpolation::canCreateFrom(*fromCSSValue) && Length
PairStyleInterpolation::canCreateFrom(*toCSSValue)) | 330 if (LengthPairStyleInterpolation::canCreateFrom(*fromCSSValue) && Length
PairStyleInterpolation::canCreateFrom(*toCSSValue)) |
331 return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property, range); | 331 return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property, range); |
332 break; | 332 break; |
333 | 333 |
334 case CSSPropertyPerspectiveOrigin: | 334 case CSSPropertyPerspectiveOrigin: |
335 case CSSPropertyTransformOrigin: { | 335 case CSSPropertyTransformOrigin: { |
336 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation
<LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop
erty, range); | 336 Interpolation* interpolation = ListStyleInterpolation<LengthStyleInterpo
lation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property, range); |
337 if (interpolation) | 337 if (interpolation) |
338 return interpolation.release(); | 338 return interpolation; |
339 | 339 |
340 // FIXME: Handle keywords: top, right, left, center, bottom | 340 // FIXME: Handle keywords: top, right, left, center, bottom |
341 fallBackToLegacy = true; | 341 fallBackToLegacy = true; |
342 | 342 |
343 break; | 343 break; |
344 } | 344 } |
345 | 345 |
346 case CSSPropertyBoxShadow: | 346 case CSSPropertyBoxShadow: |
347 case CSSPropertyTextShadow: { | 347 case CSSPropertyTextShadow: { |
348 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation
<ShadowStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop
erty); | 348 Interpolation* interpolation = ListStyleInterpolation<ShadowStyleInterpo
lation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property); |
349 if (interpolation) | 349 if (interpolation) |
350 return interpolation.release(); | 350 return interpolation; |
351 | 351 |
352 // FIXME: AnimatableShadow incorrectly animates between inset and non-in
set values so it will never indicate it needs default interpolation | 352 // FIXME: AnimatableShadow incorrectly animates between inset and non-in
set values so it will never indicate it needs default interpolation |
353 if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValu
e, *toCSSValue)) { | 353 if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValu
e, *toCSSValue)) { |
354 forceDefaultInterpolation = true; | 354 forceDefaultInterpolation = true; |
355 break; | 355 break; |
356 } | 356 } |
357 | 357 |
358 // FIXME: Handle interpolation from/to none, unspecified color values | 358 // FIXME: Handle interpolation from/to none, unspecified color values |
359 fallBackToLegacy = true; | 359 fallBackToLegacy = true; |
360 | 360 |
361 break; | 361 break; |
362 | 362 |
363 } | 363 } |
364 | 364 |
365 case CSSPropertyClip: { | 365 case CSSPropertyClip: { |
366 if (LengthBoxStyleInterpolation::usesDefaultInterpolation(*fromCSSValue,
*toCSSValue)) { | 366 if (LengthBoxStyleInterpolation::usesDefaultInterpolation(*fromCSSValue,
*toCSSValue)) { |
367 forceDefaultInterpolation = true; | 367 forceDefaultInterpolation = true; |
368 break; | 368 break; |
369 } | 369 } |
370 RefPtrWillBeRawPtr<Interpolation> interpolation = LengthBoxStyleInterpol
ation::maybeCreateFrom(*fromCSSValue, *toCSSValue, property); | 370 Interpolation* interpolation = LengthBoxStyleInterpolation::maybeCreateF
rom(*fromCSSValue, *toCSSValue, property); |
371 if (interpolation) | 371 if (interpolation) |
372 return interpolation.release(); | 372 return interpolation; |
373 break; | 373 break; |
374 } | 374 } |
375 | 375 |
376 case CSSPropertyBorderImageSlice: | 376 case CSSPropertyBorderImageSlice: |
377 case CSSPropertyWebkitMaskBoxImageSlice: { | 377 case CSSPropertyWebkitMaskBoxImageSlice: { |
378 RefPtrWillBeRawPtr<Interpolation> interpolation = ImageSliceStyleInterpo
lation::maybeCreate(*fromCSSValue, *toCSSValue, property); | 378 Interpolation* interpolation = ImageSliceStyleInterpolation::maybeCreate
(*fromCSSValue, *toCSSValue, property); |
379 if (interpolation) | 379 if (interpolation) |
380 return interpolation.release(); | 380 return interpolation; |
381 if (ImageSliceStyleInterpolation::usesDefaultInterpolation(*fromCSSValue
, *toCSSValue)) | 381 if (ImageSliceStyleInterpolation::usesDefaultInterpolation(*fromCSSValue
, *toCSSValue)) |
382 forceDefaultInterpolation = true; | 382 forceDefaultInterpolation = true; |
383 | 383 |
384 break; | 384 break; |
385 } | 385 } |
386 | 386 |
387 case CSSPropertyStrokeDasharray: { | 387 case CSSPropertyStrokeDasharray: { |
388 RefPtrWillBeRawPtr<Interpolation> interpolation = SVGStrokeDasharrayStyl
eInterpolation::maybeCreate(*fromCSSValue, *toCSSValue, property); | 388 Interpolation* interpolation = SVGStrokeDasharrayStyleInterpolation::may
beCreate(*fromCSSValue, *toCSSValue, property); |
389 if (interpolation) | 389 if (interpolation) |
390 return interpolation.release(); | 390 return interpolation; |
391 | 391 |
392 break; | 392 break; |
393 } | 393 } |
394 | 394 |
395 case CSSPropertyWebkitFilter: { | 395 case CSSPropertyWebkitFilter: { |
396 RefPtrWillBeRawPtr<Interpolation> interpolation = FilterStyleInterpolati
on::maybeCreateList(*fromCSSValue, *toCSSValue, property); | 396 Interpolation* interpolation = FilterStyleInterpolation::maybeCreateList
(*fromCSSValue, *toCSSValue, property); |
397 if (interpolation) | 397 if (interpolation) |
398 return interpolation.release(); | 398 return interpolation; |
399 | 399 |
400 // FIXME: Support drop shadow interpolation. | 400 // FIXME: Support drop shadow interpolation. |
401 fallBackToLegacy = true; | 401 fallBackToLegacy = true; |
402 break; | 402 break; |
403 } | 403 } |
404 | 404 |
405 default: | 405 default: |
406 // Fall back to LegacyStyleInterpolation. | 406 // Fall back to LegacyStyleInterpolation. |
407 fallBackToLegacy = true; | 407 fallBackToLegacy = true; |
408 break; | 408 break; |
(...skipping 12 matching lines...) Expand all Loading... |
421 if (fallBackToLegacy) { | 421 if (fallBackToLegacy) { |
422 if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(
*fromCSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleRe
solve(*toCSSValue)) { | 422 if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(
*fromCSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleRe
solve(*toCSSValue)) { |
423 // FIXME: Handle these cases outside of DeferredLegacyStyleInterpola
tion. | 423 // FIXME: Handle these cases outside of DeferredLegacyStyleInterpola
tion. |
424 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSV
alue, property); | 424 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSV
alue, property); |
425 } | 425 } |
426 | 426 |
427 // FIXME: Remove the use of AnimatableValues and Elements here. | 427 // FIXME: Remove the use of AnimatableValues and Elements here. |
428 ASSERT(element); | 428 ASSERT(element); |
429 populateAnimatableValue(property, *element, baseStyle); | 429 populateAnimatableValue(property, *element, baseStyle); |
430 end.populateAnimatableValue(property, *element, baseStyle); | 430 end.populateAnimatableValue(property, *element, baseStyle); |
431 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAni
matableValue(), property); | 431 return LegacyStyleInterpolation::create(const_cast<AnimatableValue*>(get
AnimatableValue()), const_cast<AnimatableValue*>(end.getAnimatableValue()), prop
erty); |
432 } | 432 } |
433 | 433 |
434 ASSERT(AnimatableValue::usesDefaultInterpolation( | 434 ASSERT(AnimatableValue::usesDefaultInterpolation( |
435 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, proper
ty, fromCSSValue).get(), | 435 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, proper
ty, fromCSSValue), |
436 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, proper
ty, toCSSValue).get())); | 436 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, proper
ty, toCSSValue))); |
437 | 437 |
438 return nullptr; | 438 return nullptr; |
439 | 439 |
440 } | 440 } |
441 | 441 |
442 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr
opertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction
> easing) const | 442 Keyframe::PropertySpecificKeyframe* StringKeyframe::CSSPropertySpecificKeyframe:
:neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
443 { | 443 { |
444 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, st
atic_cast<CSSValue*>(0), AnimationEffect::CompositeAdd)); | 444 return new CSSPropertySpecificKeyframe(offset, easing, static_cast<CSSValue*
>(0), AnimationEffect::CompositeAdd); |
445 } | 445 } |
446 | 446 |
447 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr
opertySpecificKeyframe::cloneWithOffset(double offset) const | 447 Keyframe::PropertySpecificKeyframe* StringKeyframe::CSSPropertySpecificKeyframe:
:cloneWithOffset(double offset) const |
448 { | 448 { |
449 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); | 449 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); |
450 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; | 450 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; |
451 return adoptPtrWillBeNoop(theClone); | 451 return theClone; |
452 } | 452 } |
453 | 453 |
454 DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe) | 454 DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe) |
455 { | 455 { |
456 visitor->trace(m_value); | 456 visitor->trace(m_value); |
457 visitor->trace(m_animatableValueCache); | 457 visitor->trace(m_animatableValueCache); |
458 Keyframe::PropertySpecificKeyframe::trace(visitor); | 458 Keyframe::PropertySpecificKeyframe::trace(visitor); |
459 } | 459 } |
460 | 460 |
461 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, AnimationEffect::CompositeOperat
ion op) | 461 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, AnimationEffect::CompositeOperat
ion op) |
462 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 462 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
463 , m_value(value) | 463 , m_value(value) |
464 { | 464 { |
465 } | 465 } |
466 | 466 |
467 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) | 467 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) |
468 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos
iteReplace) | 468 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos
iteReplace) |
469 , m_value(value) | 469 , m_value(value) |
470 { | 470 { |
471 ASSERT(!isNull(m_offset)); | 471 ASSERT(!isNull(m_offset)); |
472 } | 472 } |
473 | 473 |
474 DEFINE_TRACE(StringKeyframe::SVGPropertySpecificKeyframe) | 474 DEFINE_TRACE(StringKeyframe::SVGPropertySpecificKeyframe) |
475 { | 475 { |
476 Keyframe::PropertySpecificKeyframe::trace(visitor); | 476 Keyframe::PropertySpecificKeyframe::trace(visitor); |
477 } | 477 } |
478 | 478 |
479 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
yframe::cloneWithOffset(double offset) const | 479 Keyframe::PropertySpecificKeyframe* SVGPropertySpecificKeyframe::cloneWithOffset
(double offset) const |
480 { | 480 { |
481 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, m_easing,
m_value)); | 481 return new SVGPropertySpecificKeyframe(offset, m_easing, m_value); |
482 } | 482 } |
483 | 483 |
484 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
yframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const | 484 Keyframe::PropertySpecificKeyframe* SVGPropertySpecificKeyframe::neutralKeyframe
(double offset, PassRefPtr<TimingFunction> easing) const |
485 { | 485 { |
486 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, ""
, AnimationEffect::CompositeAdd)); | 486 return new SVGPropertySpecificKeyframe(offset, easing, "", AnimationEffect::
CompositeAdd); |
487 } | 487 } |
488 | 488 |
489 namespace { | 489 namespace { |
490 | 490 |
491 PassRefPtrWillBeRawPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fr
omValue, SVGPropertyBase* toValue, SVGAnimatedPropertyBase* attribute) | 491 Interpolation* createSVGInterpolation(SVGPropertyBase* fromValue, SVGPropertyBas
e* toValue, SVGAnimatedPropertyBase* attribute) |
492 { | 492 { |
493 RefPtrWillBeRawPtr<Interpolation> interpolation = nullptr; | 493 Interpolation* interpolation = nullptr; |
494 ASSERT(fromValue->type() == toValue->type()); | 494 ASSERT(fromValue->type() == toValue->type()); |
495 switch (fromValue->type()) { | 495 switch (fromValue->type()) { |
496 case AnimatedAngle: | 496 case AnimatedAngle: |
497 if (AngleSVGInterpolation::canCreateFrom(fromValue) && AngleSVGInterpola
tion::canCreateFrom(toValue)) | 497 if (AngleSVGInterpolation::canCreateFrom(fromValue) && AngleSVGInterpola
tion::canCreateFrom(toValue)) |
498 return AngleSVGInterpolation::create(fromValue, toValue, attribute); | 498 return AngleSVGInterpolation::create(fromValue, toValue, attribute); |
499 break; | 499 break; |
500 case AnimatedInteger: | 500 case AnimatedInteger: |
501 return IntegerSVGInterpolation::create(fromValue, toValue, attribute); | 501 return IntegerSVGInterpolation::create(fromValue, toValue, attribute); |
502 case AnimatedIntegerOptionalInteger: { | 502 case AnimatedIntegerOptionalInteger: { |
503 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; | 503 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; |
(...skipping 23 matching lines...) Expand all Loading... |
527 return RectSVGInterpolation::create(fromValue, toValue, attribute); | 527 return RectSVGInterpolation::create(fromValue, toValue, attribute); |
528 case AnimatedTransformList: | 528 case AnimatedTransformList: |
529 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr
eate(fromValue, toValue, attribute); | 529 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr
eate(fromValue, toValue, attribute); |
530 break; | 530 break; |
531 | 531 |
532 // TODO(ericwilligers): Support more animation types. | 532 // TODO(ericwilligers): Support more animation types. |
533 default: | 533 default: |
534 break; | 534 break; |
535 } | 535 } |
536 if (interpolation) | 536 if (interpolation) |
537 return interpolation.release(); | 537 return interpolation; |
538 | 538 |
539 return DefaultSVGInterpolation::create(fromValue, toValue, attribute); | 539 return DefaultSVGInterpolation::create(fromValue, toValue, attribute); |
540 } | 540 } |
541 | 541 |
542 } // namespace | 542 } // namespace |
543 | 543 |
544 PassRefPtrWillBeRawPtr<Interpolation> SVGPropertySpecificKeyframe::maybeCreateIn
terpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& e
nd, Element* element, const ComputedStyle* baseStyle) const | 544 Interpolation* SVGPropertySpecificKeyframe::maybeCreateInterpolation(PropertyHan
dle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element* element, c
onst ComputedStyle* baseStyle) const |
545 { | 545 { |
546 ASSERT(element); | 546 ASSERT(element); |
547 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute = toSVGElement(element
)->propertyFromAttribute(*propertyHandle.svgAttribute()); | 547 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute = toSVGElement(element
)->propertyFromAttribute(*propertyHandle.svgAttribute()); |
548 ASSERT(attribute); | 548 ASSERT(attribute); |
549 | 549 |
550 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); | 550 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); |
551 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); | 551 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); |
552 | 552 |
553 if (!fromValue || !toValue) | 553 if (!fromValue || !toValue) |
554 return nullptr; | 554 return nullptr; |
555 | 555 |
556 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); | 556 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); |
557 } | 557 } |
558 | 558 |
559 } // namespace blink | 559 } // namespace blink |
OLD | NEW |