OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
3 * | |
4 * This library is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU Library General Public | |
6 * License as published by the Free Software Foundation; either | |
7 * version 2 of the License, or (at your option) any later version. | |
8 * | |
9 * This library is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * Library General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU Library General Public License | |
15 * along with this library; see the file COPYING.LIB. If not, write to | |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
17 * Boston, MA 02110-1301, USA. | |
18 */ | |
19 | |
20 #ifndef SVGStaticListPropertyTearOff_h | |
21 #define SVGStaticListPropertyTearOff_h | |
22 | |
23 #include "core/svg/properties/SVGListProperty.h" | |
24 | |
25 namespace WebCore { | |
26 | |
27 class ExceptionState; | |
28 | |
29 template<typename PropertyType> | |
30 class SVGStaticListPropertyTearOff : public SVGListProperty<PropertyType> { | |
31 public: | |
32 typedef SVGListProperty<PropertyType> Base; | |
33 | |
34 typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; | |
35 typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; | |
36 | |
37 using Base::m_role; | |
38 using Base::m_values; | |
39 | |
40 static PassRefPtr<SVGStaticListPropertyTearOff<PropertyType> > create(SVGEle
ment* contextElement, PropertyType& values) | |
41 { | |
42 ASSERT(contextElement); | |
43 return adoptRef(new SVGStaticListPropertyTearOff<PropertyType>(contextEl
ement, values)); | |
44 } | |
45 | |
46 SVGElement* contextElement() const { return m_contextElement; } | |
47 | |
48 // SVGList API | |
49 void clear(ExceptionState& exceptionState) | |
50 { | |
51 Base::clearValues(exceptionState); | |
52 } | |
53 | |
54 ListItemType initialize(const ListItemType& newItem, ExceptionState& excepti
onState) | |
55 { | |
56 return Base::initializeValues(newItem, exceptionState); | |
57 } | |
58 | |
59 ListItemType getItem(unsigned index, ExceptionState& exceptionState) | |
60 { | |
61 return Base::getItemValues(index, exceptionState); | |
62 } | |
63 | |
64 ListItemType insertItemBefore(const ListItemType& newItem, unsigned index, E
xceptionState& exceptionState) | |
65 { | |
66 return Base::insertItemBeforeValues(newItem, index, exceptionState); | |
67 } | |
68 | |
69 ListItemType replaceItem(const ListItemType& newItem, unsigned index, Except
ionState& exceptionState) | |
70 { | |
71 return Base::replaceItemValues(newItem, index, exceptionState); | |
72 } | |
73 | |
74 ListItemType removeItem(unsigned index, ExceptionState& exceptionState) | |
75 { | |
76 return Base::removeItemValues(index, exceptionState); | |
77 } | |
78 | |
79 ListItemType appendItem(const ListItemType& newItem, ExceptionState& excepti
onState) | |
80 { | |
81 return Base::appendItemValues(newItem, exceptionState); | |
82 } | |
83 | |
84 private: | |
85 SVGStaticListPropertyTearOff(SVGElement* contextElement, PropertyType& value
s) | |
86 : SVGListProperty<PropertyType>(UndefinedRole, values, 0) | |
87 , m_contextElement(contextElement) | |
88 { | |
89 m_contextElement->setContextElement(); | |
90 } | |
91 | |
92 virtual void commitChange() | |
93 { | |
94 ASSERT(m_values); | |
95 ASSERT(m_contextElement); | |
96 m_values->commitChange(m_contextElement); | |
97 } | |
98 | |
99 virtual bool processIncomingListItemValue(const ListItemType&, unsigned*) | |
100 { | |
101 // no-op for static lists | |
102 return true; | |
103 } | |
104 | |
105 virtual bool processIncomingListItemWrapper(RefPtr<ListItemTearOff>&, unsign
ed*) | |
106 { | |
107 ASSERT_NOT_REACHED(); | |
108 return true; | |
109 } | |
110 | |
111 private: | |
112 SVGElement* m_contextElement; | |
113 }; | |
114 | |
115 } | |
116 | |
117 #endif // SVGStaticListPropertyTearOff_h | |
OLD | NEW |