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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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) 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 private: 150 private:
151 inline bool checkIndexBound(size_t, ExceptionState&); 151 inline bool checkIndexBound(size_t, ExceptionState&);
152 bool removeFromOldOwnerListAndAdjustIndex(PassRefPtr<ItemPropertyType>, size _t* indexToModify); 152 bool removeFromOldOwnerListAndAdjustIndex(PassRefPtr<ItemPropertyType>, size _t* indexToModify);
153 size_t findItem(PassRefPtr<ItemPropertyType>); 153 size_t findItem(PassRefPtr<ItemPropertyType>);
154 154
155 Vector<RefPtr<ItemPropertyType> > m_values; 155 Vector<RefPtr<ItemPropertyType> > m_values;
156 156
157 static PassRefPtr<Derived> toDerived(PassRefPtr<NewSVGPropertyBase> passBase ) 157 static PassRefPtr<Derived> toDerived(PassRefPtr<NewSVGPropertyBase> passBase )
158 { 158 {
159 if (!passBase) 159 if (!passBase)
160 return 0; 160 return nullptr;
161 161
162 RefPtr<NewSVGPropertyBase> base = passBase; 162 RefPtr<NewSVGPropertyBase> base = passBase;
163 ASSERT(base->type() == Derived::classType()); 163 ASSERT(base->type() == Derived::classType());
164 return static_pointer_cast<Derived>(base); 164 return static_pointer_cast<Derived>(base);
165 } 165 }
166 }; 166 };
167 167
168 template<typename Derived, typename ItemProperty> 168 template<typename Derived, typename ItemProperty>
169 bool NewSVGListPropertyHelper<Derived, ItemProperty>::operator==(const Derived& other) const 169 bool NewSVGListPropertyHelper<Derived, ItemProperty>::operator==(const Derived& other) const
170 { 170 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter. 205 // Spec: Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
206 clear(); 206 clear();
207 append(newItem); 207 append(newItem);
208 return newItem.release(); 208 return newItem.release();
209 } 209 }
210 210
211 template<typename Derived, typename ItemProperty> 211 template<typename Derived, typename ItemProperty>
212 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::getIte m(size_t index, ExceptionState& exceptionState) 212 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::getIte m(size_t index, ExceptionState& exceptionState)
213 { 213 {
214 if (!checkIndexBound(index, exceptionState)) 214 if (!checkIndexBound(index, exceptionState))
215 return 0; 215 return nullptr;
216 216
217 ASSERT(index < m_values.size()); 217 ASSERT(index < m_values.size());
218 ASSERT(m_values.at(index)->ownerList() == this); 218 ASSERT(m_values.at(index)->ownerList() == this);
219 return m_values.at(index); 219 return m_values.at(index);
220 } 220 }
221 221
222 template<typename Derived, typename ItemProperty> 222 template<typename Derived, typename ItemProperty>
223 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::insert ItemBefore(PassRefPtr<ItemProperty> passNewItem, size_t index) 223 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::insert ItemBefore(PassRefPtr<ItemProperty> passNewItem, size_t index)
224 { 224 {
225 // Spec: If the index is greater than or equal to numberOfItems, then the ne w item is appended to the end of the list. 225 // Spec: If the index is greater than or equal to numberOfItems, then the ne w item is appended to the end of the list.
(...skipping 14 matching lines...) Expand all
240 newItem->setOwnerList(this); 240 newItem->setOwnerList(this);
241 241
242 return newItem.release(); 242 return newItem.release();
243 } 243 }
244 244
245 template<typename Derived, typename ItemProperty> 245 template<typename Derived, typename ItemProperty>
246 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::remove Item(size_t index, ExceptionState& exceptionState) 246 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::remove Item(size_t index, ExceptionState& exceptionState)
247 { 247 {
248 if (index >= m_values.size()) { 248 if (index >= m_values.size()) {
249 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("index", index, m_values.size())); 249 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("index", index, m_values.size()));
250 return 0; 250 return nullptr;
251 } 251 }
252 ASSERT(m_values.at(index)->ownerList() == this); 252 ASSERT(m_values.at(index)->ownerList() == this);
253 RefPtr<ItemPropertyType> oldItem = m_values.at(index); 253 RefPtr<ItemPropertyType> oldItem = m_values.at(index);
254 m_values.remove(index); 254 m_values.remove(index);
255 oldItem->setOwnerList(0); 255 oldItem->setOwnerList(0);
256 return oldItem.release(); 256 return oldItem.release();
257 } 257 }
258 258
259 template<typename Derived, typename ItemProperty> 259 template<typename Derived, typename ItemProperty>
260 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::append Item(PassRefPtr<ItemProperty> passNewItem) 260 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::append Item(PassRefPtr<ItemProperty> passNewItem)
261 { 261 {
262 RefPtr<ItemPropertyType> newItem = passNewItem; 262 RefPtr<ItemPropertyType> newItem = passNewItem;
263 263
264 // Spec: If newItem is already in a list, it is removed from its previous li st before it is inserted into this list. 264 // Spec: If newItem is already in a list, it is removed from its previous li st before it is inserted into this list.
265 removeFromOldOwnerListAndAdjustIndex(newItem, 0); 265 removeFromOldOwnerListAndAdjustIndex(newItem, 0);
266 266
267 // Append the value and wrapper at the end of the list. 267 // Append the value and wrapper at the end of the list.
268 append(newItem); 268 append(newItem);
269 269
270 return newItem.release(); 270 return newItem.release();
271 } 271 }
272 272
273 template<typename Derived, typename ItemProperty> 273 template<typename Derived, typename ItemProperty>
274 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::replac eItem(PassRefPtr<ItemProperty> passNewItem, size_t index, ExceptionState& except ionState) 274 PassRefPtr<ItemProperty> NewSVGListPropertyHelper<Derived, ItemProperty>::replac eItem(PassRefPtr<ItemProperty> passNewItem, size_t index, ExceptionState& except ionState)
275 { 275 {
276 if (!checkIndexBound(index, exceptionState)) 276 if (!checkIndexBound(index, exceptionState))
277 return 0; 277 return nullptr;
278 278
279 RefPtr<ItemPropertyType> newItem = passNewItem; 279 RefPtr<ItemPropertyType> newItem = passNewItem;
280 280
281 // Spec: If newItem is already in a list, it is removed from its previous li st before it is inserted into this list. 281 // Spec: If newItem is already in a list, it is removed from its previous li st before it is inserted into this list.
282 // Spec: If the item is already in this list, note that the index of the ite m to replace is before the removal of the item. 282 // Spec: If the item is already in this list, note that the index of the ite m to replace is before the removal of the item.
283 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { 283 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) {
284 // Replacing the item with itself is a no-op. 284 // Replacing the item with itself is a no-op.
285 return newItem.release(); 285 return newItem.release();
286 } 286 }
287 287
288 if (m_values.isEmpty()) { 288 if (m_values.isEmpty()) {
289 // 'newItem' already lived in our list, we removed it, and now we're emp ty, which means there's nothing to replace. 289 // 'newItem' already lived in our list, we removed it, and now we're emp ty, which means there's nothing to replace.
290 exceptionState.throwDOMException(IndexSizeError, String::format("Failed to replace the provided item at index %zu.", index)); 290 exceptionState.throwDOMException(IndexSizeError, String::format("Failed to replace the provided item at index %zu.", index));
291 return 0; 291 return nullptr;
292 } 292 }
293 293
294 // Update the value at the desired position 'index'. 294 // Update the value at the desired position 'index'.
295 RefPtr<ItemPropertyType>& position = m_values[index]; 295 RefPtr<ItemPropertyType>& position = m_values[index];
296 ASSERT(position->ownerList() == this); 296 ASSERT(position->ownerList() == this);
297 position->setOwnerList(0); 297 position->setOwnerList(0);
298 position = newItem; 298 position = newItem;
299 newItem->setOwnerList(this); 299 newItem->setOwnerList(this);
300 300
301 return newItem.release(); 301 return newItem.release();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 typename Vector<RefPtr<ItemPropertyType> >::const_iterator it = from->m_valu es.begin(); 362 typename Vector<RefPtr<ItemPropertyType> >::const_iterator it = from->m_valu es.begin();
363 typename Vector<RefPtr<ItemPropertyType> >::const_iterator itEnd = from->m_v alues.end(); 363 typename Vector<RefPtr<ItemPropertyType> >::const_iterator itEnd = from->m_v alues.end();
364 for (; it != itEnd; ++it) { 364 for (; it != itEnd; ++it) {
365 append((*it)->clone()); 365 append((*it)->clone());
366 } 366 }
367 } 367 }
368 368
369 } 369 }
370 370
371 #endif // NewSVGListPropertyHelper_h 371 #endif // NewSVGListPropertyHelper_h
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/filters/SVGFilterBuilder.cpp ('k') | Source/core/svg/properties/NewSVGListPropertyTearOffHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698