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

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: Review changes 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 4daaf8bc351bb5f6d13f5ab4c8c020c59e64efe3..a36ba8424495437cf520e4d17ed1a1a6c91d1661 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,59 @@ 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) {
+ switch (property) {
dstockwell 2013/10/09 23:15:07 do we need this switch? if it's not one of these p
alancutter (OOO until 2018) 2013/10/10 00:58:38 Removed switch.
+ case CSSPropertyBackgroundImage:
+ case CSSPropertyBackgroundPositionX:
+ case CSSPropertyBackgroundPositionY:
+ fillLayer = new FillLayer(BackgroundFillLayer);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ 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 +168,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;
« 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