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

Side by Side Diff: third_party/WebKit/Source/core/svg/properties/SVGListPropertyHelper.h

Issue 2390773004: reflow comments in core/svg/ (Closed)
Patch Set: comments (heh!) Created 4 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
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ASSERT((*it)->ownerList() == this); 178 ASSERT((*it)->ownerList() == this);
179 (*it)->setOwnerList(nullptr); 179 (*it)->setOwnerList(nullptr);
180 } 180 }
181 181
182 m_values.clear(); 182 m_values.clear();
183 } 183 }
184 184
185 template <typename Derived, typename ItemProperty> 185 template <typename Derived, typename ItemProperty>
186 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::initialize( 186 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::initialize(
187 ItemProperty* newItem) { 187 ItemProperty* newItem) {
188 // Spec: Clears all existing current items from the list and re-initializes th e list to hold the single item specified by the parameter. 188 // Spec: Clears all existing current items from the list and re-initializes
189 // the list to hold the single item specified by the parameter.
189 clear(); 190 clear();
190 append(newItem); 191 append(newItem);
191 return newItem; 192 return newItem;
192 } 193 }
193 194
194 template <typename Derived, typename ItemProperty> 195 template <typename Derived, typename ItemProperty>
195 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::getItem( 196 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::getItem(
196 size_t index, 197 size_t index,
197 ExceptionState& exceptionState) { 198 ExceptionState& exceptionState) {
198 if (!checkIndexBound(index, exceptionState)) 199 if (!checkIndexBound(index, exceptionState))
199 return nullptr; 200 return nullptr;
200 201
201 ASSERT(index < m_values.size()); 202 ASSERT(index < m_values.size());
202 ASSERT(m_values.at(index)->ownerList() == this); 203 ASSERT(m_values.at(index)->ownerList() == this);
203 return m_values.at(index); 204 return m_values.at(index);
204 } 205 }
205 206
206 template <typename Derived, typename ItemProperty> 207 template <typename Derived, typename ItemProperty>
207 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::insertItemBefore( 208 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::insertItemBefore(
208 ItemProperty* newItem, 209 ItemProperty* newItem,
209 size_t index) { 210 size_t index) {
210 // Spec: If the index is greater than or equal to length, then the new item is appended to the end of the list. 211 // Spec: If the index is greater than or equal to length, then the new item is
212 // appended to the end of the list.
211 if (index > m_values.size()) 213 if (index > m_values.size())
212 index = m_values.size(); 214 index = m_values.size();
213 215
214 // Spec: Inserts a new item into the list at the specified position. The index of the item before which the new item is to be 216 // Spec: Inserts a new item into the list at the specified position. The index
215 // inserted. The first item is number 0. If the index is equal to 0, then the new item is inserted at the front of the list. 217 // of the item before which the new item is to be inserted. The first item is
218 // number 0. If the index is equal to 0, then the new item is inserted at the
219 // front of the list.
216 m_values.insert(index, newItem); 220 m_values.insert(index, newItem);
217 newItem->setOwnerList(this); 221 newItem->setOwnerList(this);
218 222
219 return newItem; 223 return newItem;
220 } 224 }
221 225
222 template <typename Derived, typename ItemProperty> 226 template <typename Derived, typename ItemProperty>
223 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::removeItem( 227 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::removeItem(
224 size_t index, 228 size_t index,
225 ExceptionState& exceptionState) { 229 ExceptionState& exceptionState) {
(...skipping 21 matching lines...) Expand all
247 251
248 template <typename Derived, typename ItemProperty> 252 template <typename Derived, typename ItemProperty>
249 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::replaceItem( 253 ItemProperty* SVGListPropertyHelper<Derived, ItemProperty>::replaceItem(
250 ItemProperty* newItem, 254 ItemProperty* newItem,
251 size_t index, 255 size_t index,
252 ExceptionState& exceptionState) { 256 ExceptionState& exceptionState) {
253 if (!checkIndexBound(index, exceptionState)) 257 if (!checkIndexBound(index, exceptionState))
254 return nullptr; 258 return nullptr;
255 259
256 if (m_values.isEmpty()) { 260 if (m_values.isEmpty()) {
257 // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace. 261 // 'newItem' already lived in our list, we removed it, and now we're empty,
262 // which means there's nothing to replace.
258 exceptionState.throwDOMException( 263 exceptionState.throwDOMException(
259 IndexSizeError, 264 IndexSizeError,
260 String::format("Failed to replace the provided item at index %zu.", 265 String::format("Failed to replace the provided item at index %zu.",
261 index)); 266 index));
262 return nullptr; 267 return nullptr;
263 } 268 }
264 269
265 // Update the value at the desired position 'index'. 270 // Update the value at the desired position 'index'.
266 Member<ItemPropertyType>& position = m_values[index]; 271 Member<ItemPropertyType>& position = m_values[index];
267 ASSERT(position->ownerList() == this); 272 ASSERT(position->ownerList() == this);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 bool SVGListPropertyHelper<Derived, ItemProperty>::adjustFromToListValues( 313 bool SVGListPropertyHelper<Derived, ItemProperty>::adjustFromToListValues(
309 Derived* fromList, 314 Derived* fromList,
310 Derived* toList, 315 Derived* toList,
311 float percentage, 316 float percentage,
312 AnimationMode mode) { 317 AnimationMode mode) {
313 // If no 'to' value is given, nothing to animate. 318 // If no 'to' value is given, nothing to animate.
314 size_t toListSize = toList->length(); 319 size_t toListSize = toList->length();
315 if (!toListSize) 320 if (!toListSize)
316 return false; 321 return false;
317 322
318 // If the 'from' value is given and it's length doesn't match the 'to' value l ist length, fallback to a discrete animation. 323 // If the 'from' value is given and it's length doesn't match the 'to' value
324 // list length, fallback to a discrete animation.
319 size_t fromListSize = fromList->length(); 325 size_t fromListSize = fromList->length();
320 if (fromListSize != toListSize && fromListSize) { 326 if (fromListSize != toListSize && fromListSize) {
321 if (percentage < 0.5) { 327 if (percentage < 0.5) {
322 if (mode != ToAnimation) 328 if (mode != ToAnimation)
323 deepCopy(fromList); 329 deepCopy(fromList);
324 } else { 330 } else {
325 deepCopy(toList); 331 deepCopy(toList);
326 } 332 }
327 333
328 return false; 334 return false;
329 } 335 }
330 336
331 ASSERT(!fromListSize || fromListSize == toListSize); 337 ASSERT(!fromListSize || fromListSize == toListSize);
332 if (length() < toListSize) { 338 if (length() < toListSize) {
333 size_t paddingCount = toListSize - length(); 339 size_t paddingCount = toListSize - length();
334 for (size_t i = 0; i < paddingCount; ++i) 340 for (size_t i = 0; i < paddingCount; ++i)
335 append(createPaddingItem()); 341 append(createPaddingItem());
336 } 342 }
337 343
338 return true; 344 return true;
339 } 345 }
340 346
341 } // namespace blink 347 } // namespace blink
342 348
343 #endif // SVGListPropertyHelper_h 349 #endif // SVGListPropertyHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698