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

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: Rebased to latest master 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 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu e, const StyleResolverState& state, NumberRange range = AllValues)
77 {
78 const RenderStyle* style = state.style();
79 if (value->isLength())
80 return BorderImageLength(toAnimatableLength(value)->toLength(style, stat e.rootElementStyle(), style->effectiveZoom(), range));
81 if (value->isDouble())
82 return BorderImageLength(toAnimatableDouble(value)->toDouble());
83 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
84 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
85 return BorderImageLength(cssPrimitiveValue->convertToLength<AnyConversion>(s tyle, 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 BorderImageLengthBox animatableValueToBorderImageLengthBox(const AnimatableValue * value, const StyleResolverState& state, NumberRange range = AllValues)
105 {
106 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value );
107 return BorderImageLengthBox(
108 animatableValueToBorderImageLength(animatableLengthBox->top(), state, ra nge),
109 animatableValueToBorderImageLength(animatableLengthBox->right(), state, range),
110 animatableValueToBorderImageLength(animatableLengthBox->bottom(), state, range),
111 animatableValueToBorderImageLength(animatableLengthBox->left(), state, r ange));
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(animatableValueToBorderImageLengthBox(value, state, 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(animatableValueToBorderImageLengthBox(value, state, 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 case CSSPropertyWebkitColumnWidth: 498 case CSSPropertyWebkitColumnWidth:
477 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::epsilon())); 499 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::epsilon()));
478 return; 500 return;
479 case CSSPropertyWebkitColumnRuleWidth: 501 case CSSPropertyWebkitColumnRuleWidth:
480 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(va lue)); 502 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(va lue));
481 return; 503 return;
482 case CSSPropertyWebkitFilter: 504 case CSSPropertyWebkitFilter:
483 style->setFilter(toAnimatableFilterOperations(value)->operations()); 505 style->setFilter(toAnimatableFilterOperations(value)->operations());
484 return; 506 return;
485 case CSSPropertyWebkitMaskBoxImageOutset: 507 case CSSPropertyWebkitMaskBoxImageOutset:
486 style->setMaskBoxImageOutset(animatableValueToLengthBox(value, state, No nNegativeValues)); 508 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value , state, NonNegativeValues));
487 return; 509 return;
488 case CSSPropertyWebkitMaskBoxImageSlice: 510 case CSSPropertyWebkitMaskBoxImageSlice:
489 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLeng thBoxAndBool(value)->box(), state, NonNegativeValues)); 511 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLeng thBoxAndBool(value)->box(), state, NonNegativeValues));
490 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fl ag()); 512 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fl ag());
491 return; 513 return;
492 case CSSPropertyWebkitMaskBoxImageSource: 514 case CSSPropertyWebkitMaskBoxImageSource:
493 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage()); 515 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage());
494 return; 516 return;
495 case CSSPropertyWebkitMaskBoxImageWidth: 517 case CSSPropertyWebkitMaskBoxImageWidth:
496 style->setMaskBoxImageWidth(animatableValueToLengthBox(value, state, Non NegativeValues)); 518 style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value, state, NonNegativeValues));
497 return; 519 return;
498 case CSSPropertyWebkitMaskImage: 520 case CSSPropertyWebkitMaskImage:
499 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), v alue, state); 521 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), v alue, state);
500 return; 522 return;
501 case CSSPropertyWebkitMaskPositionX: 523 case CSSPropertyWebkitMaskPositionX:
502 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers( ), value, state); 524 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers( ), value, state);
503 return; 525 return;
504 case CSSPropertyWebkitMaskPositionY: 526 case CSSPropertyWebkitMaskPositionY:
505 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers( ), value, state); 527 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers( ), value, state);
506 return; 528 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 case CSSPropertyZoom: 581 case CSSPropertyZoom:
560 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min())); 582 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min()));
561 return; 583 return;
562 default: 584 default:
563 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web Animations not yet implemented: Unable to apply AnimatableValue to RenderStyle: %s", getPropertyNameString(property).utf8().data()); 585 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web Animations not yet implemented: Unable to apply AnimatableValue to RenderStyle: %s", getPropertyNameString(property).utf8().data());
564 ASSERT_NOT_REACHED(); 586 ASSERT_NOT_REACHED();
565 } 587 }
566 } 588 }
567 589
568 } // namespace WebCore 590 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/css/CSSAnimatableValueFactory.cpp ('k') | Source/core/frame/animation/CSSPropertyAnimation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698