OLD | NEW |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 bool operator==(const Derived&) const; | 120 bool operator==(const Derived&) const; |
121 bool operator!=(const Derived& other) const | 121 bool operator!=(const Derived& other) const |
122 { | 122 { |
123 return !(*this == other); | 123 return !(*this == other); |
124 } | 124 } |
125 | 125 |
126 bool isEmpty() const | 126 bool isEmpty() const |
127 { | 127 { |
128 return !numberOfItems(); | 128 return !length(); |
129 } | 129 } |
130 | 130 |
131 // SVGList*Property DOM spec: | 131 // SVGList*Property DOM spec: |
132 | 132 |
133 size_t numberOfItems() const | 133 size_t length() const |
134 { | 134 { |
135 return m_values.size(); | 135 return m_values.size(); |
136 } | 136 } |
137 | 137 |
138 void clear(); | 138 void clear(); |
139 | 139 |
140 PassRefPtr<ItemPropertyType> initialize(PassRefPtr<ItemPropertyType>); | 140 PassRefPtr<ItemPropertyType> initialize(PassRefPtr<ItemPropertyType>); |
141 PassRefPtr<ItemPropertyType> getItem(size_t, ExceptionState&); | 141 PassRefPtr<ItemPropertyType> getItem(size_t, ExceptionState&); |
142 PassRefPtr<ItemPropertyType> insertItemBefore(PassRefPtr<ItemPropertyType>,
size_t); | 142 PassRefPtr<ItemPropertyType> insertItemBefore(PassRefPtr<ItemPropertyType>,
size_t); |
143 PassRefPtr<ItemPropertyType> removeItem(size_t, ExceptionState&); | 143 PassRefPtr<ItemPropertyType> removeItem(size_t, ExceptionState&); |
(...skipping 17 matching lines...) Expand all Loading... |
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 { |
171 if (numberOfItems() != other.numberOfItems()) | 171 if (length() != other.length()) |
172 return false; | 172 return false; |
173 | 173 |
174 size_t length = numberOfItems(); | 174 size_t size = length(); |
175 for (size_t i = 0; i < length; ++i) { | 175 for (size_t i = 0; i < size; ++i) { |
176 if (*at(i) != *other.at(i)) | 176 if (*at(i) != *other.at(i)) |
177 return false; | 177 return false; |
178 } | 178 } |
179 | 179 |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 template<typename Derived, typename ItemProperty> | 183 template<typename Derived, typename ItemProperty> |
184 void NewSVGListPropertyHelper<Derived, ItemProperty>::clear() | 184 void NewSVGListPropertyHelper<Derived, ItemProperty>::clear() |
185 { | 185 { |
(...skipping 29 matching lines...) Expand all Loading... |
215 return nullptr; | 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 length, then the new item
is appended to the end of the list. |
226 if (index > m_values.size()) | 226 if (index > m_values.size()) |
227 index = m_values.size(); | 227 index = m_values.size(); |
228 | 228 |
229 RefPtr<ItemPropertyType> newItem = passNewItem; | 229 RefPtr<ItemPropertyType> newItem = passNewItem; |
230 | 230 |
231 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. | 231 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. |
232 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { | 232 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { |
233 // Inserting the item before itself is a no-op. | 233 // Inserting the item before itself is a no-op. |
234 return newItem.release(); | 234 return newItem.release(); |
235 } | 235 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |