summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp b/chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp
index a9f1ae6d982..2c2f63e4e8b 100644
--- a/chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp
+++ b/chromium/third_party/WebKit/Source/core/animation/AnimatableRepeatable.cpp
@@ -31,63 +31,57 @@
#include "config.h"
#include "core/animation/AnimatableRepeatable.h"
-namespace {
+#include "wtf/MathExtras.h"
-size_t greatestCommonDivisor(size_t a, size_t b)
-{
- return b ? greatestCommonDivisor(b, a % b) : a;
-}
+namespace WebCore {
-size_t lowestCommonMultiple(size_t a, size_t b)
+bool AnimatableRepeatable::usesDefaultInterpolationWith(const AnimatableValue* value) const
{
- ASSERT(a && b);
- return a / greatestCommonDivisor(a, b) * b;
+ const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& fromValues = m_values;
+ const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& toValues = toAnimatableRepeatable(value)->m_values;
+ ASSERT(!fromValues.isEmpty() && !toValues.isEmpty());
+ size_t size = lowestCommonMultiple(fromValues.size(), toValues.size());
+ ASSERT(size > 0);
+ 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 (AnimatableValue::usesDefaultInterpolation(from, to))
+ return true;
+ }
+ return false;
}
-} // namespace
-
-namespace WebCore {
-
-bool AnimatableRepeatable::interpolateLists(const Vector<RefPtr<AnimatableValue> >& fromValues, const Vector<RefPtr<AnimatableValue> >& toValues, double fraction, Vector<RefPtr<AnimatableValue> >& interpolatedValues)
+bool AnimatableRepeatable::interpolateLists(const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& fromValues, const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& toValues, double fraction, WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& interpolatedValues)
{
// Interpolation behaviour spec: http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list
ASSERT(interpolatedValues.isEmpty());
ASSERT(!fromValues.isEmpty() && !toValues.isEmpty());
size_t size = lowestCommonMultiple(fromValues.size(), toValues.size());
+ ASSERT(size > 0);
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->usesNonDefaultInterpolationWith(to))
+ if (AnimatableValue::usesDefaultInterpolation(from, to))
return false;
interpolatedValues.append(interpolate(from, to, fraction));
}
return true;
}
-PassRefPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(const AnimatableValue* value, double fraction) const
+PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(const AnimatableValue* value, double fraction) const
{
- Vector<RefPtr<AnimatableValue> > interpolatedValues;
+ WillBeHeapVector<RefPtrWillBeMember<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
-{
- const Vector<RefPtr<AnimatableValue> >& otherValues = toAnimatableRepeatable(value)->m_values;
- ASSERT(!m_values.isEmpty() && !otherValues.isEmpty());
- Vector<RefPtr<AnimatableValue> > addedValues(lowestCommonMultiple(m_values.size(), otherValues.size()));
- for (size_t i = 0; i < addedValues.size(); ++i) {
- const AnimatableValue* left = m_values[i % m_values.size()].get();
- const AnimatableValue* right = otherValues[i % otherValues.size()].get();
- addedValues[i] = add(left, right);
- }
- return create(addedValues);
+ if (success)
+ return create(interpolatedValues);
+ return defaultInterpolateTo(this, value, fraction);
}
bool AnimatableRepeatable::equalTo(const AnimatableValue* value) const
{
- const Vector<RefPtr<AnimatableValue> >& otherValues = toAnimatableRepeatable(value)->m_values;
+ const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& otherValues = toAnimatableRepeatable(value)->m_values;
if (m_values.size() != otherValues.size())
return false;
for (size_t i = 0; i < m_values.size(); ++i) {
@@ -97,4 +91,10 @@ bool AnimatableRepeatable::equalTo(const AnimatableValue* value) const
return true;
}
+void AnimatableRepeatable::trace(Visitor* visitor)
+{
+ visitor->trace(m_values);
+ AnimatableValue::trace(visitor);
+}
+
} // namespace WebCore