| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 { | 53 { |
| 54 } | 54 } |
| 55 | 55 |
| 56 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, Element* element, StyleSheetContents* styleSheetContents) | 56 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, Element* element, StyleSheetContents* styleSheetContents) |
| 57 { | 57 { |
| 58 ASSERT(property != CSSPropertyInvalid); | 58 ASSERT(property != CSSPropertyInvalid); |
| 59 if (CSSAnimations::isAnimatableProperty(property)) | 59 if (CSSAnimations::isAnimatableProperty(property)) |
| 60 m_propertySet->setProperty(property, value, false, styleSheetContents); | 60 m_propertySet->setProperty(property, value, false, styleSheetContents); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtrWillBeRa
wPtr<CSSValue> value) | 63 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtr<CSSValu
e> value) |
| 64 { | 64 { |
| 65 ASSERT(property != CSSPropertyInvalid); | 65 ASSERT(property != CSSPropertyInvalid); |
| 66 ASSERT(CSSAnimations::isAnimatableProperty(property)); | 66 ASSERT(CSSAnimations::isAnimatableProperty(property)); |
| 67 m_propertySet->setProperty(property, value, false); | 67 m_propertySet->setProperty(property, value, false); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void StringKeyframe::setPropertyValue(const QualifiedName& attributeName, const
String& value, Element* element) | 70 void StringKeyframe::setPropertyValue(const QualifiedName& attributeName, const
String& value, Element* element) |
| 71 { | 71 { |
| 72 ASSERT(element->isSVGElement()); | 72 ASSERT(element->isSVGElement()); |
| 73 m_svgPropertyMap.set(&attributeName, value); | 73 m_svgPropertyMap.set(&attributeName, value); |
| 74 } | 74 } |
| 75 | 75 |
| 76 PropertyHandleSet StringKeyframe::properties() const | 76 PropertyHandleSet StringKeyframe::properties() const |
| 77 { | 77 { |
| 78 // This is not used in time-critical code, so we probably don't need to | 78 // This is not used in time-critical code, so we probably don't need to |
| 79 // worry about caching this result. | 79 // worry about caching this result. |
| 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 PassRefPtr<Keyframe> StringKeyframe::clone() const |
| 91 { | 91 { |
| 92 return adoptRefWillBeNoop(new StringKeyframe(*this)); | 92 return adoptRef(new StringKeyframe(*this)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::creat
ePropertySpecificKeyframe(PropertyHandle property) const | 95 PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpe
cificKeyframe(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 adoptPtr(new CSSPropertySpecificKeyframe(offset(), &easing(), css
PropertyValue(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 adoptPtr(new SVGPropertySpecificKeyframe(offset(), &easing(), svgProp
ertyValue(*property.svgAttribute()), composite())); |
| 102 } | |
| 103 | |
| 104 DEFINE_TRACE(StringKeyframe) | |
| 105 { | |
| 106 visitor->trace(m_propertySet); | |
| 107 Keyframe::trace(visitor); | |
| 108 } | 102 } |
| 109 | 103 |
| 110 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, EffectModel::Composi
teOperation op) | 104 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, EffectModel::Composi
teOperation op) |
| 111 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 105 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
| 112 , m_value(value) | 106 , m_value(value) |
| 113 { } | 107 { } |
| 114 | 108 |
| 115 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value) | 109 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value) |
| 116 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) | 110 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) |
| 117 , m_value(value) | 111 , m_value(value) |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 if (!forceDefaultInterpolation) { | 476 if (!forceDefaultInterpolation) { |
| 483 ASSERT(AnimatableValue::usesDefaultInterpolation( | 477 ASSERT(AnimatableValue::usesDefaultInterpolation( |
| 484 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, fromCSSValue).get(), | 478 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, fromCSSValue).get(), |
| 485 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, toCSSValue).get())); | 479 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, toCSSValue).get())); |
| 486 } | 480 } |
| 487 | 481 |
| 488 return nullptr; | 482 return nullptr; |
| 489 | 483 |
| 490 } | 484 } |
| 491 | 485 |
| 492 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr
opertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction
> easing) const | 486 PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecif
icKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) co
nst |
| 493 { | 487 { |
| 494 return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, st
atic_cast<CSSValue*>(0), EffectModel::CompositeAdd)); | 488 return adoptPtr(new CSSPropertySpecificKeyframe(offset, easing, static_cast<
CSSValue*>(0), EffectModel::CompositeAdd)); |
| 495 } | 489 } |
| 496 | 490 |
| 497 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPr
opertySpecificKeyframe::cloneWithOffset(double offset) const | 491 PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecif
icKeyframe::cloneWithOffset(double offset) const |
| 498 { | 492 { |
| 499 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); | 493 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); |
| 500 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; | 494 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; |
| 501 return adoptPtrWillBeNoop(theClone); | 495 return adoptPtr(theClone); |
| 502 } | |
| 503 | |
| 504 DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe) | |
| 505 { | |
| 506 visitor->trace(m_value); | |
| 507 visitor->trace(m_animatableValueCache); | |
| 508 Keyframe::PropertySpecificKeyframe::trace(visitor); | |
| 509 } | 496 } |
| 510 | 497 |
| 511 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, EffectModel::CompositeOperation
op) | 498 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, EffectModel::CompositeOperation
op) |
| 512 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 499 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
| 513 , m_value(value) | 500 , m_value(value) |
| 514 { | 501 { |
| 515 } | 502 } |
| 516 | 503 |
| 517 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) | 504 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) |
| 518 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) | 505 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) |
| 519 , m_value(value) | 506 , m_value(value) |
| 520 { | 507 { |
| 521 ASSERT(!isNull(m_offset)); | 508 ASSERT(!isNull(m_offset)); |
| 522 } | 509 } |
| 523 | 510 |
| 524 DEFINE_TRACE(StringKeyframe::SVGPropertySpecificKeyframe) | 511 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::clon
eWithOffset(double offset) const |
| 525 { | 512 { |
| 526 Keyframe::PropertySpecificKeyframe::trace(visitor); | 513 return adoptPtr(new SVGPropertySpecificKeyframe(offset, m_easing, m_value)); |
| 527 } | 514 } |
| 528 | 515 |
| 529 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
yframe::cloneWithOffset(double offset) const | 516 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut
ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| 530 { | 517 { |
| 531 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, m_easing,
m_value)); | 518 return adoptPtr(new SVGPropertySpecificKeyframe(offset, easing, "", EffectMo
del::CompositeAdd)); |
| 532 } | |
| 533 | |
| 534 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
yframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const | |
| 535 { | |
| 536 return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, ""
, EffectModel::CompositeAdd)); | |
| 537 } | 519 } |
| 538 | 520 |
| 539 namespace { | 521 namespace { |
| 540 | 522 |
| 541 PassRefPtrWillBeRawPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fr
omValue, SVGPropertyBase* toValue, SVGAnimatedPropertyBase* attribute) | 523 PassRefPtrWillBeRawPtr<Interpolation> createSVGInterpolation(SVGPropertyBase* fr
omValue, SVGPropertyBase* toValue, SVGAnimatedPropertyBase* attribute) |
| 542 { | 524 { |
| 543 RefPtrWillBeRawPtr<Interpolation> interpolation = nullptr; | 525 RefPtrWillBeRawPtr<Interpolation> interpolation = nullptr; |
| 544 ASSERT(fromValue->type() == toValue->type()); | 526 ASSERT(fromValue->type() == toValue->type()); |
| 545 switch (fromValue->type()) { | 527 switch (fromValue->type()) { |
| 546 case AnimatedAngle: | 528 case AnimatedAngle: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); | 582 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); |
| 601 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); | 583 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); |
| 602 | 584 |
| 603 if (!fromValue || !toValue) | 585 if (!fromValue || !toValue) |
| 604 return nullptr; | 586 return nullptr; |
| 605 | 587 |
| 606 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); | 588 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); |
| 607 } | 589 } |
| 608 | 590 |
| 609 } // namespace blink | 591 } // namespace blink |
| OLD | NEW |