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 "JSHTMLOptGroupElement.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 "JSDOMConvertStrings.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMWrapperCache.h"
33#include "ScriptExecutionContext.h"
34#include <JavaScriptCore/HeapSnapshotBuilder.h>
35#include <JavaScriptCore/JSCInlines.h>
36#include <wtf/GetPtr.h>
37#include <wtf/PointerPreparations.h>
38#include <wtf/URL.h>
39
40
41namespace WebCore {
42using namespace JSC;
43
44// Attributes
45
46JSC::EncodedJSValue jsHTMLOptGroupElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
47bool setJSHTMLOptGroupElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
48JSC::EncodedJSValue jsHTMLOptGroupElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49bool setJSHTMLOptGroupElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50JSC::EncodedJSValue jsHTMLOptGroupElementLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51bool setJSHTMLOptGroupElementLabel(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
52
53class JSHTMLOptGroupElementPrototype : public JSC::JSNonFinalObject {
54public:
55 using Base = JSC::JSNonFinalObject;
56 static JSHTMLOptGroupElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
57 {
58 JSHTMLOptGroupElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLOptGroupElementPrototype>(vm.heap)) JSHTMLOptGroupElementPrototype(vm, globalObject, structure);
59 ptr->finishCreation(vm);
60 return ptr;
61 }
62
63 DECLARE_INFO;
64 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
65 {
66 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
67 }
68
69private:
70 JSHTMLOptGroupElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
71 : JSC::JSNonFinalObject(vm, structure)
72 {
73 }
74
75 void finishCreation(JSC::VM&);
76};
77
78using JSHTMLOptGroupElementConstructor = JSDOMConstructorNotConstructable<JSHTMLOptGroupElement>;
79
80template<> JSValue JSHTMLOptGroupElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
81{
82 return JSHTMLElement::getConstructor(vm, &globalObject);
83}
84
85template<> void JSHTMLOptGroupElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
86{
87 putDirect(vm, vm.propertyNames->prototype, JSHTMLOptGroupElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLOptGroupElement"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90}
91
92template<> const ClassInfo JSHTMLOptGroupElementConstructor::s_info = { "HTMLOptGroupElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptGroupElementConstructor) };
93
94/* Hash table for prototype */
95
96static const HashTableValue JSHTMLOptGroupElementPrototypeTableValues[] =
97{
98 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptGroupElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptGroupElementConstructor) } },
99 { "disabled", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptGroupElementDisabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptGroupElementDisabled) } },
100 { "label", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLOptGroupElementLabel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLOptGroupElementLabel) } },
101};
102
103const ClassInfo JSHTMLOptGroupElementPrototype::s_info = { "HTMLOptGroupElementPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptGroupElementPrototype) };
104
105void JSHTMLOptGroupElementPrototype::finishCreation(VM& vm)
106{
107 Base::finishCreation(vm);
108 reifyStaticProperties(vm, JSHTMLOptGroupElement::info(), JSHTMLOptGroupElementPrototypeTableValues, *this);
109}
110
111const ClassInfo JSHTMLOptGroupElement::s_info = { "HTMLOptGroupElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLOptGroupElement) };
112
113JSHTMLOptGroupElement::JSHTMLOptGroupElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLOptGroupElement>&& impl)
114 : JSHTMLElement(structure, globalObject, WTFMove(impl))
115{
116}
117
118void JSHTMLOptGroupElement::finishCreation(VM& vm)
119{
120 Base::finishCreation(vm);
121 ASSERT(inherits(vm, info()));
122
123}
124
125JSObject* JSHTMLOptGroupElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
126{
127 return JSHTMLOptGroupElementPrototype::create(vm, &globalObject, JSHTMLOptGroupElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject)));
128}
129
130JSObject* JSHTMLOptGroupElement::prototype(VM& vm, JSDOMGlobalObject& globalObject)
131{
132 return getDOMPrototype<JSHTMLOptGroupElement>(vm, globalObject);
133}
134
135JSValue JSHTMLOptGroupElement::getConstructor(VM& vm, const JSGlobalObject* globalObject)
136{
137 return getDOMConstructor<JSHTMLOptGroupElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
138}
139
140template<> inline JSHTMLOptGroupElement* IDLAttribute<JSHTMLOptGroupElement>::cast(ExecState& state, EncodedJSValue thisValue)
141{
142 return jsDynamicCast<JSHTMLOptGroupElement*>(state.vm(), JSValue::decode(thisValue));
143}
144
145EncodedJSValue jsHTMLOptGroupElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
146{
147 VM& vm = state->vm();
148 auto throwScope = DECLARE_THROW_SCOPE(vm);
149 auto* prototype = jsDynamicCast<JSHTMLOptGroupElementPrototype*>(vm, JSValue::decode(thisValue));
150 if (UNLIKELY(!prototype))
151 return throwVMTypeError(state, throwScope);
152 return JSValue::encode(JSHTMLOptGroupElement::getConstructor(state->vm(), prototype->globalObject()));
153}
154
155bool setJSHTMLOptGroupElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
156{
157 VM& vm = state->vm();
158 auto throwScope = DECLARE_THROW_SCOPE(vm);
159 auto* prototype = jsDynamicCast<JSHTMLOptGroupElementPrototype*>(vm, JSValue::decode(thisValue));
160 if (UNLIKELY(!prototype)) {
161 throwVMTypeError(state, throwScope);
162 return false;
163 }
164 // Shadowing a built-in constructor
165 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
166}
167
168static inline JSValue jsHTMLOptGroupElementDisabledGetter(ExecState& state, JSHTMLOptGroupElement& thisObject, ThrowScope& throwScope)
169{
170 UNUSED_PARAM(throwScope);
171 UNUSED_PARAM(state);
172 auto& impl = thisObject.wrapped();
173 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::disabledAttr));
174 return result;
175}
176
177EncodedJSValue jsHTMLOptGroupElementDisabled(ExecState* state, EncodedJSValue thisValue, PropertyName)
178{
179 return IDLAttribute<JSHTMLOptGroupElement>::get<jsHTMLOptGroupElementDisabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "disabled");
180}
181
182static inline bool setJSHTMLOptGroupElementDisabledSetter(ExecState& state, JSHTMLOptGroupElement& thisObject, JSValue value, ThrowScope& throwScope)
183{
184 UNUSED_PARAM(throwScope);
185 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
186 auto& impl = thisObject.wrapped();
187 auto nativeValue = convert<IDLBoolean>(state, value);
188 RETURN_IF_EXCEPTION(throwScope, false);
189 AttributeSetter::call(state, throwScope, [&] {
190 return impl.setBooleanAttribute(WebCore::HTMLNames::disabledAttr, WTFMove(nativeValue));
191 });
192 return true;
193}
194
195bool setJSHTMLOptGroupElementDisabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
196{
197 return IDLAttribute<JSHTMLOptGroupElement>::set<setJSHTMLOptGroupElementDisabledSetter>(*state, thisValue, encodedValue, "disabled");
198}
199
200static inline JSValue jsHTMLOptGroupElementLabelGetter(ExecState& state, JSHTMLOptGroupElement& thisObject, ThrowScope& throwScope)
201{
202 UNUSED_PARAM(throwScope);
203 UNUSED_PARAM(state);
204 auto& impl = thisObject.wrapped();
205 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::labelAttr));
206 return result;
207}
208
209EncodedJSValue jsHTMLOptGroupElementLabel(ExecState* state, EncodedJSValue thisValue, PropertyName)
210{
211 return IDLAttribute<JSHTMLOptGroupElement>::get<jsHTMLOptGroupElementLabelGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "label");
212}
213
214static inline bool setJSHTMLOptGroupElementLabelSetter(ExecState& state, JSHTMLOptGroupElement& thisObject, JSValue value, ThrowScope& throwScope)
215{
216 UNUSED_PARAM(throwScope);
217 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
218 auto& impl = thisObject.wrapped();
219 auto nativeValue = convert<IDLDOMString>(state, value);
220 RETURN_IF_EXCEPTION(throwScope, false);
221 AttributeSetter::call(state, throwScope, [&] {
222 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::labelAttr, WTFMove(nativeValue));
223 });
224 return true;
225}
226
227bool setJSHTMLOptGroupElementLabel(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
228{
229 return IDLAttribute<JSHTMLOptGroupElement>::set<setJSHTMLOptGroupElementLabelSetter>(*state, thisValue, encodedValue, "label");
230}
231
232void JSHTMLOptGroupElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
233{
234 auto* thisObject = jsCast<JSHTMLOptGroupElement*>(cell);
235 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
236 if (thisObject->scriptExecutionContext())
237 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
238 Base::heapSnapshot(cell, builder);
239}
240
241HTMLOptGroupElement* JSHTMLOptGroupElement::toWrapped(JSC::VM& vm, JSC::JSValue value)
242{
243 if (auto* wrapper = jsDynamicCast<JSHTMLOptGroupElement*>(vm, value))
244 return &wrapper->wrapped();
245 return nullptr;
246}
247
248}
249