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 | |
40 | namespace WebCore { |
41 | using namespace JSC; |
42 | |
43 | // Attributes |
44 | |
45 | JSC::EncodedJSValue jsHTMLSourceElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
46 | bool setJSHTMLSourceElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
47 | JSC::EncodedJSValue jsHTMLSourceElementSrc(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | bool setJSHTMLSourceElementSrc(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
49 | JSC::EncodedJSValue jsHTMLSourceElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | bool setJSHTMLSourceElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
51 | JSC::EncodedJSValue jsHTMLSourceElementSrcset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
52 | bool setJSHTMLSourceElementSrcset(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
53 | JSC::EncodedJSValue jsHTMLSourceElementSizes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | bool setJSHTMLSourceElementSizes(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
55 | JSC::EncodedJSValue jsHTMLSourceElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | bool setJSHTMLSourceElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
57 | |
58 | class JSHTMLSourceElementPrototype : public JSC::JSNonFinalObject { |
59 | public: |
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 | |
74 | private: |
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 | |
83 | using JSHTMLSourceElementConstructor = JSDOMConstructorNotConstructable<JSHTMLSourceElement>; |
84 | |
85 | template<> JSValue JSHTMLSourceElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
86 | { |
87 | return JSHTMLElement::getConstructor(vm, &globalObject); |
88 | } |
89 | |
90 | template<> 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 | |
97 | template<> const ClassInfo JSHTMLSourceElementConstructor::s_info = { "HTMLSourceElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSourceElementConstructor) }; |
98 | |
99 | /* Hash table for prototype */ |
100 | |
101 | static 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 | |
111 | const ClassInfo JSHTMLSourceElementPrototype::s_info = { "HTMLSourceElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSourceElementPrototype) }; |
112 | |
113 | void JSHTMLSourceElementPrototype::finishCreation(VM& vm) |
114 | { |
115 | Base::finishCreation(vm); |
116 | reifyStaticProperties(vm, JSHTMLSourceElement::info(), JSHTMLSourceElementPrototypeTableValues, *this); |
117 | } |
118 | |
119 | const ClassInfo JSHTMLSourceElement::s_info = { "HTMLSourceElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLSourceElement) }; |
120 | |
121 | JSHTMLSourceElement::JSHTMLSourceElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLSourceElement>&& impl) |
122 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
123 | { |
124 | } |
125 | |
126 | void JSHTMLSourceElement::finishCreation(VM& vm) |
127 | { |
128 | Base::finishCreation(vm); |
129 | ASSERT(inherits(vm, info())); |
130 | |
131 | } |
132 | |
133 | JSObject* JSHTMLSourceElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
134 | { |
135 | return JSHTMLSourceElementPrototype::create(vm, &globalObject, JSHTMLSourceElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
136 | } |
137 | |
138 | JSObject* JSHTMLSourceElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
139 | { |
140 | return getDOMPrototype<JSHTMLSourceElement>(vm, globalObject); |
141 | } |
142 | |
143 | JSValue JSHTMLSourceElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
144 | { |
145 | return getDOMConstructor<JSHTMLSourceElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
146 | } |
147 | |
148 | template<> inline JSHTMLSourceElement* IDLAttribute<JSHTMLSourceElement>::cast(ExecState& state, EncodedJSValue thisValue) |
149 | { |
150 | return jsDynamicCast<JSHTMLSourceElement*>(state.vm(), JSValue::decode(thisValue)); |
151 | } |
152 | |
153 | EncodedJSValue 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 | |
163 | bool 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 | |
176 | static 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 | |
185 | EncodedJSValue jsHTMLSourceElementSrc(ExecState* state, EncodedJSValue thisValue, PropertyName) |
186 | { |
187 | return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementSrcGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "src" ); |
188 | } |
189 | |
190 | static 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 | |
203 | bool setJSHTMLSourceElementSrc(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
204 | { |
205 | return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementSrcSetter>(*state, thisValue, encodedValue, "src" ); |
206 | } |
207 | |
208 | static 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 | |
217 | EncodedJSValue jsHTMLSourceElementType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
218 | { |
219 | return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
220 | } |
221 | |
222 | static 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 | |
235 | bool setJSHTMLSourceElementType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
236 | { |
237 | return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementTypeSetter>(*state, thisValue, encodedValue, "type" ); |
238 | } |
239 | |
240 | static 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 | |
249 | EncodedJSValue jsHTMLSourceElementSrcset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
250 | { |
251 | return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementSrcsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "srcset" ); |
252 | } |
253 | |
254 | static 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 | |
267 | bool setJSHTMLSourceElementSrcset(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
268 | { |
269 | return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementSrcsetSetter>(*state, thisValue, encodedValue, "srcset" ); |
270 | } |
271 | |
272 | static 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 | |
281 | EncodedJSValue jsHTMLSourceElementSizes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
282 | { |
283 | return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementSizesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sizes" ); |
284 | } |
285 | |
286 | static 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 | |
299 | bool setJSHTMLSourceElementSizes(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
300 | { |
301 | return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementSizesSetter>(*state, thisValue, encodedValue, "sizes" ); |
302 | } |
303 | |
304 | static 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 | |
313 | EncodedJSValue jsHTMLSourceElementMedia(ExecState* state, EncodedJSValue thisValue, PropertyName) |
314 | { |
315 | return IDLAttribute<JSHTMLSourceElement>::get<jsHTMLSourceElementMediaGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "media" ); |
316 | } |
317 | |
318 | static 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 | |
331 | bool setJSHTMLSourceElementMedia(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
332 | { |
333 | return IDLAttribute<JSHTMLSourceElement>::set<setJSHTMLSourceElementMediaSetter>(*state, thisValue, encodedValue, "media" ); |
334 | } |
335 | |
336 | void 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 | |