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