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

Side by Side Diff: Source/core/animation/ListSVGInterpolation.h

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 template<typename InterpolationType, typename NonInterpolableType> 14 template<typename InterpolationType, typename NonInterpolableType>
15 class ListSVGInterpolationImpl : public SVGInterpolation { 15 class ListSVGInterpolationImpl : public SVGInterpolation {
16 public: 16 public:
17 typedef typename InterpolationType::ListType ListType; 17 typedef typename InterpolationType::ListType ListType;
18 typedef typename InterpolationType::ListType::ItemPropertyType ItemPropertyT ype; 18 typedef typename InterpolationType::ListType::ItemPropertyType ItemPropertyT ype;
19 19
20 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, No nInterpolableType>> maybeCreate(SVGPropertyBase* start, SVGPropertyBase* end, Pa ssRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) 20 static ListSVGInterpolationImpl<InterpolationType, NonInterpolableType>* may beCreate(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SV GAnimatedPropertyBase> attribute)
21 { 21 {
22 ASSERT(start->type() == ListType::classType()); 22 ASSERT(start->type() == ListType::classType());
23 ASSERT(end->type() == ListType::classType()); 23 ASSERT(end->type() == ListType::classType());
24 24
25 ListType* startList = static_cast<ListType*>(start); 25 ListType* startList = static_cast<ListType*>(start);
26 ListType* endList = static_cast<ListType*>(end); 26 ListType* endList = static_cast<ListType*>(end);
27 if (startList->length() != endList->length()) 27 if (startList->length() != endList->length())
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 InterpolableList* startValue = InterpolableList::create(length);
39 OwnPtrWillBeRawPtr<InterpolableList> endValue = InterpolableList::create (length); 39 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 new ListSVGInterpolationImpl<InterpolationType, NonInterpolableTy pe>(startValue, endValue, attribute, nonInterpolableData);
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(InterpolableValue* start, InterpolableValue* end, P assRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute, Vector<NonInterpolable Type> 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++)
60 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i), m_nonInterpolableData.at(i), element)); 60 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i), m_nonInterpolableData.at(i), element));
61 return result.release(); 61 return result.release();
62 } 62 }
63 63
64 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const 64 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const
65 { 65 {
66 return fromInterpolableValue(*m_cachedValue, m_nonInterpolableData, &ele ment, attribute()); 66 return fromInterpolableValue(*m_cachedValue, m_nonInterpolableData, &ele ment, attribute());
67 } 67 }
68 68
69 Vector<NonInterpolableType> m_nonInterpolableData; 69 Vector<NonInterpolableType> m_nonInterpolableData;
70 }; 70 };
71 71
72 template<typename InterpolationType> 72 template<typename InterpolationType>
73 class ListSVGInterpolationImpl<InterpolationType, void> : public SVGInterpolatio n { 73 class ListSVGInterpolationImpl<InterpolationType, void> : public SVGInterpolatio n {
74 public: 74 public:
75 typedef typename InterpolationType::ListType ListType; 75 typedef typename InterpolationType::ListType ListType;
76 76
77 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, vo id>> maybeCreate(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeR awPtr<SVGAnimatedPropertyBase> attribute) 77 static ListSVGInterpolationImpl<InterpolationType, void>* maybeCreate(SVGPro pertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedProper tyBase> attribute)
78 { 78 {
79 ASSERT(start->type() == ListType::classType()); 79 ASSERT(start->type() == ListType::classType());
80 ASSERT(end->type() == ListType::classType()); 80 ASSERT(end->type() == ListType::classType());
81 81
82 ListType* startList = static_cast<ListType*>(start); 82 ListType* startList = static_cast<ListType*>(start);
83 ListType* endList = static_cast<ListType*>(end); 83 ListType* endList = static_cast<ListType*>(end);
84 if (startList->length() != endList->length()) 84 if (startList->length() != endList->length())
85 return nullptr; 85 return nullptr;
86 86
87 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType , void>(toInterpolableValue(startList), toInterpolableValue(endList), attribute) ); 87 return new ListSVGInterpolationImpl<InterpolationType, void>(toInterpola bleValue(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(InterpolableValue* start, InterpolableValue* end, P assRefPtrWillBeRawPtr<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 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 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;
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++) {
115 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i))); 115 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i)));
116 } 116 }
117 return result.release(); 117 return result.release();
118 } 118 }
119 119
120 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const 120 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const
121 { 121 {
122 return fromInterpolableValue(*m_cachedValue); 122 return fromInterpolableValue(*m_cachedValue);
123 } 123 }
124 }; 124 };
125 125
126 template<typename InterpolationType> 126 template<typename InterpolationType>
127 class ListSVGInterpolation { 127 class ListSVGInterpolation {
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 ListSVGInterpolationImpl<InterpolationType, typename InterpolationTyp e::NonInterpolableType>* maybeCreate(SVGPropertyBase* start, SVGPropertyBase* en d, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute)
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
OLDNEW
« no previous file with comments | « Source/core/animation/LengthStyleInterpolationTest.cpp ('k') | Source/core/animation/ListStyleInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698