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 "JSHTMLSourceElement.h"
23
24#include "CustomElementReactionQueue.h"
25#include "HTMLNames.h"
26#include "JSDOMAttribute.h"
27#include "JSDOMBinding.h"
28#include "JSDOMConstructorNotConstructable.h"
29#include "JSDOMConvertStrings.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMWrapperCache.h"
32#include "ScriptExecutionContext.h"
33#include <JavaScriptCore/HeapSnapshotBuilder.h>
34#include <JavaScriptCore/JSCInlines.h>
35#include <wtf/GetPtr.h>
36#include <wtf/PointerPreparations.h>
37#include <wtf/URL.h>
38
39
40namespace WebCore {
41using namespace JSC;
42
43// Attributes
44
45JSC::EncodedJSValue jsHTMLSourceElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46bool setJSHTMLSourceElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47JSC::EncodedJSValue jsHTMLSourceElementSrc(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSHTMLSourceElementSrc(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsHTMLSourceElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSHTMLSourceElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsHTMLSourceElementSrcset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52bool setJSHTMLSourceElementSrcset(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53JSC::EncodedJSValue jsHTMLSourceElementSizes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54bool setJSHTMLSourceElementSizes(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
55JSC::EncodedJSValue jsHTMLSourceElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56bool setJSHTMLSourceElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
57
58class JSHTMLSourceElementPrototype : public JSC::JSNonFinalObject {
59public:
60 using Base = JSC::JSNonFinalObject;
61 static JSHTMLSourceElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
62 {
63 JSHTMLSourceElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLSourceElementPrototype>(vm.heap)) JSHTMLSourceElementPrototype(vm, globalObject, structure);
64 ptr->finishCreation(vm);
65 return ptr;
66 }
67
68 DECLARE_INFO;
69 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
70 {
71 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
72 }
73
74private:
75 JSHTMLSourceElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
76 : JSC::JSNonFinalObject(vm, structure)
77 {
78 }
79
80 void finishCreation(JSC::VM&);
81};
82
83using JSHTMLSourceElementConstructor = JSDOMConstructorNotConstructable<JSHTMLSourceElement>;
84
85template<> JSValue JSHTMLSourceElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
86{
87 return JSHTMLElement::getConstructor(vm, &globalObject);
88}
89
90template<> void JSHTMLSourceElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
91{
92 putDirect(vm, vm.propertyNames->prototype, JSHTMLSourceElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLSourceElement"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
95}
96
97template<> const ClassInfo JSHTMLSourceElementConstructor::s_info = { "HTMLSourceElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSourceElementConstructor) };
98
99/* Hash table for prototype */
100
101static const HashTableValue JSHTMLSourceElementPrototypeTableValues[] =
102{
103 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSourceElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSourceElementConstructor) } },
104 { "src", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSourceElementSrc), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSourceElementSrc) } },
105 { "type", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSourceElementType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSourceElementType) } },
106 { "srcset", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSourceElementSrcset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSourceElementSrcset) } },
107 { "sizes", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSourceElementSizes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSourceElementSizes) } },
108 { "media", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLSourceElementMedia), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLSourceElementMedia) } },
109};
110
111const ClassInfo JSHTMLSourceElementPrototype::s_info = { "HTMLSourceElementPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSourceElementPrototype) };
112
113void JSHTMLSourceElementPrototype::finishCreation(VM& vm)
114{
115 Base::finishCreation(vm);
116 reifyStaticProperties(vm, JSHTMLSourceElement::info(), JSHTMLSourceElementPrototypeTableValues, *this);
117}
118
119const ClassInfo JSHTMLSourceElement::s_info = { "HTMLSourceElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSourceElement) };
120
121JSHTMLSourceElement::JSHTMLSourceElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLSourceElement>&& impl)
122 : JSHTMLElement(structure, globalObject, WTFMove(impl))
123{
124}
125
126void JSHTMLSourceElement::finishCreation(VM& vm)
127{
128 Base::finishCreation(vm);
129 ASSERT(inherits(vm, info()));
130
131}
132
133JSObject* JSHTMLSourceElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
134{
135 return JSHTMLSourceElementPrototype::create(vm, &globalObject, JSHTMLSourceElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject)));
136}
137
138JSObject* JSHTMLSourceElement::prototype(VM& vm, JSDOMGlobalObject& globalObject)
139{
140 return getDOMPrototype<JSHTMLSourceElement>(vm, globalObject);
141}
142
143JSValue JSHTMLSourceElement::getConstructor(VM& vm, const JSGlobalObject* globalObject)
144{
145 return getDOMConstructor<JSHTMLSourceElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
146}
147
148template<> inline JSHTMLSourceElement* IDLAttribute<JSHTMLSourceElement>::cast(ExecState& state, EncodedJSValue thisValue)
149{
150 return jsDynamicCast<JSHTMLSourceElement*>(state.vm(), JSValue::decode(thisValue));
151}
152
153EncodedJSValue jsHTMLSourceElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
154{
155 VM& vm = state->vm();
156 auto throwScope = DECLARE_THROW_SCOPE(vm);
157 auto* prototype = jsDynamicCast<JSHTMLSourceElementPrototype*>(vm, JSValue::decode(thisValue));
158 if (UNLIKELY(!prototype))
159 return throwVMTypeError(state, throwScope);
160 return JSValue::encode(JSHTMLSourceElement::getConstructor(state->vm(), prototype->globalObject()));
161}
162
163bool setJSHTMLSourceElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
164{
165 VM& vm = state->vm();
166 auto throwScope = DECLARE_THROW_SCOPE(vm);
167 auto* prototype = jsDynamicCast<JSHTMLSourceElementPrototype*>(vm, JSValue::decode(thisValue));
168 if (UNLIKELY(!prototype)) {
169 throwVMTypeError(state, throwScope);
170 return false;
171 }
172 // Shadowing a built-in constructor
173 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
174}
175
176static inline JSValue jsHTMLSourceElementSrcGetter(ExecState& state, JSHTMLSourceElement& thisObject, ThrowScope& throwScope)
177{
178 UNUSED_PARAM(throwScope);
179 UNUSED_PARAM(state);
180 auto& impl = thisObject.wrapped();
181 JSValue result = toJS<IDLUSVString>(state, throwScope, impl.getURLAttribute(WebCore::HTMLNames::srcAttr));
182 return result;
183}
184
185EncodedJSValue jsHTMLSourceElementSrc(ExecState* state, EncodedJSValue thisValue, PropertyName)
186{
187 return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementSrcGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "src");
188}
189
190static inline bool setJSHTMLSourceElementSrcSetter(ExecState& state, JSHTMLSourceElement& thisObject, JSValue value, ThrowScope& throwScope)
191{
192 UNUSED_PARAM(throwScope);
193 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
194 auto& impl = thisObject.wrapped();
195 auto nativeValue = convert<IDLUSVString>(state, value);
196 RETURN_IF_EXCEPTION(throwScope, false);
197 AttributeSetter::call(state, throwScope, [&] {
198 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::srcAttr, WTFMove(nativeValue));
199 });
200 return true;
201}
202
203bool setJSHTMLSourceElementSrc(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
204{
205 return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementSrcSetter>(*state, thisValue, encodedValue, "src");
206}
207
208static inline JSValue jsHTMLSourceElementTypeGetter(ExecState& state, JSHTMLSourceElement& thisObject, ThrowScope& throwScope)
209{
210 UNUSED_PARAM(throwScope);
211 UNUSED_PARAM(state);
212 auto& impl = thisObject.wrapped();
213 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::typeAttr));
214 return result;
215}
216
217EncodedJSValue jsHTMLSourceElementType(ExecState* state, EncodedJSValue thisValue, PropertyName)
218{
219 return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type");
220}
221
222static inline bool setJSHTMLSourceElementTypeSetter(ExecState& state, JSHTMLSourceElement& thisObject, JSValue value, ThrowScope& throwScope)
223{
224 UNUSED_PARAM(throwScope);
225 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
226 auto& impl = thisObject.wrapped();
227 auto nativeValue = convert<IDLDOMString>(state, value);
228 RETURN_IF_EXCEPTION(throwScope, false);
229 AttributeSetter::call(state, throwScope, [&] {
230 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::typeAttr, WTFMove(nativeValue));
231 });
232 return true;
233}
234
235bool setJSHTMLSourceElementType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
236{
237 return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementTypeSetter>(*state, thisValue, encodedValue, "type");
238}
239
240static inline JSValue jsHTMLSourceElementSrcsetGetter(ExecState& state, JSHTMLSourceElement& thisObject, ThrowScope& throwScope)
241{
242 UNUSED_PARAM(throwScope);
243 UNUSED_PARAM(state);
244 auto& impl = thisObject.wrapped();
245 JSValue result = toJS<IDLUSVString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::srcsetAttr));
246 return result;
247}
248
249EncodedJSValue jsHTMLSourceElementSrcset(ExecState* state, EncodedJSValue thisValue, PropertyName)
250{
251 return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementSrcsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "srcset");
252}
253
254static inline bool setJSHTMLSourceElementSrcsetSetter(ExecState& state, JSHTMLSourceElement& thisObject, JSValue value, ThrowScope& throwScope)
255{
256 UNUSED_PARAM(throwScope);
257 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
258 auto& impl = thisObject.wrapped();
259 auto nativeValue = convert<IDLUSVString>(state, value);
260 RETURN_IF_EXCEPTION(throwScope, false);
261 AttributeSetter::call(state, throwScope, [&] {
262 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::srcsetAttr, WTFMove(nativeValue));
263 });
264 return true;
265}
266
267bool setJSHTMLSourceElementSrcset(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
268{
269 return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementSrcsetSetter>(*state, thisValue, encodedValue, "srcset");
270}
271
272static inline JSValue jsHTMLSourceElementSizesGetter(ExecState& state, JSHTMLSourceElement& thisObject, ThrowScope& throwScope)
273{
274 UNUSED_PARAM(throwScope);
275 UNUSED_PARAM(state);
276 auto& impl = thisObject.wrapped();
277 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::sizesAttr));
278 return result;
279}
280
281EncodedJSValue jsHTMLSourceElementSizes(ExecState* state, EncodedJSValue thisValue, PropertyName)
282{
283 return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementSizesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sizes");
284}
285
286static inline bool setJSHTMLSourceElementSizesSetter(ExecState& state, JSHTMLSourceElement& thisObject, JSValue value, ThrowScope& throwScope)
287{
288 UNUSED_PARAM(throwScope);
289 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
290 auto& impl = thisObject.wrapped();
291 auto nativeValue = convert<IDLDOMString>(state, value);
292 RETURN_IF_EXCEPTION(throwScope, false);
293 AttributeSetter::call(state, throwScope, [&] {
294 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::sizesAttr, WTFMove(nativeValue));
295 });
296 return true;
297}
298
299bool setJSHTMLSourceElementSizes(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
300{
301 return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementSizesSetter>(*state, thisValue, encodedValue, "sizes");
302}
303
304static inline JSValue jsHTMLSourceElementMediaGetter(ExecState& state, JSHTMLSourceElement& thisObject, ThrowScope& throwScope)
305{
306 UNUSED_PARAM(throwScope);
307 UNUSED_PARAM(state);
308 auto& impl = thisObject.wrapped();
309 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::mediaAttr));
310 return result;
311}
312
313EncodedJSValue jsHTMLSourceElementMedia(ExecState* state, EncodedJSValue thisValue, PropertyName)
314{
315 return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementMediaGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "media");
316}
317
318static inline bool setJSHTMLSourceElementMediaSetter(ExecState& state, JSHTMLSourceElement& thisObject, JSValue value, ThrowScope& throwScope)
319{
320 UNUSED_PARAM(throwScope);
321 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
322 auto& impl = thisObject.wrapped();
323 auto nativeValue = convert<IDLDOMString>(state, value);
324 RETURN_IF_EXCEPTION(throwScope, false);
325 AttributeSetter::call(state, throwScope, [&] {
326 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::mediaAttr, WTFMove(nativeValue));
327 });
328 return true;
329}
330
331bool setJSHTMLSourceElementMedia(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
332{
333 return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementMediaSetter>(*state, thisValue, encodedValue, "media");
334}
335
336void JSHTMLSourceElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
337{
338 auto* thisObject = jsCast<JSHTMLSourceElement*>(cell);
339 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
340 if (thisObject->scriptExecutionContext())
341 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
342 Base::heapSnapshot(cell, builder);
343}
344
345
346}
347