Chromium Code Reviews| Index: Source/core/animation/css/CSSAnimatableValueFactory.cpp |
| diff --git a/Source/core/animation/css/CSSAnimatableValueFactory.cpp b/Source/core/animation/css/CSSAnimatableValueFactory.cpp |
| index 8242cb306ebccbef500b7e92a6683c47da8985f7..7d9a1f49ad0e3aac79922fb6a96324e8c15fa570 100644 |
| --- a/Source/core/animation/css/CSSAnimatableValueFactory.cpp |
| +++ b/Source/core/animation/css/CSSAnimatableValueFactory.cpp |
| @@ -39,6 +39,7 @@ |
| #include "core/animation/AnimatableLength.h" |
| #include "core/animation/AnimatableLengthBox.h" |
| #include "core/animation/AnimatableLengthSize.h" |
| +#include "core/animation/AnimatableRepeatable.h" |
| #include "core/animation/AnimatableSVGLength.h" |
| #include "core/animation/AnimatableSVGPaint.h" |
| #include "core/animation/AnimatableShapeValue.h" |
| @@ -113,6 +114,32 @@ inline static PassRefPtr<AnimatableValue> createFromLengthSize(const LengthSize |
| createFromLength(lengthSize.height(), style)); |
| } |
| +template<typename T> |
| +static inline PassRefPtr<AnimatableValue> createFrom(T, const RenderStyle*); |
| + |
| +template <> |
| +PassRefPtr<AnimatableValue> createFrom<Length>(Length length, const RenderStyle* style) |
| +{ |
| + return createFromLength(length, style); |
| +} |
| + |
| +template <> |
| +PassRefPtr<AnimatableValue> createFrom<StyleImage*>(StyleImage* image, const RenderStyle*) |
| +{ |
| + return AnimatableImage::create(image); |
| +} |
| + |
| +template<typename T> |
| +inline static PassRefPtr<AnimatableValue> createFromFillLayers(const FillLayer* fillLayer, T getter, bool (FillLayer::*isSet)() const, const RenderStyle* style) |
|
dstockwell
2013/10/08 23:02:46
This seems a bit yuck. Couldn't this just be a sin
alancutter (OOO until 2018)
2013/10/09 07:20:55
I agree that function pointers and code duplicatio
|
| +{ |
| + Vector<RefPtr<AnimatableValue> > values; |
| + while (fillLayer && (fillLayer->*isSet)()) { |
| + values.append(createFrom((fillLayer->*getter)(), style)); |
| + fillLayer = fillLayer->next(); |
| + } |
| + return AnimatableRepeatable::create(values); |
| +} |
| + |
| PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSPropertyID property, const RenderStyle* style) |
| { |
| Color color = style->colorIncludingFallback(property, false); |
| @@ -138,6 +165,12 @@ PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop |
| switch (property) { |
| case CSSPropertyBackgroundColor: |
| return createFromColor(property, style); |
| + case CSSPropertyBackgroundImage: |
| + return createFromFillLayers(style->backgroundLayers(), &FillLayer::image, &FillLayer::isImageSet, style); |
| + case CSSPropertyBackgroundPositionX: |
| + return createFromFillLayers(style->backgroundLayers(), &FillLayer::xPosition, &FillLayer::isXPositionSet, style); |
| + case CSSPropertyBackgroundPositionY: |
| + return createFromFillLayers(style->backgroundLayers(), &FillLayer::yPosition, &FillLayer::isYPositionSet, style); |
| case CSSPropertyBaselineShift: |
| return AnimatableSVGLength::create(style->baselineShiftValue()); |
| case CSSPropertyBorderBottomColor: |