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

Side by Side Diff: Source/core/svg/properties/SVGListPropertyTearOff.h

Issue 25164005: Merge 158408 "Revert 157959 "Introduce a new reference graph to ..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1650/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 Base::clearValuesAndWrappers(es); 85 Base::clearValuesAndWrappers(es);
86 } 86 }
87 87
88 PassListItemTearOff initialize(PassListItemTearOff passNewItem, ExceptionSta te& es) 88 PassListItemTearOff initialize(PassListItemTearOff passNewItem, ExceptionSta te& es)
89 { 89 {
90 return Base::initializeValuesAndWrappers(passNewItem, es); 90 return Base::initializeValuesAndWrappers(passNewItem, es);
91 } 91 }
92 92
93 PassListItemTearOff getItem(unsigned index, ExceptionState& es) 93 PassListItemTearOff getItem(unsigned index, ExceptionState& es)
94 { 94 {
95 ASSERT(m_animatedProperty); 95 return Base::getItemValuesAndWrappers(m_animatedProperty.get(), index, e s);
96 return Base::getItemValuesAndWrappers(m_animatedProperty, index, es);
97 } 96 }
98 97
99 PassListItemTearOff insertItemBefore(PassListItemTearOff passNewItem, unsign ed index, ExceptionState& es) 98 PassListItemTearOff insertItemBefore(PassListItemTearOff passNewItem, unsign ed index, ExceptionState& es)
100 { 99 {
101 return Base::insertItemBeforeValuesAndWrappers(passNewItem, index, es); 100 return Base::insertItemBeforeValuesAndWrappers(passNewItem, index, es);
102 } 101 }
103 102
104 PassListItemTearOff replaceItem(PassListItemTearOff passNewItem, unsigned in dex, ExceptionState& es) 103 PassListItemTearOff replaceItem(PassListItemTearOff passNewItem, unsigned in dex, ExceptionState& es)
105 { 104 {
106 return Base::replaceItemValuesAndWrappers(passNewItem, index, es); 105 return Base::replaceItemValuesAndWrappers(passNewItem, index, es);
107 } 106 }
108 107
109 PassListItemTearOff removeItem(unsigned index, ExceptionState& es) 108 PassListItemTearOff removeItem(unsigned index, ExceptionState& es)
110 { 109 {
111 ASSERT(m_animatedProperty); 110 return Base::removeItemValuesAndWrappers(m_animatedProperty.get(), index , es);
112 return Base::removeItemValuesAndWrappers(m_animatedProperty, index, es);
113 } 111 }
114 112
115 PassListItemTearOff appendItem(PassListItemTearOff passNewItem, ExceptionSta te& es) 113 PassListItemTearOff appendItem(PassListItemTearOff passNewItem, ExceptionSta te& es)
116 { 114 {
117 return Base::appendItemValuesAndWrappers(passNewItem, es); 115 return Base::appendItemValuesAndWrappers(passNewItem, es);
118 } 116 }
119 117
120 SVGElement* contextElement() const
121 {
122 ASSERT(m_animatedProperty);
123 return m_animatedProperty->contextElement();
124 }
125
126 void clearAnimatedProperty()
127 {
128 ASSERT(m_animatedProperty);
129 Base::detachListWrappers(0);
130 m_animatedProperty = 0;
131 m_values = 0;
132 m_wrappers = 0;
133 }
134
135 protected: 118 protected:
136 SVGListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPro pertyRole role, PropertyType& values, ListWrapperCache& wrappers) 119 SVGListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPro pertyRole role, PropertyType& values, ListWrapperCache& wrappers)
137 : SVGListProperty<PropertyType>(role, values, &wrappers) 120 : SVGListProperty<PropertyType>(role, values, &wrappers)
138 , m_animatedProperty(animatedProperty) 121 , m_animatedProperty(animatedProperty)
139 { 122 {
140 ASSERT(m_animatedProperty);
141 } 123 }
142 124
143 virtual bool isReadOnly() const 125 virtual bool isReadOnly() const
144 { 126 {
145 if (m_role == AnimValRole) 127 if (m_role == AnimValRole)
146 return true; 128 return true;
147 if (m_animatedProperty && m_animatedProperty->isReadOnly()) 129 if (m_animatedProperty && m_animatedProperty->isReadOnly())
148 return true; 130 return true;
149 return false; 131 return false;
150 } 132 }
151 133
152 virtual void commitChange() 134 virtual void commitChange()
153 { 135 {
154 ASSERT(m_values); 136 ASSERT(m_values);
155 ASSERT(m_wrappers); 137 ASSERT(m_wrappers);
156 ASSERT(m_animatedProperty);
157 138
158 // Update existing wrappers, as the index in the values list has changed . 139 // Update existing wrappers, as the index in the values list has changed .
159 unsigned size = m_wrappers->size(); 140 unsigned size = m_wrappers->size();
160 ASSERT(size == m_values->size()); 141 ASSERT(size == m_values->size());
161 for (unsigned i = 0; i < size; ++i) { 142 for (unsigned i = 0; i < size; ++i) {
162 ListItemTearOff* item = m_wrappers->at(i).get(); 143 ListItemTearOff* item = m_wrappers->at(i).get();
163 if (!item) 144 if (!item)
164 continue; 145 continue;
165 item->setAnimatedProperty(m_animatedProperty); 146 item->setAnimatedProperty(m_animatedProperty.get());
166 item->setValue(m_values->at(i)); 147 item->setValue(m_values->at(i));
167 } 148 }
168 149
169 m_animatedProperty->commitChange(); 150 m_animatedProperty->commitChange();
170 } 151 }
171 152
172 virtual bool processIncomingListItemValue(const ListItemType&, unsigned*) 153 virtual bool processIncomingListItemValue(const ListItemType&, unsigned*)
173 { 154 {
174 ASSERT_NOT_REACHED(); 155 ASSERT_NOT_REACHED();
175 return true; 156 return true;
(...skipping 15 matching lines...) Expand all
191 // Otherwhise we'll end up having two SVGAnimatedPropertys that oper ate on the same SVGPropertyTearOff. Consider the example above: 172 // Otherwhise we'll end up having two SVGAnimatedPropertys that oper ate on the same SVGPropertyTearOff. Consider the example above:
192 // SVGRectElements SVGAnimatedLength 'width' property baseVal points to the same tear off object 173 // SVGRectElements SVGAnimatedLength 'width' property baseVal points to the same tear off object
193 // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. t extElement.x.baseVal.getItem(0).value += 150 would 174 // that's inserted into SVGTextElements SVGAnimatedLengthList 'x'. t extElement.x.baseVal.getItem(0).value += 150 would
194 // mutate the rectElement width _and_ the textElement x list. That's obviously wrong, take care of that. 175 // mutate the rectElement width _and_ the textElement x list. That's obviously wrong, take care of that.
195 newItem = ListItemTearOff::create(newItem->propertyReference()); 176 newItem = ListItemTearOff::create(newItem->propertyReference());
196 return true; 177 return true;
197 } 178 }
198 179
199 // Spec: If newItem is already in a list, it is removed from its previou s list before it is inserted into this list. 180 // Spec: If newItem is already in a list, it is removed from its previou s list before it is inserted into this list.
200 // 'newItem' is already living in another list. If it's not our list, sy nchronize the other lists wrappers after the removal. 181 // 'newItem' is already living in another list. If it's not our list, sy nchronize the other lists wrappers after the removal.
201 ASSERT(m_animatedProperty);
202 bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty; 182 bool livesInOtherList = animatedPropertyOfItem != m_animatedProperty;
203 AnimatedListPropertyTearOff* propertyTearOff = static_cast<AnimatedListP ropertyTearOff*>(animatedPropertyOfItem); 183 AnimatedListPropertyTearOff* propertyTearOff = static_cast<AnimatedListP ropertyTearOff*>(animatedPropertyOfItem);
204 int indexToRemove = propertyTearOff->findItem(newItem.get()); 184 int indexToRemove = propertyTearOff->findItem(newItem.get());
205 ASSERT(indexToRemove != -1); 185 ASSERT(indexToRemove != -1);
206 186
207 // Do not remove newItem if already in this list at the target index. 187 // Do not remove newItem if already in this list at the target index.
208 if (!livesInOtherList && indexToModify && static_cast<unsigned>(indexToR emove) == *indexToModify) 188 if (!livesInOtherList && indexToModify && static_cast<unsigned>(indexToR emove) == *indexToModify)
209 return false; 189 return false;
210 190
211 propertyTearOff->removeItemFromList(indexToRemove, livesInOtherList); 191 propertyTearOff->removeItemFromList(indexToRemove, livesInOtherList);
212 192
213 if (!indexToModify) 193 if (!indexToModify)
214 return true; 194 return true;
215 195
216 // If the item lived in our list, adjust the insertion index. 196 // If the item lived in our list, adjust the insertion index.
217 if (!livesInOtherList) { 197 if (!livesInOtherList) {
218 unsigned& index = *indexToModify; 198 unsigned& index = *indexToModify;
219 // Spec: If the item is already in this list, note that the index of the item to (replace|insert before) is before the removal of the item. 199 // Spec: If the item is already in this list, note that the index of the item to (replace|insert before) is before the removal of the item.
220 if (static_cast<unsigned>(indexToRemove) < index) 200 if (static_cast<unsigned>(indexToRemove) < index)
221 --index; 201 --index;
222 } 202 }
223 203
224 return true; 204 return true;
225 } 205 }
226 206
227 // Back pointer to the animated property that created us 207 // Back pointer to the animated property that created us
228 // For example (text.x.baseVal): m_animatedProperty points to the 'x' SVGAni matedLengthList object 208 // For example (text.x.baseVal): m_animatedProperty points to the 'x' SVGAni matedLengthList object
229 AnimatedListPropertyTearOff* m_animatedProperty; 209 RefPtr<AnimatedListPropertyTearOff> m_animatedProperty;
230 }; 210 };
231 211
232 } 212 }
233 213
234 #endif // SVGListPropertyTearOff_h 214 #endif // SVGListPropertyTearOff_h
OLDNEW
« no previous file with comments | « Source/core/svg/properties/SVGAnimatedProperty.cpp ('k') | Source/core/svg/properties/SVGPathSegListPropertyTearOff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698