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

Unified Diff: Source/core/animation/css/CSSAnimatableValueFactory.cpp

Issue 26247003: Web Animations CSS: Support animation of background-position and background-image (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Refixed test expectations Created 7 years, 2 months 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
« no previous file with comments | « Source/core/animation/AnimatableValue.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/css/CSSAnimatableValueFactory.cpp
diff --git a/Source/core/animation/css/CSSAnimatableValueFactory.cpp b/Source/core/animation/css/CSSAnimatableValueFactory.cpp
index 53a85c5887481ddd639c3f515e18e4d2ec5ccb86..2970ab469089b5572b479092e9b28726af826baf 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,32 @@ 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) {
+ if (property == CSSPropertyBackgroundImage) {
+ if (!fillLayer->isImageSet())
+ break;
+ values.append(AnimatableImage::create(fillLayer->image()));
+ } else if (property == CSSPropertyBackgroundPositionX) {
+ if (!fillLayer->isXPositionSet())
+ break;
+ values.append(createFromLength(fillLayer->xPosition(), style));
+ } else if (property == CSSPropertyBackgroundPositionY) {
+ if (!fillLayer->isYPositionSet())
+ break;
+ values.append(createFromLength(fillLayer->yPosition(), style));
+ } else {
+ 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 +164,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:
« no previous file with comments | « Source/core/animation/AnimatableValue.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698