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

Unified Diff: Source/core/animation/AnimatableRepeatable.cpp

Issue 26292004: Web Animations CSS: Support animation of stroke-dasharray property (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments 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/AnimatableRepeatable.h ('k') | Source/core/animation/AnimatableStrokeDasharrayList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/AnimatableRepeatable.cpp
diff --git a/Source/core/animation/AnimatableRepeatable.cpp b/Source/core/animation/AnimatableRepeatable.cpp
index e87036b1c5930e2e1694559339bf546dadec7065..d6196c662ea7cb9b3d121c63c2f6787caa0d65a7 100644
--- a/Source/core/animation/AnimatableRepeatable.cpp
+++ b/Source/core/animation/AnimatableRepeatable.cpp
@@ -48,21 +48,28 @@ size_t lowestCommonMultiple(size_t a, size_t b)
namespace WebCore {
-PassRefPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(const AnimatableValue* value, double fraction) const
+bool AnimatableRepeatable::interpolateLists(const Vector<RefPtr<AnimatableValue> >& fromValues, const Vector<RefPtr<AnimatableValue> >& toValues, double fraction, Vector<RefPtr<AnimatableValue> >& interpolatedValues)
{
// Interpolation behaviour spec: http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list
- const Vector<RefPtr<AnimatableValue> >& otherValues = toAnimatableRepeatable(value)->m_values;
- ASSERT(!m_values.isEmpty() && !otherValues.isEmpty());
- Vector<RefPtr<AnimatableValue> > interpolatedValues(lowestCommonMultiple(m_values.size(), otherValues.size()));
- for (size_t i = 0; i < interpolatedValues.size(); ++i) {
- const AnimatableValue* from = m_values[i % m_values.size()].get();
- const AnimatableValue* to = otherValues[i % otherValues.size()].get();
+ ASSERT(interpolatedValues.isEmpty());
+ ASSERT(!fromValues.isEmpty() && !toValues.isEmpty());
+ size_t size = lowestCommonMultiple(fromValues.size(), toValues.size());
+ for (size_t i = 0; i < size; ++i) {
+ const AnimatableValue* from = fromValues[i % fromValues.size()].get();
+ const AnimatableValue* to = toValues[i % toValues.size()].get();
// Spec: If a pair of values cannot be interpolated, then the lists are not interpolable.
if (!from->isSameType(to))
- return defaultInterpolateTo(this, value, fraction);
- interpolatedValues[i] = interpolate(from, to, fraction);
+ return false;
+ interpolatedValues.append(interpolate(from, to, fraction));
}
- return create(interpolatedValues);
+ return true;
+}
+
+PassRefPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(const AnimatableValue* value, double fraction) const
+{
+ Vector<RefPtr<AnimatableValue> > interpolatedValues;
+ bool success = interpolateLists(m_values, toAnimatableRepeatable(value)->m_values, fraction, interpolatedValues);
+ return success ? create(interpolatedValues) : defaultInterpolateTo(this, value, fraction);
}
PassRefPtr<AnimatableValue> AnimatableRepeatable::addWith(const AnimatableValue* value) const
« no previous file with comments | « Source/core/animation/AnimatableRepeatable.h ('k') | Source/core/animation/AnimatableStrokeDasharrayList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698