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 "JSNamedNodeMap.h"
23
24#include "CustomElementReactionQueue.h"
25#include "Element.h"
26#include "JSAttr.h"
27#include "JSDOMAbstractOperations.h"
28#include "JSDOMAttribute.h"
29#include "JSDOMBinding.h"
30#include "JSDOMConstructorNotConstructable.h"
31#include "JSDOMConvertInterface.h"
32#include "JSDOMConvertNullable.h"
33#include "JSDOMConvertNumbers.h"
34#include "JSDOMConvertStrings.h"
35#include "JSDOMExceptionHandling.h"
36#include "JSDOMGlobalObject.h"
37#include "JSDOMOperation.h"
38#include "JSDOMWrapperCache.h"
39#include "JSNodeCustom.h"
40#include "ScriptExecutionContext.h"
41#include <JavaScriptCore/ArrayPrototype.h>
42#include <JavaScriptCore/BuiltinNames.h>
43#include <JavaScriptCore/FunctionPrototype.h>
44#include <JavaScriptCore/HeapSnapshotBuilder.h>
45#include <JavaScriptCore/JSCInlines.h>
46#include <JavaScriptCore/PropertyNameArray.h>
47#include <wtf/GetPtr.h>
48#include <wtf/PointerPreparations.h>
49#include <wtf/URL.h>
50
51
52namespace WebCore {
53using namespace JSC;
54
55// Functions
56
57JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionItem(JSC::ExecState*);
58JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItem(JSC::ExecState*);
59JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItemNS(JSC::ExecState*);
60JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItem(JSC::ExecState*);
61JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItemNS(JSC::ExecState*);
62JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionRemoveNamedItem(JSC::ExecState*);
63JSC::EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionRemoveNamedItemNS(JSC::ExecState*);
64
65// Attributes
66
67JSC::EncodedJSValue jsNamedNodeMapConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
68bool setJSNamedNodeMapConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
69JSC::EncodedJSValue jsNamedNodeMapLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
70
71class JSNamedNodeMapPrototype : public JSC::JSNonFinalObject {
72public:
73 using Base = JSC::JSNonFinalObject;
74 static JSNamedNodeMapPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
75 {
76 JSNamedNodeMapPrototype* ptr = new (NotNull, JSC::allocateCell<JSNamedNodeMapPrototype>(vm.heap)) JSNamedNodeMapPrototype(vm, globalObject, structure);
77 ptr->finishCreation(vm);
78 return ptr;
79 }
80
81 DECLARE_INFO;
82 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
83 {
84 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
85 }
86
87private:
88 JSNamedNodeMapPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
89 : JSC::JSNonFinalObject(vm, structure)
90 {
91 }
92
93 void finishCreation(JSC::VM&);
94};
95
96using JSNamedNodeMapConstructor = JSDOMConstructorNotConstructable<JSNamedNodeMap>;
97
98template<> JSValue JSNamedNodeMapConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
99{
100 UNUSED_PARAM(vm);
101 return globalObject.functionPrototype();
102}
103
104template<> void JSNamedNodeMapConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
105{
106 putDirect(vm, vm.propertyNames->prototype, JSNamedNodeMap::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
107 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("NamedNodeMap"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
108 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
109}
110
111template<> const ClassInfo JSNamedNodeMapConstructor::s_info = { "NamedNodeMap", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNamedNodeMapConstructor) };
112
113/* Hash table for prototype */
114
115static const HashTableValue JSNamedNodeMapPrototypeTableValues[] =
116{
117 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNamedNodeMapConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNamedNodeMapConstructor) } },
118 { "length", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNamedNodeMapLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
119 { "item", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionItem), (intptr_t) (1) } },
120 { "getNamedItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionGetNamedItem), (intptr_t) (1) } },
121 { "getNamedItemNS", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionGetNamedItemNS), (intptr_t) (2) } },
122 { "setNamedItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionSetNamedItem), (intptr_t) (1) } },
123 { "setNamedItemNS", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionSetNamedItemNS), (intptr_t) (1) } },
124 { "removeNamedItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionRemoveNamedItem), (intptr_t) (1) } },
125 { "removeNamedItemNS", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNamedNodeMapPrototypeFunctionRemoveNamedItemNS), (intptr_t) (2) } },
126};
127
128const ClassInfo JSNamedNodeMapPrototype::s_info = { "NamedNodeMapPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNamedNodeMapPrototype) };
129
130void JSNamedNodeMapPrototype::finishCreation(VM& vm)
131{
132 Base::finishCreation(vm);
133 reifyStaticProperties(vm, JSNamedNodeMap::info(), JSNamedNodeMapPrototypeTableValues, *this);
134 putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
135}
136
137const ClassInfo JSNamedNodeMap::s_info = { "NamedNodeMap", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNamedNodeMap) };
138
139JSNamedNodeMap::JSNamedNodeMap(Structure* structure, JSDOMGlobalObject& globalObject, Ref<NamedNodeMap>&& impl)
140 : JSDOMWrapper<NamedNodeMap>(structure, globalObject, WTFMove(impl))
141{
142}
143
144void JSNamedNodeMap::finishCreation(VM& vm)
145{
146 Base::finishCreation(vm);
147 ASSERT(inherits(vm, info()));
148
149}
150
151JSObject* JSNamedNodeMap::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
152{
153 return JSNamedNodeMapPrototype::create(vm, &globalObject, JSNamedNodeMapPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
154}
155
156JSObject* JSNamedNodeMap::prototype(VM& vm, JSDOMGlobalObject& globalObject)
157{
158 return getDOMPrototype<JSNamedNodeMap>(vm, globalObject);
159}
160
161JSValue JSNamedNodeMap::getConstructor(VM& vm, const JSGlobalObject* globalObject)
162{
163 return getDOMConstructor<JSNamedNodeMapConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
164}
165
166void JSNamedNodeMap::destroy(JSC::JSCell* cell)
167{
168 JSNamedNodeMap* thisObject = static_cast<JSNamedNodeMap*>(cell);
169 thisObject->JSNamedNodeMap::~JSNamedNodeMap();
170}
171
172bool JSNamedNodeMap::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
173{
174 auto* thisObject = jsCast<JSNamedNodeMap*>(object);
175 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
176 if (auto index = parseIndex(propertyName)) {
177 if (index.value() < thisObject->wrapped().length()) {
178 auto value = toJS<IDLNullable<IDLInterface<Attr>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value()));
179 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
180 return true;
181 }
182 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
183 }
184 using GetterIDLType = IDLInterface<Attr>;
185 auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> {
186 auto result = thisObject.wrapped().getNamedItem(propertyNameToAtomString(propertyName));
187 if (!GetterIDLType::isNullValue(result))
188 return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
189 return WTF::nullopt;
190 };
191 if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) {
192 auto value = toJS<IDLNullable<IDLInterface<Attr>>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value()));
193 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), value);
194 return true;
195 }
196 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
197}
198
199bool JSNamedNodeMap::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
200{
201 auto* thisObject = jsCast<JSNamedNodeMap*>(object);
202 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
203 if (LIKELY(index <= MAX_ARRAY_INDEX)) {
204 if (index < thisObject->wrapped().length()) {
205 auto value = toJS<IDLNullable<IDLInterface<Attr>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index));
206 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
207 return true;
208 }
209 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
210 }
211 auto propertyName = Identifier::from(state, index);
212 using GetterIDLType = IDLInterface<Attr>;
213 auto getterFunctor = [] (auto& thisObject, auto propertyName) -> Optional<typename GetterIDLType::ImplementationType> {
214 auto result = thisObject.wrapped().getNamedItem(propertyNameToAtomString(propertyName));
215 if (!GetterIDLType::isNullValue(result))
216 return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
217 return WTF::nullopt;
218 };
219 if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::No>(*state, *thisObject, propertyName, getterFunctor)) {
220 auto value = toJS<IDLNullable<IDLInterface<Attr>>>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value()));
221 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), value);
222 return true;
223 }
224 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
225}
226
227void JSNamedNodeMap::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
228{
229 auto* thisObject = jsCast<JSNamedNodeMap*>(object);
230 ASSERT_GC_OBJECT_INHERITS(object, info());
231 for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
232 propertyNames.add(Identifier::from(state, i));
233 if (mode.includeDontEnumProperties()) {
234 for (auto& propertyName : thisObject->wrapped().supportedPropertyNames())
235 propertyNames.add(Identifier::fromString(state, propertyName));
236 }
237 JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
238}
239
240template<> inline JSNamedNodeMap* IDLAttribute<JSNamedNodeMap>::cast(ExecState& state, EncodedJSValue thisValue)
241{
242 return jsDynamicCast<JSNamedNodeMap*>(state.vm(), JSValue::decode(thisValue));
243}
244
245template<> inline JSNamedNodeMap* IDLOperation<JSNamedNodeMap>::cast(ExecState& state)
246{
247 return jsDynamicCast<JSNamedNodeMap*>(state.vm(), state.thisValue());
248}
249
250EncodedJSValue jsNamedNodeMapConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
251{
252 VM& vm = state->vm();
253 auto throwScope = DECLARE_THROW_SCOPE(vm);
254 auto* prototype = jsDynamicCast<JSNamedNodeMapPrototype*>(vm, JSValue::decode(thisValue));
255 if (UNLIKELY(!prototype))
256 return throwVMTypeError(state, throwScope);
257 return JSValue::encode(JSNamedNodeMap::getConstructor(state->vm(), prototype->globalObject()));
258}
259
260bool setJSNamedNodeMapConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
261{
262 VM& vm = state->vm();
263 auto throwScope = DECLARE_THROW_SCOPE(vm);
264 auto* prototype = jsDynamicCast<JSNamedNodeMapPrototype*>(vm, JSValue::decode(thisValue));
265 if (UNLIKELY(!prototype)) {
266 throwVMTypeError(state, throwScope);
267 return false;
268 }
269 // Shadowing a built-in constructor
270 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
271}
272
273static inline JSValue jsNamedNodeMapLengthGetter(ExecState& state, JSNamedNodeMap& thisObject, ThrowScope& throwScope)
274{
275 UNUSED_PARAM(throwScope);
276 UNUSED_PARAM(state);
277 auto& impl = thisObject.wrapped();
278 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length());
279 return result;
280}
281
282EncodedJSValue jsNamedNodeMapLength(ExecState* state, EncodedJSValue thisValue, PropertyName)
283{
284 return IDLAttribute<JSNamedNodeMap>::get<jsNamedNodeMapLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length");
285}
286
287static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
288{
289 UNUSED_PARAM(state);
290 UNUSED_PARAM(throwScope);
291 auto& impl = castedThis->wrapped();
292 if (UNLIKELY(state->argumentCount() < 1))
293 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
294 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
295 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
296 return JSValue::encode(toJS<IDLNullable<IDLInterface<Attr>>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index))));
297}
298
299EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionItem(ExecState* state)
300{
301 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionItemBody>(*state, "item");
302}
303
304static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionGetNamedItemBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
305{
306 UNUSED_PARAM(state);
307 UNUSED_PARAM(throwScope);
308 auto& impl = castedThis->wrapped();
309 if (UNLIKELY(state->argumentCount() < 1))
310 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
311 auto qualifiedName = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
312 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
313 return JSValue::encode(toJS<IDLNullable<IDLInterface<Attr>>>(*state, *castedThis->globalObject(), impl.getNamedItem(WTFMove(qualifiedName))));
314}
315
316EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItem(ExecState* state)
317{
318 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionGetNamedItemBody>(*state, "getNamedItem");
319}
320
321static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionGetNamedItemNSBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
322{
323 UNUSED_PARAM(state);
324 UNUSED_PARAM(throwScope);
325 auto& impl = castedThis->wrapped();
326 if (UNLIKELY(state->argumentCount() < 2))
327 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
328 auto namespaceURI = convert<IDLNullable<IDLDOMString>>(*state, state->uncheckedArgument(0));
329 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
330 auto localName = convert<IDLDOMString>(*state, state->uncheckedArgument(1));
331 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
332 return JSValue::encode(toJS<IDLNullable<IDLInterface<Attr>>>(*state, *castedThis->globalObject(), impl.getNamedItemNS(WTFMove(namespaceURI), WTFMove(localName))));
333}
334
335EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionGetNamedItemNS(ExecState* state)
336{
337 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionGetNamedItemNSBody>(*state, "getNamedItemNS");
338}
339
340static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionSetNamedItemBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
341{
342 UNUSED_PARAM(state);
343 UNUSED_PARAM(throwScope);
344 CustomElementReactionStack customElementReactionStack(*state);
345 auto& impl = castedThis->wrapped();
346 if (UNLIKELY(state->argumentCount() < 1))
347 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
348 auto attr = convert<IDLInterface<Attr>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "attr", "NamedNodeMap", "setNamedItem", "Attr"); });
349 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
350 return JSValue::encode(toJS<IDLNullable<IDLInterface<Attr>>>(*state, *castedThis->globalObject(), throwScope, impl.setNamedItem(*attr)));
351}
352
353EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItem(ExecState* state)
354{
355 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionSetNamedItemBody>(*state, "setNamedItem");
356}
357
358static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionSetNamedItemNSBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
359{
360 UNUSED_PARAM(state);
361 UNUSED_PARAM(throwScope);
362 CustomElementReactionStack customElementReactionStack(*state);
363 auto& impl = castedThis->wrapped();
364 if (UNLIKELY(state->argumentCount() < 1))
365 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
366 auto attr = convert<IDLInterface<Attr>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "attr", "NamedNodeMap", "setNamedItemNS", "Attr"); });
367 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
368 return JSValue::encode(toJS<IDLNullable<IDLInterface<Attr>>>(*state, *castedThis->globalObject(), throwScope, impl.setNamedItem(*attr)));
369}
370
371EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionSetNamedItemNS(ExecState* state)
372{
373 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionSetNamedItemNSBody>(*state, "setNamedItemNS");
374}
375
376static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionRemoveNamedItemBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
377{
378 UNUSED_PARAM(state);
379 UNUSED_PARAM(throwScope);
380 CustomElementReactionStack customElementReactionStack(*state);
381 auto& impl = castedThis->wrapped();
382 if (UNLIKELY(state->argumentCount() < 1))
383 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
384 auto qualifiedName = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
385 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
386 return JSValue::encode(toJS<IDLInterface<Attr>>(*state, *castedThis->globalObject(), throwScope, impl.removeNamedItem(WTFMove(qualifiedName))));
387}
388
389EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionRemoveNamedItem(ExecState* state)
390{
391 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionRemoveNamedItemBody>(*state, "removeNamedItem");
392}
393
394static inline JSC::EncodedJSValue jsNamedNodeMapPrototypeFunctionRemoveNamedItemNSBody(JSC::ExecState* state, typename IDLOperation<JSNamedNodeMap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
395{
396 UNUSED_PARAM(state);
397 UNUSED_PARAM(throwScope);
398 CustomElementReactionStack customElementReactionStack(*state);
399 auto& impl = castedThis->wrapped();
400 if (UNLIKELY(state->argumentCount() < 2))
401 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
402 auto namespaceURI = convert<IDLNullable<IDLDOMString>>(*state, state->uncheckedArgument(0));
403 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
404 auto localName = convert<IDLDOMString>(*state, state->uncheckedArgument(1));
405 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
406 return JSValue::encode(toJS<IDLInterface<Attr>>(*state, *castedThis->globalObject(), throwScope, impl.removeNamedItemNS(WTFMove(namespaceURI), WTFMove(localName))));
407}
408
409EncodedJSValue JSC_HOST_CALL jsNamedNodeMapPrototypeFunctionRemoveNamedItemNS(ExecState* state)
410{
411 return IDLOperation<JSNamedNodeMap>::call<jsNamedNodeMapPrototypeFunctionRemoveNamedItemNSBody>(*state, "removeNamedItemNS");
412}
413
414void JSNamedNodeMap::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
415{
416 auto* thisObject = jsCast<JSNamedNodeMap*>(cell);
417 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
418 if (thisObject->scriptExecutionContext())
419 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
420 Base::heapSnapshot(cell, builder);
421}
422
423bool JSNamedNodeMapOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
424{
425 auto* jsNamedNodeMap = jsCast<JSNamedNodeMap*>(handle.slot()->asCell());
426 Element* element = WTF::getPtr(jsNamedNodeMap->wrapped().element());
427 if (!element)
428 return false;
429 if (UNLIKELY(reason))
430 *reason = "Reachable from NamedNodeMapOwner";
431 void* root = WebCore::root(element);
432 return visitor.containsOpaqueRoot(root);
433}
434
435void JSNamedNodeMapOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
436{
437 auto* jsNamedNodeMap = static_cast<JSNamedNodeMap*>(handle.slot()->asCell());
438 auto& world = *static_cast<DOMWrapperWorld*>(context);
439 uncacheWrapper(world, &jsNamedNodeMap->wrapped(), jsNamedNodeMap);
440}
441
442JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<NamedNodeMap>&& impl)
443{
444 // If you hit this failure the interface definition has the ImplementationLacksVTable
445 // attribute. You should remove that attribute. If the class has subclasses
446 // that may be passed through this toJS() function you should use the SkipVTableValidation
447 // attribute to NamedNodeMap.
448 static_assert(!std::is_polymorphic<NamedNodeMap>::value, "NamedNodeMap is polymorphic but the IDL claims it is not");
449 return createWrapper<NamedNodeMap>(globalObject, WTFMove(impl));
450}
451
452JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, NamedNodeMap& impl)
453{
454 return wrap(state, globalObject, impl);
455}
456
457NamedNodeMap* JSNamedNodeMap::toWrapped(JSC::VM& vm, JSC::JSValue value)
458{
459 if (auto* wrapper = jsDynamicCast<JSNamedNodeMap*>(vm, value))
460 return &wrapper->wrapped();
461 return nullptr;
462}
463
464}
465