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

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: Rebase 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/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
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
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 namespace { 91 namespace {
79 InterpolationRange setRange(CSSPropertyID id) 92 InterpolationRange setRange(CSSPropertyID id)
80 { 93 {
81 switch (id) { 94 switch (id) {
82 case CSSPropertyOrphans: 95 case CSSPropertyOrphans:
83 case CSSPropertyWebkitColumnCount: 96 case CSSPropertyWebkitColumnCount:
84 case CSSPropertyWidows: 97 case CSSPropertyWidows:
85 return RangeRoundGreaterThanOrEqualToOne; 98 return RangeRoundGreaterThanOrEqualToOne;
86 case CSSPropertyWebkitColumnRuleWidth: 99 case CSSPropertyWebkitColumnRuleWidth:
87 case CSSPropertyZIndex: 100 case CSSPropertyZIndex:
(...skipping 22 matching lines...) Expand all
110 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe:: maybeCreateInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyfr ame& end, Element* element) const 123 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe:: maybeCreateInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyfr ame& end, Element* element) const
111 { 124 {
112 CSSValue* fromCSSValue = m_value.get(); 125 CSSValue* fromCSSValue = m_value.get();
113 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value(); 126 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end).value();
114 InterpolationRange range = RangeAll; 127 InterpolationRange range = RangeAll;
115 bool fallBackToLegacy = false; 128 bool fallBackToLegacy = false;
116 129
117 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr ect. 130 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr ect.
118 bool forceDefaultInterpolation = false; 131 bool forceDefaultInterpolation = false;
119 132
133 // FIXME: Remove this check once neutral keyframes are implemented in String Keyframes.
134 if (!fromCSSValue || !toCSSValue)
135 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue , property);
136
137 ASSERT(fromCSSValue && toCSSValue);
138
120 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { 139 if (!CSSPropertyMetadata::isAnimatableProperty(property)) {
121 if (fromCSSValue == toCSSValue) 140 if (fromCSSValue == toCSSValue)
122 return ConstantStyleInterpolation::create(fromCSSValue, property); 141 return ConstantStyleInterpolation::create(fromCSSValue, property);
123 142
124 return nullptr; 143 return nullptr;
125 } 144 }
126 145
127 // FIXME: Generate this giant switch statement. 146 // FIXME: Generate this giant switch statement.
128 switch (property) { 147 switch (property) {
129 case CSSPropertyLineHeight: 148 case CSSPropertyLineHeight:
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 395 }
377 396
378 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) 397 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor)
379 { 398 {
380 visitor->trace(m_value); 399 visitor->trace(m_value);
381 visitor->trace(m_animatableValueCache); 400 visitor->trace(m_animatableValueCache);
382 Keyframe::PropertySpecificKeyframe::trace(visitor); 401 Keyframe::PropertySpecificKeyframe::trace(visitor);
383 } 402 }
384 403
385 } 404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698