| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 PassRefPtrWillBeRawPtr<ItemTearOffType> initialize(PassRefPtrWillBeRawPtr<It
emTearOffType> passItem, ExceptionState& exceptionState) | 100 PassRefPtrWillBeRawPtr<ItemTearOffType> initialize(PassRefPtrWillBeRawPtr<It
emTearOffType> passItem, ExceptionState& exceptionState) |
| 101 { | 101 { |
| 102 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; | 102 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; |
| 103 | 103 |
| 104 if (toDerived()->isImmutable()) { | 104 if (toDerived()->isImmutable()) { |
| 105 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 105 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); |
| 106 return nullptr; | 106 return nullptr; |
| 107 } | 107 } |
| 108 | 108 |
| 109 if (!item) { | 109 ASSERT(item); |
| 110 exceptionState.throwTypeError("Lists must be initialized with a vali
d item."); | |
| 111 return nullptr; | |
| 112 } | |
| 113 | 110 |
| 114 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->init
ialize(getValueForInsertionFromTearOff(item)); | 111 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->init
ialize(getValueForInsertionFromTearOff(item)); |
| 115 toDerived()->commitChange(); | 112 toDerived()->commitChange(); |
| 116 | 113 |
| 117 return createItemTearOff(value.release()); | 114 return createItemTearOff(value.release()); |
| 118 } | 115 } |
| 119 | 116 |
| 120 PassRefPtrWillBeRawPtr<ItemTearOffType> getItem(unsigned long index, Excepti
onState& exceptionState) | 117 PassRefPtrWillBeRawPtr<ItemTearOffType> getItem(unsigned long index, Excepti
onState& exceptionState) |
| 121 { | 118 { |
| 122 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->getI
tem(index, exceptionState); | 119 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->getI
tem(index, exceptionState); |
| 123 return createItemTearOff(value.release()); | 120 return createItemTearOff(value.release()); |
| 124 } | 121 } |
| 125 | 122 |
| 126 PassRefPtrWillBeRawPtr<ItemTearOffType> insertItemBefore(PassRefPtrWillBeRaw
Ptr<ItemTearOffType> passItem, unsigned long index, ExceptionState& exceptionSta
te) | 123 PassRefPtrWillBeRawPtr<ItemTearOffType> insertItemBefore(PassRefPtrWillBeRaw
Ptr<ItemTearOffType> passItem, unsigned long index, ExceptionState& exceptionSta
te) |
| 127 { | 124 { |
| 128 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; | 125 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; |
| 129 | 126 |
| 130 if (toDerived()->isImmutable()) { | 127 if (toDerived()->isImmutable()) { |
| 131 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 128 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); |
| 132 return nullptr; | 129 return nullptr; |
| 133 } | 130 } |
| 134 | 131 |
| 135 if (!item) { | 132 ASSERT(item); |
| 136 exceptionState.throwTypeError("An invalid item cannot be inserted to
a list."); | |
| 137 return nullptr; | |
| 138 } | |
| 139 | 133 |
| 140 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->inse
rtItemBefore(getValueForInsertionFromTearOff(item), index); | 134 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->inse
rtItemBefore(getValueForInsertionFromTearOff(item), index); |
| 141 toDerived()->commitChange(); | 135 toDerived()->commitChange(); |
| 142 | 136 |
| 143 return createItemTearOff(value.release()); | 137 return createItemTearOff(value.release()); |
| 144 } | 138 } |
| 145 | 139 |
| 146 PassRefPtrWillBeRawPtr<ItemTearOffType> replaceItem(PassRefPtrWillBeRawPtr<I
temTearOffType> passItem, unsigned long index, ExceptionState& exceptionState) | 140 PassRefPtrWillBeRawPtr<ItemTearOffType> replaceItem(PassRefPtrWillBeRawPtr<I
temTearOffType> passItem, unsigned long index, ExceptionState& exceptionState) |
| 147 { | 141 { |
| 148 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; | 142 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; |
| 149 | 143 |
| 150 if (toDerived()->isImmutable()) { | 144 if (toDerived()->isImmutable()) { |
| 151 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 145 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); |
| 152 return nullptr; | 146 return nullptr; |
| 153 } | 147 } |
| 154 | 148 |
| 155 if (!item) { | 149 ASSERT(item); |
| 156 exceptionState.throwTypeError("An invalid item cannot be replaced wi
th an existing list item."); | |
| 157 return nullptr; | |
| 158 } | |
| 159 | 150 |
| 160 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->repl
aceItem(getValueForInsertionFromTearOff(item), index, exceptionState); | 151 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->repl
aceItem(getValueForInsertionFromTearOff(item), index, exceptionState); |
| 161 toDerived()->commitChange(); | 152 toDerived()->commitChange(); |
| 162 | 153 |
| 163 return createItemTearOff(value.release()); | 154 return createItemTearOff(value.release()); |
| 164 } | 155 } |
| 165 | 156 |
| 166 bool anonymousIndexedSetter(unsigned index, PassRefPtrWillBeRawPtr<ItemTearO
ffType> passItem, ExceptionState& exceptionState) | 157 bool anonymousIndexedSetter(unsigned index, PassRefPtrWillBeRawPtr<ItemTearO
ffType> passItem, ExceptionState& exceptionState) |
| 167 { | 158 { |
| 168 replaceItem(passItem, index, exceptionState); | 159 replaceItem(passItem, index, exceptionState); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 179 | 170 |
| 180 PassRefPtrWillBeRawPtr<ItemTearOffType> appendItem(PassRefPtrWillBeRawPtr<It
emTearOffType> passItem, ExceptionState& exceptionState) | 171 PassRefPtrWillBeRawPtr<ItemTearOffType> appendItem(PassRefPtrWillBeRawPtr<It
emTearOffType> passItem, ExceptionState& exceptionState) |
| 181 { | 172 { |
| 182 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; | 173 RefPtrWillBeRawPtr<ItemTearOffType> item = passItem; |
| 183 | 174 |
| 184 if (toDerived()->isImmutable()) { | 175 if (toDerived()->isImmutable()) { |
| 185 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 176 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); |
| 186 return nullptr; | 177 return nullptr; |
| 187 } | 178 } |
| 188 | 179 |
| 189 if (!item) { | 180 ASSERT(item); |
| 190 exceptionState.throwTypeError("An invalid item cannot be appended to
a list."); | |
| 191 return nullptr; | |
| 192 } | |
| 193 | 181 |
| 194 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->appe
ndItem(getValueForInsertionFromTearOff(item)); | 182 RefPtrWillBeRawPtr<ItemPropertyType> value = toDerived()->target()->appe
ndItem(getValueForInsertionFromTearOff(item)); |
| 195 toDerived()->commitChange(); | 183 toDerived()->commitChange(); |
| 196 | 184 |
| 197 return createItemTearOff(value.release()); | 185 return createItemTearOff(value.release()); |
| 198 } | 186 } |
| 199 | 187 |
| 200 protected: | 188 protected: |
| 201 SVGListPropertyTearOffHelper(PassRefPtrWillBeRawPtr<ListPropertyType> target
, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const Qua
lifiedName& attributeName = QualifiedName::null()) | 189 SVGListPropertyTearOffHelper(PassRefPtrWillBeRawPtr<ListPropertyType> target
, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const Qua
lifiedName& attributeName = QualifiedName::null()) |
| 202 : SVGPropertyTearOff<ListPropertyType>(target, contextElement, propertyI
sAnimVal, attributeName) | 190 : SVGPropertyTearOff<ListPropertyType>(target, contextElement, propertyI
sAnimVal, attributeName) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 219 return ItemTraits::createTearOff(value, 0, PropertyIsNotAnimVal, Qualifi
edName::null()); | 207 return ItemTraits::createTearOff(value, 0, PropertyIsNotAnimVal, Qualifi
edName::null()); |
| 220 } | 208 } |
| 221 | 209 |
| 222 private: | 210 private: |
| 223 Derived* toDerived() { return static_cast<Derived*>(this); } | 211 Derived* toDerived() { return static_cast<Derived*>(this); } |
| 224 }; | 212 }; |
| 225 | 213 |
| 226 } | 214 } |
| 227 | 215 |
| 228 #endif // SVGListPropertyTearOffHelper_h | 216 #endif // SVGListPropertyTearOffHelper_h |
| OLD | NEW |