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 "JSImageBitmap.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertNumbers.h"
28#include "JSDOMExceptionHandling.h"
29#include "JSDOMOperation.h"
30#include "JSDOMWrapperCache.h"
31#include "ScriptExecutionContext.h"
32#include <JavaScriptCore/FunctionPrototype.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
40namespace WebCore {
41using namespace JSC;
42
43// Functions
44
45JSC::EncodedJSValue JSC_HOST_CALL jsImageBitmapPrototypeFunctionClose(JSC::ExecState*);
46
47// Attributes
48
49JSC::EncodedJSValue jsImageBitmapConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSImageBitmapConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsImageBitmapWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsImageBitmapHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53
54class JSImageBitmapPrototype : public JSC::JSNonFinalObject {
55public:
56 using Base = JSC::JSNonFinalObject;
57 static JSImageBitmapPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58 {
59 JSImageBitmapPrototype* ptr = new (NotNull, JSC::allocateCell<JSImageBitmapPrototype>(vm.heap)) JSImageBitmapPrototype(vm, globalObject, structure);
60 ptr->finishCreation(vm);
61 return ptr;
62 }
63
64 DECLARE_INFO;
65 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66 {
67 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68 }
69
70private:
71 JSImageBitmapPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72 : JSC::JSNonFinalObject(vm, structure)
73 {
74 }
75
76 void finishCreation(JSC::VM&);
77};
78
79using JSImageBitmapConstructor = JSDOMConstructorNotConstructable<JSImageBitmap>;
80
81template<> JSValue JSImageBitmapConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82{
83 UNUSED_PARAM(vm);
84 return globalObject.functionPrototype();
85}
86
87template<> void JSImageBitmapConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
88{
89 putDirect(vm, vm.propertyNames->prototype, JSImageBitmap::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ImageBitmap"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92}
93
94template<> const ClassInfo JSImageBitmapConstructor::s_info = { "ImageBitmap", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSImageBitmapConstructor) };
95
96/* Hash table for prototype */
97
98static const HashTableValue JSImageBitmapPrototypeTableValues[] =
99{
100 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsImageBitmapConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSImageBitmapConstructor) } },
101 { "width", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsImageBitmapWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
102 { "height", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsImageBitmapHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
103 { "close", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsImageBitmapPrototypeFunctionClose), (intptr_t) (0) } },
104};
105
106const ClassInfo JSImageBitmapPrototype::s_info = { "ImageBitmapPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSImageBitmapPrototype) };
107
108void JSImageBitmapPrototype::finishCreation(VM& vm)
109{
110 Base::finishCreation(vm);
111 reifyStaticProperties(vm, JSImageBitmap::info(), JSImageBitmapPrototypeTableValues, *this);
112}
113
114const ClassInfo JSImageBitmap::s_info = { "ImageBitmap", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSImageBitmap) };
115
116JSImageBitmap::JSImageBitmap(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ImageBitmap>&& impl)
117 : JSDOMWrapper<ImageBitmap>(structure, globalObject, WTFMove(impl))
118{
119}
120
121void JSImageBitmap::finishCreation(VM& vm)
122{
123 Base::finishCreation(vm);
124 ASSERT(inherits(vm, info()));
125
126}
127
128JSObject* JSImageBitmap::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
129{
130 return JSImageBitmapPrototype::create(vm, &globalObject, JSImageBitmapPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
131}
132
133JSObject* JSImageBitmap::prototype(VM& vm, JSDOMGlobalObject& globalObject)
134{
135 return getDOMPrototype<JSImageBitmap>(vm, globalObject);
136}
137
138JSValue JSImageBitmap::getConstructor(VM& vm, const JSGlobalObject* globalObject)
139{
140 return getDOMConstructor<JSImageBitmapConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
141}
142
143void JSImageBitmap::destroy(JSC::JSCell* cell)
144{
145 JSImageBitmap* thisObject = static_cast<JSImageBitmap*>(cell);
146 thisObject->JSImageBitmap::~JSImageBitmap();
147}
148
149template<> inline JSImageBitmap* IDLAttribute<JSImageBitmap>::cast(ExecState& state, EncodedJSValue thisValue)
150{
151 return jsDynamicCast<JSImageBitmap*>(state.vm(), JSValue::decode(thisValue));
152}
153
154template<> inline JSImageBitmap* IDLOperation<JSImageBitmap>::cast(ExecState& state)
155{
156 return jsDynamicCast<JSImageBitmap*>(state.vm(), state.thisValue());
157}
158
159EncodedJSValue jsImageBitmapConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
160{
161 VM& vm = state->vm();
162 auto throwScope = DECLARE_THROW_SCOPE(vm);
163 auto* prototype = jsDynamicCast<JSImageBitmapPrototype*>(vm, JSValue::decode(thisValue));
164 if (UNLIKELY(!prototype))
165 return throwVMTypeError(state, throwScope);
166 return JSValue::encode(JSImageBitmap::getConstructor(state->vm(), prototype->globalObject()));
167}
168
169bool setJSImageBitmapConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
170{
171 VM& vm = state->vm();
172 auto throwScope = DECLARE_THROW_SCOPE(vm);
173 auto* prototype = jsDynamicCast<JSImageBitmapPrototype*>(vm, JSValue::decode(thisValue));
174 if (UNLIKELY(!prototype)) {
175 throwVMTypeError(state, throwScope);
176 return false;
177 }
178 // Shadowing a built-in constructor
179 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
180}
181
182static inline JSValue jsImageBitmapWidthGetter(ExecState& state, JSImageBitmap& thisObject, ThrowScope& throwScope)
183{
184 UNUSED_PARAM(throwScope);
185 UNUSED_PARAM(state);
186 auto& impl = thisObject.wrapped();
187 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.width());
188 return result;
189}
190
191EncodedJSValue jsImageBitmapWidth(ExecState* state, EncodedJSValue thisValue, PropertyName)
192{
193 return IDLAttribute<JSImageBitmap>::get<jsImageBitmapWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width");
194}
195
196static inline JSValue jsImageBitmapHeightGetter(ExecState& state, JSImageBitmap& thisObject, ThrowScope& throwScope)
197{
198 UNUSED_PARAM(throwScope);
199 UNUSED_PARAM(state);
200 auto& impl = thisObject.wrapped();
201 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.height());
202 return result;
203}
204
205EncodedJSValue jsImageBitmapHeight(ExecState* state, EncodedJSValue thisValue, PropertyName)
206{
207 return IDLAttribute<JSImageBitmap>::get<jsImageBitmapHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height");
208}
209
210static inline JSC::EncodedJSValue jsImageBitmapPrototypeFunctionCloseBody(JSC::ExecState* state, typename IDLOperation<JSImageBitmap>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
211{
212 UNUSED_PARAM(state);
213 UNUSED_PARAM(throwScope);
214 auto& impl = castedThis->wrapped();
215 impl.close();
216 return JSValue::encode(jsUndefined());
217}
218
219EncodedJSValue JSC_HOST_CALL jsImageBitmapPrototypeFunctionClose(ExecState* state)
220{
221 return IDLOperation<JSImageBitmap>::call<jsImageBitmapPrototypeFunctionCloseBody>(*state, "close");
222}
223
224void JSImageBitmap::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
225{
226 auto* thisObject = jsCast<JSImageBitmap*>(cell);
227 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
228 if (thisObject->scriptExecutionContext())
229 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
230 Base::heapSnapshot(cell, builder);
231}
232
233bool JSImageBitmapOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
234{
235 UNUSED_PARAM(handle);
236 UNUSED_PARAM(visitor);
237 UNUSED_PARAM(reason);
238 return false;
239}
240
241void JSImageBitmapOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
242{
243 auto* jsImageBitmap = static_cast<JSImageBitmap*>(handle.slot()->asCell());
244 auto& world = *static_cast<DOMWrapperWorld*>(context);
245 uncacheWrapper(world, &jsImageBitmap->wrapped(), jsImageBitmap);
246}
247
248JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ImageBitmap>&& impl)
249{
250 // If you hit this failure the interface definition has the ImplementationLacksVTable
251 // attribute. You should remove that attribute. If the class has subclasses
252 // that may be passed through this toJS() function you should use the SkipVTableValidation
253 // attribute to ImageBitmap.
254 static_assert(!std::is_polymorphic<ImageBitmap>::value, "ImageBitmap is polymorphic but the IDL claims it is not");
255 return createWrapper<ImageBitmap>(globalObject, WTFMove(impl));
256}
257
258JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ImageBitmap& impl)
259{
260 return wrap(state, globalObject, impl);
261}
262
263ImageBitmap* JSImageBitmap::toWrapped(JSC::VM& vm, JSC::JSValue value)
264{
265 if (auto* wrapper = jsDynamicCast<JSImageBitmap*>(vm, value))
266 return &wrapper->wrapped();
267 return nullptr;
268}
269
270}
271