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/CSSValueInterpolationType.h" | 9 #include "core/animation/CSSValueInterpolationType.h" |
10 #include "core/animation/ColorStyleInterpolation.h" | 10 #include "core/animation/ColorStyleInterpolation.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 PropertyHandleSet properties; | 80 PropertyHandleSet properties; |
81 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) | 81 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) |
82 properties.add(PropertyHandle(m_propertySet->propertyAt(i).id())); | 82 properties.add(PropertyHandle(m_propertySet->propertyAt(i).id())); |
83 | 83 |
84 for (const auto& key: m_svgPropertyMap.keys()) | 84 for (const auto& key: m_svgPropertyMap.keys()) |
85 properties.add(PropertyHandle(*key)); | 85 properties.add(PropertyHandle(*key)); |
86 | 86 |
87 return properties; | 87 return properties; |
88 } | 88 } |
89 | 89 |
90 PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const | 90 Keyframe* StringKeyframe::clone() const |
91 { | 91 { |
92 return adoptRefWillBeNoop(new StringKeyframe(*this)); | 92 return new StringKeyframe(*this); |
93 } | 93 } |
94 | 94 |
95 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::creat
ePropertySpecificKeyframe(PropertyHandle property) const | 95 Keyframe::PropertySpecificKeyframe* StringKeyframe::createPropertySpecificKeyfra
me(PropertyHandle property) const |
96 { | 96 { |
97 if (property.isCSSProperty()) | 97 if (property.isCSSProperty()) |
98 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset(), &eas
ing(), cssPropertyValue(property.cssProperty()), composite())); | 98 return new CSSPropertySpecificKeyframe(offset(), &easing(), cssPropertyV
alue(property.cssProperty()), composite()); |
99 | 99 |
100 ASSERT(property.isSVGAttribute()); | 100 ASSERT(property.isSVGAttribute()); |
101 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset(), &easing(
), svgPropertyValue(*property.svgAttribute()), composite())); | 101 return new SVGPropertySpecificKeyframe(offset(), &easing(), svgPropertyValue
(*property.svgAttribute()), composite()); |
102 } | 102 } |
103 | 103 |
104 DEFINE_TRACE(StringKeyframe) | 104 DEFINE_TRACE(StringKeyframe) |
105 { | 105 { |
106 visitor->trace(m_propertySet); | 106 visitor->trace(m_propertySet); |
107 Keyframe::trace(visitor); | 107 Keyframe::trace(visitor); |
108 } | 108 } |
109 | 109 |
110 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, EffectModel::Composi
teOperation op) | 110 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, EffectModel::Composi
teOperation op) |
111 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 111 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 break; | 177 break; |
178 } | 178 } |
179 applicableTypes->append(new CSSValueInterpolationType(property)); | 179 applicableTypes->append(new CSSValueInterpolationType(property)); |
180 applicableTypesMap.add(property, applicableTypes); | 180 applicableTypesMap.add(property, applicableTypes); |
181 return applicableTypes; | 181 return applicableTypes; |
182 } | 182 } |
183 | 183 |
184 } // namespace | 184 } // namespace |
185 | 185 |
186 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram
e::createLegacyStyleInterpolation(CSSPropertyID property, Keyframe::PropertySpec
ificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const | 186 Interpolation* StringKeyframe::CSSPropertySpecificKeyframe::createLegacyStyleInt
erpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe& end, Elem
ent* element, const ComputedStyle* baseStyle) const |
187 { | 187 { |
188 CSSValue& fromCSSValue = *m_value.get(); | 188 CSSValue& fromCSSValue = *m_value; |
189 CSSValue& toCSSValue = *toCSSPropertySpecificKeyframe(end).value(); | 189 CSSValue& toCSSValue = *toCSSPropertySpecificKeyframe(end).value(); |
190 if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(from
CSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve
(toCSSValue)) { | 190 if (DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(from
CSSValue) || DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve
(toCSSValue)) { |
191 // FIXME: Handle these cases outside of DeferredLegacyStyleInterpolation
. | 191 // FIXME: Handle these cases outside of DeferredLegacyStyleInterpolation
. |
192 return DeferredLegacyStyleInterpolation::create(&fromCSSValue, &toCSSVal
ue, property); | 192 return DeferredLegacyStyleInterpolation::create(&fromCSSValue, &toCSSVal
ue, property); |
193 } | 193 } |
194 | 194 |
195 // FIXME: Remove the use of AnimatableValues and Elements here. | 195 // FIXME: Remove the use of AnimatableValues and Elements here. |
196 ASSERT(element); | 196 ASSERT(element); |
197 populateAnimatableValue(property, *element, baseStyle); | 197 populateAnimatableValue(property, *element, baseStyle); |
198 end.populateAnimatableValue(property, *element, baseStyle); | 198 end.populateAnimatableValue(property, *element, baseStyle); |
199 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAnimata
bleValue(), property); | 199 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAnimata
bleValue(), property); |
200 } | 200 } |
201 | 201 |
202 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram
e::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpe
cificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const | 202 Interpolation* StringKeyframe::CSSPropertySpecificKeyframe::maybeCreateInterpola
tion(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Ele
ment* element, const ComputedStyle* baseStyle) const |
203 { | 203 { |
204 CSSPropertyID property = propertyHandle.cssProperty(); | 204 CSSPropertyID property = propertyHandle.cssProperty(); |
205 const Vector<const InterpolationType*>* applicableTypes = applicableTypesFor
Property(property); | 205 const Vector<const InterpolationType*>* applicableTypes = applicableTypesFor
Property(property); |
206 if (applicableTypes) | 206 if (applicableTypes) |
207 return InvalidatableStyleInterpolation::create(*applicableTypes, *this,
toCSSPropertySpecificKeyframe(end)); | 207 return InvalidatableStyleInterpolation::create(*applicableTypes, *this,
toCSSPropertySpecificKeyframe(end)); |
208 | 208 |
209 // TODO(alancutter): Remove the remainder of this function. | 209 // TODO(alancutter): Remove the remainder of this function. |
210 | 210 |
211 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe
ct, and a template parameter specific converter. | 211 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe
ct, and a template parameter specific converter. |
212 CSSValue* fromCSSValue = m_value.get(); | 212 CSSValue* fromCSSValue = m_value.get(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 case CSSPropertyFontSizeAdjust: | 317 case CSSPropertyFontSizeAdjust: |
318 case CSSPropertyOpacity: | 318 case CSSPropertyOpacity: |
319 case CSSPropertyStopOpacity: | 319 case CSSPropertyStopOpacity: |
320 case CSSPropertyStrokeOpacity: | 320 case CSSPropertyStrokeOpacity: |
321 case CSSPropertyStrokeMiterlimit: | 321 case CSSPropertyStrokeMiterlimit: |
322 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl
eInterpolation::canCreateFrom(*toCSSValue)) | 322 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl
eInterpolation::canCreateFrom(*toCSSValue)) |
323 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue,
property, toCSSPrimitiveValue(fromCSSValue)->isNumber(), setRange(property)); | 323 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue,
property, toCSSPrimitiveValue(fromCSSValue)->isNumber(), setRange(property)); |
324 break; | 324 break; |
325 | 325 |
326 case CSSPropertyMotionRotation: { | 326 case CSSPropertyMotionRotation: { |
327 RefPtrWillBeRawPtr<Interpolation> interpolation = DoubleStyleInterpolati
on::maybeCreateFromMotionRotation(*fromCSSValue, *toCSSValue, property); | 327 Interpolation* interpolation = DoubleStyleInterpolation::maybeCreateFrom
MotionRotation(*fromCSSValue, *toCSSValue, property); |
328 if (interpolation) | 328 if (interpolation) |
329 return interpolation.release(); | 329 return interpolation; |
330 break; | 330 break; |
331 } | 331 } |
332 case CSSPropertyVisibility: | 332 case CSSPropertyVisibility: |
333 if (VisibilityStyleInterpolation::canCreateFrom(*fromCSSValue) && Visibi
lityStyleInterpolation::canCreateFrom(*toCSSValue) && (VisibilityStyleInterpolat
ion::isVisible(*fromCSSValue) || VisibilityStyleInterpolation::isVisible(*toCSSV
alue))) | 333 if (VisibilityStyleInterpolation::canCreateFrom(*fromCSSValue) && Visibi
lityStyleInterpolation::canCreateFrom(*toCSSValue) && (VisibilityStyleInterpolat
ion::isVisible(*fromCSSValue) || VisibilityStyleInterpolation::isVisible(*toCSSV
alue))) |
334 return VisibilityStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property); | 334 return VisibilityStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property); |
335 | 335 |
336 break; | 336 break; |
337 | 337 |
338 case CSSPropertyBackgroundColor: | 338 case CSSPropertyBackgroundColor: |
339 case CSSPropertyBorderBottomColor: | 339 case CSSPropertyBorderBottomColor: |
340 case CSSPropertyBorderLeftColor: | 340 case CSSPropertyBorderLeftColor: |
341 case CSSPropertyBorderRightColor: | 341 case CSSPropertyBorderRightColor: |
342 case CSSPropertyBorderTopColor: | 342 case CSSPropertyBorderTopColor: |
343 case CSSPropertyColor: | 343 case CSSPropertyColor: |
344 case CSSPropertyFill: | 344 case CSSPropertyFill: |
345 case CSSPropertyFloodColor: | 345 case CSSPropertyFloodColor: |
346 case CSSPropertyLightingColor: | 346 case CSSPropertyLightingColor: |
347 case CSSPropertyOutlineColor: | 347 case CSSPropertyOutlineColor: |
348 case CSSPropertyStopColor: | 348 case CSSPropertyStopColor: |
349 case CSSPropertyStroke: | 349 case CSSPropertyStroke: |
350 case CSSPropertyTextDecorationColor: | 350 case CSSPropertyTextDecorationColor: |
351 case CSSPropertyWebkitColumnRuleColor: | 351 case CSSPropertyWebkitColumnRuleColor: |
352 case CSSPropertyWebkitTextStrokeColor: | 352 case CSSPropertyWebkitTextStrokeColor: |
353 { | 353 { |
354 RefPtrWillBeRawPtr<Interpolation> interpolation = ColorStyleInterpol
ation::maybeCreateFromColor(*fromCSSValue, *toCSSValue, property); | 354 Interpolation* interpolation = ColorStyleInterpolation::maybeCreateF
romColor(*fromCSSValue, *toCSSValue, property); |
355 if (interpolation) | 355 if (interpolation) |
356 return interpolation.release(); | 356 return interpolation; |
357 | 357 |
358 // Current color should use LegacyStyleInterpolation | 358 // Current color should use LegacyStyleInterpolation |
359 if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*from
CSSValue, *toCSSValue)) | 359 if (ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*from
CSSValue, *toCSSValue)) |
360 return createLegacyStyleInterpolation(property, end, element, ba
seStyle); | 360 return createLegacyStyleInterpolation(property, end, element, ba
seStyle); |
361 | 361 |
362 break; | 362 break; |
363 } | 363 } |
364 | 364 |
365 case CSSPropertyBorderImageSource: | 365 case CSSPropertyBorderImageSource: |
366 case CSSPropertyListStyleImage: | 366 case CSSPropertyListStyleImage: |
(...skipping 12 matching lines...) Expand all Loading... |
379 case CSSPropertyBorderTopRightRadius: | 379 case CSSPropertyBorderTopRightRadius: |
380 range = RangeNonNegative; | 380 range = RangeNonNegative; |
381 // Fall through | 381 // Fall through |
382 case CSSPropertyObjectPosition: | 382 case CSSPropertyObjectPosition: |
383 if (LengthPairStyleInterpolation::canCreateFrom(*fromCSSValue) && Length
PairStyleInterpolation::canCreateFrom(*toCSSValue)) | 383 if (LengthPairStyleInterpolation::canCreateFrom(*fromCSSValue) && Length
PairStyleInterpolation::canCreateFrom(*toCSSValue)) |
384 return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property, range); | 384 return LengthPairStyleInterpolation::create(*fromCSSValue, *toCSSVal
ue, property, range); |
385 break; | 385 break; |
386 | 386 |
387 case CSSPropertyPerspectiveOrigin: | 387 case CSSPropertyPerspectiveOrigin: |
388 case CSSPropertyTransformOrigin: { | 388 case CSSPropertyTransformOrigin: { |
389 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation
<LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop
erty, range); | 389 Interpolation* interpolation = ListStyleInterpolation<LengthStyleInterpo
lation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property, range); |
390 if (interpolation) | 390 if (interpolation) |
391 return interpolation.release(); | 391 return interpolation; |
392 | 392 |
393 // FIXME: Handle keywords: top, right, left, center, bottom | 393 // FIXME: Handle keywords: top, right, left, center, bottom |
394 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; | 394 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; |
395 } | 395 } |
396 | 396 |
397 case CSSPropertyBoxShadow: | 397 case CSSPropertyBoxShadow: |
398 case CSSPropertyTextShadow: { | 398 case CSSPropertyTextShadow: { |
399 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation
<ShadowStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop
erty); | 399 Interpolation* interpolation = ListStyleInterpolation<ShadowStyleInterpo
lation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property); |
400 if (interpolation) | 400 if (interpolation) |
401 return interpolation.release(); | 401 return interpolation; |
402 | 402 |
403 // FIXME: AnimatableShadow incorrectly animates between inset and non-in
set values so it will never indicate it needs default interpolation | 403 // FIXME: AnimatableShadow incorrectly animates between inset and non-in
set values so it will never indicate it needs default interpolation |
404 if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValu
e, *toCSSValue)) { | 404 if (ShadowStyleInterpolation::usesDefaultStyleInterpolation(*fromCSSValu
e, *toCSSValue)) { |
405 forceDefaultInterpolation = true; | 405 forceDefaultInterpolation = true; |
406 break; | 406 break; |
407 } | 407 } |
408 | 408 |
409 // FIXME: Handle interpolation from/to none, unspecified color values | 409 // FIXME: Handle interpolation from/to none, unspecified color values |
410 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; | 410 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; |
411 } | 411 } |
412 | 412 |
413 case CSSPropertyClip: { | 413 case CSSPropertyClip: { |
414 if (LengthBoxStyleInterpolation::usesDefaultInterpolation(*fromCSSValue,
*toCSSValue)) { | 414 if (LengthBoxStyleInterpolation::usesDefaultInterpolation(*fromCSSValue,
*toCSSValue)) { |
415 forceDefaultInterpolation = true; | 415 forceDefaultInterpolation = true; |
416 break; | 416 break; |
417 } | 417 } |
418 RefPtrWillBeRawPtr<Interpolation> interpolation = LengthBoxStyleInterpol
ation::maybeCreateFrom(*fromCSSValue, *toCSSValue, property); | 418 Interpolation* interpolation = LengthBoxStyleInterpolation::maybeCreateF
rom(*fromCSSValue, *toCSSValue, property); |
419 if (interpolation) | 419 if (interpolation) |
420 return interpolation.release(); | 420 return interpolation; |
421 break; | 421 break; |
422 } | 422 } |
423 | 423 |
424 case CSSPropertyBorderImageSlice: | 424 case CSSPropertyBorderImageSlice: |
425 case CSSPropertyWebkitMaskBoxImageSlice: { | 425 case CSSPropertyWebkitMaskBoxImageSlice: { |
426 RefPtrWillBeRawPtr<Interpolation> interpolation = ImageSliceStyleInterpo
lation::maybeCreate(*fromCSSValue, *toCSSValue, property); | 426 Interpolation* interpolation = ImageSliceStyleInterpolation::maybeCreate
(*fromCSSValue, *toCSSValue, property); |
427 if (interpolation) | 427 if (interpolation) |
428 return interpolation.release(); | 428 return interpolation; |
429 if (ImageSliceStyleInterpolation::usesDefaultInterpolation(*fromCSSValue
, *toCSSValue)) | 429 if (ImageSliceStyleInterpolation::usesDefaultInterpolation(*fromCSSValue
, *toCSSValue)) |
430 forceDefaultInterpolation = true; | 430 forceDefaultInterpolation = true; |
431 | 431 |
432 break; | 432 break; |
433 } | 433 } |
434 | 434 |
435 case CSSPropertyStrokeDasharray: { | 435 case CSSPropertyStrokeDasharray: { |
436 RefPtrWillBeRawPtr<Interpolation> interpolation = SVGStrokeDasharrayStyl
eInterpolation::maybeCreate(*fromCSSValue, *toCSSValue, property); | 436 Interpolation* interpolation = SVGStrokeDasharrayStyleInterpolation::may
beCreate(*fromCSSValue, *toCSSValue, property); |
437 if (interpolation) | 437 if (interpolation) |
438 return interpolation.release(); | 438 return interpolation; |
439 | 439 |
440 break; | 440 break; |
441 } | 441 } |
442 | 442 |
443 case CSSPropertyWebkitFilter: { | 443 case CSSPropertyWebkitFilter: { |
444 RefPtrWillBeRawPtr<Interpolation> interpolation = FilterStyleInterpolati
on::maybeCreateList(*fromCSSValue, *toCSSValue, property); | 444 Interpolation* interpolation = FilterStyleInterpolation::maybeCreateList
(*fromCSSValue, *toCSSValue, property); |
445 if (interpolation) | 445 if (interpolation) |
446 return interpolation.release(); | 446 return interpolation; |
447 | 447 |
448 // FIXME: Support drop shadow interpolation. | 448 // FIXME: Support drop shadow interpolation. |
449 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; | 449 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; |
450 break; | 450 break; |
451 } | 451 } |
452 | 452 |
453 case CSSPropertyTranslate: { | 453 case CSSPropertyTranslate: { |
454 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation
<LengthStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop
erty, range); | 454 Interpolation* interpolation = ListStyleInterpolation<LengthStyleInterpo
lation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property, range); |
455 if (interpolation) | 455 if (interpolation) |
456 return interpolation.release(); | 456 return interpolation; |
457 | 457 |
458 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length
does not match. | 458 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length
does not match. |
459 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; | 459 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; |
460 break; | 460 break; |
461 } | 461 } |
462 | 462 |
463 case CSSPropertyScale: { | 463 case CSSPropertyScale: { |
464 RefPtrWillBeRawPtr<Interpolation> interpolation = ListStyleInterpolation
<DoubleStyleInterpolation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, prop
erty, range); | 464 Interpolation* interpolation = ListStyleInterpolation<DoubleStyleInterpo
lation>::maybeCreateFromList(*fromCSSValue, *toCSSValue, property, range); |
465 if (interpolation) | 465 if (interpolation) |
466 return interpolation.release(); | 466 return interpolation; |
467 | 467 |
468 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length
does not match. | 468 // TODO(soonm): Legacy mode is used when from and to cssvaluelist length
does not match. |
469 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; | 469 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; |
470 break; | 470 break; |
471 } | 471 } |
472 | 472 |
473 default: | 473 default: |
474 // Fall back to LegacyStyleInterpolation. | 474 // Fall back to LegacyStyleInterpolation. |
475 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; | 475 return createLegacyStyleInterpolation(property, end, element, baseStyle)
; |
476 break; | 476 break; |
477 } | 477 } |
478 | 478 |
479 if (fromCSSValue == toCSSValue) | 479 if (fromCSSValue == toCSSValue) |
480 return ConstantStyleInterpolation::create(fromCSSValue, property); | 480 return ConstantStyleInterpolation::create(fromCSSValue, property); |
481 | 481 |
482 if (!forceDefaultInterpolation) { | 482 if (!forceDefaultInterpolation) { |
483 ASSERT(AnimatableValue::usesDefaultInterpolation( | 483 ASSERT(AnimatableValue::usesDefaultInterpolation( |
484 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, fromCSSValue).get(), | 484 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, fromCSSValue), |
485 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, toCSSValue).get())); | 485 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, toCSSValue))); |
486 } | 486 } |
487 | 487 |
488 return nullptr; | 488 return nullptr; |
489 | 489 |
490 } | 490 } |
491 | 491 |
492 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr
opertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction
> easing) const | 492 Keyframe::PropertySpecificKeyframe* StringKeyframe::CSSPropertySpecificKeyframe:
:neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
493 { | 493 { |
494 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, st
atic_cast<CSSValue*>(0), EffectModel::CompositeAdd)); | 494 return new CSSPropertySpecificKeyframe(offset, easing, static_cast<CSSValue*
>(0), EffectModel::CompositeAdd); |
495 } | 495 } |
496 | 496 |
497 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr
opertySpecificKeyframe::cloneWithOffset(double offset) const | 497 Keyframe::PropertySpecificKeyframe* StringKeyframe::CSSPropertySpecificKeyframe:
:cloneWithOffset(double offset) const |
498 { | 498 { |
499 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); | 499 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); |
500 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; | 500 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; |
501 return adoptPtrWillBeNoop(theClone); | 501 return theClone; |
502 } | 502 } |
503 | 503 |
504 DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe) | 504 DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe) |
505 { | 505 { |
506 visitor->trace(m_value); | 506 visitor->trace(m_value); |
507 visitor->trace(m_animatableValueCache); | 507 visitor->trace(m_animatableValueCache); |
508 Keyframe::PropertySpecificKeyframe::trace(visitor); | 508 Keyframe::PropertySpecificKeyframe::trace(visitor); |
509 } | 509 } |
510 | 510 |
511 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, EffectModel::CompositeOperation
op) | 511 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, EffectModel::CompositeOperation
op) |
512 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 512 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
513 , m_value(value) | 513 , m_value(value) |
514 { | 514 { |
515 } | 515 } |
516 | 516 |
517 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) | 517 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) |
518 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) | 518 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) |
519 , m_value(value) | 519 , m_value(value) |
520 { | 520 { |
521 ASSERT(!isNull(m_offset)); | 521 ASSERT(!isNull(m_offset)); |
522 } | 522 } |
523 | 523 |
524 DEFINE_TRACE(StringKeyframe::SVGPropertySpecificKeyframe) | 524 DEFINE_TRACE(StringKeyframe::SVGPropertySpecificKeyframe) |
525 { | 525 { |
526 Keyframe::PropertySpecificKeyframe::trace(visitor); | 526 Keyframe::PropertySpecificKeyframe::trace(visitor); |
527 } | 527 } |
528 | 528 |
529 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
yframe::cloneWithOffset(double offset) const | 529 Keyframe::PropertySpecificKeyframe* SVGPropertySpecificKeyframe::cloneWithOffset
(double offset) const |
530 { | 530 { |
531 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, m_easing,
m_value)); | 531 return new SVGPropertySpecificKeyframe(offset, m_easing, m_value); |
532 } | 532 } |
533 | 533 |
534 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
yframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const | 534 Keyframe::PropertySpecificKeyframe* SVGPropertySpecificKeyframe::neutralKeyframe
(double offset, PassRefPtr<TimingFunction> easing) const |
535 { | 535 { |
536 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, ""
, EffectModel::CompositeAdd)); | 536 return new SVGPropertySpecificKeyframe(offset, easing, "", EffectModel::Comp
ositeAdd); |
537 } | 537 } |
538 | 538 |
539 namespace { | 539 namespace { |
540 | 540 |
541 PassRefPtrWillBeRawPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fr
omValue, SVGPropertyBase* toValue, SVGAnimatedPropertyBase* attribute) | 541 Interpolation* createSVGInterpolation(SVGPropertyBase* fromValue, SVGPropertyBas
e* toValue, SVGAnimatedPropertyBase* attribute) |
542 { | 542 { |
543 RefPtrWillBeRawPtr<Interpolation> interpolation = nullptr; | 543 Interpolation* interpolation = nullptr; |
544 ASSERT(fromValue->type() == toValue->type()); | 544 ASSERT(fromValue->type() == toValue->type()); |
545 switch (fromValue->type()) { | 545 switch (fromValue->type()) { |
546 case AnimatedAngle: | 546 case AnimatedAngle: |
547 if (AngleSVGInterpolation::canCreateFrom(fromValue) && AngleSVGInterpola
tion::canCreateFrom(toValue)) | 547 if (AngleSVGInterpolation::canCreateFrom(fromValue) && AngleSVGInterpola
tion::canCreateFrom(toValue)) |
548 return AngleSVGInterpolation::create(fromValue, toValue, attribute); | 548 return AngleSVGInterpolation::create(fromValue, toValue, attribute); |
549 break; | 549 break; |
550 case AnimatedInteger: | 550 case AnimatedInteger: |
551 return IntegerSVGInterpolation::create(fromValue, toValue, attribute); | 551 return IntegerSVGInterpolation::create(fromValue, toValue, attribute); |
552 case AnimatedIntegerOptionalInteger: { | 552 case AnimatedIntegerOptionalInteger: { |
553 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; | 553 int min = &attribute->attributeName() == &SVGNames::orderAttr ? 1 : 0; |
(...skipping 23 matching lines...) Expand all Loading... |
577 return RectSVGInterpolation::create(fromValue, toValue, attribute); | 577 return RectSVGInterpolation::create(fromValue, toValue, attribute); |
578 case AnimatedTransformList: | 578 case AnimatedTransformList: |
579 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr
eate(fromValue, toValue, attribute); | 579 interpolation = ListSVGInterpolation<TransformSVGInterpolation>::maybeCr
eate(fromValue, toValue, attribute); |
580 break; | 580 break; |
581 | 581 |
582 // TODO(ericwilligers): Support more animation types. | 582 // TODO(ericwilligers): Support more animation types. |
583 default: | 583 default: |
584 break; | 584 break; |
585 } | 585 } |
586 if (interpolation) | 586 if (interpolation) |
587 return interpolation.release(); | 587 return interpolation; |
588 | 588 |
589 return DefaultSVGInterpolation::create(fromValue, toValue, attribute); | 589 return DefaultSVGInterpolation::create(fromValue, toValue, attribute); |
590 } | 590 } |
591 | 591 |
592 } // namespace | 592 } // namespace |
593 | 593 |
594 PassRefPtrWillBeRawPtr<Interpolation> SVGPropertySpecificKeyframe::maybeCreateIn
terpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& e
nd, Element* element, const ComputedStyle* baseStyle) const | 594 Interpolation* SVGPropertySpecificKeyframe::maybeCreateInterpolation(PropertyHan
dle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element* element, c
onst ComputedStyle* baseStyle) const |
595 { | 595 { |
596 ASSERT(element); | 596 ASSERT(element); |
597 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute = toSVGElement(element
)->propertyFromAttribute(*propertyHandle.svgAttribute()); | 597 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute = toSVGElement(element
)->propertyFromAttribute(*propertyHandle.svgAttribute()); |
598 ASSERT(attribute); | 598 ASSERT(attribute); |
599 | 599 |
600 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); | 600 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); |
601 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); | 601 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); |
602 | 602 |
603 if (!fromValue || !toValue) | 603 if (!fromValue || !toValue) |
604 return nullptr; | 604 return nullptr; |
605 | 605 |
606 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); | 606 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); |
607 } | 607 } |
608 | 608 |
609 } // namespace blink | 609 } // namespace blink |
OLD | NEW |