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 "JSHTMLSelectElement.h"
23
24#include "CustomElementReactionQueue.h"
25#include "HTMLNames.h"
26#include "JSDOMAttribute.h"
27#include "JSDOMBinding.h"
28#include "JSDOMConstructorNotConstructable.h"
29#include "JSDOMConvertBoolean.h"
30#include "JSDOMConvertInterface.h"
31#include "JSDOMConvertNullable.h"
32#include "JSDOMConvertNumbers.h"
33#include "JSDOMConvertStrings.h"
34#include "JSDOMConvertUnion.h"
35#include "JSDOMExceptionHandling.h"
36#include "JSDOMGlobalObject.h"
37#include "JSDOMOperation.h"
38#include "JSDOMWrapperCache.h"
39#include "JSHTMLCollection.h"
40#include "JSHTMLFormElement.h"
41#include "JSHTMLOptGroupElement.h"
42#include "JSHTMLOptionElement.h"
43#include "JSHTMLOptionsCollection.h"
44#include "JSNodeList.h"
45#include "JSValidityState.h"
46#include "RuntimeEnabledFeatures.h"
47#include "ScriptExecutionContext.h"
48#include <JavaScriptCore/ArrayPrototype.h>
49#include <JavaScriptCore/BuiltinNames.h>
50#include <JavaScriptCore/HeapSnapshotBuilder.h>
51#include <JavaScriptCore/JSCInlines.h>
52#include <JavaScriptCore/PropertyNameArray.h>
53#include <wtf/GetPtr.h>
54#include <wtf/PointerPreparations.h>
55#include <wtf/URL.h>
56#include <wtf/Variant.h>
57
58
59namespace WebCore {
60using namespace JSC;
61
62// Functions
63
64JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionItem(JSC::ExecState*);
65JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionNamedItem(JSC::ExecState*);
66JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionAdd(JSC::ExecState*);
67JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionRemove(JSC::ExecState*);
68JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionCheckValidity(JSC::ExecState*);
69JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionReportValidity(JSC::ExecState*);
70JSC::EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionSetCustomValidity(JSC::ExecState*);
71
72// Attributes
73
74JSC::EncodedJSValue jsHTMLSelectElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
75bool setJSHTMLSelectElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
76JSC::EncodedJSValue jsHTMLSelectElementAutocomplete(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
77bool setJSHTMLSelectElementAutocomplete(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
78JSC::EncodedJSValue jsHTMLSelectElementAutofocus(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
79bool setJSHTMLSelectElementAutofocus(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
80JSC::EncodedJSValue jsHTMLSelectElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
81bool setJSHTMLSelectElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
82JSC::EncodedJSValue jsHTMLSelectElementForm(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
83JSC::EncodedJSValue jsHTMLSelectElementMultiple(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
84bool setJSHTMLSelectElementMultiple(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
85JSC::EncodedJSValue jsHTMLSelectElementName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
86bool setJSHTMLSelectElementName(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
87JSC::EncodedJSValue jsHTMLSelectElementRequired(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
88bool setJSHTMLSelectElementRequired(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
89JSC::EncodedJSValue jsHTMLSelectElementSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
90bool setJSHTMLSelectElementSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
91JSC::EncodedJSValue jsHTMLSelectElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
92JSC::EncodedJSValue jsHTMLSelectElementOptions(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
93JSC::EncodedJSValue jsHTMLSelectElementLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
94bool setJSHTMLSelectElementLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
95JSC::EncodedJSValue jsHTMLSelectElementSelectedOptions(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
96JSC::EncodedJSValue jsHTMLSelectElementSelectedIndex(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
97bool setJSHTMLSelectElementSelectedIndex(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
98JSC::EncodedJSValue jsHTMLSelectElementValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
99bool setJSHTMLSelectElementValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
100JSC::EncodedJSValue jsHTMLSelectElementWillValidate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
101JSC::EncodedJSValue jsHTMLSelectElementValidity(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
102JSC::EncodedJSValue jsHTMLSelectElementValidationMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
103JSC::EncodedJSValue jsHTMLSelectElementLabels(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
104
105class JSHTMLSelectElementPrototype : public JSC::JSNonFinalObject {
106public:
107 using Base = JSC::JSNonFinalObject;
108 static JSHTMLSelectElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
109 {
110 JSHTMLSelectElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLSelectElementPrototype>(vm.heap)) JSHTMLSelectElementPrototype(vm, globalObject, structure);
111 ptr->finishCreation(vm);
112 return ptr;
113 }
114
115 DECLARE_INFO;
116 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
117 {
118 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
119 }
120
121private:
122 JSHTMLSelectElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
123 : JSC::JSNonFinalObject(vm, structure)
124 {
125 }
126
127 void finishCreation(JSC::VM&);
128};
129
130using JSHTMLSelectElementConstructor = JSDOMConstructorNotConstructable<JSHTMLSelectElement>;
131
132template<> JSValue JSHTMLSelectElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
133{
134 return JSHTMLElement::getConstructor(vm, &globalObject);
135}
136
137template<> void JSHTMLSelectElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
138{
139 putDirect(vm, vm.propertyNames->prototype, JSHTMLSelectElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
140 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLSelectElement"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
141 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
142}
143
144template<> const ClassInfo JSHTMLSelectElementConstructor::s_info = { "HTMLSelectElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSelectElementConstructor) };
145
146/* Hash table for prototype */
147
148static const HashTableValue JSHTMLSelectElementPrototypeTableValues[] =
149{
150 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementConstructor) } },
151 { "autocomplete", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementAutocomplete), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementAutocomplete) } },
152 { "autofocus", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementAutofocus), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementAutofocus) } },
153 { "disabled", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementDisabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementDisabled) } },
154 { "form", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementForm), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
155 { "multiple", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementMultiple), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementMultiple) } },
156 { "name", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementName) } },
157 { "required", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementRequired), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementRequired) } },
158 { "size", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementSize) } },
159 { "type", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
160 { "options", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementOptions), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
161 { "length", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementLength) } },
162 { "selectedOptions", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementSelectedOptions), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
163 { "selectedIndex", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementSelectedIndex), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementSelectedIndex) } },
164 { "value", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSelectElementValue) } },
165 { "willValidate", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementWillValidate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
166 { "validity", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementValidity), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
167 { "validationMessage", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementValidationMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
168 { "labels", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSelectElementLabels), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
169 { "item", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionItem), (intptr_t) (1) } },
170 { "namedItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionNamedItem), (intptr_t) (1) } },
171 { "add", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionAdd), (intptr_t) (1) } },
172 { "remove", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionRemove), (intptr_t) (0) } },
173 { "checkValidity", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionCheckValidity), (intptr_t) (0) } },
174 { "reportValidity", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionReportValidity), (intptr_t) (0) } },
175 { "setCustomValidity", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHTMLSelectElementPrototypeFunctionSetCustomValidity), (intptr_t) (1) } },
176};
177
178const ClassInfo JSHTMLSelectElementPrototype::s_info = { "HTMLSelectElementPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSelectElementPrototype) };
179
180void JSHTMLSelectElementPrototype::finishCreation(VM& vm)
181{
182 Base::finishCreation(vm);
183 reifyStaticProperties(vm, JSHTMLSelectElement::info(), JSHTMLSelectElementPrototypeTableValues, *this);
184 bool hasDisabledRuntimeProperties = false;
185 if (!RuntimeEnabledFeatures::sharedFeatures().interactiveFormValidationEnabled()) {
186 hasDisabledRuntimeProperties = true;
187 auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("reportValidity"), strlen("reportValidity"));
188 VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
189 JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
190 }
191 if (hasDisabledRuntimeProperties && structure()->isDictionary())
192 flattenDictionaryObject(vm);
193 putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
194}
195
196const ClassInfo JSHTMLSelectElement::s_info = { "HTMLSelectElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSelectElement) };
197
198JSHTMLSelectElement::JSHTMLSelectElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLSelectElement>&& impl)
199 : JSHTMLElement(structure, globalObject, WTFMove(impl))
200{
201}
202
203void JSHTMLSelectElement::finishCreation(VM& vm)
204{
205 Base::finishCreation(vm);
206 ASSERT(inherits(vm, info()));
207
208}
209
210JSObject* JSHTMLSelectElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
211{
212 return JSHTMLSelectElementPrototype::create(vm, &globalObject, JSHTMLSelectElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject)));
213}
214
215JSObject* JSHTMLSelectElement::prototype(VM& vm, JSDOMGlobalObject& globalObject)
216{
217 return getDOMPrototype<JSHTMLSelectElement>(vm, globalObject);
218}
219
220JSValue JSHTMLSelectElement::getConstructor(VM& vm, const JSGlobalObject* globalObject)
221{
222 return getDOMConstructor<JSHTMLSelectElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
223}
224
225bool JSHTMLSelectElement::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
226{
227 auto* thisObject = jsCast<JSHTMLSelectElement*>(object);
228 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
229 if (auto index = parseIndex(propertyName)) {
230 if (index.value() < thisObject->wrapped().length()) {
231 auto value = toJS<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value()));
232 slot.setValue(thisObject, static_cast<unsigned>(0), value);
233 return true;
234 }
235 }
236 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
237}
238
239bool JSHTMLSelectElement::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
240{
241 auto* thisObject = jsCast<JSHTMLSelectElement*>(object);
242 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
243 if (LIKELY(index <= MAX_ARRAY_INDEX)) {
244 if (index < thisObject->wrapped().length()) {
245 auto value = toJS<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index));
246 slot.setValue(thisObject, static_cast<unsigned>(0), value);
247 return true;
248 }
249 }
250 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
251}
252
253void JSHTMLSelectElement::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
254{
255 auto* thisObject = jsCast<JSHTMLSelectElement*>(object);
256 ASSERT_GC_OBJECT_INHERITS(object, info());
257 for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
258 propertyNames.add(Identifier::from(state, i));
259 JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
260}
261
262bool JSHTMLSelectElement::put(JSCell* cell, ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot& putPropertySlot)
263{
264 auto* thisObject = jsCast<JSHTMLSelectElement*>(cell);
265 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
266
267 CustomElementReactionStack customElementReactionStack(*state);
268 if (auto index = parseIndex(propertyName)) {
269 auto throwScope = DECLARE_THROW_SCOPE(state->vm());
270 auto nativeValue = convert<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, value);
271 RETURN_IF_EXCEPTION(throwScope, true);
272 thisObject->wrapped().setItem(index.value(), WTFMove(nativeValue));
273 return true;
274 }
275
276 return JSObject::put(thisObject, state, propertyName, value, putPropertySlot);
277}
278
279bool JSHTMLSelectElement::putByIndex(JSCell* cell, ExecState* state, unsigned index, JSValue value, bool shouldThrow)
280{
281 auto* thisObject = jsCast<JSHTMLSelectElement*>(cell);
282 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
283
284 CustomElementReactionStack customElementReactionStack(*state);
285 if (LIKELY(index <= MAX_ARRAY_INDEX)) {
286 auto throwScope = DECLARE_THROW_SCOPE(state->vm());
287 auto nativeValue = convert<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, value);
288 RETURN_IF_EXCEPTION(throwScope, true);
289 thisObject->wrapped().setItem(index, WTFMove(nativeValue));
290 return true;
291 }
292
293 return JSObject::putByIndex(cell, state, index, value, shouldThrow);
294}
295
296bool JSHTMLSelectElement::defineOwnProperty(JSObject* object, ExecState* state, PropertyName propertyName, const PropertyDescriptor& propertyDescriptor, bool shouldThrow)
297{
298 auto* thisObject = jsCast<JSHTMLSelectElement*>(object);
299 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
300
301 CustomElementReactionStack customElementReactionStack(*state);
302 if (auto index = parseIndex(propertyName)) {
303 if (!propertyDescriptor.isDataDescriptor())
304 return false;
305 auto throwScope = DECLARE_THROW_SCOPE(state->vm());
306 auto nativeValue = convert<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, propertyDescriptor.value());
307 RETURN_IF_EXCEPTION(throwScope, true);
308 thisObject->wrapped().setItem(index.value(), WTFMove(nativeValue));
309 return true;
310 }
311
312 PropertyDescriptor newPropertyDescriptor = propertyDescriptor;
313 newPropertyDescriptor.setConfigurable(true);
314 return JSObject::defineOwnProperty(object, state, propertyName, newPropertyDescriptor, shouldThrow);
315}
316
317template<> inline JSHTMLSelectElement* IDLAttribute<JSHTMLSelectElement>::cast(ExecState& state, EncodedJSValue thisValue)
318{
319 return jsDynamicCast<JSHTMLSelectElement*>(state.vm(), JSValue::decode(thisValue));
320}
321
322template<> inline JSHTMLSelectElement* IDLOperation<JSHTMLSelectElement>::cast(ExecState& state)
323{
324 return jsDynamicCast<JSHTMLSelectElement*>(state.vm(), state.thisValue());
325}
326
327EncodedJSValue jsHTMLSelectElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
328{
329 VM& vm = state->vm();
330 auto throwScope = DECLARE_THROW_SCOPE(vm);
331 auto* prototype = jsDynamicCast<JSHTMLSelectElementPrototype*>(vm, JSValue::decode(thisValue));
332 if (UNLIKELY(!prototype))
333 return throwVMTypeError(state, throwScope);
334 return JSValue::encode(JSHTMLSelectElement::getConstructor(state->vm(), prototype->globalObject()));
335}
336
337bool setJSHTMLSelectElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
338{
339 VM& vm = state->vm();
340 auto throwScope = DECLARE_THROW_SCOPE(vm);
341 auto* prototype = jsDynamicCast<JSHTMLSelectElementPrototype*>(vm, JSValue::decode(thisValue));
342 if (UNLIKELY(!prototype)) {
343 throwVMTypeError(state, throwScope);
344 return false;
345 }
346 // Shadowing a built-in constructor
347 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
348}
349
350static inline JSValue jsHTMLSelectElementAutocompleteGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
351{
352 UNUSED_PARAM(throwScope);
353 UNUSED_PARAM(state);
354 auto& impl = thisObject.wrapped();
355 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.autocomplete());
356 return result;
357}
358
359EncodedJSValue jsHTMLSelectElementAutocomplete(ExecState* state, EncodedJSValue thisValue, PropertyName)
360{
361 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementAutocompleteGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "autocomplete");
362}
363
364static inline bool setJSHTMLSelectElementAutocompleteSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
365{
366 UNUSED_PARAM(throwScope);
367 CustomElementReactionStack customElementReactionStack(state);
368 auto& impl = thisObject.wrapped();
369 auto nativeValue = convert<IDLDOMString>(state, value);
370 RETURN_IF_EXCEPTION(throwScope, false);
371 AttributeSetter::call(state, throwScope, [&] {
372 return impl.setAutocomplete(WTFMove(nativeValue));
373 });
374 return true;
375}
376
377bool setJSHTMLSelectElementAutocomplete(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
378{
379 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementAutocompleteSetter>(*state, thisValue, encodedValue, "autocomplete");
380}
381
382static inline JSValue jsHTMLSelectElementAutofocusGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
383{
384 UNUSED_PARAM(throwScope);
385 UNUSED_PARAM(state);
386 auto& impl = thisObject.wrapped();
387 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::autofocusAttr));
388 return result;
389}
390
391EncodedJSValue jsHTMLSelectElementAutofocus(ExecState* state, EncodedJSValue thisValue, PropertyName)
392{
393 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementAutofocusGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "autofocus");
394}
395
396static inline bool setJSHTMLSelectElementAutofocusSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
397{
398 UNUSED_PARAM(throwScope);
399 CustomElementReactionStack customElementReactionStack(state);
400 auto& impl = thisObject.wrapped();
401 auto nativeValue = convert<IDLBoolean>(state, value);
402 RETURN_IF_EXCEPTION(throwScope, false);
403 AttributeSetter::call(state, throwScope, [&] {
404 return impl.setBooleanAttribute(WebCore::HTMLNames::autofocusAttr, WTFMove(nativeValue));
405 });
406 return true;
407}
408
409bool setJSHTMLSelectElementAutofocus(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
410{
411 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementAutofocusSetter>(*state, thisValue, encodedValue, "autofocus");
412}
413
414static inline JSValue jsHTMLSelectElementDisabledGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
415{
416 UNUSED_PARAM(throwScope);
417 UNUSED_PARAM(state);
418 auto& impl = thisObject.wrapped();
419 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::disabledAttr));
420 return result;
421}
422
423EncodedJSValue jsHTMLSelectElementDisabled(ExecState* state, EncodedJSValue thisValue, PropertyName)
424{
425 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementDisabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "disabled");
426}
427
428static inline bool setJSHTMLSelectElementDisabledSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
429{
430 UNUSED_PARAM(throwScope);
431 CustomElementReactionStack customElementReactionStack(state);
432 auto& impl = thisObject.wrapped();
433 auto nativeValue = convert<IDLBoolean>(state, value);
434 RETURN_IF_EXCEPTION(throwScope, false);
435 AttributeSetter::call(state, throwScope, [&] {
436 return impl.setBooleanAttribute(WebCore::HTMLNames::disabledAttr, WTFMove(nativeValue));
437 });
438 return true;
439}
440
441bool setJSHTMLSelectElementDisabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
442{
443 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementDisabledSetter>(*state, thisValue, encodedValue, "disabled");
444}
445
446static inline JSValue jsHTMLSelectElementFormGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
447{
448 UNUSED_PARAM(throwScope);
449 UNUSED_PARAM(state);
450 auto& impl = thisObject.wrapped();
451 JSValue result = toJS<IDLNullable<IDLInterface<HTMLFormElement>>>(state, *thisObject.globalObject(), throwScope, impl.form());
452 return result;
453}
454
455EncodedJSValue jsHTMLSelectElementForm(ExecState* state, EncodedJSValue thisValue, PropertyName)
456{
457 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementFormGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "form");
458}
459
460static inline JSValue jsHTMLSelectElementMultipleGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
461{
462 UNUSED_PARAM(throwScope);
463 UNUSED_PARAM(state);
464 auto& impl = thisObject.wrapped();
465 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.multiple());
466 return result;
467}
468
469EncodedJSValue jsHTMLSelectElementMultiple(ExecState* state, EncodedJSValue thisValue, PropertyName)
470{
471 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementMultipleGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "multiple");
472}
473
474static inline bool setJSHTMLSelectElementMultipleSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
475{
476 UNUSED_PARAM(throwScope);
477 CustomElementReactionStack customElementReactionStack(state);
478 auto& impl = thisObject.wrapped();
479 auto nativeValue = convert<IDLBoolean>(state, value);
480 RETURN_IF_EXCEPTION(throwScope, false);
481 AttributeSetter::call(state, throwScope, [&] {
482 return impl.setMultiple(WTFMove(nativeValue));
483 });
484 return true;
485}
486
487bool setJSHTMLSelectElementMultiple(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
488{
489 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementMultipleSetter>(*state, thisValue, encodedValue, "multiple");
490}
491
492static inline JSValue jsHTMLSelectElementNameGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
493{
494 UNUSED_PARAM(throwScope);
495 UNUSED_PARAM(state);
496 auto& impl = thisObject.wrapped();
497 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.getNameAttribute());
498 return result;
499}
500
501EncodedJSValue jsHTMLSelectElementName(ExecState* state, EncodedJSValue thisValue, PropertyName)
502{
503 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name");
504}
505
506static inline bool setJSHTMLSelectElementNameSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
507{
508 UNUSED_PARAM(throwScope);
509 CustomElementReactionStack customElementReactionStack(state);
510 auto& impl = thisObject.wrapped();
511 auto nativeValue = convert<IDLDOMString>(state, value);
512 RETURN_IF_EXCEPTION(throwScope, false);
513 AttributeSetter::call(state, throwScope, [&] {
514 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, WTFMove(nativeValue));
515 });
516 return true;
517}
518
519bool setJSHTMLSelectElementName(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
520{
521 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementNameSetter>(*state, thisValue, encodedValue, "name");
522}
523
524static inline JSValue jsHTMLSelectElementRequiredGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
525{
526 UNUSED_PARAM(throwScope);
527 UNUSED_PARAM(state);
528 auto& impl = thisObject.wrapped();
529 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::requiredAttr));
530 return result;
531}
532
533EncodedJSValue jsHTMLSelectElementRequired(ExecState* state, EncodedJSValue thisValue, PropertyName)
534{
535 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementRequiredGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "required");
536}
537
538static inline bool setJSHTMLSelectElementRequiredSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
539{
540 UNUSED_PARAM(throwScope);
541 CustomElementReactionStack customElementReactionStack(state);
542 auto& impl = thisObject.wrapped();
543 auto nativeValue = convert<IDLBoolean>(state, value);
544 RETURN_IF_EXCEPTION(throwScope, false);
545 AttributeSetter::call(state, throwScope, [&] {
546 return impl.setBooleanAttribute(WebCore::HTMLNames::requiredAttr, WTFMove(nativeValue));
547 });
548 return true;
549}
550
551bool setJSHTMLSelectElementRequired(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
552{
553 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementRequiredSetter>(*state, thisValue, encodedValue, "required");
554}
555
556static inline JSValue jsHTMLSelectElementSizeGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
557{
558 UNUSED_PARAM(throwScope);
559 UNUSED_PARAM(state);
560 auto& impl = thisObject.wrapped();
561 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.size());
562 return result;
563}
564
565EncodedJSValue jsHTMLSelectElementSize(ExecState* state, EncodedJSValue thisValue, PropertyName)
566{
567 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementSizeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "size");
568}
569
570static inline bool setJSHTMLSelectElementSizeSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
571{
572 UNUSED_PARAM(throwScope);
573 CustomElementReactionStack customElementReactionStack(state);
574 auto& impl = thisObject.wrapped();
575 auto nativeValue = convert<IDLUnsignedLong>(state, value);
576 RETURN_IF_EXCEPTION(throwScope, false);
577 AttributeSetter::call(state, throwScope, [&] {
578 return impl.setSize(WTFMove(nativeValue));
579 });
580 return true;
581}
582
583bool setJSHTMLSelectElementSize(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
584{
585 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementSizeSetter>(*state, thisValue, encodedValue, "size");
586}
587
588static inline JSValue jsHTMLSelectElementTypeGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
589{
590 UNUSED_PARAM(throwScope);
591 UNUSED_PARAM(state);
592 auto& impl = thisObject.wrapped();
593 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type());
594 return result;
595}
596
597EncodedJSValue jsHTMLSelectElementType(ExecState* state, EncodedJSValue thisValue, PropertyName)
598{
599 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type");
600}
601
602static inline JSValue jsHTMLSelectElementOptionsGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
603{
604 UNUSED_PARAM(throwScope);
605 UNUSED_PARAM(state);
606 auto& impl = thisObject.wrapped();
607 JSValue result = toJS<IDLInterface<HTMLOptionsCollection>>(state, *thisObject.globalObject(), throwScope, impl.options());
608 return result;
609}
610
611EncodedJSValue jsHTMLSelectElementOptions(ExecState* state, EncodedJSValue thisValue, PropertyName)
612{
613 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementOptionsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "options");
614}
615
616static inline JSValue jsHTMLSelectElementLengthGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
617{
618 UNUSED_PARAM(throwScope);
619 UNUSED_PARAM(state);
620 auto& impl = thisObject.wrapped();
621 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length());
622 return result;
623}
624
625EncodedJSValue jsHTMLSelectElementLength(ExecState* state, EncodedJSValue thisValue, PropertyName)
626{
627 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length");
628}
629
630static inline bool setJSHTMLSelectElementLengthSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
631{
632 UNUSED_PARAM(throwScope);
633 CustomElementReactionStack customElementReactionStack(state);
634 auto& impl = thisObject.wrapped();
635 auto nativeValue = convert<IDLUnsignedLong>(state, value);
636 RETURN_IF_EXCEPTION(throwScope, false);
637 AttributeSetter::call(state, throwScope, [&] {
638 return impl.setLength(WTFMove(nativeValue));
639 });
640 return true;
641}
642
643bool setJSHTMLSelectElementLength(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
644{
645 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementLengthSetter>(*state, thisValue, encodedValue, "length");
646}
647
648static inline JSValue jsHTMLSelectElementSelectedOptionsGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
649{
650 UNUSED_PARAM(throwScope);
651 UNUSED_PARAM(state);
652 auto& impl = thisObject.wrapped();
653 JSValue result = toJS<IDLInterface<HTMLCollection>>(state, *thisObject.globalObject(), throwScope, impl.selectedOptions());
654 return result;
655}
656
657EncodedJSValue jsHTMLSelectElementSelectedOptions(ExecState* state, EncodedJSValue thisValue, PropertyName)
658{
659 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementSelectedOptionsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selectedOptions");
660}
661
662static inline JSValue jsHTMLSelectElementSelectedIndexGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
663{
664 UNUSED_PARAM(throwScope);
665 UNUSED_PARAM(state);
666 auto& impl = thisObject.wrapped();
667 JSValue result = toJS<IDLLong>(state, throwScope, impl.selectedIndex());
668 return result;
669}
670
671EncodedJSValue jsHTMLSelectElementSelectedIndex(ExecState* state, EncodedJSValue thisValue, PropertyName)
672{
673 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementSelectedIndexGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selectedIndex");
674}
675
676static inline bool setJSHTMLSelectElementSelectedIndexSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
677{
678 UNUSED_PARAM(throwScope);
679 auto& impl = thisObject.wrapped();
680 auto nativeValue = convert<IDLLong>(state, value);
681 RETURN_IF_EXCEPTION(throwScope, false);
682 AttributeSetter::call(state, throwScope, [&] {
683 return impl.setSelectedIndex(WTFMove(nativeValue));
684 });
685 return true;
686}
687
688bool setJSHTMLSelectElementSelectedIndex(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
689{
690 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementSelectedIndexSetter>(*state, thisValue, encodedValue, "selectedIndex");
691}
692
693static inline JSValue jsHTMLSelectElementValueGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
694{
695 UNUSED_PARAM(throwScope);
696 UNUSED_PARAM(state);
697 auto& impl = thisObject.wrapped();
698 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.value());
699 return result;
700}
701
702EncodedJSValue jsHTMLSelectElementValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
703{
704 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value");
705}
706
707static inline bool setJSHTMLSelectElementValueSetter(ExecState& state, JSHTMLSelectElement& thisObject, JSValue value, ThrowScope& throwScope)
708{
709 UNUSED_PARAM(throwScope);
710 auto& impl = thisObject.wrapped();
711 auto nativeValue = convert<IDLDOMString>(state, value);
712 RETURN_IF_EXCEPTION(throwScope, false);
713 AttributeSetter::call(state, throwScope, [&] {
714 return impl.setValue(WTFMove(nativeValue));
715 });
716 return true;
717}
718
719bool setJSHTMLSelectElementValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
720{
721 return IDLAttribute<JSHTMLSelectElement>::set<setJSHTMLSelectElementValueSetter>(*state, thisValue, encodedValue, "value");
722}
723
724static inline JSValue jsHTMLSelectElementWillValidateGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
725{
726 UNUSED_PARAM(throwScope);
727 UNUSED_PARAM(state);
728 auto& impl = thisObject.wrapped();
729 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.willValidate());
730 return result;
731}
732
733EncodedJSValue jsHTMLSelectElementWillValidate(ExecState* state, EncodedJSValue thisValue, PropertyName)
734{
735 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementWillValidateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "willValidate");
736}
737
738static inline JSValue jsHTMLSelectElementValidityGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
739{
740 UNUSED_PARAM(throwScope);
741 UNUSED_PARAM(state);
742 auto& impl = thisObject.wrapped();
743 JSValue result = toJS<IDLInterface<ValidityState>>(state, *thisObject.globalObject(), throwScope, impl.validity());
744 return result;
745}
746
747EncodedJSValue jsHTMLSelectElementValidity(ExecState* state, EncodedJSValue thisValue, PropertyName)
748{
749 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementValidityGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "validity");
750}
751
752static inline JSValue jsHTMLSelectElementValidationMessageGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
753{
754 UNUSED_PARAM(throwScope);
755 UNUSED_PARAM(state);
756 auto& impl = thisObject.wrapped();
757 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.validationMessage());
758 return result;
759}
760
761EncodedJSValue jsHTMLSelectElementValidationMessage(ExecState* state, EncodedJSValue thisValue, PropertyName)
762{
763 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementValidationMessageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "validationMessage");
764}
765
766static inline JSValue jsHTMLSelectElementLabelsGetter(ExecState& state, JSHTMLSelectElement& thisObject, ThrowScope& throwScope)
767{
768 UNUSED_PARAM(throwScope);
769 UNUSED_PARAM(state);
770 auto& impl = thisObject.wrapped();
771 JSValue result = toJS<IDLInterface<NodeList>>(state, *thisObject.globalObject(), throwScope, impl.labels());
772 return result;
773}
774
775EncodedJSValue jsHTMLSelectElementLabels(ExecState* state, EncodedJSValue thisValue, PropertyName)
776{
777 return IDLAttribute<JSHTMLSelectElement>::get<jsHTMLSelectElementLabelsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "labels");
778}
779
780static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
781{
782 UNUSED_PARAM(state);
783 UNUSED_PARAM(throwScope);
784 auto& impl = castedThis->wrapped();
785 if (UNLIKELY(state->argumentCount() < 1))
786 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
787 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
788 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
789 return JSValue::encode(toJS<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, *castedThis->globalObject(), impl.item(WTFMove(index))));
790}
791
792EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionItem(ExecState* state)
793{
794 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionItemBody>(*state, "item");
795}
796
797static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionNamedItemBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
798{
799 UNUSED_PARAM(state);
800 UNUSED_PARAM(throwScope);
801 auto& impl = castedThis->wrapped();
802 if (UNLIKELY(state->argumentCount() < 1))
803 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
804 auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
805 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
806 return JSValue::encode(toJS<IDLNullable<IDLInterface<HTMLOptionElement>>>(*state, *castedThis->globalObject(), impl.namedItem(WTFMove(name))));
807}
808
809EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionNamedItem(ExecState* state)
810{
811 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionNamedItemBody>(*state, "namedItem");
812}
813
814static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionAddBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
815{
816 UNUSED_PARAM(state);
817 UNUSED_PARAM(throwScope);
818 CustomElementReactionStack customElementReactionStack(*state);
819 auto& impl = castedThis->wrapped();
820 if (UNLIKELY(state->argumentCount() < 1))
821 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
822 auto element = convert<IDLUnion<IDLInterface<HTMLOptionElement>, IDLInterface<HTMLOptGroupElement>>>(*state, state->uncheckedArgument(0));
823 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
824 auto before = state->argument(1).isUndefined() ? WTF::nullopt : convert<IDLNullable<IDLUnion<IDLInterface<HTMLElement>, IDLLong>>>(*state, state->uncheckedArgument(1));
825 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
826 propagateException(*state, throwScope, impl.add(WTFMove(element), WTFMove(before)));
827 return JSValue::encode(jsUndefined());
828}
829
830EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionAdd(ExecState* state)
831{
832 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionAddBody>(*state, "add");
833}
834
835static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionRemove1Body(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
836{
837 UNUSED_PARAM(state);
838 UNUSED_PARAM(throwScope);
839 CustomElementReactionStack customElementReactionStack(*state);
840 auto& impl = castedThis->wrapped();
841 propagateException(*state, throwScope, impl.remove());
842 return JSValue::encode(jsUndefined());
843}
844
845static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionRemove2Body(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
846{
847 UNUSED_PARAM(state);
848 UNUSED_PARAM(throwScope);
849 CustomElementReactionStack customElementReactionStack(*state);
850 auto& impl = castedThis->wrapped();
851 auto index = convert<IDLLong>(*state, state->uncheckedArgument(0));
852 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
853 impl.remove(WTFMove(index));
854 return JSValue::encode(jsUndefined());
855}
856
857static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionRemoveOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
858{
859 UNUSED_PARAM(state);
860 UNUSED_PARAM(throwScope);
861 VM& vm = state->vm();
862 UNUSED_PARAM(vm);
863 size_t argsCount = std::min<size_t>(1, state->argumentCount());
864 if (argsCount == 0) {
865 return jsHTMLSelectElementPrototypeFunctionRemove1Body(state, castedThis, throwScope);
866 }
867 if (argsCount == 1) {
868 return jsHTMLSelectElementPrototypeFunctionRemove2Body(state, castedThis, throwScope);
869 }
870 return throwVMTypeError(state, throwScope);
871}
872
873EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionRemove(ExecState* state)
874{
875 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionRemoveOverloadDispatcher>(*state, "remove");
876}
877
878static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionCheckValidityBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
879{
880 UNUSED_PARAM(state);
881 UNUSED_PARAM(throwScope);
882 auto& impl = castedThis->wrapped();
883 return JSValue::encode(toJS<IDLBoolean>(impl.checkValidity()));
884}
885
886EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionCheckValidity(ExecState* state)
887{
888 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionCheckValidityBody>(*state, "checkValidity");
889}
890
891static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionReportValidityBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
892{
893 UNUSED_PARAM(state);
894 UNUSED_PARAM(throwScope);
895 auto& impl = castedThis->wrapped();
896 return JSValue::encode(toJS<IDLBoolean>(impl.reportValidity()));
897}
898
899EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionReportValidity(ExecState* state)
900{
901 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionReportValidityBody>(*state, "reportValidity");
902}
903
904static inline JSC::EncodedJSValue jsHTMLSelectElementPrototypeFunctionSetCustomValidityBody(JSC::ExecState* state, typename IDLOperation<JSHTMLSelectElement>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
905{
906 UNUSED_PARAM(state);
907 UNUSED_PARAM(throwScope);
908 auto& impl = castedThis->wrapped();
909 if (UNLIKELY(state->argumentCount() < 1))
910 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
911 auto error = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
912 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
913 impl.setCustomValidity(WTFMove(error));
914 return JSValue::encode(jsUndefined());
915}
916
917EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionSetCustomValidity(ExecState* state)
918{
919 return IDLOperation<JSHTMLSelectElement>::call<jsHTMLSelectElementPrototypeFunctionSetCustomValidityBody>(*state, "setCustomValidity");
920}
921
922void JSHTMLSelectElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
923{
924 auto* thisObject = jsCast<JSHTMLSelectElement*>(cell);
925 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
926 if (thisObject->scriptExecutionContext())
927 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
928 Base::heapSnapshot(cell, builder);
929}
930
931HTMLSelectElement* JSHTMLSelectElement::toWrapped(JSC::VM& vm, JSC::JSValue value)
932{
933 if (auto* wrapper = jsDynamicCast<JSHTMLSelectElement*>(vm, value))
934 return &wrapper->wrapped();
935 return nullptr;
936}
937
938}
939