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 27 matching lines...) Expand all Loading... |
38 const AnimatableValue* value) const { | 38 const AnimatableValue* value) const { |
39 const Vector<RefPtr<AnimatableValue>>& fromValues = m_values; | 39 const Vector<RefPtr<AnimatableValue>>& fromValues = m_values; |
40 const Vector<RefPtr<AnimatableValue>>& toValues = | 40 const Vector<RefPtr<AnimatableValue>>& toValues = |
41 toAnimatableRepeatable(value)->m_values; | 41 toAnimatableRepeatable(value)->m_values; |
42 DCHECK(!fromValues.isEmpty() && !toValues.isEmpty()); | 42 DCHECK(!fromValues.isEmpty() && !toValues.isEmpty()); |
43 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); | 43 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); |
44 DCHECK_GT(size, 0U); | 44 DCHECK_GT(size, 0U); |
45 for (size_t i = 0; i < size; ++i) { | 45 for (size_t i = 0; i < size; ++i) { |
46 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); | 46 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); |
47 const AnimatableValue* to = toValues[i % toValues.size()].get(); | 47 const AnimatableValue* to = toValues[i % toValues.size()].get(); |
48 // Spec: If a pair of values cannot be interpolated, then the lists are not
interpolable. | 48 // Spec: If a pair of values cannot be interpolated, then the lists are not |
| 49 // interpolable. |
49 if (AnimatableValue::usesDefaultInterpolation(from, to)) | 50 if (AnimatableValue::usesDefaultInterpolation(from, to)) |
50 return true; | 51 return true; |
51 } | 52 } |
52 return false; | 53 return false; |
53 } | 54 } |
54 | 55 |
55 bool AnimatableRepeatable::interpolateLists( | 56 bool AnimatableRepeatable::interpolateLists( |
56 const Vector<RefPtr<AnimatableValue>>& fromValues, | 57 const Vector<RefPtr<AnimatableValue>>& fromValues, |
57 const Vector<RefPtr<AnimatableValue>>& toValues, | 58 const Vector<RefPtr<AnimatableValue>>& toValues, |
58 double fraction, | 59 double fraction, |
59 Vector<RefPtr<AnimatableValue>>& interpolatedValues) { | 60 Vector<RefPtr<AnimatableValue>>& interpolatedValues) { |
60 // Interpolation behaviour spec: http://www.w3.org/TR/css3-transitions/#animty
pe-repeatable-list | 61 // Interpolation behaviour spec: |
| 62 // http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list |
61 DCHECK(interpolatedValues.isEmpty()); | 63 DCHECK(interpolatedValues.isEmpty()); |
62 DCHECK(!fromValues.isEmpty() && !toValues.isEmpty()); | 64 DCHECK(!fromValues.isEmpty() && !toValues.isEmpty()); |
63 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); | 65 size_t size = lowestCommonMultiple(fromValues.size(), toValues.size()); |
64 DCHECK_GT(size, 0U); | 66 DCHECK_GT(size, 0U); |
65 for (size_t i = 0; i < size; ++i) { | 67 for (size_t i = 0; i < size; ++i) { |
66 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); | 68 const AnimatableValue* from = fromValues[i % fromValues.size()].get(); |
67 const AnimatableValue* to = toValues[i % toValues.size()].get(); | 69 const AnimatableValue* to = toValues[i % toValues.size()].get(); |
68 // Spec: If a pair of values cannot be interpolated, then the lists are not
interpolable. | 70 // Spec: If a pair of values cannot be interpolated, then the lists are not |
| 71 // interpolable. |
69 if (AnimatableValue::usesDefaultInterpolation(from, to)) | 72 if (AnimatableValue::usesDefaultInterpolation(from, to)) |
70 return false; | 73 return false; |
71 interpolatedValues.append(interpolate(from, to, fraction)); | 74 interpolatedValues.append(interpolate(from, to, fraction)); |
72 } | 75 } |
73 return true; | 76 return true; |
74 } | 77 } |
75 | 78 |
76 PassRefPtr<AnimatableValue> AnimatableRepeatable::interpolateTo( | 79 PassRefPtr<AnimatableValue> AnimatableRepeatable::interpolateTo( |
77 const AnimatableValue* value, | 80 const AnimatableValue* value, |
78 double fraction) const { | 81 double fraction) const { |
(...skipping 12 matching lines...) Expand all Loading... |
91 if (m_values.size() != otherValues.size()) | 94 if (m_values.size() != otherValues.size()) |
92 return false; | 95 return false; |
93 for (size_t i = 0; i < m_values.size(); ++i) { | 96 for (size_t i = 0; i < m_values.size(); ++i) { |
94 if (!m_values[i]->equals(otherValues[i].get())) | 97 if (!m_values[i]->equals(otherValues[i].get())) |
95 return false; | 98 return false; |
96 } | 99 } |
97 return true; | 100 return true; |
98 } | 101 } |
99 | 102 |
100 } // namespace blink | 103 } // namespace blink |
OLD | NEW |