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

Side by Side Diff: Source/core/css/resolver/AnimatedStyleBuilder.cpp

Issue 55813002: Convert animation and renderer code to know about BorderImageLength (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@length-relative-die-step-1-4
Patch Set: Created 7 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver State& state, NumberRange range = AllValues) 66 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver State& state, NumberRange range = AllValues)
67 { 67 {
68 const RenderStyle* style = state.style(); 68 const RenderStyle* style = state.style();
69 if (value->isLength()) 69 if (value->isLength())
70 return toAnimatableLength(value)->toLength(style, state.rootElementStyle (), style->effectiveZoom(), range); 70 return toAnimatableLength(value)->toLength(style, state.rootElementStyle (), style->effectiveZoom(), range);
71 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); 71 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
72 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); 72 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
73 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl ementStyle(), style->effectiveZoom()); 73 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl ementStyle(), style->effectiveZoom());
74 } 74 }
75 75
76 LengthOrNumber animatableValueToLengthOrNumber(const AnimatableValue* value, con st StyleResolverState& state, NumberRange range = AllValues)
77 {
78 const RenderStyle* style = state.style();
79 if (value->isLength())
80 return LengthOrNumber(toAnimatableLength(value)->toLength(style, state.r ootElementStyle(), style->effectiveZoom(), range));
81 if (value->isDouble())
82 return LengthOrNumber(toAnimatableDouble(value)->toDouble());
83 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
84 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
85 return LengthOrNumber(cssPrimitiveValue->convertToLength<AnyConversion>(styl e, state.rootElementStyle(), style->effectiveZoom()));
86 }
87
76 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) 88 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>())
77 { 89 {
78 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV alues); 90 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV alues);
79 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max); 91 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max);
80 } 92 }
81 93
82 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state, NumberRange range = AllValues) 94 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state, NumberRange range = AllValues)
83 { 95 {
84 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value ); 96 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value );
85 return LengthBox( 97 return LengthBox(
86 animatableValueToLength(animatableLengthBox->top(), state, range), 98 animatableValueToLength(animatableLengthBox->top(), state, range),
87 animatableValueToLength(animatableLengthBox->right(), state, range), 99 animatableValueToLength(animatableLengthBox->right(), state, range),
88 animatableValueToLength(animatableLengthBox->bottom(), state, range), 100 animatableValueToLength(animatableLengthBox->bottom(), state, range),
89 animatableValueToLength(animatableLengthBox->left(), state, range)); 101 animatableValueToLength(animatableLengthBox->left(), state, range));
90 } 102 }
91 103
104 LengthOrNumberBox animatableValueToLengthOrNumberBox(const AnimatableValue* valu e, const StyleResolverState& state, NumberRange range = AllValues)
105 {
106 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value );
107 return LengthOrNumberBox(
108 animatableValueToLengthOrNumber(animatableLengthBox->top(), state, range ),
109 animatableValueToLengthOrNumber(animatableLengthBox->right(), state, ran ge),
110 animatableValueToLengthOrNumber(animatableLengthBox->bottom(), state, ra nge),
111 animatableValueToLengthOrNumber(animatableLengthBox->left(), state, rang e));
112 }
113
92 LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const Sty leResolverState& state, NumberRange range = AllValues) 114 LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const Sty leResolverState& state, NumberRange range = AllValues)
93 { 115 {
94 const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint (value); 116 const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint (value);
95 return LengthPoint( 117 return LengthPoint(
96 animatableValueToLength(animatableLengthPoint->x(), state, range), 118 animatableValueToLength(animatableLengthPoint->x(), state, range),
97 animatableValueToLength(animatableLengthPoint->y(), state, range)); 119 animatableValueToLength(animatableLengthPoint->y(), state, range));
98 } 120 }
99 121
100 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const Style ResolverState& state, NumberRange range) 122 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const Style ResolverState& state, NumberRange range)
101 { 123 {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 case CSSPropertyBorderBottomLeftRadius: 264 case CSSPropertyBorderBottomLeftRadius:
243 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, NonNegativeValues)); 265 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat e, NonNegativeValues));
244 return; 266 return;
245 case CSSPropertyBorderBottomRightRadius: 267 case CSSPropertyBorderBottomRightRadius:
246 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta te, NonNegativeValues)); 268 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta te, NonNegativeValues));
247 return; 269 return;
248 case CSSPropertyBorderBottomWidth: 270 case CSSPropertyBorderBottomWidth:
249 style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value) ); 271 style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value) );
250 return; 272 return;
251 case CSSPropertyBorderImageOutset: 273 case CSSPropertyBorderImageOutset:
252 style->setBorderImageOutset(animatableValueToLengthBox(value, state, Non NegativeValues)); 274 style->setBorderImageOutset(animatableValueToLengthOrNumberBox(value, st ate, NonNegativeValues));
253 return; 275 return;
254 case CSSPropertyBorderImageSlice: 276 case CSSPropertyBorderImageSlice:
255 style->setBorderImageSlices(animatableValueToLengthBox(value, state, Non NegativeValues)); 277 style->setBorderImageSlices(animatableValueToLengthBox(value, state, Non NegativeValues));
256 return; 278 return;
257 case CSSPropertyBorderImageSource: 279 case CSSPropertyBorderImageSource:
258 style->setBorderImageSource(toAnimatableImage(value)->toStyleImage()); 280 style->setBorderImageSource(toAnimatableImage(value)->toStyleImage());
259 return; 281 return;
260 case CSSPropertyBorderImageWidth: 282 case CSSPropertyBorderImageWidth:
261 style->setBorderImageWidth(animatableValueToLengthBox(value, state, NonN egativeValues)); 283 style->setBorderImageWidth(animatableValueToLengthOrNumberBox(value, sta te, NonNegativeValues));
262 return; 284 return;
263 case CSSPropertyBorderLeftColor: 285 case CSSPropertyBorderLeftColor:
264 style->setBorderLeftColor(toAnimatableColor(value)->color()); 286 style->setBorderLeftColor(toAnimatableColor(value)->color());
265 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi nkColor()); 287 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi nkColor());
266 return; 288 return;
267 case CSSPropertyBorderLeftWidth: 289 case CSSPropertyBorderLeftWidth:
268 style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value)); 290 style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value));
269 return; 291 return;
270 case CSSPropertyBorderRightColor: 292 case CSSPropertyBorderRightColor:
271 style->setBorderRightColor(toAnimatableColor(value)->color()); 293 style->setBorderRightColor(toAnimatableColor(value)->color());
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 case CSSPropertyWebkitColumnWidth: 492 case CSSPropertyWebkitColumnWidth:
471 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::epsilon())); 493 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::epsilon()));
472 return; 494 return;
473 case CSSPropertyWebkitColumnRuleWidth: 495 case CSSPropertyWebkitColumnRuleWidth:
474 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(va lue)); 496 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(va lue));
475 return; 497 return;
476 case CSSPropertyWebkitFilter: 498 case CSSPropertyWebkitFilter:
477 style->setFilter(toAnimatableFilterOperations(value)->operations()); 499 style->setFilter(toAnimatableFilterOperations(value)->operations());
478 return; 500 return;
479 case CSSPropertyWebkitMaskBoxImageOutset: 501 case CSSPropertyWebkitMaskBoxImageOutset:
480 style->setMaskBoxImageOutset(animatableValueToLengthBox(value, state, No nNegativeValues)); 502 style->setMaskBoxImageOutset(animatableValueToLengthOrNumberBox(value, s tate, NonNegativeValues));
481 return; 503 return;
482 case CSSPropertyWebkitMaskBoxImageSlice: 504 case CSSPropertyWebkitMaskBoxImageSlice:
483 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLeng thBoxAndBool(value)->box(), state, NonNegativeValues)); 505 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLeng thBoxAndBool(value)->box(), state, NonNegativeValues));
484 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fl ag()); 506 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fl ag());
485 return; 507 return;
486 case CSSPropertyWebkitMaskBoxImageSource: 508 case CSSPropertyWebkitMaskBoxImageSource:
487 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage()); 509 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage());
488 return; 510 return;
489 case CSSPropertyWebkitMaskBoxImageWidth: 511 case CSSPropertyWebkitMaskBoxImageWidth:
490 style->setMaskBoxImageWidth(animatableValueToLengthBox(value, state, Non NegativeValues)); 512 style->setMaskBoxImageWidth(animatableValueToLengthOrNumberBox(value, st ate, NonNegativeValues));
491 return; 513 return;
492 case CSSPropertyWebkitMaskImage: 514 case CSSPropertyWebkitMaskImage:
493 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), v alue, state); 515 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), v alue, state);
494 return; 516 return;
495 case CSSPropertyWebkitMaskPositionX: 517 case CSSPropertyWebkitMaskPositionX:
496 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers( ), value, state); 518 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers( ), value, state);
497 return; 519 return;
498 case CSSPropertyWebkitMaskPositionY: 520 case CSSPropertyWebkitMaskPositionY:
499 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers( ), value, state); 521 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers( ), value, state);
500 return; 522 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 case CSSPropertyZoom: 575 case CSSPropertyZoom:
554 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min())); 576 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min()));
555 return; 577 return;
556 default: 578 default:
557 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend erStyle: %s", getPropertyNameString(property).utf8().data()); 579 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend erStyle: %s", getPropertyNameString(property).utf8().data());
558 ASSERT_NOT_REACHED(); 580 ASSERT_NOT_REACHED();
559 } 581 }
560 } 582 }
561 583
562 } // namespace WebCore 584 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698