1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | #include "JSDOMTokenList.h" |
23 | |
24 | #include "CustomElementReactionQueue.h" |
25 | #include "Element.h" |
26 | #include "JSDOMAttribute.h" |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConstructorNotConstructable.h" |
29 | #include "JSDOMConvertBoolean.h" |
30 | #include "JSDOMConvertNullable.h" |
31 | #include "JSDOMConvertNumbers.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMConvertVariadic.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMIterator.h" |
36 | #include "JSDOMOperation.h" |
37 | #include "JSDOMWrapperCache.h" |
38 | #include "JSNodeCustom.h" |
39 | #include "ScriptExecutionContext.h" |
40 | #include <JavaScriptCore/ArrayPrototype.h> |
41 | #include <JavaScriptCore/BuiltinNames.h> |
42 | #include <JavaScriptCore/FunctionPrototype.h> |
43 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
44 | #include <JavaScriptCore/JSCInlines.h> |
45 | #include <JavaScriptCore/PropertyNameArray.h> |
46 | #include <wtf/GetPtr.h> |
47 | #include <wtf/PointerPreparations.h> |
48 | #include <wtf/URL.h> |
49 | |
50 | |
51 | namespace WebCore { |
52 | using namespace JSC; |
53 | |
54 | // Functions |
55 | |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionItem(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionContains(JSC::ExecState*); |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionAdd(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionRemove(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToggle(JSC::ExecState*); |
61 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionReplace(JSC::ExecState*); |
62 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionSupports(JSC::ExecState*); |
63 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToString(JSC::ExecState*); |
64 | |
65 | // Attributes |
66 | |
67 | JSC::EncodedJSValue jsDOMTokenListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
68 | bool setJSDOMTokenListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
69 | JSC::EncodedJSValue jsDOMTokenListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
70 | JSC::EncodedJSValue jsDOMTokenListValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
71 | bool setJSDOMTokenListValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
72 | |
73 | class JSDOMTokenListPrototype : public JSC::JSNonFinalObject { |
74 | public: |
75 | using Base = JSC::JSNonFinalObject; |
76 | static JSDOMTokenListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
77 | { |
78 | JSDOMTokenListPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMTokenListPrototype>(vm.heap)) JSDOMTokenListPrototype(vm, globalObject, structure); |
79 | ptr->finishCreation(vm); |
80 | return ptr; |
81 | } |
82 | |
83 | DECLARE_INFO; |
84 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
85 | { |
86 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
87 | } |
88 | |
89 | private: |
90 | JSDOMTokenListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
91 | : JSC::JSNonFinalObject(vm, structure) |
92 | { |
93 | } |
94 | |
95 | void finishCreation(JSC::VM&); |
96 | }; |
97 | |
98 | using JSDOMTokenListConstructor = JSDOMConstructorNotConstructable<JSDOMTokenList>; |
99 | |
100 | template<> JSValue JSDOMTokenListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
101 | { |
102 | UNUSED_PARAM(vm); |
103 | return globalObject.functionPrototype(); |
104 | } |
105 | |
106 | template<> void JSDOMTokenListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
107 | { |
108 | putDirect(vm, vm.propertyNames->prototype, JSDOMTokenList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
109 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DOMTokenList"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
110 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
111 | } |
112 | |
113 | template<> const ClassInfo JSDOMTokenListConstructor::s_info = { "DOMTokenList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMTokenListConstructor) }; |
114 | |
115 | /* Hash table for prototype */ |
116 | |
117 | static const HashTableValue JSDOMTokenListPrototypeTableValues[] = |
118 | { |
119 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMTokenListConstructor) } }, |
120 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
121 | { "value" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMTokenListValue) } }, |
122 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionItem), (intptr_t) (1) } }, |
123 | { "contains" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionContains), (intptr_t) (1) } }, |
124 | { "add" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionAdd), (intptr_t) (0) } }, |
125 | { "remove" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionRemove), (intptr_t) (0) } }, |
126 | { "toggle" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionToggle), (intptr_t) (1) } }, |
127 | { "replace" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionReplace), (intptr_t) (2) } }, |
128 | { "supports" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionSupports), (intptr_t) (1) } }, |
129 | { "toString" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMTokenListPrototypeFunctionToString), (intptr_t) (0) } }, |
130 | }; |
131 | |
132 | const ClassInfo JSDOMTokenListPrototype::s_info = { "DOMTokenListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMTokenListPrototype) }; |
133 | |
134 | void JSDOMTokenListPrototype::finishCreation(VM& vm) |
135 | { |
136 | Base::finishCreation(vm); |
137 | reifyStaticProperties(vm, JSDOMTokenList::info(), JSDOMTokenListPrototypeTableValues, *this); |
138 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
139 | addValueIterableMethods(*globalObject(), *this); |
140 | } |
141 | |
142 | const ClassInfo JSDOMTokenList::s_info = { "DOMTokenList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMTokenList) }; |
143 | |
144 | JSDOMTokenList::JSDOMTokenList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMTokenList>&& impl) |
145 | : JSDOMWrapper<DOMTokenList>(structure, globalObject, WTFMove(impl)) |
146 | { |
147 | } |
148 | |
149 | void JSDOMTokenList::finishCreation(VM& vm) |
150 | { |
151 | Base::finishCreation(vm); |
152 | ASSERT(inherits(vm, info())); |
153 | |
154 | } |
155 | |
156 | JSObject* JSDOMTokenList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
157 | { |
158 | return JSDOMTokenListPrototype::create(vm, &globalObject, JSDOMTokenListPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
159 | } |
160 | |
161 | JSObject* JSDOMTokenList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
162 | { |
163 | return getDOMPrototype<JSDOMTokenList>(vm, globalObject); |
164 | } |
165 | |
166 | JSValue JSDOMTokenList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
167 | { |
168 | return getDOMConstructor<JSDOMTokenListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
169 | } |
170 | |
171 | void JSDOMTokenList::destroy(JSC::JSCell* cell) |
172 | { |
173 | JSDOMTokenList* thisObject = static_cast<JSDOMTokenList*>(cell); |
174 | thisObject->JSDOMTokenList::~JSDOMTokenList(); |
175 | } |
176 | |
177 | bool JSDOMTokenList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
178 | { |
179 | auto* thisObject = jsCast<JSDOMTokenList*>(object); |
180 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
181 | if (auto index = parseIndex(propertyName)) { |
182 | if (index.value() < thisObject->wrapped().length()) { |
183 | auto value = toJS<IDLNullable<IDLDOMString>>(*state, thisObject->wrapped().item(index.value())); |
184 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
185 | return true; |
186 | } |
187 | } |
188 | return JSObject::getOwnPropertySlot(object, state, propertyName, slot); |
189 | } |
190 | |
191 | bool JSDOMTokenList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
192 | { |
193 | auto* thisObject = jsCast<JSDOMTokenList*>(object); |
194 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
195 | if (LIKELY(index <= MAX_ARRAY_INDEX)) { |
196 | if (index < thisObject->wrapped().length()) { |
197 | auto value = toJS<IDLNullable<IDLDOMString>>(*state, thisObject->wrapped().item(index)); |
198 | slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value); |
199 | return true; |
200 | } |
201 | } |
202 | return JSObject::getOwnPropertySlotByIndex(object, state, index, slot); |
203 | } |
204 | |
205 | void JSDOMTokenList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
206 | { |
207 | auto* thisObject = jsCast<JSDOMTokenList*>(object); |
208 | ASSERT_GC_OBJECT_INHERITS(object, info()); |
209 | for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i) |
210 | propertyNames.add(Identifier::from(state, i)); |
211 | JSObject::getOwnPropertyNames(object, state, propertyNames, mode); |
212 | } |
213 | |
214 | template<> inline JSDOMTokenList* IDLAttribute<JSDOMTokenList>::cast(ExecState& state, EncodedJSValue thisValue) |
215 | { |
216 | return jsDynamicCast<JSDOMTokenList*>(state.vm(), JSValue::decode(thisValue)); |
217 | } |
218 | |
219 | template<> inline JSDOMTokenList* IDLOperation<JSDOMTokenList>::cast(ExecState& state) |
220 | { |
221 | return jsDynamicCast<JSDOMTokenList*>(state.vm(), state.thisValue()); |
222 | } |
223 | |
224 | EncodedJSValue jsDOMTokenListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
225 | { |
226 | VM& vm = state->vm(); |
227 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
228 | auto* prototype = jsDynamicCast<JSDOMTokenListPrototype*>(vm, JSValue::decode(thisValue)); |
229 | if (UNLIKELY(!prototype)) |
230 | return throwVMTypeError(state, throwScope); |
231 | return JSValue::encode(JSDOMTokenList::getConstructor(state->vm(), prototype->globalObject())); |
232 | } |
233 | |
234 | bool setJSDOMTokenListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
235 | { |
236 | VM& vm = state->vm(); |
237 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
238 | auto* prototype = jsDynamicCast<JSDOMTokenListPrototype*>(vm, JSValue::decode(thisValue)); |
239 | if (UNLIKELY(!prototype)) { |
240 | throwVMTypeError(state, throwScope); |
241 | return false; |
242 | } |
243 | // Shadowing a built-in constructor |
244 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
245 | } |
246 | |
247 | static inline JSValue jsDOMTokenListLengthGetter(ExecState& state, JSDOMTokenList& thisObject, ThrowScope& throwScope) |
248 | { |
249 | UNUSED_PARAM(throwScope); |
250 | UNUSED_PARAM(state); |
251 | auto& impl = thisObject.wrapped(); |
252 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
253 | return result; |
254 | } |
255 | |
256 | EncodedJSValue jsDOMTokenListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
257 | { |
258 | return IDLAttribute<JSDOMTokenList>::get<jsDOMTokenListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
259 | } |
260 | |
261 | static inline JSValue jsDOMTokenListValueGetter(ExecState& state, JSDOMTokenList& thisObject, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | UNUSED_PARAM(state); |
265 | auto& impl = thisObject.wrapped(); |
266 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.value()); |
267 | return result; |
268 | } |
269 | |
270 | EncodedJSValue jsDOMTokenListValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
271 | { |
272 | return IDLAttribute<JSDOMTokenList>::get<jsDOMTokenListValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value" ); |
273 | } |
274 | |
275 | static inline bool setJSDOMTokenListValueSetter(ExecState& state, JSDOMTokenList& thisObject, JSValue value, ThrowScope& throwScope) |
276 | { |
277 | UNUSED_PARAM(throwScope); |
278 | CustomElementReactionStack customElementReactionStack(state); |
279 | auto& impl = thisObject.wrapped(); |
280 | auto nativeValue = convert<IDLDOMString>(state, value); |
281 | RETURN_IF_EXCEPTION(throwScope, false); |
282 | AttributeSetter::call(state, throwScope, [&] { |
283 | return impl.setValue(WTFMove(nativeValue)); |
284 | }); |
285 | return true; |
286 | } |
287 | |
288 | bool setJSDOMTokenListValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
289 | { |
290 | return IDLAttribute<JSDOMTokenList>::set<setJSDOMTokenListValueSetter>(*state, thisValue, encodedValue, "value" ); |
291 | } |
292 | |
293 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
294 | { |
295 | UNUSED_PARAM(state); |
296 | UNUSED_PARAM(throwScope); |
297 | auto& impl = castedThis->wrapped(); |
298 | if (UNLIKELY(state->argumentCount() < 1)) |
299 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
300 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
301 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
302 | return JSValue::encode(toJS<IDLNullable<IDLDOMString>>(*state, impl.item(WTFMove(index)))); |
303 | } |
304 | |
305 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionItem(ExecState* state) |
306 | { |
307 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionItemBody>(*state, "item" ); |
308 | } |
309 | |
310 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionContainsBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
311 | { |
312 | UNUSED_PARAM(state); |
313 | UNUSED_PARAM(throwScope); |
314 | auto& impl = castedThis->wrapped(); |
315 | if (UNLIKELY(state->argumentCount() < 1)) |
316 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
317 | auto token = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
318 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
319 | return JSValue::encode(toJS<IDLBoolean>(impl.contains(WTFMove(token)))); |
320 | } |
321 | |
322 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionContains(ExecState* state) |
323 | { |
324 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionContainsBody>(*state, "contains" ); |
325 | } |
326 | |
327 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionAddBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
328 | { |
329 | UNUSED_PARAM(state); |
330 | UNUSED_PARAM(throwScope); |
331 | CustomElementReactionStack customElementReactionStack(*state); |
332 | auto& impl = castedThis->wrapped(); |
333 | auto tokens = convertVariadicArguments<IDLDOMString>(*state, 0); |
334 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
335 | propagateException(*state, throwScope, impl.add(WTFMove(tokens))); |
336 | return JSValue::encode(jsUndefined()); |
337 | } |
338 | |
339 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionAdd(ExecState* state) |
340 | { |
341 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionAddBody>(*state, "add" ); |
342 | } |
343 | |
344 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionRemoveBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
345 | { |
346 | UNUSED_PARAM(state); |
347 | UNUSED_PARAM(throwScope); |
348 | CustomElementReactionStack customElementReactionStack(*state); |
349 | auto& impl = castedThis->wrapped(); |
350 | auto tokens = convertVariadicArguments<IDLDOMString>(*state, 0); |
351 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
352 | propagateException(*state, throwScope, impl.remove(WTFMove(tokens))); |
353 | return JSValue::encode(jsUndefined()); |
354 | } |
355 | |
356 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionRemove(ExecState* state) |
357 | { |
358 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionRemoveBody>(*state, "remove" ); |
359 | } |
360 | |
361 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionToggleBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
362 | { |
363 | UNUSED_PARAM(state); |
364 | UNUSED_PARAM(throwScope); |
365 | CustomElementReactionStack customElementReactionStack(*state); |
366 | auto& impl = castedThis->wrapped(); |
367 | if (UNLIKELY(state->argumentCount() < 1)) |
368 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
369 | auto token = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
370 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
371 | auto force = state->argument(1).isUndefined() ? Optional<Converter<IDLBoolean>::ReturnType>() : Optional<Converter<IDLBoolean>::ReturnType>(convert<IDLBoolean>(*state, state->uncheckedArgument(1))); |
372 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
373 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, impl.toggle(WTFMove(token), WTFMove(force)))); |
374 | } |
375 | |
376 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToggle(ExecState* state) |
377 | { |
378 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionToggleBody>(*state, "toggle" ); |
379 | } |
380 | |
381 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionReplaceBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
382 | { |
383 | UNUSED_PARAM(state); |
384 | UNUSED_PARAM(throwScope); |
385 | CustomElementReactionStack customElementReactionStack(*state); |
386 | auto& impl = castedThis->wrapped(); |
387 | if (UNLIKELY(state->argumentCount() < 2)) |
388 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
389 | auto token = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
390 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
391 | auto newToken = convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
392 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
393 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, impl.replace(WTFMove(token), WTFMove(newToken)))); |
394 | } |
395 | |
396 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionReplace(ExecState* state) |
397 | { |
398 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionReplaceBody>(*state, "replace" ); |
399 | } |
400 | |
401 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionSupportsBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
402 | { |
403 | UNUSED_PARAM(state); |
404 | UNUSED_PARAM(throwScope); |
405 | auto& impl = castedThis->wrapped(); |
406 | if (UNLIKELY(state->argumentCount() < 1)) |
407 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
408 | auto token = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
409 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
410 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, impl.supports(WTFMove(token)))); |
411 | } |
412 | |
413 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionSupports(ExecState* state) |
414 | { |
415 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionSupportsBody>(*state, "supports" ); |
416 | } |
417 | |
418 | static inline JSC::EncodedJSValue jsDOMTokenListPrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSDOMTokenList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
419 | { |
420 | UNUSED_PARAM(state); |
421 | UNUSED_PARAM(throwScope); |
422 | auto& impl = castedThis->wrapped(); |
423 | return JSValue::encode(toJS<IDLDOMString>(*state, impl.value())); |
424 | } |
425 | |
426 | EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToString(ExecState* state) |
427 | { |
428 | return IDLOperation<JSDOMTokenList>::call<jsDOMTokenListPrototypeFunctionToStringBody>(*state, "toString" ); |
429 | } |
430 | |
431 | void JSDOMTokenList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
432 | { |
433 | auto* thisObject = jsCast<JSDOMTokenList*>(cell); |
434 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
435 | if (thisObject->scriptExecutionContext()) |
436 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
437 | Base::heapSnapshot(cell, builder); |
438 | } |
439 | |
440 | bool JSDOMTokenListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
441 | { |
442 | auto* jsDOMTokenList = jsCast<JSDOMTokenList*>(handle.slot()->asCell()); |
443 | Element* element = WTF::getPtr(jsDOMTokenList->wrapped().element()); |
444 | if (!element) |
445 | return false; |
446 | if (UNLIKELY(reason)) |
447 | *reason = "Reachable from DOMTokenListOwner" ; |
448 | void* root = WebCore::root(element); |
449 | return visitor.containsOpaqueRoot(root); |
450 | } |
451 | |
452 | void JSDOMTokenListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
453 | { |
454 | auto* jsDOMTokenList = static_cast<JSDOMTokenList*>(handle.slot()->asCell()); |
455 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
456 | uncacheWrapper(world, &jsDOMTokenList->wrapped(), jsDOMTokenList); |
457 | } |
458 | |
459 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMTokenList>&& impl) |
460 | { |
461 | return createWrapper<DOMTokenList>(globalObject, WTFMove(impl)); |
462 | } |
463 | |
464 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMTokenList& impl) |
465 | { |
466 | return wrap(state, globalObject, impl); |
467 | } |
468 | |
469 | DOMTokenList* JSDOMTokenList::toWrapped(JSC::VM& vm, JSC::JSValue value) |
470 | { |
471 | if (auto* wrapper = jsDynamicCast<JSDOMTokenList*>(vm, value)) |
472 | return &wrapper->wrapped(); |
473 | return nullptr; |
474 | } |
475 | |
476 | } |
477 | |