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

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: 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
Index: Source/core/css/resolver/AnimatedStyleBuilder.cpp
diff --git a/Source/core/css/resolver/AnimatedStyleBuilder.cpp b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
index 012e38707eb0adc708a814a1165207c686a119ce..9280bf72be1527775d8af67ae9f4c18ca9e28d74 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"
@@ -91,6 +92,47 @@ LengthSize animatableValueToLengthSize(const AnimatableValue* value, const Style
animatableValueToLength(animatableLengthSize->height(), state, range));
}
+void setLengthOnFillLayers(void (FillLayer::*setter)(Length), void (FillLayer::*clear)(), const AnimatableValue* value, StyleResolverState& state)
+{
+ FillLayer* fillLayer = state.style()->accessBackgroundLayers();
+ const Vector<RefPtr<AnimatableValue> >& values = toAnimatableRepeatable(value)->values();
+ ASSERT(!values.isEmpty());
dstockwell 2013/10/08 22:57:31 I didn't see this assertion in the factory.
alancutter (OOO until 2018) 2013/10/09 07:20:55 Added assertion to factory.
+ FillLayer* prev = 0;
+ for (size_t i = 0; i < values.size(); ++i) {
+ if (!fillLayer) {
+ fillLayer = new FillLayer(BackgroundFillLayer);
+ prev->setNext(fillLayer);
+ }
+ (fillLayer->*setter)(animatableValueToLength(values[i].get(), state));
+ prev = fillLayer;
+ fillLayer = fillLayer->next();
+ }
+ while (fillLayer) {
+ (fillLayer->*clear)();
+ fillLayer = fillLayer->next();
+ }
+}
+
+void setImageOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value)
dstockwell 2013/10/08 23:02:46 and here, if we template on CSSPropertyID we shoul
alancutter (OOO until 2018) 2013/10/09 07:20:55 Done.
+{
+ 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);
+ }
+ fillLayer->setImage(toAnimatableImage(values[i].get())->toStyleImage());
+ prev = fillLayer;
+ fillLayer = fillLayer->next();
+ }
+ while (fillLayer) {
+ fillLayer->clearImage();
+ fillLayer = fillLayer->next();
+ }
+}
+
} // namespace
// FIXME: Generate this function.
@@ -106,6 +148,15 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
style->setBackgroundColor(toAnimatableColor(value)->color());
style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLinkColor());
return;
+ case CSSPropertyBackgroundImage:
+ setImageOnFillLayers(style->accessBackgroundLayers(), value);
+ return;
+ case CSSPropertyBackgroundPositionX:
+ setLengthOnFillLayers(&FillLayer::setXPosition, &FillLayer::clearXPosition, value, state);
+ return;
+ case CSSPropertyBackgroundPositionY:
+ setLengthOnFillLayers(&FillLayer::setYPosition, &FillLayer::clearYPosition, value, state);
+ return;
case CSSPropertyBaselineShift:
style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength());
return;
« Source/core/animation/css/CSSAnimatableValueFactory.cpp ('K') | « Source/core/core.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698