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 "JSHTMLOptionElement.h" |
23 | |
24 | #include "CustomElementReactionQueue.h" |
25 | #include "Document.h" |
26 | #include "HTMLNames.h" |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertInterface.h" |
32 | #include "JSDOMConvertNumbers.h" |
33 | #include "JSDOMConvertStrings.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMGlobalObject.h" |
36 | #include "JSDOMNamedConstructor.h" |
37 | #include "JSDOMWrapperCache.h" |
38 | #include "JSHTMLFormElement.h" |
39 | #include "ScriptExecutionContext.h" |
40 | #include <JavaScriptCore/FunctionPrototype.h> |
41 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
42 | #include <JavaScriptCore/JSCInlines.h> |
43 | #include <wtf/GetPtr.h> |
44 | #include <wtf/PointerPreparations.h> |
45 | #include <wtf/URL.h> |
46 | |
47 | |
48 | namespace WebCore { |
49 | using namespace JSC; |
50 | |
51 | // Attributes |
52 | |
53 | JSC::EncodedJSValue jsHTMLOptionElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | bool setJSHTMLOptionElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
55 | JSC::EncodedJSValue jsHTMLOptionElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | bool setJSHTMLOptionElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
57 | JSC::EncodedJSValue jsHTMLOptionElementForm(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
58 | JSC::EncodedJSValue jsHTMLOptionElementLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | bool setJSHTMLOptionElementLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
60 | JSC::EncodedJSValue jsHTMLOptionElementDefaultSelected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
61 | bool setJSHTMLOptionElementDefaultSelected(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
62 | JSC::EncodedJSValue jsHTMLOptionElementSelected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
63 | bool setJSHTMLOptionElementSelected(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
64 | JSC::EncodedJSValue jsHTMLOptionElementValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
65 | bool setJSHTMLOptionElementValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
66 | JSC::EncodedJSValue jsHTMLOptionElementText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
67 | bool setJSHTMLOptionElementText(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
68 | JSC::EncodedJSValue jsHTMLOptionElementIndex(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
69 | |
70 | class JSHTMLOptionElementPrototype : public JSC::JSNonFinalObject { |
71 | public: |
72 | using Base = JSC::JSNonFinalObject; |
73 | static JSHTMLOptionElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
74 | { |
75 | JSHTMLOptionElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLOptionElementPrototype>(vm.heap)) JSHTMLOptionElementPrototype(vm, globalObject, structure); |
76 | ptr->finishCreation(vm); |
77 | return ptr; |
78 | } |
79 | |
80 | DECLARE_INFO; |
81 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
82 | { |
83 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
84 | } |
85 | |
86 | private: |
87 | JSHTMLOptionElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
88 | : JSC::JSNonFinalObject(vm, structure) |
89 | { |
90 | } |
91 | |
92 | void finishCreation(JSC::VM&); |
93 | }; |
94 | |
95 | using JSHTMLOptionElementConstructor = JSDOMConstructorNotConstructable<JSHTMLOptionElement>; |
96 | using JSHTMLOptionElementNamedConstructor = JSDOMNamedConstructor<JSHTMLOptionElement>; |
97 | |
98 | template<> JSValue JSHTMLOptionElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
99 | { |
100 | return JSHTMLElement::getConstructor(vm, &globalObject); |
101 | } |
102 | |
103 | template<> void JSHTMLOptionElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
104 | { |
105 | putDirect(vm, vm.propertyNames->prototype, JSHTMLOptionElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
106 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLOptionElement"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
107 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
108 | } |
109 | |
110 | template<> const ClassInfo JSHTMLOptionElementConstructor::s_info = { "HTMLOptionElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptionElementConstructor) }; |
111 | |
112 | template<> EncodedJSValue JSC_HOST_CALL JSHTMLOptionElementNamedConstructor::construct(ExecState* state) |
113 | { |
114 | VM& vm = state->vm(); |
115 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
116 | UNUSED_PARAM(throwScope); |
117 | auto* castedThis = jsCast<JSHTMLOptionElementNamedConstructor*>(state->jsCallee()); |
118 | ASSERT(castedThis); |
119 | auto* context = castedThis->scriptExecutionContext(); |
120 | if (UNLIKELY(!context)) |
121 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "HTMLOptionElement" ); |
122 | ASSERT(context->isDocument()); |
123 | auto& document = downcast<Document>(*context); |
124 | auto text = state->argument(0).isUndefined() ? emptyString() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
125 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
126 | auto value = state->argument(1).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
127 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
128 | auto defaultSelected = convert<IDLBoolean>(*state, state->argument(2)); |
129 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
130 | auto selected = convert<IDLBoolean>(*state, state->argument(3)); |
131 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
132 | auto object = HTMLOptionElement::createForJSConstructor(document, WTFMove(text), WTFMove(value), WTFMove(defaultSelected), WTFMove(selected)); |
133 | return JSValue::encode(toJSNewlyCreated<IDLInterface<HTMLOptionElement>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
134 | } |
135 | |
136 | template<> JSValue JSHTMLOptionElementNamedConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
137 | { |
138 | UNUSED_PARAM(vm); |
139 | return globalObject.functionPrototype(); |
140 | } |
141 | |
142 | template<> void JSHTMLOptionElementNamedConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
143 | { |
144 | putDirect(vm, vm.propertyNames->prototype, JSHTMLOptionElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
145 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Option"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
146 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
147 | } |
148 | |
149 | template<> const ClassInfo JSHTMLOptionElementNamedConstructor::s_info = { "Option" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptionElementNamedConstructor) }; |
150 | |
151 | /* Hash table for prototype */ |
152 | |
153 | static const HashTableValue JSHTMLOptionElementPrototypeTableValues[] = |
154 | { |
155 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementConstructor) } }, |
156 | { "disabled" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementDisabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementDisabled) } }, |
157 | { "form" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementForm), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
158 | { "label" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementLabel) } }, |
159 | { "defaultSelected" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementDefaultSelected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementDefaultSelected) } }, |
160 | { "selected" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementSelected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementSelected) } }, |
161 | { "value" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementValue) } }, |
162 | { "text" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptionElementText) } }, |
163 | { "index" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptionElementIndex), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
164 | }; |
165 | |
166 | const ClassInfo JSHTMLOptionElementPrototype::s_info = { "HTMLOptionElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptionElementPrototype) }; |
167 | |
168 | void JSHTMLOptionElementPrototype::finishCreation(VM& vm) |
169 | { |
170 | Base::finishCreation(vm); |
171 | reifyStaticProperties(vm, JSHTMLOptionElement::info(), JSHTMLOptionElementPrototypeTableValues, *this); |
172 | } |
173 | |
174 | const ClassInfo JSHTMLOptionElement::s_info = { "HTMLOptionElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptionElement) }; |
175 | |
176 | JSHTMLOptionElement::JSHTMLOptionElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLOptionElement>&& impl) |
177 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
178 | { |
179 | } |
180 | |
181 | void JSHTMLOptionElement::finishCreation(VM& vm) |
182 | { |
183 | Base::finishCreation(vm); |
184 | ASSERT(inherits(vm, info())); |
185 | |
186 | } |
187 | |
188 | JSObject* JSHTMLOptionElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
189 | { |
190 | return JSHTMLOptionElementPrototype::create(vm, &globalObject, JSHTMLOptionElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
191 | } |
192 | |
193 | JSObject* JSHTMLOptionElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
194 | { |
195 | return getDOMPrototype<JSHTMLOptionElement>(vm, globalObject); |
196 | } |
197 | |
198 | JSValue JSHTMLOptionElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
199 | { |
200 | return getDOMConstructor<JSHTMLOptionElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
201 | } |
202 | |
203 | JSValue JSHTMLOptionElement::getNamedConstructor(VM& vm, JSGlobalObject* globalObject) |
204 | { |
205 | return getDOMConstructor<JSHTMLOptionElementNamedConstructor>(vm, *jsCast<JSDOMGlobalObject*>(globalObject)); |
206 | } |
207 | |
208 | template<> inline JSHTMLOptionElement* IDLAttribute<JSHTMLOptionElement>::cast(ExecState& state, EncodedJSValue thisValue) |
209 | { |
210 | return jsDynamicCast<JSHTMLOptionElement*>(state.vm(), JSValue::decode(thisValue)); |
211 | } |
212 | |
213 | EncodedJSValue jsHTMLOptionElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
214 | { |
215 | VM& vm = state->vm(); |
216 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
217 | auto* prototype = jsDynamicCast<JSHTMLOptionElementPrototype*>(vm, JSValue::decode(thisValue)); |
218 | if (UNLIKELY(!prototype)) |
219 | return throwVMTypeError(state, throwScope); |
220 | return JSValue::encode(JSHTMLOptionElement::getConstructor(state->vm(), prototype->globalObject())); |
221 | } |
222 | |
223 | bool setJSHTMLOptionElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
224 | { |
225 | VM& vm = state->vm(); |
226 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
227 | auto* prototype = jsDynamicCast<JSHTMLOptionElementPrototype*>(vm, JSValue::decode(thisValue)); |
228 | if (UNLIKELY(!prototype)) { |
229 | throwVMTypeError(state, throwScope); |
230 | return false; |
231 | } |
232 | // Shadowing a built-in constructor |
233 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
234 | } |
235 | |
236 | static inline JSValue jsHTMLOptionElementDisabledGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
237 | { |
238 | UNUSED_PARAM(throwScope); |
239 | UNUSED_PARAM(state); |
240 | auto& impl = thisObject.wrapped(); |
241 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::disabledAttr)); |
242 | return result; |
243 | } |
244 | |
245 | EncodedJSValue jsHTMLOptionElementDisabled(ExecState* state, EncodedJSValue thisValue, PropertyName) |
246 | { |
247 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementDisabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "disabled" ); |
248 | } |
249 | |
250 | static inline bool setJSHTMLOptionElementDisabledSetter(ExecState& state, JSHTMLOptionElement& thisObject, JSValue value, ThrowScope& throwScope) |
251 | { |
252 | UNUSED_PARAM(throwScope); |
253 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
254 | auto& impl = thisObject.wrapped(); |
255 | auto nativeValue = convert<IDLBoolean>(state, value); |
256 | RETURN_IF_EXCEPTION(throwScope, false); |
257 | AttributeSetter::call(state, throwScope, [&] { |
258 | return impl.setBooleanAttribute(WebCore::HTMLNames::disabledAttr, WTFMove(nativeValue)); |
259 | }); |
260 | return true; |
261 | } |
262 | |
263 | bool setJSHTMLOptionElementDisabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
264 | { |
265 | return IDLAttribute<JSHTMLOptionElement>::set<setJSHTMLOptionElementDisabledSetter>(*state, thisValue, encodedValue, "disabled" ); |
266 | } |
267 | |
268 | static inline JSValue jsHTMLOptionElementFormGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
269 | { |
270 | UNUSED_PARAM(throwScope); |
271 | UNUSED_PARAM(state); |
272 | auto& impl = thisObject.wrapped(); |
273 | JSValue result = toJS<IDLInterface<HTMLFormElement>>(state, *thisObject.globalObject(), throwScope, impl.form()); |
274 | return result; |
275 | } |
276 | |
277 | EncodedJSValue jsHTMLOptionElementForm(ExecState* state, EncodedJSValue thisValue, PropertyName) |
278 | { |
279 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementFormGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "form" ); |
280 | } |
281 | |
282 | static inline JSValue jsHTMLOptionElementLabelGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
283 | { |
284 | UNUSED_PARAM(throwScope); |
285 | UNUSED_PARAM(state); |
286 | auto& impl = thisObject.wrapped(); |
287 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.label()); |
288 | return result; |
289 | } |
290 | |
291 | EncodedJSValue jsHTMLOptionElementLabel(ExecState* state, EncodedJSValue thisValue, PropertyName) |
292 | { |
293 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label" ); |
294 | } |
295 | |
296 | static inline bool setJSHTMLOptionElementLabelSetter(ExecState& state, JSHTMLOptionElement& thisObject, JSValue value, ThrowScope& throwScope) |
297 | { |
298 | UNUSED_PARAM(throwScope); |
299 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
300 | auto& impl = thisObject.wrapped(); |
301 | auto nativeValue = convert<IDLDOMString>(state, value); |
302 | RETURN_IF_EXCEPTION(throwScope, false); |
303 | AttributeSetter::call(state, throwScope, [&] { |
304 | return impl.setLabel(WTFMove(nativeValue)); |
305 | }); |
306 | return true; |
307 | } |
308 | |
309 | bool setJSHTMLOptionElementLabel(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
310 | { |
311 | return IDLAttribute<JSHTMLOptionElement>::set<setJSHTMLOptionElementLabelSetter>(*state, thisValue, encodedValue, "label" ); |
312 | } |
313 | |
314 | static inline JSValue jsHTMLOptionElementDefaultSelectedGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
315 | { |
316 | UNUSED_PARAM(throwScope); |
317 | UNUSED_PARAM(state); |
318 | auto& impl = thisObject.wrapped(); |
319 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::selectedAttr)); |
320 | return result; |
321 | } |
322 | |
323 | EncodedJSValue jsHTMLOptionElementDefaultSelected(ExecState* state, EncodedJSValue thisValue, PropertyName) |
324 | { |
325 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementDefaultSelectedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "defaultSelected" ); |
326 | } |
327 | |
328 | static inline bool setJSHTMLOptionElementDefaultSelectedSetter(ExecState& state, JSHTMLOptionElement& thisObject, JSValue value, ThrowScope& throwScope) |
329 | { |
330 | UNUSED_PARAM(throwScope); |
331 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
332 | auto& impl = thisObject.wrapped(); |
333 | auto nativeValue = convert<IDLBoolean>(state, value); |
334 | RETURN_IF_EXCEPTION(throwScope, false); |
335 | AttributeSetter::call(state, throwScope, [&] { |
336 | return impl.setBooleanAttribute(WebCore::HTMLNames::selectedAttr, WTFMove(nativeValue)); |
337 | }); |
338 | return true; |
339 | } |
340 | |
341 | bool setJSHTMLOptionElementDefaultSelected(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
342 | { |
343 | return IDLAttribute<JSHTMLOptionElement>::set<setJSHTMLOptionElementDefaultSelectedSetter>(*state, thisValue, encodedValue, "defaultSelected" ); |
344 | } |
345 | |
346 | static inline JSValue jsHTMLOptionElementSelectedGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
347 | { |
348 | UNUSED_PARAM(throwScope); |
349 | UNUSED_PARAM(state); |
350 | auto& impl = thisObject.wrapped(); |
351 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.selected()); |
352 | return result; |
353 | } |
354 | |
355 | EncodedJSValue jsHTMLOptionElementSelected(ExecState* state, EncodedJSValue thisValue, PropertyName) |
356 | { |
357 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementSelectedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selected" ); |
358 | } |
359 | |
360 | static inline bool setJSHTMLOptionElementSelectedSetter(ExecState& state, JSHTMLOptionElement& thisObject, JSValue value, ThrowScope& throwScope) |
361 | { |
362 | UNUSED_PARAM(throwScope); |
363 | auto& impl = thisObject.wrapped(); |
364 | auto nativeValue = convert<IDLBoolean>(state, value); |
365 | RETURN_IF_EXCEPTION(throwScope, false); |
366 | AttributeSetter::call(state, throwScope, [&] { |
367 | return impl.setSelected(WTFMove(nativeValue)); |
368 | }); |
369 | return true; |
370 | } |
371 | |
372 | bool setJSHTMLOptionElementSelected(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
373 | { |
374 | return IDLAttribute<JSHTMLOptionElement>::set<setJSHTMLOptionElementSelectedSetter>(*state, thisValue, encodedValue, "selected" ); |
375 | } |
376 | |
377 | static inline JSValue jsHTMLOptionElementValueGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
378 | { |
379 | UNUSED_PARAM(throwScope); |
380 | UNUSED_PARAM(state); |
381 | auto& impl = thisObject.wrapped(); |
382 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.value()); |
383 | return result; |
384 | } |
385 | |
386 | EncodedJSValue jsHTMLOptionElementValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
387 | { |
388 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "value" ); |
389 | } |
390 | |
391 | static inline bool setJSHTMLOptionElementValueSetter(ExecState& state, JSHTMLOptionElement& thisObject, JSValue value, ThrowScope& throwScope) |
392 | { |
393 | UNUSED_PARAM(throwScope); |
394 | CustomElementReactionDisallowedScope customElementReactionDisallowedScope; |
395 | auto& impl = thisObject.wrapped(); |
396 | auto nativeValue = convert<IDLDOMString>(state, value); |
397 | RETURN_IF_EXCEPTION(throwScope, false); |
398 | AttributeSetter::call(state, throwScope, [&] { |
399 | return impl.setValue(WTFMove(nativeValue)); |
400 | }); |
401 | return true; |
402 | } |
403 | |
404 | bool setJSHTMLOptionElementValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
405 | { |
406 | return IDLAttribute<JSHTMLOptionElement>::set<setJSHTMLOptionElementValueSetter>(*state, thisValue, encodedValue, "value" ); |
407 | } |
408 | |
409 | static inline JSValue jsHTMLOptionElementTextGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
410 | { |
411 | UNUSED_PARAM(throwScope); |
412 | UNUSED_PARAM(state); |
413 | auto& impl = thisObject.wrapped(); |
414 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.text()); |
415 | return result; |
416 | } |
417 | |
418 | EncodedJSValue jsHTMLOptionElementText(ExecState* state, EncodedJSValue thisValue, PropertyName) |
419 | { |
420 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementTextGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "text" ); |
421 | } |
422 | |
423 | static inline bool setJSHTMLOptionElementTextSetter(ExecState& state, JSHTMLOptionElement& thisObject, JSValue value, ThrowScope& throwScope) |
424 | { |
425 | UNUSED_PARAM(throwScope); |
426 | CustomElementReactionStack customElementReactionStack(state); |
427 | auto& impl = thisObject.wrapped(); |
428 | auto nativeValue = convert<IDLDOMString>(state, value); |
429 | RETURN_IF_EXCEPTION(throwScope, false); |
430 | AttributeSetter::call(state, throwScope, [&] { |
431 | return impl.setText(WTFMove(nativeValue)); |
432 | }); |
433 | return true; |
434 | } |
435 | |
436 | bool setJSHTMLOptionElementText(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
437 | { |
438 | return IDLAttribute<JSHTMLOptionElement>::set<setJSHTMLOptionElementTextSetter>(*state, thisValue, encodedValue, "text" ); |
439 | } |
440 | |
441 | static inline JSValue jsHTMLOptionElementIndexGetter(ExecState& state, JSHTMLOptionElement& thisObject, ThrowScope& throwScope) |
442 | { |
443 | UNUSED_PARAM(throwScope); |
444 | UNUSED_PARAM(state); |
445 | auto& impl = thisObject.wrapped(); |
446 | JSValue result = toJS<IDLLong>(state, throwScope, impl.index()); |
447 | return result; |
448 | } |
449 | |
450 | EncodedJSValue jsHTMLOptionElementIndex(ExecState* state, EncodedJSValue thisValue, PropertyName) |
451 | { |
452 | return IDLAttribute<JSHTMLOptionElement>::get<jsHTMLOptionElementIndexGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "index" ); |
453 | } |
454 | |
455 | void JSHTMLOptionElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
456 | { |
457 | auto* thisObject = jsCast<JSHTMLOptionElement*>(cell); |
458 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
459 | if (thisObject->scriptExecutionContext()) |
460 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
461 | Base::heapSnapshot(cell, builder); |
462 | } |
463 | |
464 | #if ENABLE(BINDING_INTEGRITY) |
465 | #if PLATFORM(WIN) |
466 | #pragma warning(disable: 4483) |
467 | extern "C" { extern void (*const __identifier("??_7HTMLOptionElement@WebCore@@6B@" )[])(); } |
468 | #else |
469 | extern "C" { extern void* _ZTVN7WebCore17HTMLOptionElementE[]; } |
470 | #endif |
471 | #endif |
472 | |
473 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<HTMLOptionElement>&& impl) |
474 | { |
475 | |
476 | #if ENABLE(BINDING_INTEGRITY) |
477 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
478 | #if PLATFORM(WIN) |
479 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7HTMLOptionElement@WebCore@@6B@" )); |
480 | #else |
481 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore17HTMLOptionElementE[2]); |
482 | #endif |
483 | |
484 | // If this fails HTMLOptionElement does not have a vtable, so you need to add the |
485 | // ImplementationLacksVTable attribute to the interface definition |
486 | static_assert(std::is_polymorphic<HTMLOptionElement>::value, "HTMLOptionElement is not polymorphic" ); |
487 | |
488 | // If you hit this assertion you either have a use after free bug, or |
489 | // HTMLOptionElement has subclasses. If HTMLOptionElement has subclasses that get passed |
490 | // to toJS() we currently require HTMLOptionElement you to opt out of binding hardening |
491 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
492 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
493 | #endif |
494 | return createWrapper<HTMLOptionElement>(globalObject, WTFMove(impl)); |
495 | } |
496 | |
497 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, HTMLOptionElement& impl) |
498 | { |
499 | return wrap(state, globalObject, impl); |
500 | } |
501 | |
502 | HTMLOptionElement* JSHTMLOptionElement::toWrapped(JSC::VM& vm, JSC::JSValue value) |
503 | { |
504 | if (auto* wrapper = jsDynamicCast<JSHTMLOptionElement*>(vm, value)) |
505 | return &wrapper->wrapped(); |
506 | return nullptr; |
507 | } |
508 | |
509 | } |
510 | |