| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef NewSVGListPropertyTearOffHelper_h | 31 #ifndef SVGListPropertyTearOffHelper_h |
| 32 #define NewSVGListPropertyTearOffHelper_h | 32 #define SVGListPropertyTearOffHelper_h |
| 33 | 33 |
| 34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
| 35 #include "core/svg/properties/NewSVGPropertyTearOff.h" | 35 #include "core/svg/properties/SVGPropertyTearOff.h" |
| 36 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
| 37 #include "wtf/TypeTraits.h" | 37 #include "wtf/TypeTraits.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 template<typename ItemProperty> | 41 template<typename ItemProperty> |
| 42 class ListItemPropertyTraits { | 42 class ListItemPropertyTraits { |
| 43 public: | 43 public: |
| 44 typedef ItemProperty ItemPropertyType; | 44 typedef ItemProperty ItemPropertyType; |
| 45 typedef typename ItemPropertyType::TearOffType ItemTearOffType; | 45 typedef typename ItemPropertyType::TearOffType ItemTearOffType; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 return newItem->target(); | 64 return newItem->target(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 static PassRefPtr<ItemTearOffType> createTearOff(PassRefPtr<ItemPropertyType
> value, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, co
nst QualifiedName& attributeName) | 67 static PassRefPtr<ItemTearOffType> createTearOff(PassRefPtr<ItemPropertyType
> value, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, co
nst QualifiedName& attributeName) |
| 68 { | 68 { |
| 69 return ItemTearOffType::create(value, contextElement, propertyIsAnimVal,
attributeName); | 69 return ItemTearOffType::create(value, contextElement, propertyIsAnimVal,
attributeName); |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 template<typename Derived, typename ListProperty> | 73 template<typename Derived, typename ListProperty> |
| 74 class NewSVGListPropertyTearOffHelper : public NewSVGPropertyTearOff<ListPropert
y> { | 74 class SVGListPropertyTearOffHelper : public SVGPropertyTearOff<ListProperty> { |
| 75 public: | 75 public: |
| 76 typedef ListProperty ListPropertyType; | 76 typedef ListProperty ListPropertyType; |
| 77 typedef typename ListPropertyType::ItemPropertyType ItemPropertyType; | 77 typedef typename ListPropertyType::ItemPropertyType ItemPropertyType; |
| 78 typedef typename ItemPropertyType::TearOffType ItemTearOffType; | 78 typedef typename ItemPropertyType::TearOffType ItemTearOffType; |
| 79 typedef ListItemPropertyTraits<ItemPropertyType> ItemTraits; | 79 typedef ListItemPropertyTraits<ItemPropertyType> ItemTraits; |
| 80 | 80 |
| 81 // SVG*List DOM interface: | 81 // SVG*List DOM interface: |
| 82 | 82 |
| 83 // WebIDL requires "unsigned long" type instead of size_t. | 83 // WebIDL requires "unsigned long" type instead of size_t. |
| 84 unsigned long length() | 84 unsigned long length() |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return nullptr; | 190 return nullptr; |
| 191 } | 191 } |
| 192 | 192 |
| 193 RefPtr<ItemPropertyType> value = toDerived()->target()->appendItem(getVa
lueForInsertionFromTearOff(item)); | 193 RefPtr<ItemPropertyType> value = toDerived()->target()->appendItem(getVa
lueForInsertionFromTearOff(item)); |
| 194 toDerived()->commitChange(); | 194 toDerived()->commitChange(); |
| 195 | 195 |
| 196 return createItemTearOff(value.release()); | 196 return createItemTearOff(value.release()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 protected: | 199 protected: |
| 200 NewSVGListPropertyTearOffHelper(PassRefPtr<ListPropertyType> target, SVGElem
ent* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedNam
e& attributeName = nullQName()) | 200 SVGListPropertyTearOffHelper(PassRefPtr<ListPropertyType> target, SVGElement
* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName&
attributeName = nullQName()) |
| 201 : NewSVGPropertyTearOff<ListPropertyType>(target, contextElement, proper
tyIsAnimVal, attributeName) | 201 : SVGPropertyTearOff<ListPropertyType>(target, contextElement, propertyI
sAnimVal, attributeName) |
| 202 { | 202 { |
| 203 } | 203 } |
| 204 | 204 |
| 205 static PassRefPtr<ItemPropertyType> getValueForInsertionFromTearOff(PassRefP
tr<ItemTearOffType> passNewItem) | 205 static PassRefPtr<ItemPropertyType> getValueForInsertionFromTearOff(PassRefP
tr<ItemTearOffType> passNewItem) |
| 206 { | 206 { |
| 207 return ItemTraits::getValueForInsertionFromTearOff(passNewItem); | 207 return ItemTraits::getValueForInsertionFromTearOff(passNewItem); |
| 208 } | 208 } |
| 209 | 209 |
| 210 PassRefPtr<ItemTearOffType> createItemTearOff(PassRefPtr<ItemPropertyType> v
alue) | 210 PassRefPtr<ItemTearOffType> createItemTearOff(PassRefPtr<ItemPropertyType> v
alue) |
| 211 { | 211 { |
| 212 if (!value) | 212 if (!value) |
| 213 return nullptr; | 213 return nullptr; |
| 214 | 214 |
| 215 return ItemTraits::createTearOff(value, toDerived()->contextElement(), t
oDerived()->propertyIsAnimVal(), toDerived()->attributeName()); | 215 return ItemTraits::createTearOff(value, toDerived()->contextElement(), t
oDerived()->propertyIsAnimVal(), toDerived()->attributeName()); |
| 216 } | 216 } |
| 217 | 217 |
| 218 private: | 218 private: |
| 219 Derived* toDerived() { return static_cast<Derived*>(this); } | 219 Derived* toDerived() { return static_cast<Derived*>(this); } |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 } | 222 } |
| 223 | 223 |
| 224 #endif // NewSVGListPropertyTearOffHelper_h | 224 #endif // SVGListPropertyTearOffHelper_h |
| OLD | NEW |