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 "JSImageBitmapRenderingContext.h"
23
24#include "CallTracer.h"
25#include "JSDOMAttribute.h"
26#include "JSDOMBinding.h"
27#include "JSDOMConstructorNotConstructable.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertNullable.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMGlobalObject.h"
32#include "JSDOMOperation.h"
33#include "JSDOMWrapperCache.h"
34#include "JSHTMLCanvasElement.h"
35#include "JSImageBitmap.h"
36#include "ScriptExecutionContext.h"
37#include <JavaScriptCore/FunctionPrototype.h>
38#include <JavaScriptCore/HeapSnapshotBuilder.h>
39#include <JavaScriptCore/JSCInlines.h>
40#include <wtf/GetPtr.h>
41#include <wtf/PointerPreparations.h>
42#include <wtf/URL.h>
43
44
45namespace WebCore {
46using namespace JSC;
47
48// Functions
49
50JSC::EncodedJSValue JSC_HOST_CALL jsImageBitmapRenderingContextPrototypeFunctionTransferFromImageBitmap(JSC::ExecState*);
51
52// Attributes
53
54JSC::EncodedJSValue jsImageBitmapRenderingContextConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55bool setJSImageBitmapRenderingContextConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
56JSC::EncodedJSValue jsImageBitmapRenderingContextCanvas(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57
58class JSImageBitmapRenderingContextPrototype : public JSC::JSNonFinalObject {
59public:
60 using Base = JSC::JSNonFinalObject;
61 static JSImageBitmapRenderingContextPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
62 {
63 JSImageBitmapRenderingContextPrototype* ptr = new (NotNull, JSC::allocateCell<JSImageBitmapRenderingContextPrototype>(vm.heap)) JSImageBitmapRenderingContextPrototype(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 JSImageBitmapRenderingContextPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
76 : JSC::JSNonFinalObject(vm, structure)
77 {
78 }
79
80 void finishCreation(JSC::VM&);
81};
82
83using JSImageBitmapRenderingContextConstructor = JSDOMConstructorNotConstructable<JSImageBitmapRenderingContext>;
84
85template<> JSValue JSImageBitmapRenderingContextConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
86{
87 UNUSED_PARAM(vm);
88 return globalObject.functionPrototype();
89}
90
91template<> void JSImageBitmapRenderingContextConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
92{
93 putDirect(vm, vm.propertyNames->prototype, JSImageBitmapRenderingContext::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ImageBitmapRenderingContext"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
95 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96}
97
98template<> const ClassInfo JSImageBitmapRenderingContextConstructor::s_info = { "ImageBitmapRenderingContext", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSImageBitmapRenderingContextConstructor) };
99
100/* Hash table for prototype */
101
102static const HashTableValue JSImageBitmapRenderingContextPrototypeTableValues[] =
103{
104 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsImageBitmapRenderingContextConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSImageBitmapRenderingContextConstructor) } },
105 { "canvas", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsImageBitmapRenderingContextCanvas), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
106 { "transferFromImageBitmap", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsImageBitmapRenderingContextPrototypeFunctionTransferFromImageBitmap), (intptr_t) (1) } },
107};
108
109const ClassInfo JSImageBitmapRenderingContextPrototype::s_info = { "ImageBitmapRenderingContextPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSImageBitmapRenderingContextPrototype) };
110
111void JSImageBitmapRenderingContextPrototype::finishCreation(VM& vm)
112{
113 Base::finishCreation(vm);
114 reifyStaticProperties(vm, JSImageBitmapRenderingContext::info(), JSImageBitmapRenderingContextPrototypeTableValues, *this);
115}
116
117const ClassInfo JSImageBitmapRenderingContext::s_info = { "ImageBitmapRenderingContext", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSImageBitmapRenderingContext) };
118
119JSImageBitmapRenderingContext::JSImageBitmapRenderingContext(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ImageBitmapRenderingContext>&& impl)
120 : JSDOMWrapper<ImageBitmapRenderingContext>(structure, globalObject, WTFMove(impl))
121{
122}
123
124void JSImageBitmapRenderingContext::finishCreation(VM& vm)
125{
126 Base::finishCreation(vm);
127 ASSERT(inherits(vm, info()));
128
129}
130
131JSObject* JSImageBitmapRenderingContext::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
132{
133 return JSImageBitmapRenderingContextPrototype::create(vm, &globalObject, JSImageBitmapRenderingContextPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
134}
135
136JSObject* JSImageBitmapRenderingContext::prototype(VM& vm, JSDOMGlobalObject& globalObject)
137{
138 return getDOMPrototype<JSImageBitmapRenderingContext>(vm, globalObject);
139}
140
141JSValue JSImageBitmapRenderingContext::getConstructor(VM& vm, const JSGlobalObject* globalObject)
142{
143 return getDOMConstructor<JSImageBitmapRenderingContextConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
144}
145
146void JSImageBitmapRenderingContext::destroy(JSC::JSCell* cell)
147{
148 JSImageBitmapRenderingContext* thisObject = static_cast<JSImageBitmapRenderingContext*>(cell);
149 thisObject->JSImageBitmapRenderingContext::~JSImageBitmapRenderingContext();
150}
151
152template<> inline JSImageBitmapRenderingContext* IDLAttribute<JSImageBitmapRenderingContext>::cast(ExecState& state, EncodedJSValue thisValue)
153{
154 return jsDynamicCast<JSImageBitmapRenderingContext*>(state.vm(), JSValue::decode(thisValue));
155}
156
157template<> inline JSImageBitmapRenderingContext* IDLOperation<JSImageBitmapRenderingContext>::cast(ExecState& state)
158{
159 return jsDynamicCast<JSImageBitmapRenderingContext*>(state.vm(), state.thisValue());
160}
161
162EncodedJSValue jsImageBitmapRenderingContextConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
163{
164 VM& vm = state->vm();
165 auto throwScope = DECLARE_THROW_SCOPE(vm);
166 auto* prototype = jsDynamicCast<JSImageBitmapRenderingContextPrototype*>(vm, JSValue::decode(thisValue));
167 if (UNLIKELY(!prototype))
168 return throwVMTypeError(state, throwScope);
169 return JSValue::encode(JSImageBitmapRenderingContext::getConstructor(state->vm(), prototype->globalObject()));
170}
171
172bool setJSImageBitmapRenderingContextConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
173{
174 VM& vm = state->vm();
175 auto throwScope = DECLARE_THROW_SCOPE(vm);
176 auto* prototype = jsDynamicCast<JSImageBitmapRenderingContextPrototype*>(vm, JSValue::decode(thisValue));
177 if (UNLIKELY(!prototype)) {
178 throwVMTypeError(state, throwScope);
179 return false;
180 }
181 // Shadowing a built-in constructor
182 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
183}
184
185static inline JSValue jsImageBitmapRenderingContextCanvasGetter(ExecState& state, JSImageBitmapRenderingContext& thisObject, ThrowScope& throwScope)
186{
187 UNUSED_PARAM(throwScope);
188 UNUSED_PARAM(state);
189 auto& impl = thisObject.wrapped();
190 JSValue result = toJS<IDLInterface<HTMLCanvasElement>>(state, *thisObject.globalObject(), throwScope, impl.canvas());
191 return result;
192}
193
194EncodedJSValue jsImageBitmapRenderingContextCanvas(ExecState* state, EncodedJSValue thisValue, PropertyName)
195{
196 return IDLAttribute<JSImageBitmapRenderingContext>::get<jsImageBitmapRenderingContextCanvasGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "canvas");
197}
198
199static inline JSC::EncodedJSValue jsImageBitmapRenderingContextPrototypeFunctionTransferFromImageBitmapBody(JSC::ExecState* state, typename IDLOperation<JSImageBitmapRenderingContext>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
200{
201 UNUSED_PARAM(state);
202 UNUSED_PARAM(throwScope);
203 auto& impl = castedThis->wrapped();
204 if (UNLIKELY(state->argumentCount() < 1))
205 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
206 auto bitmap = convert<IDLNullable<IDLInterface<ImageBitmap>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "bitmap", "ImageBitmapRenderingContext", "transferFromImageBitmap", "ImageBitmap"); });
207 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
208 if (UNLIKELY(impl.callTracingActive())) {
209 Vector<RecordCanvasActionVariant> callTracerParameters;
210 if (bitmap)
211 callTracerParameters.append(bitmap);
212 CallTracer::recordCanvasAction(impl, "transferFromImageBitmap"_s, WTFMove(callTracerParameters));
213 }
214 propagateException(*state, throwScope, impl.transferFromImageBitmap(WTFMove(bitmap)));
215 return JSValue::encode(jsUndefined());
216}
217
218EncodedJSValue JSC_HOST_CALL jsImageBitmapRenderingContextPrototypeFunctionTransferFromImageBitmap(ExecState* state)
219{
220 return IDLOperation<JSImageBitmapRenderingContext>::call<jsImageBitmapRenderingContextPrototypeFunctionTransferFromImageBitmapBody>(*state, "transferFromImageBitmap");
221}
222
223void JSImageBitmapRenderingContext::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
224{
225 auto* thisObject = jsCast<JSImageBitmapRenderingContext*>(cell);
226 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
227 if (thisObject->scriptExecutionContext())
228 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
229 Base::heapSnapshot(cell, builder);
230}
231
232bool JSImageBitmapRenderingContextOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
233{
234 UNUSED_PARAM(handle);
235 UNUSED_PARAM(visitor);
236 UNUSED_PARAM(reason);
237 return false;
238}
239
240void JSImageBitmapRenderingContextOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
241{
242 auto* jsImageBitmapRenderingContext = static_cast<JSImageBitmapRenderingContext*>(handle.slot()->asCell());
243 auto& world = *static_cast<DOMWrapperWorld*>(context);
244 uncacheWrapper(world, &jsImageBitmapRenderingContext->wrapped(), jsImageBitmapRenderingContext);
245}
246
247#if ENABLE(BINDING_INTEGRITY)
248#if PLATFORM(WIN)
249#pragma warning(disable: 4483)
250extern "C" { extern void (*const __identifier("??_7ImageBitmapRenderingContext@WebCore@@6B@")[])(); }
251#else
252extern "C" { extern void* _ZTVN7WebCore27ImageBitmapRenderingContextE[]; }
253#endif
254#endif
255
256JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ImageBitmapRenderingContext>&& impl)
257{
258
259#if ENABLE(BINDING_INTEGRITY)
260 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
261#if PLATFORM(WIN)
262 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7ImageBitmapRenderingContext@WebCore@@6B@"));
263#else
264 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore27ImageBitmapRenderingContextE[2]);
265#endif
266
267 // If this fails ImageBitmapRenderingContext does not have a vtable, so you need to add the
268 // ImplementationLacksVTable attribute to the interface definition
269 static_assert(std::is_polymorphic<ImageBitmapRenderingContext>::value, "ImageBitmapRenderingContext is not polymorphic");
270
271 // If you hit this assertion you either have a use after free bug, or
272 // ImageBitmapRenderingContext has subclasses. If ImageBitmapRenderingContext has subclasses that get passed
273 // to toJS() we currently require ImageBitmapRenderingContext you to opt out of binding hardening
274 // by adding the SkipVTableValidation attribute to the interface IDL definition
275 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
276#endif
277 return createWrapper<ImageBitmapRenderingContext>(globalObject, WTFMove(impl));
278}
279
280JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ImageBitmapRenderingContext& impl)
281{
282 return wrap(state, globalObject, impl);
283}
284
285ImageBitmapRenderingContext* JSImageBitmapRenderingContext::toWrapped(JSC::VM& vm, JSC::JSValue value)
286{
287 if (auto* wrapper = jsDynamicCast<JSImageBitmapRenderingContext*>(vm, value))
288 return &wrapper->wrapped();
289 return nullptr;
290}
291
292}
293