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 "JSOffscreenCanvas.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructor.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMConvertStrings.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMGlobalObject.h"
32#include "JSDOMOperation.h"
33#include "JSDOMWrapperCache.h"
34#include "JSImageBitmap.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <JavaScriptCore/JSString.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43#if ENABLE(WEBGL)
44#include "JSDOMConvertAny.h"
45#include "JSDOMConvertNullable.h"
46#include "JSDOMConvertVariadic.h"
47#include "JSWebGLRenderingContext.h"
48#endif
49
50
51namespace WebCore {
52using namespace JSC;
53
54String convertEnumerationToString(OffscreenCanvas::RenderingContextType enumerationValue)
55{
56 static const NeverDestroyed<String> values[] = {
57 MAKE_STATIC_STRING_IMPL("2d"),
58 MAKE_STATIC_STRING_IMPL("webgl"),
59 };
60 static_assert(static_cast<size_t>(OffscreenCanvas::RenderingContextType::_2d) == 0, "OffscreenCanvas::RenderingContextType::_2d is not 0 as expected");
61 static_assert(static_cast<size_t>(OffscreenCanvas::RenderingContextType::Webgl) == 1, "OffscreenCanvas::RenderingContextType::Webgl is not 1 as expected");
62 ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
63 return values[static_cast<size_t>(enumerationValue)];
64}
65
66template<> JSString* convertEnumerationToJS(ExecState& state, OffscreenCanvas::RenderingContextType enumerationValue)
67{
68 return jsStringWithCache(&state, convertEnumerationToString(enumerationValue));
69}
70
71template<> Optional<OffscreenCanvas::RenderingContextType> parseEnumeration<OffscreenCanvas::RenderingContextType>(ExecState& state, JSValue value)
72{
73 auto stringValue = value.toWTFString(&state);
74 if (stringValue == "2d")
75 return OffscreenCanvas::RenderingContextType::_2d;
76 if (stringValue == "webgl")
77 return OffscreenCanvas::RenderingContextType::Webgl;
78 return WTF::nullopt;
79}
80
81template<> const char* expectedEnumerationValues<OffscreenCanvas::RenderingContextType>()
82{
83 return "\"2d\", \"webgl\"";
84}
85
86template<> OffscreenCanvas::ImageEncodeOptions convertDictionary<OffscreenCanvas::ImageEncodeOptions>(ExecState& state, JSValue value)
87{
88 VM& vm = state.vm();
89 auto throwScope = DECLARE_THROW_SCOPE(vm);
90 bool isNullOrUndefined = value.isUndefinedOrNull();
91 auto* object = isNullOrUndefined ? nullptr : value.getObject();
92 if (UNLIKELY(!isNullOrUndefined && !object)) {
93 throwTypeError(&state, throwScope);
94 return { };
95 }
96 OffscreenCanvas::ImageEncodeOptions result;
97 JSValue qualityValue;
98 if (isNullOrUndefined)
99 qualityValue = jsUndefined();
100 else {
101 qualityValue = object->get(&state, Identifier::fromString(&state, "quality"));
102 RETURN_IF_EXCEPTION(throwScope, { });
103 }
104 if (!qualityValue.isUndefined()) {
105 result.quality = convert<IDLUnrestrictedDouble>(state, qualityValue);
106 RETURN_IF_EXCEPTION(throwScope, { });
107 } else
108 result.quality = 1.0;
109 JSValue typeValue;
110 if (isNullOrUndefined)
111 typeValue = jsUndefined();
112 else {
113 typeValue = object->get(&state, Identifier::fromString(&state, "type"));
114 RETURN_IF_EXCEPTION(throwScope, { });
115 }
116 if (!typeValue.isUndefined()) {
117 result.type = convert<IDLDOMString>(state, typeValue);
118 RETURN_IF_EXCEPTION(throwScope, { });
119 } else
120 result.type = "image/png"_s;
121 return result;
122}
123
124// Functions
125
126#if ENABLE(WEBGL)
127JSC::EncodedJSValue JSC_HOST_CALL jsOffscreenCanvasPrototypeFunctionGetContext(JSC::ExecState*);
128#endif
129JSC::EncodedJSValue JSC_HOST_CALL jsOffscreenCanvasPrototypeFunctionTransferToImageBitmap(JSC::ExecState*);
130
131// Attributes
132
133JSC::EncodedJSValue jsOffscreenCanvasConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
134bool setJSOffscreenCanvasConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
135JSC::EncodedJSValue jsOffscreenCanvasWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
136bool setJSOffscreenCanvasWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
137JSC::EncodedJSValue jsOffscreenCanvasHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
138bool setJSOffscreenCanvasHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
139
140class JSOffscreenCanvasPrototype : public JSC::JSNonFinalObject {
141public:
142 using Base = JSC::JSNonFinalObject;
143 static JSOffscreenCanvasPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
144 {
145 JSOffscreenCanvasPrototype* ptr = new (NotNull, JSC::allocateCell<JSOffscreenCanvasPrototype>(vm.heap)) JSOffscreenCanvasPrototype(vm, globalObject, structure);
146 ptr->finishCreation(vm);
147 return ptr;
148 }
149
150 DECLARE_INFO;
151 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
152 {
153 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
154 }
155
156private:
157 JSOffscreenCanvasPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
158 : JSC::JSNonFinalObject(vm, structure)
159 {
160 }
161
162 void finishCreation(JSC::VM&);
163};
164
165using JSOffscreenCanvasConstructor = JSDOMConstructor<JSOffscreenCanvas>;
166
167template<> EncodedJSValue JSC_HOST_CALL JSOffscreenCanvasConstructor::construct(ExecState* state)
168{
169 VM& vm = state->vm();
170 auto throwScope = DECLARE_THROW_SCOPE(vm);
171 UNUSED_PARAM(throwScope);
172 auto* castedThis = jsCast<JSOffscreenCanvasConstructor*>(state->jsCallee());
173 ASSERT(castedThis);
174 if (UNLIKELY(state->argumentCount() < 2))
175 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
176 auto* context = castedThis->scriptExecutionContext();
177 if (UNLIKELY(!context))
178 return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "OffscreenCanvas");
179 auto width = convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(*state, state->uncheckedArgument(0));
180 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
181 auto height = convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(*state, state->uncheckedArgument(1));
182 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
183 auto object = OffscreenCanvas::create(*context, WTFMove(width), WTFMove(height));
184 return JSValue::encode(toJSNewlyCreated<IDLInterface<OffscreenCanvas>>(*state, *castedThis->globalObject(), WTFMove(object)));
185}
186
187template<> JSValue JSOffscreenCanvasConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
188{
189 return JSEventTarget::getConstructor(vm, &globalObject);
190}
191
192template<> void JSOffscreenCanvasConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
193{
194 putDirect(vm, vm.propertyNames->prototype, JSOffscreenCanvas::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
195 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("OffscreenCanvas"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
196 putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
197}
198
199template<> const ClassInfo JSOffscreenCanvasConstructor::s_info = { "OffscreenCanvas", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOffscreenCanvasConstructor) };
200
201/* Hash table for prototype */
202
203static const HashTableValue JSOffscreenCanvasPrototypeTableValues[] =
204{
205 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOffscreenCanvasConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOffscreenCanvasConstructor) } },
206 { "width", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOffscreenCanvasWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOffscreenCanvasWidth) } },
207 { "height", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOffscreenCanvasHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOffscreenCanvasHeight) } },
208#if ENABLE(WEBGL)
209 { "getContext", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsOffscreenCanvasPrototypeFunctionGetContext), (intptr_t) (1) } },
210#else
211 { 0, 0, NoIntrinsic, { 0, 0 } },
212#endif
213 { "transferToImageBitmap", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsOffscreenCanvasPrototypeFunctionTransferToImageBitmap), (intptr_t) (0) } },
214};
215
216const ClassInfo JSOffscreenCanvasPrototype::s_info = { "OffscreenCanvasPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOffscreenCanvasPrototype) };
217
218void JSOffscreenCanvasPrototype::finishCreation(VM& vm)
219{
220 Base::finishCreation(vm);
221 reifyStaticProperties(vm, JSOffscreenCanvas::info(), JSOffscreenCanvasPrototypeTableValues, *this);
222}
223
224const ClassInfo JSOffscreenCanvas::s_info = { "OffscreenCanvas", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOffscreenCanvas) };
225
226JSOffscreenCanvas::JSOffscreenCanvas(Structure* structure, JSDOMGlobalObject& globalObject, Ref<OffscreenCanvas>&& impl)
227 : JSEventTarget(structure, globalObject, WTFMove(impl))
228{
229}
230
231void JSOffscreenCanvas::finishCreation(VM& vm)
232{
233 Base::finishCreation(vm);
234 ASSERT(inherits(vm, info()));
235
236}
237
238JSObject* JSOffscreenCanvas::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
239{
240 return JSOffscreenCanvasPrototype::create(vm, &globalObject, JSOffscreenCanvasPrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject)));
241}
242
243JSObject* JSOffscreenCanvas::prototype(VM& vm, JSDOMGlobalObject& globalObject)
244{
245 return getDOMPrototype<JSOffscreenCanvas>(vm, globalObject);
246}
247
248JSValue JSOffscreenCanvas::getConstructor(VM& vm, const JSGlobalObject* globalObject)
249{
250 return getDOMConstructor<JSOffscreenCanvasConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
251}
252
253template<> inline JSOffscreenCanvas* IDLAttribute<JSOffscreenCanvas>::cast(ExecState& state, EncodedJSValue thisValue)
254{
255 return jsDynamicCast<JSOffscreenCanvas*>(state.vm(), JSValue::decode(thisValue));
256}
257
258template<> inline JSOffscreenCanvas* IDLOperation<JSOffscreenCanvas>::cast(ExecState& state)
259{
260 return jsDynamicCast<JSOffscreenCanvas*>(state.vm(), state.thisValue());
261}
262
263EncodedJSValue jsOffscreenCanvasConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
264{
265 VM& vm = state->vm();
266 auto throwScope = DECLARE_THROW_SCOPE(vm);
267 auto* prototype = jsDynamicCast<JSOffscreenCanvasPrototype*>(vm, JSValue::decode(thisValue));
268 if (UNLIKELY(!prototype))
269 return throwVMTypeError(state, throwScope);
270 return JSValue::encode(JSOffscreenCanvas::getConstructor(state->vm(), prototype->globalObject()));
271}
272
273bool setJSOffscreenCanvasConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
274{
275 VM& vm = state->vm();
276 auto throwScope = DECLARE_THROW_SCOPE(vm);
277 auto* prototype = jsDynamicCast<JSOffscreenCanvasPrototype*>(vm, JSValue::decode(thisValue));
278 if (UNLIKELY(!prototype)) {
279 throwVMTypeError(state, throwScope);
280 return false;
281 }
282 // Shadowing a built-in constructor
283 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
284}
285
286static inline JSValue jsOffscreenCanvasWidthGetter(ExecState& state, JSOffscreenCanvas& thisObject, ThrowScope& throwScope)
287{
288 UNUSED_PARAM(throwScope);
289 UNUSED_PARAM(state);
290 auto& impl = thisObject.wrapped();
291 JSValue result = toJS<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(state, throwScope, impl.width());
292 return result;
293}
294
295EncodedJSValue jsOffscreenCanvasWidth(ExecState* state, EncodedJSValue thisValue, PropertyName)
296{
297 return IDLAttribute<JSOffscreenCanvas>::get<jsOffscreenCanvasWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width");
298}
299
300static inline bool setJSOffscreenCanvasWidthSetter(ExecState& state, JSOffscreenCanvas& thisObject, JSValue value, ThrowScope& throwScope)
301{
302 UNUSED_PARAM(throwScope);
303 auto& impl = thisObject.wrapped();
304 auto nativeValue = convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(state, value);
305 RETURN_IF_EXCEPTION(throwScope, false);
306 AttributeSetter::call(state, throwScope, [&] {
307 return impl.setWidth(WTFMove(nativeValue));
308 });
309 return true;
310}
311
312bool setJSOffscreenCanvasWidth(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
313{
314 return IDLAttribute<JSOffscreenCanvas>::set<setJSOffscreenCanvasWidthSetter>(*state, thisValue, encodedValue, "width");
315}
316
317static inline JSValue jsOffscreenCanvasHeightGetter(ExecState& state, JSOffscreenCanvas& thisObject, ThrowScope& throwScope)
318{
319 UNUSED_PARAM(throwScope);
320 UNUSED_PARAM(state);
321 auto& impl = thisObject.wrapped();
322 JSValue result = toJS<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(state, throwScope, impl.height());
323 return result;
324}
325
326EncodedJSValue jsOffscreenCanvasHeight(ExecState* state, EncodedJSValue thisValue, PropertyName)
327{
328 return IDLAttribute<JSOffscreenCanvas>::get<jsOffscreenCanvasHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height");
329}
330
331static inline bool setJSOffscreenCanvasHeightSetter(ExecState& state, JSOffscreenCanvas& thisObject, JSValue value, ThrowScope& throwScope)
332{
333 UNUSED_PARAM(throwScope);
334 auto& impl = thisObject.wrapped();
335 auto nativeValue = convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(state, value);
336 RETURN_IF_EXCEPTION(throwScope, false);
337 AttributeSetter::call(state, throwScope, [&] {
338 return impl.setHeight(WTFMove(nativeValue));
339 });
340 return true;
341}
342
343bool setJSOffscreenCanvasHeight(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
344{
345 return IDLAttribute<JSOffscreenCanvas>::set<setJSOffscreenCanvasHeightSetter>(*state, thisValue, encodedValue, "height");
346}
347
348#if ENABLE(WEBGL)
349static inline JSC::EncodedJSValue jsOffscreenCanvasPrototypeFunctionGetContextBody(JSC::ExecState* state, typename IDLOperation<JSOffscreenCanvas>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
350{
351 UNUSED_PARAM(state);
352 UNUSED_PARAM(throwScope);
353 auto& impl = castedThis->wrapped();
354 if (UNLIKELY(state->argumentCount() < 1))
355 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
356 auto contextType = convert<IDLEnumeration<OffscreenCanvas::RenderingContextType>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(state, scope, 0, "contextType", "OffscreenCanvas", "getContext", expectedEnumerationValues<OffscreenCanvas::RenderingContextType>()); });
357 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
358 auto arguments = convertVariadicArguments<IDLAny>(*state, 1);
359 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
360 return JSValue::encode(toJS<IDLNullable<IDLInterface<WebGLRenderingContext>>>(*state, *castedThis->globalObject(), throwScope, impl.getContext(*state, WTFMove(contextType), WTFMove(arguments))));
361}
362
363EncodedJSValue JSC_HOST_CALL jsOffscreenCanvasPrototypeFunctionGetContext(ExecState* state)
364{
365 return IDLOperation<JSOffscreenCanvas>::call<jsOffscreenCanvasPrototypeFunctionGetContextBody>(*state, "getContext");
366}
367
368#endif
369
370static inline JSC::EncodedJSValue jsOffscreenCanvasPrototypeFunctionTransferToImageBitmapBody(JSC::ExecState* state, typename IDLOperation<JSOffscreenCanvas>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
371{
372 UNUSED_PARAM(state);
373 UNUSED_PARAM(throwScope);
374 auto& impl = castedThis->wrapped();
375 return JSValue::encode(toJS<IDLInterface<ImageBitmap>>(*state, *castedThis->globalObject(), impl.transferToImageBitmap()));
376}
377
378EncodedJSValue JSC_HOST_CALL jsOffscreenCanvasPrototypeFunctionTransferToImageBitmap(ExecState* state)
379{
380 return IDLOperation<JSOffscreenCanvas>::call<jsOffscreenCanvasPrototypeFunctionTransferToImageBitmapBody>(*state, "transferToImageBitmap");
381}
382
383void JSOffscreenCanvas::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
384{
385 auto* thisObject = jsCast<JSOffscreenCanvas*>(cell);
386 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
387 if (thisObject->scriptExecutionContext())
388 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
389 Base::heapSnapshot(cell, builder);
390}
391
392bool JSOffscreenCanvasOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
393{
394 auto* jsOffscreenCanvas = jsCast<JSOffscreenCanvas*>(handle.slot()->asCell());
395 if (jsOffscreenCanvas->wrapped().isFiringEventListeners()) {
396 if (UNLIKELY(reason))
397 *reason = "EventTarget firing event listeners";
398 return true;
399 }
400 OffscreenCanvas* root = &jsOffscreenCanvas->wrapped();
401 if (UNLIKELY(reason))
402 *reason = "Reachable from OffscreenCanvas";
403 return visitor.containsOpaqueRoot(root);
404}
405
406void JSOffscreenCanvasOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
407{
408 auto* jsOffscreenCanvas = static_cast<JSOffscreenCanvas*>(handle.slot()->asCell());
409 auto& world = *static_cast<DOMWrapperWorld*>(context);
410 uncacheWrapper(world, &jsOffscreenCanvas->wrapped(), jsOffscreenCanvas);
411}
412
413#if ENABLE(BINDING_INTEGRITY)
414#if PLATFORM(WIN)
415#pragma warning(disable: 4483)
416extern "C" { extern void (*const __identifier("??_7OffscreenCanvas@WebCore@@6B@")[])(); }
417#else
418extern "C" { extern void* _ZTVN7WebCore15OffscreenCanvasE[]; }
419#endif
420#endif
421
422JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<OffscreenCanvas>&& impl)
423{
424
425#if ENABLE(BINDING_INTEGRITY)
426 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
427#if PLATFORM(WIN)
428 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7OffscreenCanvas@WebCore@@6B@"));
429#else
430 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15OffscreenCanvasE[2]);
431#endif
432
433 // If this fails OffscreenCanvas does not have a vtable, so you need to add the
434 // ImplementationLacksVTable attribute to the interface definition
435 static_assert(std::is_polymorphic<OffscreenCanvas>::value, "OffscreenCanvas is not polymorphic");
436
437 // If you hit this assertion you either have a use after free bug, or
438 // OffscreenCanvas has subclasses. If OffscreenCanvas has subclasses that get passed
439 // to toJS() we currently require OffscreenCanvas you to opt out of binding hardening
440 // by adding the SkipVTableValidation attribute to the interface IDL definition
441 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
442#endif
443 return createWrapper<OffscreenCanvas>(globalObject, WTFMove(impl));
444}
445
446JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, OffscreenCanvas& impl)
447{
448 return wrap(state, globalObject, impl);
449}
450
451OffscreenCanvas* JSOffscreenCanvas::toWrapped(JSC::VM& vm, JSC::JSValue value)
452{
453 if (auto* wrapper = jsDynamicCast<JSOffscreenCanvas*>(vm, value))
454 return &wrapper->wrapped();
455 return nullptr;
456}
457
458}
459