| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 ASSERT(a && b); | 43 ASSERT(a && b); |
| 44 return a / greatestCommonDivisor(a, b) * b; | 44 return a / greatestCommonDivisor(a, b) * b; |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 namespace WebCore { | 49 namespace WebCore { |
| 50 | 50 |
| 51 bool AnimatableRepeatable::usesDefaultInterpolationWith(const AnimatableValue* v
alue) const | 51 bool AnimatableRepeatable::usesDefaultInterpolationWith(const AnimatableValue* v
alue) const |
| 52 { | 52 { |
| 53 const Vector<RefPtr<AnimatableValue> >& fromValues = m_values; | 53 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& fromValues = m
_values; |
| 54 const Vector<RefPtr<AnimatableValue> >& toValues = toAnimatableRepeatable(va
lue)->m_values; | 54 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& toValues = toA
nimatableRepeatable(value)->m_values; |
| 55 ASSERT(!fromValues.isEmpty() && !toValues.isEmpty()); | 55 ASSERT(!fromValues.isEmpty() && !toValues.isEmpty()); |
| 56 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); | 56 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); |
| 57 for (size_t i = 0; i < size; ++i) { | 57 for (size_t i = 0; i < size; ++i) { |
| 58 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); | 58 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); |
| 59 const AnimatableValue* to = toValues[i % toValues.size()].get(); | 59 const AnimatableValue* to = toValues[i % toValues.size()].get(); |
| 60 // Spec: If a pair of values cannot be interpolated, then the lists are
not interpolable. | 60 // Spec: If a pair of values cannot be interpolated, then the lists are
not interpolable. |
| 61 if (AnimatableValue::usesDefaultInterpolation(from, to)) | 61 if (AnimatableValue::usesDefaultInterpolation(from, to)) |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool AnimatableRepeatable::interpolateLists(const Vector<RefPtr<AnimatableValue>
>& fromValues, const Vector<RefPtr<AnimatableValue> >& toValues, double fractio
n, Vector<RefPtr<AnimatableValue> >& interpolatedValues) | 67 bool AnimatableRepeatable::interpolateLists(const WillBeHeapVector<RefPtrWillBeM
ember<AnimatableValue> >& fromValues, const WillBeHeapVector<RefPtrWillBeMember<
AnimatableValue> >& toValues, double fraction, WillBeHeapVector<RefPtrWillBeMemb
er<AnimatableValue> >& interpolatedValues) |
| 68 { | 68 { |
| 69 // Interpolation behaviour spec: http://www.w3.org/TR/css3-transitions/#anim
type-repeatable-list | 69 // Interpolation behaviour spec: http://www.w3.org/TR/css3-transitions/#anim
type-repeatable-list |
| 70 ASSERT(interpolatedValues.isEmpty()); | 70 ASSERT(interpolatedValues.isEmpty()); |
| 71 ASSERT(!fromValues.isEmpty() && !toValues.isEmpty()); | 71 ASSERT(!fromValues.isEmpty() && !toValues.isEmpty()); |
| 72 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); | 72 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); |
| 73 for (size_t i = 0; i < size; ++i) { | 73 for (size_t i = 0; i < size; ++i) { |
| 74 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); | 74 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); |
| 75 const AnimatableValue* to = toValues[i % toValues.size()].get(); | 75 const AnimatableValue* to = toValues[i % toValues.size()].get(); |
| 76 // Spec: If a pair of values cannot be interpolated, then the lists are
not interpolable. | 76 // Spec: If a pair of values cannot be interpolated, then the lists are
not interpolable. |
| 77 if (AnimatableValue::usesDefaultInterpolation(from, to)) | 77 if (AnimatableValue::usesDefaultInterpolation(from, to)) |
| 78 return false; | 78 return false; |
| 79 interpolatedValues.append(interpolate(from, to, fraction)); | 79 interpolatedValues.append(interpolate(from, to, fraction)); |
| 80 } | 80 } |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 PassRefPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(const Animatable
Value* value, double fraction) const | 84 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(cons
t AnimatableValue* value, double fraction) const |
| 85 { | 85 { |
| 86 Vector<RefPtr<AnimatableValue> > interpolatedValues; | 86 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > interpolatedValues; |
| 87 bool success = interpolateLists(m_values, toAnimatableRepeatable(value)->m_v
alues, fraction, interpolatedValues); | 87 bool success = interpolateLists(m_values, toAnimatableRepeatable(value)->m_v
alues, fraction, interpolatedValues); |
| 88 return success ? create(interpolatedValues) : defaultInterpolateTo(this, val
ue, fraction); | 88 if (success) |
| 89 return create(interpolatedValues); |
| 90 return defaultInterpolateTo(this, value, fraction); |
| 89 } | 91 } |
| 90 | 92 |
| 91 PassRefPtr<AnimatableValue> AnimatableRepeatable::addWith(const AnimatableValue*
value) const | 93 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableRepeatable::addWith(const Anim
atableValue* value) const |
| 92 { | 94 { |
| 93 const Vector<RefPtr<AnimatableValue> >& otherValues = toAnimatableRepeatable
(value)->m_values; | 95 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& otherValues =
toAnimatableRepeatable(value)->m_values; |
| 94 ASSERT(!m_values.isEmpty() && !otherValues.isEmpty()); | 96 ASSERT(!m_values.isEmpty() && !otherValues.isEmpty()); |
| 95 Vector<RefPtr<AnimatableValue> > addedValues(lowestCommonMultiple(m_values.s
ize(), otherValues.size())); | 97 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > addedValues(lowestCom
monMultiple(m_values.size(), otherValues.size())); |
| 96 for (size_t i = 0; i < addedValues.size(); ++i) { | 98 for (size_t i = 0; i < addedValues.size(); ++i) { |
| 97 const AnimatableValue* left = m_values[i % m_values.size()].get(); | 99 const AnimatableValue* left = m_values[i % m_values.size()].get(); |
| 98 const AnimatableValue* right = otherValues[i % otherValues.size()].get()
; | 100 const AnimatableValue* right = otherValues[i % otherValues.size()].get()
; |
| 99 addedValues[i] = add(left, right); | 101 addedValues[i] = add(left, right); |
| 100 } | 102 } |
| 101 return create(addedValues); | 103 return create(addedValues); |
| 102 } | 104 } |
| 103 | 105 |
| 104 bool AnimatableRepeatable::equalTo(const AnimatableValue* value) const | 106 bool AnimatableRepeatable::equalTo(const AnimatableValue* value) const |
| 105 { | 107 { |
| 106 const Vector<RefPtr<AnimatableValue> >& otherValues = toAnimatableRepeatable
(value)->m_values; | 108 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& otherValues =
toAnimatableRepeatable(value)->m_values; |
| 107 if (m_values.size() != otherValues.size()) | 109 if (m_values.size() != otherValues.size()) |
| 108 return false; | 110 return false; |
| 109 for (size_t i = 0; i < m_values.size(); ++i) { | 111 for (size_t i = 0; i < m_values.size(); ++i) { |
| 110 if (!m_values[i]->equals(otherValues[i].get())) | 112 if (!m_values[i]->equals(otherValues[i].get())) |
| 111 return false; | 113 return false; |
| 112 } | 114 } |
| 113 return true; | 115 return true; |
| 114 } | 116 } |
| 115 | 117 |
| 118 void AnimatableRepeatable::trace(Visitor* visitor) |
| 119 { |
| 120 visitor->trace(m_values); |
| 121 } |
| 122 |
| 116 } // namespace WebCore | 123 } // namespace WebCore |
| OLD | NEW |