Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/core/animation/StringKeyframe.cpp

Issue 851693007: Prepare for responsive CSS animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 11 matching lines...) Expand all
30 { 31 {
31 } 32 }
32 33
33 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu e, StyleSheetContents* styleSheetContents) 34 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu e, StyleSheetContents* styleSheetContents)
34 { 35 {
35 ASSERT(property != CSSPropertyInvalid); 36 ASSERT(property != CSSPropertyInvalid);
36 if (CSSAnimations::isAllowedAnimation(property)) 37 if (CSSAnimations::isAllowedAnimation(property))
37 m_propertySet->setProperty(property, value, false, styleSheetContents); 38 m_propertySet->setProperty(property, value, false, styleSheetContents);
38 } 39 }
39 40
41 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtr<CSSValu e> value)
42 {
43 ASSERT(property != CSSPropertyInvalid);
44 if (CSSAnimations::isAllowedAnimation(property))
dstockwell 2015/02/05 23:04:52 ASSERT?
shend 2015/02/06 03:16:25 Done.
45 m_propertySet->setProperty(property, value, false);
46 }
47
40 PropertySet StringKeyframe::properties() const 48 PropertySet StringKeyframe::properties() const
41 { 49 {
42 // This is not used in time-critical code, so we probably don't need to 50 // This is not used in time-critical code, so we probably don't need to
43 // worry about caching this result. 51 // worry about caching this result.
44 PropertySet properties; 52 PropertySet properties;
45 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) 53 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i)
46 properties.add(m_propertySet->propertyAt(i).id()); 54 properties.add(m_propertySet->propertyAt(i).id());
47 return properties; 55 return properties;
48 } 56 }
49 57
(...skipping 17 matching lines...) Expand all
67 , m_value(value) 75 , m_value(value)
68 { } 76 { }
69 77
70 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset , PassRefPtr<TimingFunction> easing, CSSValue* value) 78 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset , PassRefPtr<TimingFunction> easing, CSSValue* value)
71 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos iteReplace) 79 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos iteReplace)
72 , m_value(value) 80 , m_value(value)
73 { 81 {
74 ASSERT(!isNull(m_offset)); 82 ASSERT(!isNull(m_offset));
75 } 83 }
76 84
85 void StringKeyframe::PropertySpecificKeyframe::setAnimatableValue(PassRefPtr<Ani matableValue> value)
86 {
87 m_animatableValueCache = value;
88 }
89
77 // FIXME: Refactor this into a generic piece that lives in InterpolationEffect, and a template parameter specific converter. 90 // 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 91 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe:: maybeCreateInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyfr ame& end, Element* element) const
79 { 92 {
80 CSSValue* fromCSSValue = m_value.get(); 93 CSSValue* fromCSSValue = m_value.get();
81 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value(); 94 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value();
82 InterpolationRange range = RangeAll; 95 InterpolationRange range = RangeAll;
83 bool fallBackToLegacy = false; 96 bool fallBackToLegacy = false;
84 97
98 // FIXME: Remove this check once neutral keyframes are implemented in String Keyframes.
99 if (!fromCSSValue || !toCSSValue)
100 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue , property);
101
102 ASSERT(fromCSSValue && toCSSValue);
103
85 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { 104 if (!CSSPropertyMetadata::isAnimatableProperty(property)) {
86 // FIXME: Remove this once TimingFunction partitioning is implemented fo r all types. 105 // FIXME: Remove this once TimingFunction partitioning is implemented fo r all types.
87 if (!RuntimeEnabledFeatures::webAnimationsAPITimingFunctionPartitioningE nabled()) 106 if (!RuntimeEnabledFeatures::webAnimationsAPITimingFunctionPartitioningE nabled())
88 return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, p roperty); 107 return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, p roperty);
89 108
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 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 306 }
288 307
289 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) 308 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor)
290 { 309 {
291 visitor->trace(m_value); 310 visitor->trace(m_value);
292 visitor->trace(m_animatableValueCache); 311 visitor->trace(m_animatableValueCache);
293 Keyframe::PropertySpecificKeyframe::trace(visitor); 312 Keyframe::PropertySpecificKeyframe::trace(visitor);
294 } 313 }
295 314
296 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698