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

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

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; 46 typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType;
47 typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; 47 typedef SVGPropertyTearOff<ListItemType> ListItemTearOff;
48 typedef PassRefPtr<ListItemTearOff> PassListItemTearOff; 48 typedef PassRefPtr<ListItemTearOff> PassListItemTearOff;
49 typedef SVGAnimatedListPropertyTearOff<PropertyType> AnimatedListPropertyTea rOff; 49 typedef SVGAnimatedListPropertyTearOff<PropertyType> AnimatedListPropertyTea rOff;
50 typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCa che ListWrapperCache; 50 typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCa che ListWrapperCache;
51 51
52 bool canAlterList(ExceptionState& es) const 52 bool canAlterList(ExceptionState& es) const
53 { 53 {
54 if (m_role == AnimValRole) { 54 if (m_role == AnimValRole) {
55 es.throwDOMException(NoModificationAllowedError); 55 es.throwUninformativeAndGenericDOMException(NoModificationAllowedErr or);
56 return false; 56 return false;
57 } 57 }
58 58
59 return true; 59 return true;
60 } 60 }
61 61
62 static void detachListWrappersAndResize(ListWrapperCache* wrappers, unsigned newListSize = 0) 62 static void detachListWrappersAndResize(ListWrapperCache* wrappers, unsigned newListSize = 0)
63 { 63 {
64 // See SVGPropertyTearOff::detachWrapper() for an explanation about what 's happening here. 64 // See SVGPropertyTearOff::detachWrapper() for an explanation about what 's happening here.
65 ASSERT(wrappers); 65 ASSERT(wrappers);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 m_wrappers->append(newItem); 165 m_wrappers->append(newItem);
166 166
167 commitChange(); 167 commitChange();
168 return newItem.release(); 168 return newItem.release();
169 } 169 }
170 170
171 // SVGList::getItem() 171 // SVGList::getItem()
172 bool canGetItem(unsigned index, ExceptionState& es) 172 bool canGetItem(unsigned index, ExceptionState& es)
173 { 173 {
174 if (index >= m_values->size()) { 174 if (index >= m_values->size()) {
175 es.throwDOMException(IndexSizeError); 175 es.throwUninformativeAndGenericDOMException(IndexSizeError);
176 return false; 176 return false;
177 } 177 }
178 178
179 return true; 179 return true;
180 } 180 }
181 181
182 ListItemType getItemValues(unsigned index, ExceptionState& es) 182 ListItemType getItemValues(unsigned index, ExceptionState& es)
183 { 183 {
184 if (!canGetItem(index, es)) 184 if (!canGetItem(index, es))
185 return ListItemType(); 185 return ListItemType();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return newItem.release(); 267 return newItem.release();
268 } 268 }
269 269
270 // SVGList::replaceItem() 270 // SVGList::replaceItem()
271 bool canReplaceItem(unsigned index, ExceptionState& es) 271 bool canReplaceItem(unsigned index, ExceptionState& es)
272 { 272 {
273 if (!canAlterList(es)) 273 if (!canAlterList(es))
274 return false; 274 return false;
275 275
276 if (index >= m_values->size()) { 276 if (index >= m_values->size()) {
277 es.throwDOMException(IndexSizeError); 277 es.throwUninformativeAndGenericDOMException(IndexSizeError);
278 return false; 278 return false;
279 } 279 }
280 280
281 return true; 281 return true;
282 } 282 }
283 283
284 ListItemType replaceItemValues(const ListItemType& newItem, unsigned index, ExceptionState& es) 284 ListItemType replaceItemValues(const ListItemType& newItem, unsigned index, ExceptionState& es)
285 { 285 {
286 if (!canReplaceItem(index, es)) 286 if (!canReplaceItem(index, es))
287 return ListItemType(); 287 return ListItemType();
288 288
289 // Spec: If newItem is already in a list, it is removed from its previou s list before it is inserted into this list. 289 // Spec: If newItem is already in a list, it is removed from its previou s list before it is inserted into this list.
290 // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item. 290 // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item.
291 if (!processIncomingListItemValue(newItem, &index)) { 291 if (!processIncomingListItemValue(newItem, &index)) {
292 // Replacing the item with itself is a no-op. 292 // Replacing the item with itself is a no-op.
293 return newItem; 293 return newItem;
294 } 294 }
295 295
296 if (m_values->isEmpty()) { 296 if (m_values->isEmpty()) {
297 // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace. 297 // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace.
298 es.throwDOMException(IndexSizeError); 298 es.throwUninformativeAndGenericDOMException(IndexSizeError);
299 return ListItemType(); 299 return ListItemType();
300 } 300 }
301 301
302 // Update the value at the desired position 'index'. 302 // Update the value at the desired position 'index'.
303 m_values->at(index) = newItem; 303 m_values->at(index) = newItem;
304 304
305 commitChange(); 305 commitChange();
306 return newItem; 306 return newItem;
307 } 307 }
308 308
(...skipping 13 matching lines...) Expand all
322 RefPtr<ListItemTearOff> newItem = passNewItem; 322 RefPtr<ListItemTearOff> newItem = passNewItem;
323 323
324 // Spec: If newItem is already in a list, it is removed from its previou s list before it is inserted into this list. 324 // Spec: If newItem is already in a list, it is removed from its previou s list before it is inserted into this list.
325 // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item. 325 // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item.
326 if (!processIncomingListItemWrapper(newItem, &index)) 326 if (!processIncomingListItemWrapper(newItem, &index))
327 return newItem.release(); 327 return newItem.release();
328 328
329 if (m_values->isEmpty()) { 329 if (m_values->isEmpty()) {
330 ASSERT(m_wrappers->isEmpty()); 330 ASSERT(m_wrappers->isEmpty());
331 // 'passNewItem' already lived in our list, we removed it, and now w e're empty, which means there's nothing to replace. 331 // 'passNewItem' already lived in our list, we removed it, and now w e're empty, which means there's nothing to replace.
332 es.throwDOMException(IndexSizeError); 332 es.throwUninformativeAndGenericDOMException(IndexSizeError);
333 return 0; 333 return 0;
334 } 334 }
335 335
336 // Detach the existing wrapper. 336 // Detach the existing wrapper.
337 RefPtr<ListItemTearOff> oldItem = m_wrappers->at(index); 337 RefPtr<ListItemTearOff> oldItem = m_wrappers->at(index);
338 if (oldItem) 338 if (oldItem)
339 oldItem->detachWrapper(); 339 oldItem->detachWrapper();
340 340
341 // Update the value and the wrapper at the desired position 'index'. 341 // Update the value and the wrapper at the desired position 'index'.
342 m_values->at(index) = newItem->propertyReference(); 342 m_values->at(index) = newItem->propertyReference();
343 m_wrappers->at(index) = newItem; 343 m_wrappers->at(index) = newItem;
344 344
345 commitChange(); 345 commitChange();
346 return newItem.release(); 346 return newItem.release();
347 } 347 }
348 348
349 // SVGList::removeItem() 349 // SVGList::removeItem()
350 bool canRemoveItem(unsigned index, ExceptionState& es) 350 bool canRemoveItem(unsigned index, ExceptionState& es)
351 { 351 {
352 if (!canAlterList(es)) 352 if (!canAlterList(es))
353 return false; 353 return false;
354 354
355 if (index >= m_values->size()) { 355 if (index >= m_values->size()) {
356 es.throwDOMException(IndexSizeError); 356 es.throwUninformativeAndGenericDOMException(IndexSizeError);
357 return false; 357 return false;
358 } 358 }
359 359
360 return true; 360 return true;
361 } 361 }
362 362
363 ListItemType removeItemValues(unsigned index, ExceptionState& es) 363 ListItemType removeItemValues(unsigned index, ExceptionState& es)
364 { 364 {
365 if (!canRemoveItem(index, es)) 365 if (!canRemoveItem(index, es))
366 return ListItemType(); 366 return ListItemType();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 SVGPropertyRole m_role; 474 SVGPropertyRole m_role;
475 bool m_ownsValues; 475 bool m_ownsValues;
476 PropertyType* m_values; 476 PropertyType* m_values;
477 ListWrapperCache* m_wrappers; 477 ListWrapperCache* m_wrappers;
478 }; 478 };
479 479
480 } 480 }
481 481
482 #endif // SVGListProperty_h 482 #endif // SVGListProperty_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGViewSpec.cpp ('k') | Source/core/svg/properties/SVGTransformListPropertyTearOff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698