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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/resolver/AnimatedStyleBuilder.cpp
diff --git a/Source/core/css/resolver/AnimatedStyleBuilder.cpp b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
index c44ca173c18072d98f71c46652f25fa696f989f5..8bd8bcdb1fc5b45817eda2bbd6bc0fdf1c767272 100644
--- a/Source/core/css/resolver/AnimatedStyleBuilder.cpp
+++ b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
@@ -73,6 +73,18 @@ Length animatableValueToLength(const AnimatableValue* value, const StyleResolver
return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootElementStyle(), style->effectiveZoom());
}
+LengthOrNumber animatableValueToLengthOrNumber(const AnimatableValue* value, const StyleResolverState& state, NumberRange range = AllValues)
+{
+ const RenderStyle* style = state.style();
+ if (value->isLength())
+ return LengthOrNumber(toAnimatableLength(value)->toLength(style, state.rootElementStyle(), style->effectiveZoom(), range));
+ if (value->isDouble())
+ return LengthOrNumber(toAnimatableDouble(value)->toDouble());
+ RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
+ CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
+ return LengthOrNumber(cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootElementStyle(), style->effectiveZoom()));
+}
+
template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>())
{
COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingValues);
@@ -89,6 +101,16 @@ LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
animatableValueToLength(animatableLengthBox->left(), state, range));
}
+LengthOrNumberBox animatableValueToLengthOrNumberBox(const AnimatableValue* value, const StyleResolverState& state, NumberRange range = AllValues)
+{
+ const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value);
+ return LengthOrNumberBox(
+ animatableValueToLengthOrNumber(animatableLengthBox->top(), state, range),
+ animatableValueToLengthOrNumber(animatableLengthBox->right(), state, range),
+ animatableValueToLengthOrNumber(animatableLengthBox->bottom(), state, range),
+ animatableValueToLengthOrNumber(animatableLengthBox->left(), state, range));
+}
+
LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const StyleResolverState& state, NumberRange range = AllValues)
{
const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint(value);
@@ -249,7 +271,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value));
return;
case CSSPropertyBorderImageOutset:
- style->setBorderImageOutset(animatableValueToLengthBox(value, state, NonNegativeValues));
+ style->setBorderImageOutset(animatableValueToLengthOrNumberBox(value, state, NonNegativeValues));
return;
case CSSPropertyBorderImageSlice:
style->setBorderImageSlices(animatableValueToLengthBox(value, state, NonNegativeValues));
@@ -258,7 +280,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
style->setBorderImageSource(toAnimatableImage(value)->toStyleImage());
return;
case CSSPropertyBorderImageWidth:
- style->setBorderImageWidth(animatableValueToLengthBox(value, state, NonNegativeValues));
+ style->setBorderImageWidth(animatableValueToLengthOrNumberBox(value, state, NonNegativeValues));
return;
case CSSPropertyBorderLeftColor:
style->setBorderLeftColor(toAnimatableColor(value)->color());
@@ -477,7 +499,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
style->setFilter(toAnimatableFilterOperations(value)->operations());
return;
case CSSPropertyWebkitMaskBoxImageOutset:
- style->setMaskBoxImageOutset(animatableValueToLengthBox(value, state, NonNegativeValues));
+ style->setMaskBoxImageOutset(animatableValueToLengthOrNumberBox(value, state, NonNegativeValues));
return;
case CSSPropertyWebkitMaskBoxImageSlice:
style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), state, NonNegativeValues));
@@ -487,7 +509,7 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage());
return;
case CSSPropertyWebkitMaskBoxImageWidth:
- style->setMaskBoxImageWidth(animatableValueToLengthBox(value, state, NonNegativeValues));
+ style->setMaskBoxImageWidth(animatableValueToLengthOrNumberBox(value, state, NonNegativeValues));
return;
case CSSPropertyWebkitMaskImage:
setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), value, state);

Powered by Google App Engine
This is Rietveld 408576698