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

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

Issue 1243313002: Migrate the remaining CSS properties interpolable as Lengths to LengthInterpolationType (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 4 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
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/CSSValueInterpolationType.h" 9 #include "core/animation/CSSValueInterpolationType.h"
10 #include "core/animation/ColorStyleInterpolation.h" 10 #include "core/animation/ColorStyleInterpolation.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const Vector<const InterpolationType*>* applicableTypesForProperty(CSSPropertyID property) 157 const Vector<const InterpolationType*>* applicableTypesForProperty(CSSPropertyID property)
158 { 158 {
159 using ApplicableTypesMap = HashMap<CSSPropertyID, const Vector<const Interpo lationType*>*>; 159 using ApplicableTypesMap = HashMap<CSSPropertyID, const Vector<const Interpo lationType*>*>;
160 DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ()); 160 DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ());
161 auto entry = applicableTypesMap.find(property); 161 auto entry = applicableTypesMap.find(property);
162 if (entry != applicableTypesMap.end()) 162 if (entry != applicableTypesMap.end())
163 return entry->value; 163 return entry->value;
164 164
165 auto applicableTypes = new Vector<const InterpolationType*>(); 165 auto applicableTypes = new Vector<const InterpolationType*>();
166 switch (property) { 166 switch (property) {
167 case CSSPropertyBaselineShift:
168 case CSSPropertyBorderBottomWidth:
169 case CSSPropertyBorderLeftWidth:
170 case CSSPropertyBorderRightWidth:
171 case CSSPropertyBorderTopWidth:
172 case CSSPropertyBottom:
173 case CSSPropertyCx:
174 case CSSPropertyCy:
175 case CSSPropertyFlexBasis:
176 case CSSPropertyHeight:
167 case CSSPropertyLeft: 177 case CSSPropertyLeft:
178 case CSSPropertyLetterSpacing:
179 case CSSPropertyMarginBottom:
180 case CSSPropertyMarginLeft:
181 case CSSPropertyMarginRight:
182 case CSSPropertyMarginTop:
183 case CSSPropertyMaxHeight:
184 case CSSPropertyMaxWidth:
185 case CSSPropertyMinHeight:
186 case CSSPropertyMinWidth:
187 case CSSPropertyMotionOffset:
188 case CSSPropertyOutlineOffset:
189 case CSSPropertyOutlineWidth:
190 case CSSPropertyPaddingBottom:
191 case CSSPropertyPaddingLeft:
192 case CSSPropertyPaddingRight:
193 case CSSPropertyPaddingTop:
194 case CSSPropertyPerspective:
195 case CSSPropertyR:
196 case CSSPropertyRight:
197 case CSSPropertyRx:
198 case CSSPropertyRy:
199 case CSSPropertyShapeMargin:
200 case CSSPropertyStrokeDashoffset:
201 case CSSPropertyStrokeWidth:
202 case CSSPropertyTop:
203 case CSSPropertyVerticalAlign:
204 case CSSPropertyWebkitBorderHorizontalSpacing:
205 case CSSPropertyWebkitBorderVerticalSpacing:
206 case CSSPropertyWebkitColumnGap:
207 case CSSPropertyWebkitColumnRuleWidth:
208 case CSSPropertyWebkitColumnWidth:
209 case CSSPropertyWebkitPerspectiveOriginX:
210 case CSSPropertyWebkitPerspectiveOriginY:
211 case CSSPropertyWebkitTransformOriginX:
212 case CSSPropertyWebkitTransformOriginY:
213 case CSSPropertyWebkitTransformOriginZ:
214 case CSSPropertyWidth:
215 case CSSPropertyWordSpacing:
216 case CSSPropertyX:
217 case CSSPropertyY:
168 applicableTypes->append(new LengthInterpolationType(property)); 218 applicableTypes->append(new LengthInterpolationType(property));
169 break; 219 break;
170 default: 220 default:
171 // TODO(alancutter): Support all interpolable CSS properties here so we can stop falling back to the old StyleInterpolation implementation. 221 // TODO(alancutter): Support all interpolable CSS properties here so we can stop falling back to the old StyleInterpolation implementation.
172 if (CSSPropertyMetadata::isInterpolableProperty(property)) { 222 if (CSSPropertyMetadata::isInterpolableProperty(property)) {
173 delete applicableTypes; 223 delete applicableTypes;
174 applicableTypesMap.add(property, nullptr); 224 applicableTypesMap.add(property, nullptr);
175 return nullptr; 225 return nullptr;
176 } 226 }
177 break; 227 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return nullptr; 279 return nullptr;
230 } 280 }
231 281
232 if (fromCSSValue->isCSSWideKeyword() || toCSSValue->isCSSWideKeyword()) 282 if (fromCSSValue->isCSSWideKeyword() || toCSSValue->isCSSWideKeyword())
233 return createLegacyStyleInterpolation(property, end, element, baseStyle) ; 283 return createLegacyStyleInterpolation(property, end, element, baseStyle) ;
234 284
235 switch (property) { 285 switch (property) {
236 case CSSPropertyLineHeight: 286 case CSSPropertyLineHeight:
237 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue)) 287 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue))
238 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative); 288 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative);
239
240 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl eInterpolation::canCreateFrom(*toCSSValue)) 289 if (DoubleStyleInterpolation::canCreateFrom(*fromCSSValue) && DoubleStyl eInterpolation::canCreateFrom(*toCSSValue))
241 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, true, RangeNonNegative); 290 return DoubleStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, true, RangeNonNegative);
242 291
243 break; 292 break;
244 case CSSPropertyBorderBottomWidth: 293
245 case CSSPropertyBorderLeftWidth:
246 case CSSPropertyBorderRightWidth:
247 case CSSPropertyBorderTopWidth:
248 case CSSPropertyFlexBasis:
249 case CSSPropertyFontSize: 294 case CSSPropertyFontSize:
250 case CSSPropertyHeight: 295 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl eInterpolation::canCreateFrom(*toCSSValue))
251 case CSSPropertyMaxHeight: 296 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, RangeNonNegative);
252 case CSSPropertyMaxWidth:
253 case CSSPropertyMinHeight:
254 case CSSPropertyMinWidth:
255 case CSSPropertyOutlineWidth:
256 case CSSPropertyPaddingBottom:
257 case CSSPropertyPaddingLeft:
258 case CSSPropertyPaddingRight:
259 case CSSPropertyPaddingTop:
260 case CSSPropertyPerspective:
261 case CSSPropertyR:
262 case CSSPropertyRx:
263 case CSSPropertyRy:
264 case CSSPropertyShapeMargin:
265 case CSSPropertyStrokeWidth:
266 case CSSPropertyWebkitBorderHorizontalSpacing:
267 case CSSPropertyWebkitBorderVerticalSpacing:
268 case CSSPropertyWebkitColumnGap:
269 case CSSPropertyWebkitColumnWidth:
270 case CSSPropertyWidth:
271 range = RangeNonNegative;
272 // Fall through
273 case CSSPropertyBaselineShift:
274 case CSSPropertyBottom:
275 case CSSPropertyCx:
276 case CSSPropertyCy:
277 case CSSPropertyLeft:
278 case CSSPropertyLetterSpacing:
279 case CSSPropertyMarginBottom:
280 case CSSPropertyMarginLeft:
281 case CSSPropertyMarginRight:
282 case CSSPropertyMarginTop:
283 case CSSPropertyMotionOffset:
284 case CSSPropertyOutlineOffset:
285 case CSSPropertyRight:
286 case CSSPropertyStrokeDashoffset:
287 case CSSPropertyTop:
288 case CSSPropertyVerticalAlign:
289 case CSSPropertyWordSpacing:
290 case CSSPropertyWebkitColumnRuleWidth:
291 case CSSPropertyWebkitPerspectiveOriginX:
292 case CSSPropertyWebkitPerspectiveOriginY:
293 case CSSPropertyWebkitTransformOriginX:
294 case CSSPropertyWebkitTransformOriginY:
295 case CSSPropertyWebkitTransformOriginZ:
296 case CSSPropertyX:
297 case CSSPropertyY:
298 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue, property) && LengthStyleInterpolation::canCreateFrom(*toCSSValue, property))
299 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue, property, range);
300 297
301 // FIXME: Handle keywords e.g. 'smaller', 'larger'. 298 // FIXME: Handle keywords e.g. 'smaller', 'larger'.
302 if (property == CSSPropertyFontSize) 299 if (property == CSSPropertyFontSize)
303 return createLegacyStyleInterpolation(property, end, element, baseSt yle); 300 return createLegacyStyleInterpolation(property, end, element, baseSt yle);
304 301
305 // FIXME: Handle keywords e.g. 'baseline', 'sub'. 302 // FIXME: Handle keywords e.g. 'baseline', 'sub'.
306 if (property == CSSPropertyBaselineShift) 303 if (property == CSSPropertyBaselineShift)
307 return createLegacyStyleInterpolation(property, end, element, baseSt yle); 304 return createLegacyStyleInterpolation(property, end, element, baseSt yle);
308 305
309 break; 306 break;
307
310 case CSSPropertyOrphans: 308 case CSSPropertyOrphans:
311 case CSSPropertyWidows: 309 case CSSPropertyWidows:
312 case CSSPropertyZIndex: 310 case CSSPropertyZIndex:
313 case CSSPropertyWebkitColumnCount: 311 case CSSPropertyWebkitColumnCount:
314 case CSSPropertyShapeImageThreshold: 312 case CSSPropertyShapeImageThreshold:
315 case CSSPropertyFillOpacity: 313 case CSSPropertyFillOpacity:
316 case CSSPropertyFloodOpacity: 314 case CSSPropertyFloodOpacity:
317 case CSSPropertyFontSizeAdjust: 315 case CSSPropertyFontSizeAdjust:
318 case CSSPropertyOpacity: 316 case CSSPropertyOpacity:
319 case CSSPropertyStopOpacity: 317 case CSSPropertyStopOpacity:
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value); 598 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase( )->cloneForAnimation(m_value);
601 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); 599 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()- >cloneForAnimation(toSVGPropertySpecificKeyframe(end).value());
602 600
603 if (!fromValue || !toValue) 601 if (!fromValue || !toValue)
604 return nullptr; 602 return nullptr;
605 603
606 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( )); 604 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get( ));
607 } 605 }
608 606
609 } // namespace blink 607 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698