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 | |
23 | #if ENABLE(VIDEO_TRACK) |
24 | |
25 | #include "JSTrackEvent.h" |
26 | |
27 | #include "JSAudioTrack.h" |
28 | #include "JSDOMAttribute.h" |
29 | #include "JSDOMBinding.h" |
30 | #include "JSDOMConstructor.h" |
31 | #include "JSDOMConvertBoolean.h" |
32 | #include "JSDOMConvertInterface.h" |
33 | #include "JSDOMConvertNullable.h" |
34 | #include "JSDOMConvertUnion.h" |
35 | #include "JSDOMExceptionHandling.h" |
36 | #include "JSDOMGlobalObject.h" |
37 | #include "JSDOMWrapperCache.h" |
38 | #include "JSTextTrack.h" |
39 | #include "JSVideoTrack.h" |
40 | #include "ScriptExecutionContext.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 | #include <wtf/Variant.h> |
47 | |
48 | #if ENABLE(VIDEO_TRACK) |
49 | #include "JSDOMConvertStrings.h" |
50 | #endif |
51 | |
52 | |
53 | namespace WebCore { |
54 | using namespace JSC; |
55 | |
56 | template<> TrackEvent::Init convertDictionary<TrackEvent::Init>(ExecState& state, JSValue value) |
57 | { |
58 | VM& vm = state.vm(); |
59 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
60 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
61 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
62 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
63 | throwTypeError(&state, throwScope); |
64 | return { }; |
65 | } |
66 | TrackEvent::Init result; |
67 | JSValue bubblesValue; |
68 | if (isNullOrUndefined) |
69 | bubblesValue = jsUndefined(); |
70 | else { |
71 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
72 | RETURN_IF_EXCEPTION(throwScope, { }); |
73 | } |
74 | if (!bubblesValue.isUndefined()) { |
75 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
76 | RETURN_IF_EXCEPTION(throwScope, { }); |
77 | } else |
78 | result.bubbles = false; |
79 | JSValue cancelableValue; |
80 | if (isNullOrUndefined) |
81 | cancelableValue = jsUndefined(); |
82 | else { |
83 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
84 | RETURN_IF_EXCEPTION(throwScope, { }); |
85 | } |
86 | if (!cancelableValue.isUndefined()) { |
87 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
88 | RETURN_IF_EXCEPTION(throwScope, { }); |
89 | } else |
90 | result.cancelable = false; |
91 | JSValue composedValue; |
92 | if (isNullOrUndefined) |
93 | composedValue = jsUndefined(); |
94 | else { |
95 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
96 | RETURN_IF_EXCEPTION(throwScope, { }); |
97 | } |
98 | if (!composedValue.isUndefined()) { |
99 | result.composed = convert<IDLBoolean>(state, composedValue); |
100 | RETURN_IF_EXCEPTION(throwScope, { }); |
101 | } else |
102 | result.composed = false; |
103 | JSValue trackValue; |
104 | if (isNullOrUndefined) |
105 | trackValue = jsUndefined(); |
106 | else { |
107 | trackValue = object->get(&state, Identifier::fromString(&state, "track" )); |
108 | RETURN_IF_EXCEPTION(throwScope, { }); |
109 | } |
110 | if (!trackValue.isUndefined()) { |
111 | result.track = convert<IDLNullable<IDLUnion<IDLInterface<VideoTrack>, IDLInterface<AudioTrack>, IDLInterface<TextTrack>>>>(state, trackValue); |
112 | RETURN_IF_EXCEPTION(throwScope, { }); |
113 | } else |
114 | result.track = WTF::nullopt; |
115 | return result; |
116 | } |
117 | |
118 | // Attributes |
119 | |
120 | JSC::EncodedJSValue jsTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
121 | bool setJSTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
122 | JSC::EncodedJSValue jsTrackEventTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
123 | |
124 | class JSTrackEventPrototype : public JSC::JSNonFinalObject { |
125 | public: |
126 | using Base = JSC::JSNonFinalObject; |
127 | static JSTrackEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
128 | { |
129 | JSTrackEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSTrackEventPrototype>(vm.heap)) JSTrackEventPrototype(vm, globalObject, structure); |
130 | ptr->finishCreation(vm); |
131 | return ptr; |
132 | } |
133 | |
134 | DECLARE_INFO; |
135 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
136 | { |
137 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
138 | } |
139 | |
140 | private: |
141 | JSTrackEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
142 | : JSC::JSNonFinalObject(vm, structure) |
143 | { |
144 | } |
145 | |
146 | void finishCreation(JSC::VM&); |
147 | }; |
148 | |
149 | using JSTrackEventConstructor = JSDOMConstructor<JSTrackEvent>; |
150 | |
151 | template<> EncodedJSValue JSC_HOST_CALL JSTrackEventConstructor::construct(ExecState* state) |
152 | { |
153 | VM& vm = state->vm(); |
154 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
155 | UNUSED_PARAM(throwScope); |
156 | auto* castedThis = jsCast<JSTrackEventConstructor*>(state->jsCallee()); |
157 | ASSERT(castedThis); |
158 | if (UNLIKELY(state->argumentCount() < 1)) |
159 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
160 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
161 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
162 | auto eventInitDict = convert<IDLDictionary<TrackEvent::Init>>(*state, state->argument(1)); |
163 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
164 | auto object = TrackEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
165 | return JSValue::encode(toJSNewlyCreated<IDLInterface<TrackEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
166 | } |
167 | |
168 | template<> JSValue JSTrackEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
169 | { |
170 | return JSEvent::getConstructor(vm, &globalObject); |
171 | } |
172 | |
173 | template<> void JSTrackEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
174 | { |
175 | putDirect(vm, vm.propertyNames->prototype, JSTrackEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
176 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TrackEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
177 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
178 | } |
179 | |
180 | template<> const ClassInfo JSTrackEventConstructor::s_info = { "TrackEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTrackEventConstructor) }; |
181 | |
182 | /* Hash table for prototype */ |
183 | |
184 | static const HashTableValue JSTrackEventPrototypeTableValues[] = |
185 | { |
186 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTrackEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTrackEventConstructor) } }, |
187 | { "track" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTrackEventTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
188 | }; |
189 | |
190 | const ClassInfo JSTrackEventPrototype::s_info = { "TrackEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTrackEventPrototype) }; |
191 | |
192 | void JSTrackEventPrototype::finishCreation(VM& vm) |
193 | { |
194 | Base::finishCreation(vm); |
195 | reifyStaticProperties(vm, JSTrackEvent::info(), JSTrackEventPrototypeTableValues, *this); |
196 | } |
197 | |
198 | const ClassInfo JSTrackEvent::s_info = { "TrackEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTrackEvent) }; |
199 | |
200 | JSTrackEvent::JSTrackEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TrackEvent>&& impl) |
201 | : JSEvent(structure, globalObject, WTFMove(impl)) |
202 | { |
203 | } |
204 | |
205 | void JSTrackEvent::finishCreation(VM& vm) |
206 | { |
207 | Base::finishCreation(vm); |
208 | ASSERT(inherits(vm, info())); |
209 | |
210 | } |
211 | |
212 | JSObject* JSTrackEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
213 | { |
214 | return JSTrackEventPrototype::create(vm, &globalObject, JSTrackEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
215 | } |
216 | |
217 | JSObject* JSTrackEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
218 | { |
219 | return getDOMPrototype<JSTrackEvent>(vm, globalObject); |
220 | } |
221 | |
222 | JSValue JSTrackEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
223 | { |
224 | return getDOMConstructor<JSTrackEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
225 | } |
226 | |
227 | template<> inline JSTrackEvent* IDLAttribute<JSTrackEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
228 | { |
229 | return jsDynamicCast<JSTrackEvent*>(state.vm(), JSValue::decode(thisValue)); |
230 | } |
231 | |
232 | EncodedJSValue jsTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
233 | { |
234 | VM& vm = state->vm(); |
235 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
236 | auto* prototype = jsDynamicCast<JSTrackEventPrototype*>(vm, JSValue::decode(thisValue)); |
237 | if (UNLIKELY(!prototype)) |
238 | return throwVMTypeError(state, throwScope); |
239 | return JSValue::encode(JSTrackEvent::getConstructor(state->vm(), prototype->globalObject())); |
240 | } |
241 | |
242 | bool setJSTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
243 | { |
244 | VM& vm = state->vm(); |
245 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
246 | auto* prototype = jsDynamicCast<JSTrackEventPrototype*>(vm, JSValue::decode(thisValue)); |
247 | if (UNLIKELY(!prototype)) { |
248 | throwVMTypeError(state, throwScope); |
249 | return false; |
250 | } |
251 | // Shadowing a built-in constructor |
252 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
253 | } |
254 | |
255 | static inline JSValue jsTrackEventTrackGetter(ExecState& state, JSTrackEvent& thisObject, ThrowScope& throwScope) |
256 | { |
257 | UNUSED_PARAM(throwScope); |
258 | UNUSED_PARAM(state); |
259 | auto& impl = thisObject.wrapped(); |
260 | JSValue result = toJS<IDLNullable<IDLUnion<IDLInterface<VideoTrack>, IDLInterface<AudioTrack>, IDLInterface<TextTrack>>>>(state, *thisObject.globalObject(), throwScope, impl.track()); |
261 | return result; |
262 | } |
263 | |
264 | EncodedJSValue jsTrackEventTrack(ExecState* state, EncodedJSValue thisValue, PropertyName) |
265 | { |
266 | return IDLAttribute<JSTrackEvent>::get<jsTrackEventTrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "track" ); |
267 | } |
268 | |
269 | void JSTrackEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
270 | { |
271 | auto* thisObject = jsCast<JSTrackEvent*>(cell); |
272 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
273 | if (thisObject->scriptExecutionContext()) |
274 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
275 | Base::heapSnapshot(cell, builder); |
276 | } |
277 | |
278 | #if ENABLE(BINDING_INTEGRITY) |
279 | #if PLATFORM(WIN) |
280 | #pragma warning(disable: 4483) |
281 | extern "C" { extern void (*const __identifier("??_7TrackEvent@WebCore@@6B@" )[])(); } |
282 | #else |
283 | extern "C" { extern void* _ZTVN7WebCore10TrackEventE[]; } |
284 | #endif |
285 | #endif |
286 | |
287 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TrackEvent>&& impl) |
288 | { |
289 | |
290 | #if ENABLE(BINDING_INTEGRITY) |
291 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
292 | #if PLATFORM(WIN) |
293 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TrackEvent@WebCore@@6B@" )); |
294 | #else |
295 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore10TrackEventE[2]); |
296 | #endif |
297 | |
298 | // If this fails TrackEvent does not have a vtable, so you need to add the |
299 | // ImplementationLacksVTable attribute to the interface definition |
300 | static_assert(std::is_polymorphic<TrackEvent>::value, "TrackEvent is not polymorphic" ); |
301 | |
302 | // If you hit this assertion you either have a use after free bug, or |
303 | // TrackEvent has subclasses. If TrackEvent has subclasses that get passed |
304 | // to toJS() we currently require TrackEvent you to opt out of binding hardening |
305 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
306 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
307 | #endif |
308 | return createWrapper<TrackEvent>(globalObject, WTFMove(impl)); |
309 | } |
310 | |
311 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TrackEvent& impl) |
312 | { |
313 | return wrap(state, globalObject, impl); |
314 | } |
315 | |
316 | |
317 | } |
318 | |
319 | #endif // ENABLE(VIDEO_TRACK) |
320 | |