OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ListSVGInterpolation_h | 5 #ifndef ListSVGInterpolation_h |
6 #define ListSVGInterpolation_h | 6 #define ListSVGInterpolation_h |
7 | 7 |
8 #include "core/animation/SVGInterpolation.h" | 8 #include "core/animation/SVGInterpolation.h" |
9 #include "core/svg/properties/SVGAnimatedProperty.h" | 9 #include "core/svg/properties/SVGAnimatedProperty.h" |
10 #include "core/svg/properties/SVGProperty.h" | 10 #include "core/svg/properties/SVGProperty.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 return nullptr; | 28 return nullptr; |
29 | 29 |
30 size_t length = startList->length(); | 30 size_t length = startList->length(); |
31 for (size_t i = 0; i < length; i++) { | 31 for (size_t i = 0; i < length; i++) { |
32 if (!InterpolationType::canCreateFrom(startList->at(i), endList->at(
i))) { | 32 if (!InterpolationType::canCreateFrom(startList->at(i), endList->at(
i))) { |
33 return nullptr; | 33 return nullptr; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 Vector<NonInterpolableType> nonInterpolableData(length); | 37 Vector<NonInterpolableType> nonInterpolableData(length); |
38 OwnPtrWillBeRawPtr<InterpolableList> startValue = InterpolableList::crea
te(length); | 38 OwnPtr<InterpolableList> startValue = InterpolableList::create(length); |
39 OwnPtrWillBeRawPtr<InterpolableList> endValue = InterpolableList::create
(length); | 39 OwnPtr<InterpolableList> endValue = InterpolableList::create(length); |
40 for (size_t i = 0; i < length; i++) { | 40 for (size_t i = 0; i < length; i++) { |
41 startValue->set(i, InterpolationType::toInterpolableValue(startList-
>at(i), attribute.get(), &nonInterpolableData.at(i))); | 41 startValue->set(i, InterpolationType::toInterpolableValue(startList-
>at(i), attribute.get(), &nonInterpolableData.at(i))); |
42 endValue->set(i, InterpolationType::toInterpolableValue(endList->at(
i), attribute.get(), nullptr)); | 42 endValue->set(i, InterpolationType::toInterpolableValue(endList->at(
i), attribute.get(), nullptr)); |
43 } | 43 } |
44 | 44 |
45 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType
, NonInterpolableType>(startValue.release(), endValue.release(), attribute, nonI
nterpolableData)); | 45 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType
, NonInterpolableType>(startValue.release(), endValue.release(), attribute, nonI
nterpolableData)); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 ListSVGInterpolationImpl(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedP
ropertyBase> attribute, Vector<NonInterpolableType> nonInterpolableData) | 49 ListSVGInterpolationImpl(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute,
Vector<NonInterpolableType> nonInterpolableData) |
50 : SVGInterpolation(start, end, attribute) | 50 : SVGInterpolation(start, end, attribute) |
51 { | 51 { |
52 m_nonInterpolableData.swap(nonInterpolableData); | 52 m_nonInterpolableData.swap(nonInterpolableData); |
53 } | 53 } |
54 | 54 |
55 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol
ableValue& value, const Vector<NonInterpolableType>& m_nonInterpolableData, cons
t SVGElement* element, const SVGAnimatedPropertyBase* attribute) | 55 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol
ableValue& value, const Vector<NonInterpolableType>& m_nonInterpolableData, cons
t SVGElement* element, const SVGAnimatedPropertyBase* attribute) |
56 { | 56 { |
57 const InterpolableList& listValue = toInterpolableList(value); | 57 const InterpolableList& listValue = toInterpolableList(value); |
58 RefPtrWillBeRawPtr<ListType> result = InterpolationType::createList(*att
ribute); | 58 RefPtrWillBeRawPtr<ListType> result = InterpolationType::createList(*att
ribute); |
59 for (size_t i = 0; i < listValue.length(); i++) | 59 for (size_t i = 0; i < listValue.length(); i++) |
(...skipping 26 matching lines...) Expand all Loading... |
86 | 86 |
87 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType
, void>(toInterpolableValue(startList), toInterpolableValue(endList), attribute)
); | 87 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType
, void>(toInterpolableValue(startList), toInterpolableValue(endList), attribute)
); |
88 } | 88 } |
89 | 89 |
90 DEFINE_INLINE_VIRTUAL_TRACE() | 90 DEFINE_INLINE_VIRTUAL_TRACE() |
91 { | 91 { |
92 SVGInterpolation::trace(visitor); | 92 SVGInterpolation::trace(visitor); |
93 } | 93 } |
94 | 94 |
95 private: | 95 private: |
96 ListSVGInterpolationImpl(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedP
ropertyBase> attribute) | 96 ListSVGInterpolationImpl(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) |
97 : SVGInterpolation(start, end, attribute) | 97 : SVGInterpolation(start, end, attribute) |
98 { | 98 { |
99 } | 99 } |
100 | 100 |
101 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(ListTyp
e* listValue) | 101 static PassOwnPtr<InterpolableValue> toInterpolableValue(ListType* listValue
) |
102 { | 102 { |
103 size_t length = listValue->length(); | 103 size_t length = listValue->length(); |
104 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(l
ength); | 104 OwnPtr<InterpolableList> result = InterpolableList::create(length); |
105 for (size_t i = 0; i < length; i++) | 105 for (size_t i = 0; i < length; i++) |
106 result->set(i, InterpolationType::toInterpolableValue(listValue->at(
i))); | 106 result->set(i, InterpolationType::toInterpolableValue(listValue->at(
i))); |
107 return result.release(); | 107 return result.release(); |
108 } | 108 } |
109 | 109 |
110 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol
ableValue& value) | 110 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol
ableValue& value) |
111 { | 111 { |
112 const InterpolableList& listValue = toInterpolableList(value); | 112 const InterpolableList& listValue = toInterpolableList(value); |
113 RefPtrWillBeRawPtr<ListType> result = ListType::create(); | 113 RefPtrWillBeRawPtr<ListType> result = ListType::create(); |
114 for (size_t i = 0; i < listValue.length(); i++) { | 114 for (size_t i = 0; i < listValue.length(); i++) { |
(...skipping 13 matching lines...) Expand all Loading... |
128 public: | 128 public: |
129 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, ty
pename InterpolationType::NonInterpolableType>> maybeCreate(SVGPropertyBase* st
art, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attri
bute) | 129 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, ty
pename InterpolationType::NonInterpolableType>> maybeCreate(SVGPropertyBase* st
art, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attri
bute) |
130 { | 130 { |
131 return ListSVGInterpolationImpl<InterpolationType, typename Interpolatio
nType::NonInterpolableType>::maybeCreate(start, end, attribute); | 131 return ListSVGInterpolationImpl<InterpolationType, typename Interpolatio
nType::NonInterpolableType>::maybeCreate(start, end, attribute); |
132 } | 132 } |
133 }; | 133 }; |
134 | 134 |
135 } // namespace blink | 135 } // namespace blink |
136 | 136 |
137 #endif // ListSVGInterpolation_h | 137 #endif // ListSVGInterpolation_h |
OLD | NEW |