OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 13 matching lines...) Expand all Loading... |
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 SVGStringListTearOff_h | 31 #ifndef SVGStringListTearOff_h |
32 #define SVGStringListTearOff_h | 32 #define SVGStringListTearOff_h |
33 | 33 |
34 #include "core/dom/ExceptionCode.h" | 34 #include "bindings/core/v8/ScriptWrappable.h" |
35 #include "core/svg/SVGStringList.h" | 35 #include "core/svg/SVGStringList.h" |
36 #include "core/svg/properties/SVGPropertyTearOff.h" | 36 #include "core/svg/properties/SVGPropertyTearOff.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 class SVGStringListTearOff : public SVGPropertyTearOff<SVGStringList>, public Sc
riptWrappable { | 40 class SVGStringListTearOff : public SVGPropertyTearOff<SVGStringList>, public Sc
riptWrappable { |
41 DEFINE_WRAPPERTYPEINFO(); | 41 DEFINE_WRAPPERTYPEINFO(); |
42 public: | 42 public: |
43 static SVGStringListTearOff* create(SVGStringList* target, SVGElement* conte
xtElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attribu
teName = QualifiedName::null()) | 43 static SVGStringListTearOff* create(SVGStringList* target, SVGElement* conte
xtElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attribu
teName = QualifiedName::null()) |
44 { | 44 { |
45 return new SVGStringListTearOff(target, contextElement, propertyIsAnimVa
l, attributeName); | 45 return new SVGStringListTearOff(target, contextElement, propertyIsAnimVa
l, attributeName); |
46 } | 46 } |
47 | 47 |
48 // SVGStringList DOM interface: | 48 // SVGStringList DOM interface: |
49 | 49 |
50 // WebIDL requires "unsigned long" type instead of size_t. | 50 // WebIDL requires "unsigned long" type instead of size_t. |
51 unsigned long length() | 51 unsigned long length() |
52 { | 52 { |
53 return target()->length(); | 53 return target()->length(); |
54 } | 54 } |
55 | 55 |
56 void clear(ExceptionState& exceptionState) | 56 void clear(ExceptionState& exceptionState) |
57 { | 57 { |
58 if (isImmutable()) { | 58 if (isImmutable()) { |
59 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 59 throwReadOnly(exceptionState); |
60 return; | 60 return; |
61 } | 61 } |
62 | |
63 target()->clear(); | 62 target()->clear(); |
64 commitChange(); | 63 commitChange(); |
65 } | 64 } |
66 | 65 |
67 String initialize(const String& item, ExceptionState& exceptionState) | 66 String initialize(const String& item, ExceptionState& exceptionState) |
68 { | 67 { |
69 if (isImmutable()) { | 68 if (isImmutable()) { |
70 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 69 throwReadOnly(exceptionState); |
71 return String(); | 70 return String(); |
72 } | 71 } |
73 | |
74 target()->initialize(item); | 72 target()->initialize(item); |
75 commitChange(); | 73 commitChange(); |
76 | |
77 return item; | 74 return item; |
78 } | 75 } |
79 | 76 |
80 String getItem(unsigned long index, ExceptionState& exceptionState) | 77 String getItem(unsigned long index, ExceptionState& exceptionState) |
81 { | 78 { |
82 return target()->getItem(index, exceptionState); | 79 return target()->getItem(index, exceptionState); |
83 } | 80 } |
84 | 81 |
85 String insertItemBefore(const String& item, unsigned long index, ExceptionSt
ate& exceptionState) | 82 String insertItemBefore(const String& item, unsigned long index, ExceptionSt
ate& exceptionState) |
86 { | 83 { |
87 if (isImmutable()) { | 84 if (isImmutable()) { |
88 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 85 throwReadOnly(exceptionState); |
89 return String(); | 86 return String(); |
90 } | 87 } |
91 | |
92 target()->insertItemBefore(item, index); | 88 target()->insertItemBefore(item, index); |
93 commitChange(); | 89 commitChange(); |
94 | |
95 return item; | 90 return item; |
96 } | 91 } |
97 | 92 |
98 String replaceItem(const String& item, unsigned long index, ExceptionState&
exceptionState) | 93 String replaceItem(const String& item, unsigned long index, ExceptionState&
exceptionState) |
99 { | 94 { |
100 if (isImmutable()) { | 95 if (isImmutable()) { |
101 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 96 throwReadOnly(exceptionState); |
102 return String(); | 97 return String(); |
103 } | 98 } |
104 | |
105 target()->replaceItem(item, index, exceptionState); | 99 target()->replaceItem(item, index, exceptionState); |
106 commitChange(); | 100 commitChange(); |
107 | |
108 return item; | 101 return item; |
109 } | 102 } |
110 | 103 |
111 bool anonymousIndexedSetter(unsigned index, const String& item, ExceptionSta
te& exceptionState) | 104 bool anonymousIndexedSetter(unsigned index, const String& item, ExceptionSta
te& exceptionState) |
112 { | 105 { |
113 replaceItem(item, index, exceptionState); | 106 replaceItem(item, index, exceptionState); |
114 return true; | 107 return true; |
115 } | 108 } |
116 | 109 |
117 String removeItem(unsigned long index, ExceptionState& exceptionState) | 110 String removeItem(unsigned long index, ExceptionState& exceptionState) |
118 { | 111 { |
119 if (isImmutable()) { | 112 if (isImmutable()) { |
120 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 113 throwReadOnly(exceptionState); |
121 return String(); | 114 return String(); |
122 } | 115 } |
123 | |
124 String removedItem = target()->removeItem(index, exceptionState); | 116 String removedItem = target()->removeItem(index, exceptionState); |
125 commitChange(); | 117 commitChange(); |
126 | |
127 return removedItem; | 118 return removedItem; |
128 } | 119 } |
129 | 120 |
130 String appendItem(const String& item, ExceptionState& exceptionState) | 121 String appendItem(const String& item, ExceptionState& exceptionState) |
131 { | 122 { |
132 if (isImmutable()) { | 123 if (isImmutable()) { |
133 exceptionState.throwDOMException(NoModificationAllowedError, "The ob
ject is read-only."); | 124 throwReadOnly(exceptionState); |
134 return String(); | 125 return String(); |
135 } | 126 } |
136 | |
137 target()->appendItem(item); | 127 target()->appendItem(item); |
138 commitChange(); | 128 commitChange(); |
139 | |
140 return item; | 129 return item; |
141 } | 130 } |
142 | 131 |
143 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 132 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
144 | 133 |
145 protected: | 134 protected: |
146 SVGStringListTearOff(SVGStringList*, SVGElement*, PropertyIsAnimValType, con
st QualifiedName&); | 135 SVGStringListTearOff(SVGStringList*, SVGElement*, PropertyIsAnimValType, con
st QualifiedName&); |
147 }; | 136 }; |
148 | 137 |
149 } // namespace blink | 138 } // namespace blink |
150 | 139 |
151 #endif // SVGStringListTearOff_h | 140 #endif // SVGStringListTearOff_h |
OLD | NEW |