| 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/ColorStyleInterpolation.h" | 8 #include "core/animation/ColorStyleInterpolation.h" |
| 9 #include "core/animation/CompositorAnimations.h" |
| 9 #include "core/animation/ConstantStyleInterpolation.h" | 10 #include "core/animation/ConstantStyleInterpolation.h" |
| 10 #include "core/animation/DeferredLegacyStyleInterpolation.h" | 11 #include "core/animation/DeferredLegacyStyleInterpolation.h" |
| 11 #include "core/animation/DoubleStyleInterpolation.h" | 12 #include "core/animation/DoubleStyleInterpolation.h" |
| 12 #include "core/animation/ImageStyleInterpolation.h" | 13 #include "core/animation/ImageStyleInterpolation.h" |
| 13 #include "core/animation/LegacyStyleInterpolation.h" | 14 #include "core/animation/LegacyStyleInterpolation.h" |
| 14 #include "core/animation/LengthBoxStyleInterpolation.h" | 15 #include "core/animation/LengthBoxStyleInterpolation.h" |
| 15 #include "core/animation/LengthPairStyleInterpolation.h" | 16 #include "core/animation/LengthPairStyleInterpolation.h" |
| 16 #include "core/animation/LengthStyleInterpolation.h" | 17 #include "core/animation/LengthStyleInterpolation.h" |
| 17 #include "core/animation/ListStyleInterpolation.h" | 18 #include "core/animation/ListStyleInterpolation.h" |
| 18 #include "core/animation/SVGLengthStyleInterpolation.h" | 19 #include "core/animation/SVGLengthStyleInterpolation.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 { | 32 { |
| 32 } | 33 } |
| 33 | 34 |
| 34 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, StyleSheetContents* styleSheetContents) | 35 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, StyleSheetContents* styleSheetContents) |
| 35 { | 36 { |
| 36 ASSERT(property != CSSPropertyInvalid); | 37 ASSERT(property != CSSPropertyInvalid); |
| 37 if (CSSAnimations::isAllowedAnimation(property)) | 38 if (CSSAnimations::isAllowedAnimation(property)) |
| 38 m_propertySet->setProperty(property, value, false, styleSheetContents); | 39 m_propertySet->setProperty(property, value, false, styleSheetContents); |
| 39 } | 40 } |
| 40 | 41 |
| 42 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtr<CSSValu
e> value) |
| 43 { |
| 44 ASSERT(property != CSSPropertyInvalid); |
| 45 ASSERT(CSSAnimations::isAllowedAnimation(property)); |
| 46 m_propertySet->setProperty(property, value, false); |
| 47 } |
| 48 |
| 41 PropertySet StringKeyframe::properties() const | 49 PropertySet StringKeyframe::properties() const |
| 42 { | 50 { |
| 43 // This is not used in time-critical code, so we probably don't need to | 51 // This is not used in time-critical code, so we probably don't need to |
| 44 // worry about caching this result. | 52 // worry about caching this result. |
| 45 PropertySet properties; | 53 PropertySet properties; |
| 46 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) | 54 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) |
| 47 properties.add(m_propertySet->propertyAt(i).id()); | 55 properties.add(m_propertySet->propertyAt(i).id()); |
| 48 return properties; | 56 return properties; |
| 49 } | 57 } |
| 50 | 58 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 , m_value(value) | 76 , m_value(value) |
| 69 { } | 77 { } |
| 70 | 78 |
| 71 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset
, PassRefPtr<TimingFunction> easing, CSSValue* value) | 79 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset
, PassRefPtr<TimingFunction> easing, CSSValue* value) |
| 72 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos
iteReplace) | 80 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos
iteReplace) |
| 73 , m_value(value) | 81 , m_value(value) |
| 74 { | 82 { |
| 75 ASSERT(!isNull(m_offset)); | 83 ASSERT(!isNull(m_offset)); |
| 76 } | 84 } |
| 77 | 85 |
| 86 void StringKeyframe::PropertySpecificKeyframe::setAnimatableValue(PassRefPtr<Ani
matableValue> value) |
| 87 { |
| 88 m_animatableValueCache = value; |
| 89 } |
| 90 |
| 78 // FIXME: Refactor this into a generic piece that lives in InterpolationEffect,
and a template parameter specific converter. | 91 // FIXME: Refactor this into a generic piece that lives in InterpolationEffect,
and a template parameter specific converter. |
| 79 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
maybeCreateInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyfr
ame& end, Element* element) const | 92 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
maybeCreateInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyfr
ame& end, Element* element) const |
| 80 { | 93 { |
| 81 CSSValue* fromCSSValue = m_value.get(); | 94 CSSValue* fromCSSValue = m_value.get(); |
| 82 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value(); | 95 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value(); |
| 83 InterpolationRange range = RangeAll; | 96 InterpolationRange range = RangeAll; |
| 84 bool fallBackToLegacy = false; | 97 bool fallBackToLegacy = false; |
| 85 | 98 |
| 86 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. | 99 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. |
| 87 bool forceDefaultInterpolation = false; | 100 bool forceDefaultInterpolation = false; |
| 88 | 101 |
| 102 // FIXME: Remove this check once neutral keyframes are implemented in String
Keyframes. |
| 103 if (!fromCSSValue || !toCSSValue) |
| 104 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue
, property); |
| 105 |
| 106 ASSERT(fromCSSValue && toCSSValue); |
| 107 |
| 89 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { | 108 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { |
| 90 if (fromCSSValue == toCSSValue) | 109 if (fromCSSValue == toCSSValue) |
| 91 return ConstantStyleInterpolation::create(fromCSSValue, property); | 110 return ConstantStyleInterpolation::create(fromCSSValue, property); |
| 92 | 111 |
| 93 return nullptr; | 112 return nullptr; |
| 94 } | 113 } |
| 95 | 114 |
| 96 // FIXME: Generate this giant switch statement. | 115 // FIXME: Generate this giant switch statement. |
| 97 switch (property) { | 116 switch (property) { |
| 98 case CSSPropertyLineHeight: | 117 case CSSPropertyLineHeight: |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } | 338 } |
| 320 | 339 |
| 321 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) | 340 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) |
| 322 { | 341 { |
| 323 visitor->trace(m_value); | 342 visitor->trace(m_value); |
| 324 visitor->trace(m_animatableValueCache); | 343 visitor->trace(m_animatableValueCache); |
| 325 Keyframe::PropertySpecificKeyframe::trace(visitor); | 344 Keyframe::PropertySpecificKeyframe::trace(visitor); |
| 326 } | 345 } |
| 327 | 346 |
| 328 } | 347 } |
| OLD | NEW |