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 373221847314d6ed53bf9a38258b7178e72a85cf..dfe9bd03842e92724f5d8fd9661e11487fd99ff9 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" |
| @@ -112,6 +113,46 @@ inline static PassRefPtr<AnimatableValue> createFromLengthSize(const LengthSize |
| createFromLength(lengthSize.height(), style)); |
| } |
| +template<CSSPropertyID property> |
| +inline static PassRefPtr<AnimatableValue> createFromFillLayers(const FillLayer* fillLayer, const RenderStyle* style) |
| +{ |
| + ASSERT(fillLayer); |
| + Vector<RefPtr<AnimatableValue> > values; |
| + while (fillLayer) { |
|
dstockwell
2013/10/09 23:15:07
Hmm, yeah I guess there's a bit too much going on
alancutter (OOO until 2018)
2013/10/10 00:58:38
Merged the switch statements using an if chain.
|
| + bool isSet; |
| + switch (property) { |
| + case CSSPropertyBackgroundImage: |
| + isSet = fillLayer->isImageSet(); |
| + break; |
| + case CSSPropertyBackgroundPositionX: |
| + isSet = fillLayer->isXPositionSet(); |
| + break; |
| + case CSSPropertyBackgroundPositionY: |
| + isSet = fillLayer->isYPositionSet(); |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| + if (!isSet) |
| + break; |
| + switch (property) { |
| + case CSSPropertyBackgroundImage: |
| + values.append(AnimatableImage::create(fillLayer->image())); |
| + break; |
| + case CSSPropertyBackgroundPositionX: |
| + values.append(createFromLength(fillLayer->xPosition(), style)); |
| + break; |
| + case CSSPropertyBackgroundPositionY: |
| + values.append(createFromLength(fillLayer->yPosition(), style)); |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| + fillLayer = fillLayer->next(); |
| + } |
| + return AnimatableRepeatable::create(values); |
| +} |
| + |
| PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSPropertyID property, const RenderStyle* style) |
| { |
| Color color = style->colorIncludingFallback(property, false); |
| @@ -137,6 +178,12 @@ PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop |
| switch (property) { |
| case CSSPropertyBackgroundColor: |
| return createFromColor(property, style); |
| + case CSSPropertyBackgroundImage: |
| + return createFromFillLayers<CSSPropertyBackgroundImage>(style->backgroundLayers(), style); |
| + case CSSPropertyBackgroundPositionX: |
| + return createFromFillLayers<CSSPropertyBackgroundPositionX>(style->backgroundLayers(), style); |
| + case CSSPropertyBackgroundPositionY: |
| + return createFromFillLayers<CSSPropertyBackgroundPositionY>(style->backgroundLayers(), style); |
| case CSSPropertyBaselineShift: |
| return AnimatableSVGLength::create(style->baselineShiftValue()); |
| case CSSPropertyBorderBottomColor: |