| 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/DefaultStyleInterpolation.h" | 11 #include "core/animation/DefaultStyleInterpolation.h" |
| 11 #include "core/animation/DeferredLegacyStyleInterpolation.h" | 12 #include "core/animation/DeferredLegacyStyleInterpolation.h" |
| 12 #include "core/animation/DoubleStyleInterpolation.h" | 13 #include "core/animation/DoubleStyleInterpolation.h" |
| 13 #include "core/animation/ImageStyleInterpolation.h" | 14 #include "core/animation/ImageStyleInterpolation.h" |
| 14 #include "core/animation/LegacyStyleInterpolation.h" | 15 #include "core/animation/LegacyStyleInterpolation.h" |
| 15 #include "core/animation/LengthBoxStyleInterpolation.h" | 16 #include "core/animation/LengthBoxStyleInterpolation.h" |
| 16 #include "core/animation/LengthPairStyleInterpolation.h" | 17 #include "core/animation/LengthPairStyleInterpolation.h" |
| 17 #include "core/animation/LengthPoint3DStyleInterpolation.h" | 18 #include "core/animation/LengthPoint3DStyleInterpolation.h" |
| 18 #include "core/animation/LengthStyleInterpolation.h" | 19 #include "core/animation/LengthStyleInterpolation.h" |
| 19 #include "core/animation/VisibilityStyleInterpolation.h" | 20 #include "core/animation/VisibilityStyleInterpolation.h" |
| 21 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 20 #include "core/animation/css/CSSAnimations.h" | 22 #include "core/animation/css/CSSAnimations.h" |
| 21 #include "core/css/CSSPropertyMetadata.h" | 23 #include "core/css/CSSPropertyMetadata.h" |
| 22 #include "core/css/resolver/StyleResolver.h" | 24 #include "core/css/resolver/StyleResolver.h" |
| 23 #include "core/rendering/style/RenderStyle.h" | 25 #include "core/rendering/style/RenderStyle.h" |
| 24 | 26 |
| 25 namespace blink { | 27 namespace blink { |
| 26 | 28 |
| 27 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) | 29 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) |
| 28 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) | 30 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
| 29 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) | 31 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) |
| 30 { | 32 { |
| 31 } | 33 } |
| 32 | 34 |
| 33 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, StyleSheetContents* styleSheetContents) | 35 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, StyleSheetContents* styleSheetContents) |
| 34 { | 36 { |
| 35 ASSERT(property != CSSPropertyInvalid); | 37 ASSERT(property != CSSPropertyInvalid); |
| 36 if (CSSAnimations::isAllowedAnimation(property)) | 38 if (CSSAnimations::isAllowedAnimation(property)) |
| 37 m_propertySet->setProperty(property, value, false, styleSheetContents); | 39 m_propertySet->setProperty(property, value, false, styleSheetContents); |
| 38 } | 40 } |
| 39 | 41 |
| 42 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtr<CSSValu
e> value) |
| 43 { |
| 44 ASSERT(property != CSSPropertyInvalid); |
| 45 if (CSSAnimations::isAllowedAnimation(property)) |
| 46 m_propertySet->setProperty(property, value, false); |
| 47 } |
| 48 |
| 40 PropertySet StringKeyframe::properties() const | 49 PropertySet StringKeyframe::properties() const |
| 41 { | 50 { |
| 42 // 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 |
| 43 // worry about caching this result. | 52 // worry about caching this result. |
| 44 PropertySet properties; | 53 PropertySet properties; |
| 45 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) | 54 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) |
| 46 properties.add(m_propertySet->propertyAt(i).id()); | 55 properties.add(m_propertySet->propertyAt(i).id()); |
| 47 return properties; | 56 return properties; |
| 48 } | 57 } |
| 49 | 58 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 67 , m_value(value) | 76 , m_value(value) |
| 68 { } | 77 { } |
| 69 | 78 |
| 70 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset
, PassRefPtr<TimingFunction> easing, CSSValue* value) | 79 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset
, PassRefPtr<TimingFunction> easing, CSSValue* value) |
| 71 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos
iteReplace) | 80 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos
iteReplace) |
| 72 , m_value(value) | 81 , m_value(value) |
| 73 { | 82 { |
| 74 ASSERT(!isNull(m_offset)); | 83 ASSERT(!isNull(m_offset)); |
| 75 } | 84 } |
| 76 | 85 |
| 86 void StringKeyframe::PropertySpecificKeyframe::setAnimatableValue(PassRefPtr<Ani
matableValue> value) |
| 87 { |
| 88 m_animatableValueCache = value; |
| 89 } |
| 90 |
| 77 // 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. |
| 78 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 |
| 79 { | 93 { |
| 80 CSSValue* fromCSSValue = m_value.get(); | 94 CSSValue* fromCSSValue = m_value.get(); |
| 81 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value(); | 95 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value(); |
| 82 InterpolationRange range = RangeAll; | 96 InterpolationRange range = RangeAll; |
| 83 bool fallBackToLegacy = false; | 97 bool fallBackToLegacy = false; |
| 84 | 98 |
| 99 // FIXME: Remove this check once neutral keyframes are implemented in String
Keyframes. |
| 100 if (!fromCSSValue || !toCSSValue) |
| 101 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue
, property); |
| 102 |
| 103 ASSERT(fromCSSValue && toCSSValue); |
| 104 |
| 85 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { | 105 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { |
| 86 // FIXME: Remove this once TimingFunction partitioning is implemented fo
r all types. | 106 // FIXME: Remove this once TimingFunction partitioning is implemented fo
r all types. |
| 87 if (!RuntimeEnabledFeatures::webAnimationsAPITimingFunctionPartitioningE
nabled()) | 107 if (!RuntimeEnabledFeatures::webAnimationsAPITimingFunctionPartitioningE
nabled()) |
| 88 return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, p
roperty); | 108 return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, p
roperty); |
| 89 | 109 |
| 90 if (fromCSSValue == toCSSValue) | 110 if (fromCSSValue == toCSSValue) |
| 91 return ConstantStyleInterpolation::create(fromCSSValue, property); | 111 return ConstantStyleInterpolation::create(fromCSSValue, property); |
| 92 | 112 |
| 93 return nullptr; | 113 return nullptr; |
| 94 } | 114 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 307 } |
| 288 | 308 |
| 289 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) | 309 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) |
| 290 { | 310 { |
| 291 visitor->trace(m_value); | 311 visitor->trace(m_value); |
| 292 visitor->trace(m_animatableValueCache); | 312 visitor->trace(m_animatableValueCache); |
| 293 Keyframe::PropertySpecificKeyframe::trace(visitor); | 313 Keyframe::PropertySpecificKeyframe::trace(visitor); |
| 294 } | 314 } |
| 295 | 315 |
| 296 } | 316 } |
| OLD | NEW |