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

Unified Diff: Source/core/css/resolver/AnimatedStyleBuilder.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/core.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/AnimatedStyleBuilder.cpp
diff --git a/Source/core/css/resolver/AnimatedStyleBuilder.cpp b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
index 76c80028dfb9687c35072258430886cb5c27ca77..e7e047b3a3a5802a1e60c2aa41c0abc9faea16a2 100644
--- a/Source/core/css/resolver/AnimatedStyleBuilder.cpp
+++ b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
@@ -38,6 +38,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"
@@ -99,6 +100,51 @@ SVGLength animatableValueToNonNegativeSVGLength(const AnimatableValue* value)
return length;
}
+template <CSSPropertyID property>
+void setOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value, StyleResolverState& state)
+{
+ const Vector<RefPtr<AnimatableValue> >& values = toAnimatableRepeatable(value)->values();
+ ASSERT(!values.isEmpty());
+ FillLayer* prev = 0;
+ for (size_t i = 0; i < values.size(); ++i) {
+ if (!fillLayer) {
+ fillLayer = new FillLayer(BackgroundFillLayer);
+ prev->setNext(fillLayer);
+ }
+ switch (property) {
+ case CSSPropertyBackgroundImage:
+ fillLayer->setImage(toAnimatableImage(values[i].get())->toStyleImage());
+ break;
+ case CSSPropertyBackgroundPositionX:
+ fillLayer->setXPosition(animatableValueToLength(values[i].get(), state));
+ break;
+ case CSSPropertyBackgroundPositionY:
+ fillLayer->setYPosition(animatableValueToLength(values[i].get(), state));
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ prev = fillLayer;
+ fillLayer = fillLayer->next();
+ }
+ while (fillLayer) {
+ switch (property) {
+ case CSSPropertyBackgroundImage:
+ fillLayer->clearImage();
+ break;
+ case CSSPropertyBackgroundPositionX:
+ fillLayer->clearXPosition();
+ break;
+ case CSSPropertyBackgroundPositionY:
+ fillLayer->clearYPosition();
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ fillLayer = fillLayer->next();
+ }
+}
+
} // namespace
// FIXME: Generate this function.
@@ -114,6 +160,15 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
style->setBackgroundColor(toAnimatableColor(value)->color());
style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLinkColor());
return;
+ case CSSPropertyBackgroundImage:
+ setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayers(), value, state);
+ return;
+ case CSSPropertyBackgroundPositionX:
+ setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundLayers(), value, state);
+ return;
+ case CSSPropertyBackgroundPositionY:
+ setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundLayers(), value, state);
+ return;
case CSSPropertyBaselineShift:
style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength());
return;
« no previous file with comments | « Source/core/core.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698