| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 class SVGListPropertyHelper : public SVGPropertyHelper<Derived> { | 47 class SVGListPropertyHelper : public SVGPropertyHelper<Derived> { |
| 48 public: | 48 public: |
| 49 typedef ItemProperty ItemPropertyType; | 49 typedef ItemProperty ItemPropertyType; |
| 50 | 50 |
| 51 SVGListPropertyHelper() | 51 SVGListPropertyHelper() |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 ~SVGListPropertyHelper() | 55 ~SVGListPropertyHelper() |
| 56 { | 56 { |
| 57 #if !ENABLE(OILPAN) |
| 57 clear(); | 58 clear(); |
| 59 #endif |
| 58 } | 60 } |
| 59 | 61 |
| 60 // used from Blink C++ code: | 62 // used from Blink C++ code: |
| 61 | 63 |
| 62 ItemPropertyType* at(size_t index) | 64 ItemPropertyType* at(size_t index) |
| 63 { | 65 { |
| 64 ASSERT(index < m_values.size()); | 66 ASSERT(index < m_values.size()); |
| 65 ASSERT(m_values.at(index)->ownerList() == this); | 67 ASSERT(m_values.at(index)->ownerList() == this); |
| 66 return m_values.at(index).get(); | 68 return m_values.at(index).get(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 const ItemPropertyType* at(size_t index) const | 71 const ItemPropertyType* at(size_t index) const |
| 70 { | 72 { |
| 71 return const_cast<SVGListPropertyHelper<Derived, ItemProperty>*>(this)->
at(index); | 73 return const_cast<SVGListPropertyHelper<Derived, ItemProperty>*>(this)->
at(index); |
| 72 } | 74 } |
| 73 | 75 |
| 74 class ConstIterator { | 76 class ConstIterator { |
| 75 private: | 77 private: |
| 76 typedef typename Vector<RefPtr<ItemPropertyType> >::const_iterator Wrapp
edType; | 78 typedef typename WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType> >
::const_iterator WrappedType; |
| 77 | 79 |
| 78 public: | 80 public: |
| 79 ConstIterator(WrappedType it) | 81 ConstIterator(WrappedType it) |
| 80 : m_it(it) | 82 : m_it(it) |
| 81 { | 83 { |
| 82 } | 84 } |
| 83 | 85 |
| 84 ConstIterator& operator++() { ++m_it; return *this; } | 86 ConstIterator& operator++() { ++m_it; return *this; } |
| 85 | 87 |
| 86 bool operator==(const ConstIterator& o) const { return m_it == o.m_it; } | 88 bool operator==(const ConstIterator& o) const { return m_it == o.m_it; } |
| 87 bool operator!=(const ConstIterator& o) const { return m_it != o.m_it; } | 89 bool operator!=(const ConstIterator& o) const { return m_it != o.m_it; } |
| 88 | 90 |
| 89 PassRefPtr<ItemPropertyType> operator*() { return *m_it; } | 91 PassRefPtrWillBeRawPtr<ItemPropertyType> operator*() { return *m_it; } |
| 90 PassRefPtr<ItemPropertyType> operator->() { return *m_it; } | 92 PassRefPtrWillBeRawPtr<ItemPropertyType> operator->() { return *m_it; } |
| 91 | 93 |
| 92 private: | 94 private: |
| 93 WrappedType m_it; | 95 WrappedType m_it; |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 ConstIterator begin() const | 98 ConstIterator begin() const |
| 97 { | 99 { |
| 98 return ConstIterator(m_values.begin()); | 100 return ConstIterator(m_values.begin()); |
| 99 } | 101 } |
| 100 | 102 |
| 101 ConstIterator lastAppended() const | 103 ConstIterator lastAppended() const |
| 102 { | 104 { |
| 103 return ConstIterator(m_values.begin() + m_values.size() - 1); | 105 return ConstIterator(m_values.begin() + m_values.size() - 1); |
| 104 } | 106 } |
| 105 | 107 |
| 106 ConstIterator end() const | 108 ConstIterator end() const |
| 107 { | 109 { |
| 108 return ConstIterator(m_values.end()); | 110 return ConstIterator(m_values.end()); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void append(PassRefPtr<ItemPropertyType> passNewItem) | 113 void append(PassRefPtrWillBeRawPtr<ItemPropertyType> passNewItem) |
| 112 { | 114 { |
| 113 RefPtr<ItemPropertyType> newItem = passNewItem; | 115 RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem; |
| 114 | 116 |
| 115 ASSERT(newItem); | 117 ASSERT(newItem); |
| 116 m_values.append(newItem); | 118 m_values.append(newItem); |
| 117 newItem->setOwnerList(this); | 119 newItem->setOwnerList(this); |
| 118 } | 120 } |
| 119 | 121 |
| 120 bool operator==(const Derived&) const; | 122 bool operator==(const Derived&) const; |
| 121 bool operator!=(const Derived& other) const | 123 bool operator!=(const Derived& other) const |
| 122 { | 124 { |
| 123 return !(*this == other); | 125 return !(*this == other); |
| 124 } | 126 } |
| 125 | 127 |
| 126 bool isEmpty() const | 128 bool isEmpty() const |
| 127 { | 129 { |
| 128 return !length(); | 130 return !length(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 virtual PassRefPtr<Derived> clone() | 133 virtual PassRefPtrWillBeRawPtr<Derived> clone() |
| 132 { | 134 { |
| 133 RefPtr<Derived> svgList = Derived::create(); | 135 RefPtrWillBeRawPtr<Derived> svgList = Derived::create(); |
| 134 svgList->deepCopy(static_cast<Derived*>(this)); | 136 svgList->deepCopy(static_cast<Derived*>(this)); |
| 135 return svgList.release(); | 137 return svgList.release(); |
| 136 } | 138 } |
| 137 | 139 |
| 138 // SVGList*Property DOM spec: | 140 // SVGList*Property DOM spec: |
| 139 | 141 |
| 140 size_t length() const | 142 size_t length() const |
| 141 { | 143 { |
| 142 return m_values.size(); | 144 return m_values.size(); |
| 143 } | 145 } |
| 144 | 146 |
| 145 void clear(); | 147 void clear(); |
| 146 | 148 |
| 147 PassRefPtr<ItemPropertyType> initialize(PassRefPtr<ItemPropertyType>); | 149 PassRefPtrWillBeRawPtr<ItemPropertyType> initialize(PassRefPtrWillBeRawPtr<I
temPropertyType>); |
| 148 PassRefPtr<ItemPropertyType> getItem(size_t, ExceptionState&); | 150 PassRefPtrWillBeRawPtr<ItemPropertyType> getItem(size_t, ExceptionState&); |
| 149 PassRefPtr<ItemPropertyType> insertItemBefore(PassRefPtr<ItemPropertyType>,
size_t); | 151 PassRefPtrWillBeRawPtr<ItemPropertyType> insertItemBefore(PassRefPtrWillBeRa
wPtr<ItemPropertyType>, size_t); |
| 150 PassRefPtr<ItemPropertyType> removeItem(size_t, ExceptionState&); | 152 PassRefPtrWillBeRawPtr<ItemPropertyType> removeItem(size_t, ExceptionState&)
; |
| 151 PassRefPtr<ItemPropertyType> appendItem(PassRefPtr<ItemPropertyType>); | 153 PassRefPtrWillBeRawPtr<ItemPropertyType> appendItem(PassRefPtrWillBeRawPtr<I
temPropertyType>); |
| 152 PassRefPtr<ItemPropertyType> replaceItem(PassRefPtr<ItemPropertyType>, size_
t, ExceptionState&); | 154 PassRefPtrWillBeRawPtr<ItemPropertyType> replaceItem(PassRefPtrWillBeRawPtr<
ItemPropertyType>, size_t, ExceptionState&); |
| 155 |
| 156 virtual void trace(Visitor* visitor) override |
| 157 { |
| 158 visitor->trace(m_values); |
| 159 SVGPropertyHelper<Derived>::trace(visitor); |
| 160 } |
| 153 | 161 |
| 154 protected: | 162 protected: |
| 155 void deepCopy(PassRefPtr<Derived>); | 163 void deepCopy(PassRefPtrWillBeRawPtr<Derived>); |
| 156 | 164 |
| 157 bool adjustFromToListValues(PassRefPtr<Derived> fromList, PassRefPtr<Derived
> toList, float percentage, AnimationMode); | 165 bool adjustFromToListValues(PassRefPtrWillBeRawPtr<Derived> fromList, PassRe
fPtrWillBeRawPtr<Derived> toList, float percentage, AnimationMode); |
| 158 | 166 |
| 159 virtual PassRefPtr<ItemPropertyType> createPaddingItem() const | 167 virtual PassRefPtrWillBeRawPtr<ItemPropertyType> createPaddingItem() const |
| 160 { | 168 { |
| 161 return ItemPropertyType::create(); | 169 return ItemPropertyType::create(); |
| 162 } | 170 } |
| 163 | 171 |
| 164 private: | 172 private: |
| 165 inline bool checkIndexBound(size_t, ExceptionState&); | 173 inline bool checkIndexBound(size_t, ExceptionState&); |
| 166 bool removeFromOldOwnerListAndAdjustIndex(PassRefPtr<ItemPropertyType>, size
_t* indexToModify); | 174 bool removeFromOldOwnerListAndAdjustIndex(PassRefPtrWillBeRawPtr<ItemPropert
yType>, size_t* indexToModify); |
| 167 size_t findItem(PassRefPtr<ItemPropertyType>); | 175 size_t findItem(PassRefPtrWillBeRawPtr<ItemPropertyType>); |
| 168 | 176 |
| 169 Vector<RefPtr<ItemPropertyType> > m_values; | 177 WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType> > m_values; |
| 170 | 178 |
| 171 static PassRefPtr<Derived> toDerived(PassRefPtr<SVGPropertyBase> passBase) | 179 static PassRefPtrWillBeRawPtr<Derived> toDerived(PassRefPtrWillBeRawPtr<SVGP
ropertyBase> passBase) |
| 172 { | 180 { |
| 173 if (!passBase) | 181 if (!passBase) |
| 174 return nullptr; | 182 return nullptr; |
| 175 | 183 |
| 176 RefPtr<SVGPropertyBase> base = passBase; | 184 RefPtrWillBeRawPtr<SVGPropertyBase> base = passBase; |
| 177 ASSERT(base->type() == Derived::classType()); | 185 ASSERT(base->type() == Derived::classType()); |
| 178 return static_pointer_cast<Derived>(base); | 186 return static_pointer_cast<Derived>(base); |
| 179 } | 187 } |
| 180 }; | 188 }; |
| 181 | 189 |
| 182 template<typename Derived, typename ItemProperty> | 190 template<typename Derived, typename ItemProperty> |
| 183 bool SVGListPropertyHelper<Derived, ItemProperty>::operator==(const Derived& oth
er) const | 191 bool SVGListPropertyHelper<Derived, ItemProperty>::operator==(const Derived& oth
er) const |
| 184 { | 192 { |
| 185 if (length() != other.length()) | 193 if (length() != other.length()) |
| 186 return false; | 194 return false; |
| 187 | 195 |
| 188 size_t size = length(); | 196 size_t size = length(); |
| 189 for (size_t i = 0; i < size; ++i) { | 197 for (size_t i = 0; i < size; ++i) { |
| 190 if (*at(i) != *other.at(i)) | 198 if (*at(i) != *other.at(i)) |
| 191 return false; | 199 return false; |
| 192 } | 200 } |
| 193 | 201 |
| 194 return true; | 202 return true; |
| 195 } | 203 } |
| 196 | 204 |
| 197 template<typename Derived, typename ItemProperty> | 205 template<typename Derived, typename ItemProperty> |
| 198 void SVGListPropertyHelper<Derived, ItemProperty>::clear() | 206 void SVGListPropertyHelper<Derived, ItemProperty>::clear() |
| 199 { | 207 { |
| 200 // detach all list items as they are no longer part of this list | 208 // detach all list items as they are no longer part of this list |
| 201 typename Vector<RefPtr<ItemPropertyType> >::const_iterator it = m_values.beg
in(); | 209 typename WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType> >::const_iter
ator it = m_values.begin(); |
| 202 typename Vector<RefPtr<ItemPropertyType> >::const_iterator itEnd = m_values.
end(); | 210 typename WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType> >::const_iter
ator itEnd = m_values.end(); |
| 203 for (; it != itEnd; ++it) { | 211 for (; it != itEnd; ++it) { |
| 204 ASSERT((*it)->ownerList() == this); | 212 ASSERT((*it)->ownerList() == this); |
| 205 (*it)->setOwnerList(0); | 213 (*it)->setOwnerList(0); |
| 206 } | 214 } |
| 207 | 215 |
| 208 m_values.clear(); | 216 m_values.clear(); |
| 209 } | 217 } |
| 210 | 218 |
| 211 template<typename Derived, typename ItemProperty> | 219 template<typename Derived, typename ItemProperty> |
| 212 PassRefPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty>::initializ
e(PassRefPtr<ItemProperty> passNewItem) | 220 PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
>::initialize(PassRefPtrWillBeRawPtr<ItemProperty> passNewItem) |
| 213 { | 221 { |
| 214 RefPtr<ItemPropertyType> newItem = passNewItem; | 222 RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem; |
| 215 | 223 |
| 216 // Spec: If the inserted item is already in a list, it is removed from its p
revious list before it is inserted into this list. | 224 // Spec: If the inserted item is already in a list, it is removed from its p
revious list before it is inserted into this list. |
| 217 removeFromOldOwnerListAndAdjustIndex(newItem, 0); | 225 removeFromOldOwnerListAndAdjustIndex(newItem, 0); |
| 218 | 226 |
| 219 // Spec: Clears all existing current items from the list and re-initializes
the list to hold the single item specified by the parameter. | 227 // Spec: Clears all existing current items from the list and re-initializes
the list to hold the single item specified by the parameter. |
| 220 clear(); | 228 clear(); |
| 221 append(newItem); | 229 append(newItem); |
| 222 return newItem.release(); | 230 return newItem.release(); |
| 223 } | 231 } |
| 224 | 232 |
| 225 template<typename Derived, typename ItemProperty> | 233 template<typename Derived, typename ItemProperty> |
| 226 PassRefPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty>::getItem(s
ize_t index, ExceptionState& exceptionState) | 234 PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
>::getItem(size_t index, ExceptionState& exceptionState) |
| 227 { | 235 { |
| 228 if (!checkIndexBound(index, exceptionState)) | 236 if (!checkIndexBound(index, exceptionState)) |
| 229 return nullptr; | 237 return nullptr; |
| 230 | 238 |
| 231 ASSERT(index < m_values.size()); | 239 ASSERT(index < m_values.size()); |
| 232 ASSERT(m_values.at(index)->ownerList() == this); | 240 ASSERT(m_values.at(index)->ownerList() == this); |
| 233 return m_values.at(index); | 241 return m_values.at(index); |
| 234 } | 242 } |
| 235 | 243 |
| 236 template<typename Derived, typename ItemProperty> | 244 template<typename Derived, typename ItemProperty> |
| 237 PassRefPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty>::insertIte
mBefore(PassRefPtr<ItemProperty> passNewItem, size_t index) | 245 PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
>::insertItemBefore(PassRefPtrWillBeRawPtr<ItemProperty> passNewItem, size_t ind
ex) |
| 238 { | 246 { |
| 239 // Spec: If the index is greater than or equal to length, then the new item
is appended to the end of the list. | 247 // Spec: If the index is greater than or equal to length, then the new item
is appended to the end of the list. |
| 240 if (index > m_values.size()) | 248 if (index > m_values.size()) |
| 241 index = m_values.size(); | 249 index = m_values.size(); |
| 242 | 250 |
| 243 RefPtr<ItemPropertyType> newItem = passNewItem; | 251 RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem; |
| 244 | 252 |
| 245 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. | 253 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. |
| 246 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { | 254 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { |
| 247 // Inserting the item before itself is a no-op. | 255 // Inserting the item before itself is a no-op. |
| 248 return newItem.release(); | 256 return newItem.release(); |
| 249 } | 257 } |
| 250 | 258 |
| 251 // Spec: Inserts a new item into the list at the specified position. The ind
ex of the item before which the new item is to be | 259 // Spec: Inserts a new item into the list at the specified position. The ind
ex of the item before which the new item is to be |
| 252 // inserted. The first item is number 0. If the index is equal to 0, then th
e new item is inserted at the front of the list. | 260 // inserted. The first item is number 0. If the index is equal to 0, then th
e new item is inserted at the front of the list. |
| 253 m_values.insert(index, newItem); | 261 m_values.insert(index, newItem); |
| 254 newItem->setOwnerList(this); | 262 newItem->setOwnerList(this); |
| 255 | 263 |
| 256 return newItem.release(); | 264 return newItem.release(); |
| 257 } | 265 } |
| 258 | 266 |
| 259 template<typename Derived, typename ItemProperty> | 267 template<typename Derived, typename ItemProperty> |
| 260 PassRefPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty>::removeIte
m(size_t index, ExceptionState& exceptionState) | 268 PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
>::removeItem(size_t index, ExceptionState& exceptionState) |
| 261 { | 269 { |
| 262 if (index >= m_values.size()) { | 270 if (index >= m_values.size()) { |
| 263 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xExceedsMaximumBound("index", index, m_values.size())); | 271 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xExceedsMaximumBound("index", index, m_values.size())); |
| 264 return nullptr; | 272 return nullptr; |
| 265 } | 273 } |
| 266 ASSERT(m_values.at(index)->ownerList() == this); | 274 ASSERT(m_values.at(index)->ownerList() == this); |
| 267 RefPtr<ItemPropertyType> oldItem = m_values.at(index); | 275 RefPtrWillBeRawPtr<ItemPropertyType> oldItem = m_values.at(index); |
| 268 m_values.remove(index); | 276 m_values.remove(index); |
| 269 oldItem->setOwnerList(0); | 277 oldItem->setOwnerList(0); |
| 270 return oldItem.release(); | 278 return oldItem.release(); |
| 271 } | 279 } |
| 272 | 280 |
| 273 template<typename Derived, typename ItemProperty> | 281 template<typename Derived, typename ItemProperty> |
| 274 PassRefPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty>::appendIte
m(PassRefPtr<ItemProperty> passNewItem) | 282 PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
>::appendItem(PassRefPtrWillBeRawPtr<ItemProperty> passNewItem) |
| 275 { | 283 { |
| 276 RefPtr<ItemPropertyType> newItem = passNewItem; | 284 RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem; |
| 277 | 285 |
| 278 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. | 286 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. |
| 279 removeFromOldOwnerListAndAdjustIndex(newItem, 0); | 287 removeFromOldOwnerListAndAdjustIndex(newItem, 0); |
| 280 | 288 |
| 281 // Append the value and wrapper at the end of the list. | 289 // Append the value and wrapper at the end of the list. |
| 282 append(newItem); | 290 append(newItem); |
| 283 | 291 |
| 284 return newItem.release(); | 292 return newItem.release(); |
| 285 } | 293 } |
| 286 | 294 |
| 287 template<typename Derived, typename ItemProperty> | 295 template<typename Derived, typename ItemProperty> |
| 288 PassRefPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty>::replaceIt
em(PassRefPtr<ItemProperty> passNewItem, size_t index, ExceptionState& exception
State) | 296 PassRefPtrWillBeRawPtr<ItemProperty> SVGListPropertyHelper<Derived, ItemProperty
>::replaceItem(PassRefPtrWillBeRawPtr<ItemProperty> passNewItem, size_t index, E
xceptionState& exceptionState) |
| 289 { | 297 { |
| 290 if (!checkIndexBound(index, exceptionState)) | 298 if (!checkIndexBound(index, exceptionState)) |
| 291 return nullptr; | 299 return nullptr; |
| 292 | 300 |
| 293 RefPtr<ItemPropertyType> newItem = passNewItem; | 301 RefPtrWillBeRawPtr<ItemPropertyType> newItem = passNewItem; |
| 294 | 302 |
| 295 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. | 303 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. |
| 296 // 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. | 304 // 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. |
| 297 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { | 305 if (!removeFromOldOwnerListAndAdjustIndex(newItem, &index)) { |
| 298 // Replacing the item with itself is a no-op. | 306 // Replacing the item with itself is a no-op. |
| 299 return newItem.release(); | 307 return newItem.release(); |
| 300 } | 308 } |
| 301 | 309 |
| 302 if (m_values.isEmpty()) { | 310 if (m_values.isEmpty()) { |
| 303 // 'newItem' already lived in our list, we removed it, and now we're emp
ty, which means there's nothing to replace. | 311 // 'newItem' already lived in our list, we removed it, and now we're emp
ty, which means there's nothing to replace. |
| 304 exceptionState.throwDOMException(IndexSizeError, String::format("Failed
to replace the provided item at index %zu.", index)); | 312 exceptionState.throwDOMException(IndexSizeError, String::format("Failed
to replace the provided item at index %zu.", index)); |
| 305 return nullptr; | 313 return nullptr; |
| 306 } | 314 } |
| 307 | 315 |
| 308 // Update the value at the desired position 'index'. | 316 // Update the value at the desired position 'index'. |
| 309 RefPtr<ItemPropertyType>& position = m_values[index]; | 317 RefPtrWillBeMember<ItemPropertyType>& position = m_values[index]; |
| 310 ASSERT(position->ownerList() == this); | 318 ASSERT(position->ownerList() == this); |
| 311 position->setOwnerList(0); | 319 position->setOwnerList(0); |
| 312 position = newItem; | 320 position = newItem; |
| 313 newItem->setOwnerList(this); | 321 newItem->setOwnerList(this); |
| 314 | 322 |
| 315 return newItem.release(); | 323 return newItem.release(); |
| 316 } | 324 } |
| 317 | 325 |
| 318 template<typename Derived, typename ItemProperty> | 326 template<typename Derived, typename ItemProperty> |
| 319 bool SVGListPropertyHelper<Derived, ItemProperty>::checkIndexBound(size_t index,
ExceptionState& exceptionState) | 327 bool SVGListPropertyHelper<Derived, ItemProperty>::checkIndexBound(size_t index,
ExceptionState& exceptionState) |
| 320 { | 328 { |
| 321 if (index >= m_values.size()) { | 329 if (index >= m_values.size()) { |
| 322 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xExceedsMaximumBound("index", index, m_values.size())); | 330 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xExceedsMaximumBound("index", index, m_values.size())); |
| 323 return false; | 331 return false; |
| 324 } | 332 } |
| 325 | 333 |
| 326 return true; | 334 return true; |
| 327 } | 335 } |
| 328 | 336 |
| 329 template<typename Derived, typename ItemProperty> | 337 template<typename Derived, typename ItemProperty> |
| 330 bool SVGListPropertyHelper<Derived, ItemProperty>::removeFromOldOwnerListAndAdju
stIndex(PassRefPtr<ItemPropertyType> passItem, size_t* indexToModify) | 338 bool SVGListPropertyHelper<Derived, ItemProperty>::removeFromOldOwnerListAndAdju
stIndex(PassRefPtrWillBeRawPtr<ItemPropertyType> passItem, size_t* indexToModify
) |
| 331 { | 339 { |
| 332 RefPtr<ItemPropertyType> item = passItem; | 340 RefPtrWillBeRawPtr<ItemPropertyType> item = passItem; |
| 333 ASSERT(item); | 341 ASSERT(item); |
| 334 RefPtr<Derived> ownerList = toDerived(item->ownerList()); | 342 RefPtrWillBeRawPtr<Derived> ownerList = toDerived(item->ownerList()); |
| 335 if (!ownerList) | 343 if (!ownerList) |
| 336 return true; | 344 return true; |
| 337 | 345 |
| 338 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. | 346 // Spec: If newItem is already in a list, it is removed from its previous li
st before it is inserted into this list. |
| 339 // 'newItem' is already living in another list. If it's not our list, synchr
onize the other lists wrappers after the removal. | 347 // 'newItem' is already living in another list. If it's not our list, synchr
onize the other lists wrappers after the removal. |
| 340 bool livesInOtherList = ownerList.get() != this; | 348 bool livesInOtherList = ownerList.get() != this; |
| 341 size_t indexToRemove = ownerList->findItem(item); | 349 size_t indexToRemove = ownerList->findItem(item); |
| 342 ASSERT(indexToRemove != WTF::kNotFound); | 350 ASSERT(indexToRemove != WTF::kNotFound); |
| 343 | 351 |
| 344 // Do not remove newItem if already in this list at the target index. | 352 // Do not remove newItem if already in this list at the target index. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 355 size_t& index = *indexToModify; | 363 size_t& index = *indexToModify; |
| 356 // 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. | 364 // 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. |
| 357 if (static_cast<size_t>(indexToRemove) < index) | 365 if (static_cast<size_t>(indexToRemove) < index) |
| 358 --index; | 366 --index; |
| 359 } | 367 } |
| 360 | 368 |
| 361 return true; | 369 return true; |
| 362 } | 370 } |
| 363 | 371 |
| 364 template<typename Derived, typename ItemProperty> | 372 template<typename Derived, typename ItemProperty> |
| 365 size_t SVGListPropertyHelper<Derived, ItemProperty>::findItem(PassRefPtr<ItemPro
pertyType> item) | 373 size_t SVGListPropertyHelper<Derived, ItemProperty>::findItem(PassRefPtrWillBeRa
wPtr<ItemPropertyType> item) |
| 366 { | 374 { |
| 367 return m_values.find(item); | 375 return m_values.find(item); |
| 368 } | 376 } |
| 369 | 377 |
| 370 template<typename Derived, typename ItemProperty> | 378 template<typename Derived, typename ItemProperty> |
| 371 void SVGListPropertyHelper<Derived, ItemProperty>::deepCopy(PassRefPtr<Derived>
passFrom) | 379 void SVGListPropertyHelper<Derived, ItemProperty>::deepCopy(PassRefPtrWillBeRawP
tr<Derived> passFrom) |
| 372 { | 380 { |
| 373 RefPtr<Derived> from = passFrom; | 381 RefPtrWillBeRawPtr<Derived> from = passFrom; |
| 374 | 382 |
| 375 clear(); | 383 clear(); |
| 376 typename Vector<RefPtr<ItemPropertyType> >::const_iterator it = from->m_valu
es.begin(); | 384 typename WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType> >::const_iter
ator it = from->m_values.begin(); |
| 377 typename Vector<RefPtr<ItemPropertyType> >::const_iterator itEnd = from->m_v
alues.end(); | 385 typename WillBeHeapVector<RefPtrWillBeMember<ItemPropertyType> >::const_iter
ator itEnd = from->m_values.end(); |
| 378 for (; it != itEnd; ++it) { | 386 for (; it != itEnd; ++it) { |
| 379 append((*it)->clone()); | 387 append((*it)->clone()); |
| 380 } | 388 } |
| 381 } | 389 } |
| 382 | 390 |
| 383 template<typename Derived, typename ItemProperty> | 391 template<typename Derived, typename ItemProperty> |
| 384 bool SVGListPropertyHelper<Derived, ItemProperty>::adjustFromToListValues(PassRe
fPtr<Derived> passFromList, PassRefPtr<Derived> passToList, float percentage, An
imationMode mode) | 392 bool SVGListPropertyHelper<Derived, ItemProperty>::adjustFromToListValues(PassRe
fPtrWillBeRawPtr<Derived> passFromList, PassRefPtrWillBeRawPtr<Derived> passToLi
st, float percentage, AnimationMode mode) |
| 385 { | 393 { |
| 386 RefPtr<Derived> fromList = passFromList; | 394 RefPtrWillBeRawPtr<Derived> fromList = passFromList; |
| 387 RefPtr<Derived> toList = passToList; | 395 RefPtrWillBeRawPtr<Derived> toList = passToList; |
| 388 | 396 |
| 389 // If no 'to' value is given, nothing to animate. | 397 // If no 'to' value is given, nothing to animate. |
| 390 size_t toListSize = toList->length(); | 398 size_t toListSize = toList->length(); |
| 391 if (!toListSize) | 399 if (!toListSize) |
| 392 return false; | 400 return false; |
| 393 | 401 |
| 394 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. | 402 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. |
| 395 size_t fromListSize = fromList->length(); | 403 size_t fromListSize = fromList->length(); |
| 396 if (fromListSize != toListSize && fromListSize) { | 404 if (fromListSize != toListSize && fromListSize) { |
| 397 if (percentage < 0.5) { | 405 if (percentage < 0.5) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 410 for (size_t i = 0; i < paddingCount; ++i) | 418 for (size_t i = 0; i < paddingCount; ++i) |
| 411 append(createPaddingItem()); | 419 append(createPaddingItem()); |
| 412 } | 420 } |
| 413 | 421 |
| 414 return true; | 422 return true; |
| 415 } | 423 } |
| 416 | 424 |
| 417 } | 425 } |
| 418 | 426 |
| 419 #endif // SVGListPropertyHelper_h | 427 #endif // SVGListPropertyHelper_h |
| OLD | NEW |