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

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

Issue 1153943003: Add foundation for removing AnimatableValues from StyleInterpolation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review changes Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/animation/PrimitiveInterpolation.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/AngleSVGInterpolation.h" 8 #include "core/animation/AngleSVGInterpolation.h"
9 #include "core/animation/AnimationType.h"
10 #include "core/animation/CSSValueAnimationType.h"
9 #include "core/animation/ColorStyleInterpolation.h" 11 #include "core/animation/ColorStyleInterpolation.h"
10 #include "core/animation/CompositorAnimations.h" 12 #include "core/animation/CompositorAnimations.h"
11 #include "core/animation/ConstantStyleInterpolation.h" 13 #include "core/animation/ConstantStyleInterpolation.h"
12 #include "core/animation/DefaultSVGInterpolation.h" 14 #include "core/animation/DefaultSVGInterpolation.h"
13 #include "core/animation/DeferredLegacyStyleInterpolation.h" 15 #include "core/animation/DeferredLegacyStyleInterpolation.h"
14 #include "core/animation/DoubleStyleInterpolation.h" 16 #include "core/animation/DoubleStyleInterpolation.h"
15 #include "core/animation/FilterStyleInterpolation.h" 17 #include "core/animation/FilterStyleInterpolation.h"
16 #include "core/animation/ImageSliceStyleInterpolation.h" 18 #include "core/animation/ImageSliceStyleInterpolation.h"
17 #include "core/animation/ImageStyleInterpolation.h" 19 #include "core/animation/ImageStyleInterpolation.h"
18 #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h" 20 #include "core/animation/IntegerOptionalIntegerSVGInterpolation.h"
19 #include "core/animation/IntegerSVGInterpolation.h" 21 #include "core/animation/IntegerSVGInterpolation.h"
22 #include "core/animation/InvalidatableStyleInterpolation.h"
20 #include "core/animation/LegacyStyleInterpolation.h" 23 #include "core/animation/LegacyStyleInterpolation.h"
21 #include "core/animation/LengthBoxStyleInterpolation.h" 24 #include "core/animation/LengthBoxStyleInterpolation.h"
22 #include "core/animation/LengthPairStyleInterpolation.h" 25 #include "core/animation/LengthPairStyleInterpolation.h"
23 #include "core/animation/LengthSVGInterpolation.h" 26 #include "core/animation/LengthSVGInterpolation.h"
24 #include "core/animation/LengthStyleInterpolation.h" 27 #include "core/animation/LengthStyleInterpolation.h"
25 #include "core/animation/ListSVGInterpolation.h" 28 #include "core/animation/ListSVGInterpolation.h"
26 #include "core/animation/ListStyleInterpolation.h" 29 #include "core/animation/ListStyleInterpolation.h"
27 #include "core/animation/NumberOptionalNumberSVGInterpolation.h" 30 #include "core/animation/NumberOptionalNumberSVGInterpolation.h"
28 #include "core/animation/NumberSVGInterpolation.h" 31 #include "core/animation/NumberSVGInterpolation.h"
29 #include "core/animation/PathSVGInterpolation.h" 32 #include "core/animation/PathSVGInterpolation.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 case CSSPropertyStrokeMiterlimit: 146 case CSSPropertyStrokeMiterlimit:
144 return RangeGreaterThanOrEqualToOne; 147 return RangeGreaterThanOrEqualToOne;
145 case CSSPropertyFontSizeAdjust: 148 case CSSPropertyFontSizeAdjust:
146 return RangeNonNegative; 149 return RangeNonNegative;
147 default: 150 default:
148 ASSERT_NOT_REACHED(); 151 ASSERT_NOT_REACHED();
149 return RangeAll; 152 return RangeAll;
150 } 153 }
151 } 154 }
152 155
156 const Vector<const AnimationType*>* applicableTypesForProperty(CSSPropertyID pro perty)
157 {
158 using ApplicableTypesMap = HashMap<CSSPropertyID, const Vector<const Animati onType*>*>;
159 DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ());
160 auto entry = applicableTypesMap.find(property);
161 if (entry != applicableTypesMap.end())
162 return entry->value;
163
164 // TODO(alancutter): Support all animatable CSS properties here so we can st op falling back to the old StyleInterpolation implementation.
165 if (CSSPropertyMetadata::isAnimatableProperty(property))
166 return nullptr;
167
168 auto applicableTypes = new Vector<const AnimationType*>();
169 applicableTypes->append(new CSSValueAnimationType(property));
170 applicableTypesMap.add(property, applicableTypes);
171 return applicableTypes;
172 }
173
153 } // namespace 174 } // namespace
154 175
155 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram e::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpe cificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const 176 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram e::maybeCreateInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpe cificKeyframe& end, Element* element, const ComputedStyle* baseStyle) const
156 { 177 {
157 CSSPropertyID property = propertyHandle.cssProperty(); 178 CSSPropertyID property = propertyHandle.cssProperty();
179 const Vector<const AnimationType*>* applicableTypes = applicableTypesForProp erty(property);
180 if (applicableTypes)
181 return InvalidatableStyleInterpolation::create(*applicableTypes, *this, toCSSPropertySpecificKeyframe(end));
182
183 // TODO(alancutter): Remove the remainder of this function.
158 184
159 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe ct, and a template parameter specific converter. 185 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe ct, and a template parameter specific converter.
160 CSSValue* fromCSSValue = m_value.get(); 186 CSSValue* fromCSSValue = m_value.get();
161 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value(); 187 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value();
162 InterpolationRange range = RangeAll; 188 InterpolationRange range = RangeAll;
163 bool fallBackToLegacy = false; 189 bool fallBackToLegacy = false;
164 190
165 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr ect. 191 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr ect.
166 bool forceDefaultInterpolation = false; 192 bool forceDefaultInterpolation = false;
167 193
168 // FIXME: Remove this check once neutral keyframes are implemented in String Keyframes. 194 // FIXME: Remove this check once neutral keyframes are implemented in String Keyframes.
169 if (!fromCSSValue || !toCSSValue) 195 if (!fromCSSValue || !toCSSValue)
170 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue , property); 196 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue , property);
171 197
172 ASSERT(fromCSSValue && toCSSValue); 198 ASSERT(fromCSSValue && toCSSValue);
173 199
174 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { 200 if (!CSSPropertyMetadata::isAnimatableProperty(property)) {
175 if (fromCSSValue == toCSSValue) 201 if (fromCSSValue == toCSSValue)
176 return ConstantStyleInterpolation::create(fromCSSValue, property); 202 return ConstantStyleInterpolation::create(fromCSSValue, property);
177 203
178 return nullptr; 204 return nullptr;
179 } 205 }
180 206
181 // FIXME: Generate this giant switch statement.
182 switch (property) { 207 switch (property) {
183 case CSSPropertyLineHeight: 208 case CSSPropertyLineHeight:
184 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue)) 209 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue))
185 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative); 210 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative);
186 211
187 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl eInterpolation::canCreateFrom(*toCSSValue)) 212 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl eInterpolation::canCreateFrom(*toCSSValue))
188 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, CSSPrimitiveValue::CSS_NUMBER, RangeNonNegative); 213 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, CSSPrimitiveValue::CSS_NUMBER, RangeNonNegative);
189 214
190 break; 215 break;
191 case CSSPropertyBorderBottomWidth: 216 case CSSPropertyBorderBottomWidth:
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value); 574 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value);
550 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); 575 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value());
551 576
552 if (!fromValue || !toValue) 577 if (!fromValue || !toValue)
553 return nullptr; 578 return nullptr;
554 579
555 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( )); 580 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( ));
556 } 581 }
557 582
558 } // namespace blink 583 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/PrimitiveInterpolation.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698