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