Chromium Code Reviews| Index: Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| diff --git a/Source/core/css/resolver/AnimatedStyleBuilder.cpp b/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| index bbdfc5948b791dea55cbd99827076188abffb4e0..0b56327e409957013cd4e3b3349c6f9e5fc1cc2e 100644 |
| --- a/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| +++ b/Source/core/css/resolver/AnimatedStyleBuilder.cpp |
| @@ -31,10 +31,14 @@ |
| #include "config.h" |
| #include "core/css/resolver/AnimatedStyleBuilder.h" |
| +#include "core/animation/AnimatableImage.h" |
| +#include "core/animation/AnimatableLengthBox.h" |
| #include "core/animation/AnimatableNumber.h" |
| #include "core/animation/AnimatableTransform.h" |
| #include "core/animation/AnimatableUnknown.h" |
| #include "core/animation/AnimatableValue.h" |
| +#include "core/animation/css/CSSAnimations.h" |
| +#include "core/css/CSSPrimitiveValueMappings.h" |
| #include "core/css/resolver/StyleBuilder.h" |
| #include "core/css/resolver/StyleResolverState.h" |
| #include "core/rendering/style/RenderStyle.h" |
| @@ -47,7 +51,11 @@ namespace { |
| Length animatableValueToLength(const AnimatableValue* value, const StyleResolverState& state) |
| { |
| const RenderStyle* style = state.style(); |
| - return toAnimatableNumber(value)->toLength(style, state.rootElementStyle(), style->effectiveZoom()); |
| + if (value->isNumber()) |
| + return toAnimatableNumber(value)->toLength(style, state.rootElementStyle(), style->effectiveZoom()); |
| + RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); |
| + CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); |
| + return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootElementStyle(), style->effectiveZoom()); |
| } |
| unsigned animatableValueToUnsigned(const AnimatableValue* value) |
| @@ -55,10 +63,17 @@ unsigned animatableValueToUnsigned(const AnimatableValue* value) |
| return clampTo<unsigned>(round(toAnimatableNumber(value)->toDouble())); |
| } |
| -} // namespace |
| +LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleResolverState& state) |
| +{ |
| + const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value); |
| + return LengthBox( |
| + animatableValueToLength(animatableLengthBox->top(), state), |
| + animatableValueToLength(animatableLengthBox->right(), state), |
| + animatableValueToLength(animatableLengthBox->bottom(), state), |
| + animatableValueToLength(animatableLengthBox->left(), state)); |
| +} |
| -// FIXME: This should handle all animatable properties |
| -// (see CSSAnimatableValueFactory for list of remaining) |
| +} // namespace |
| // FIXME: Generate this function. |
| void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& state, const AnimatableValue* value) |
| @@ -72,6 +87,18 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt |
| case CSSPropertyBorderBottomWidth: |
| style->setBorderBottomWidth(animatableValueToUnsigned(value)); |
| return; |
| + case CSSPropertyBorderImageOutset: |
| + style->setBorderImageOutset(animatableValueToLengthBox(value, state)); |
| + return; |
| + case CSSPropertyBorderImageSlice: |
| + style->setBorderImageSlices(animatableValueToLengthBox(value, state)); |
| + return; |
| + case CSSPropertyBorderImageSource: |
| + style->setBorderImageSource(toAnimatableImage(value)->toStyleImage()); |
| + return; |
| + case CSSPropertyBorderImageWidth: |
| + style->setBorderImageWidth(animatableValueToLengthBox(value, state)); |
| + return; |
| case CSSPropertyBorderLeftWidth: |
| style->setBorderLeftWidth(animatableValueToUnsigned(value)); |
| return; |
| @@ -84,9 +111,15 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt |
| case CSSPropertyBottom: |
| style->setBottom(animatableValueToLength(value, state)); |
| return; |
| + case CSSPropertyClip: |
| + style->setClip(animatableValueToLengthBox(value, state)); |
| + return; |
| case CSSPropertyHeight: |
| style->setHeight(animatableValueToLength(value, state)); |
| return; |
| + case CSSPropertyListStyleImage: |
| + style->setListStyleImage(toAnimatableImage(value)->toStyleImage()); |
| + return; |
| case CSSPropertyLeft: |
| style->setLeft(animatableValueToLength(value, state)); |
| return; |
| @@ -135,6 +168,12 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt |
| case CSSPropertyTop: |
| style->setTop(animatableValueToLength(value, state)); |
| return; |
| + case CSSPropertyWebkitMaskBoxImageSource: |
| + style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage()); |
| + return; |
| + case CSSPropertyWebkitMaskImage: |
| + style->setMaskImage(toAnimatableImage(value)->toStyleImage()); |
| + return; |
| case CSSPropertyWebkitPerspectiveOriginX: |
| style->setPerspectiveOriginX(animatableValueToLength(value, state)); |
| return; |
| @@ -154,8 +193,8 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt |
| style->setWidth(animatableValueToLength(value, state)); |
| return; |
| default: |
| - RELEASE_ASSERT_WITH_MESSAGE(false, "Unable to apply AnimatableValue to RenderStyle, not yet implemented!"); |
| - return; |
| + RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Unable to apply AnimatableValue to RenderStyle, not yet implemented: %s", getPropertyNameString(property).utf8().data()); |
|
Steve Block
2013/08/28 03:44:23
We should prefix the message with 'Web Animations
dstockwell
2013/08/28 08:21:22
Done.
|
| + ASSERT_NOT_REACHED(); |
| } |
| } |