/work/obj-fuzz/dom/bindings/ImageBitmapRenderingContextBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM ImageBitmapRenderingContext.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "ImageBitmapRenderingContextBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/DOMJSClass.h" |
8 | | #include "mozilla/dom/ImageBitmap.h" |
9 | | #include "mozilla/dom/ImageBitmapRenderingContext.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/XrayExpandoClass.h" |
12 | | #include "nsIDocument.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
18 | | using namespace mozilla::dom::binding_detail; |
19 | | |
20 | | |
21 | | namespace ImageBitmapRenderingContext_Binding { |
22 | | |
23 | | MOZ_CAN_RUN_SCRIPT static bool |
24 | | transferFromImageBitmap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ImageBitmapRenderingContext* self, const JSJitMethodCallArgs& args) |
25 | 0 | { |
26 | 0 | AUTO_PROFILER_LABEL_FAST("ImageBitmapRenderingContext.transferFromImageBitmap", DOM, cx); |
27 | 0 |
|
28 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
29 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ImageBitmapRenderingContext.transferFromImageBitmap"); |
30 | 0 | } |
31 | 0 | NonNull<mozilla::dom::ImageBitmap> arg0; |
32 | 0 | if (args[0].isObject()) { |
33 | 0 | { |
34 | 0 | nsresult rv = UnwrapObject<prototypes::id::ImageBitmap, mozilla::dom::ImageBitmap>(args[0], arg0); |
35 | 0 | if (NS_FAILED(rv)) { |
36 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ImageBitmapRenderingContext.transferFromImageBitmap", "ImageBitmap"); |
37 | 0 | return false; |
38 | 0 | } |
39 | 0 | } |
40 | 0 | } else { |
41 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ImageBitmapRenderingContext.transferFromImageBitmap"); |
42 | 0 | return false; |
43 | 0 | } |
44 | 0 | self->TransferFromImageBitmap(MOZ_KnownLive(NonNullHelper(arg0))); |
45 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
46 | 0 | args.rval().setUndefined(); |
47 | 0 | return true; |
48 | 0 | } |
49 | | |
50 | | static const JSJitInfo transferFromImageBitmap_methodinfo = { |
51 | | { (JSJitGetterOp)transferFromImageBitmap }, |
52 | | { prototypes::id::ImageBitmapRenderingContext }, |
53 | | { PrototypeTraits<prototypes::id::ImageBitmapRenderingContext>::Depth }, |
54 | | JSJitInfo::Method, |
55 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
56 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
57 | | false, /* isInfallible. False in setters. */ |
58 | | false, /* isMovable. Not relevant for setters. */ |
59 | | false, /* isEliminatable. Not relevant for setters. */ |
60 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
61 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
62 | | false, /* isTypedMethod. Only relevant for methods. */ |
63 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
64 | | }; |
65 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
66 | | static_assert(0 < 1, "There is no slot for us"); |
67 | | |
68 | | MOZ_CAN_RUN_SCRIPT static bool |
69 | | transferImageBitmap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ImageBitmapRenderingContext* self, const JSJitMethodCallArgs& args) |
70 | 0 | { |
71 | 0 | AUTO_PROFILER_LABEL_FAST("ImageBitmapRenderingContext.transferImageBitmap", DOM, cx); |
72 | 0 |
|
73 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
74 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ImageBitmapRenderingContext.transferImageBitmap"); |
75 | 0 | } |
76 | 0 | DeprecationWarning(cx, obj, nsIDocument::eImageBitmapRenderingContext_TransferImageBitmap); |
77 | 0 | NonNull<mozilla::dom::ImageBitmap> arg0; |
78 | 0 | if (args[0].isObject()) { |
79 | 0 | { |
80 | 0 | nsresult rv = UnwrapObject<prototypes::id::ImageBitmap, mozilla::dom::ImageBitmap>(args[0], arg0); |
81 | 0 | if (NS_FAILED(rv)) { |
82 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ImageBitmapRenderingContext.transferImageBitmap", "ImageBitmap"); |
83 | 0 | return false; |
84 | 0 | } |
85 | 0 | } |
86 | 0 | } else { |
87 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ImageBitmapRenderingContext.transferImageBitmap"); |
88 | 0 | return false; |
89 | 0 | } |
90 | 0 | self->TransferImageBitmap(MOZ_KnownLive(NonNullHelper(arg0))); |
91 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
92 | 0 | args.rval().setUndefined(); |
93 | 0 | return true; |
94 | 0 | } |
95 | | |
96 | | static const JSJitInfo transferImageBitmap_methodinfo = { |
97 | | { (JSJitGetterOp)transferImageBitmap }, |
98 | | { prototypes::id::ImageBitmapRenderingContext }, |
99 | | { PrototypeTraits<prototypes::id::ImageBitmapRenderingContext>::Depth }, |
100 | | JSJitInfo::Method, |
101 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
102 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
103 | | false, /* isInfallible. False in setters. */ |
104 | | false, /* isMovable. Not relevant for setters. */ |
105 | | false, /* isEliminatable. Not relevant for setters. */ |
106 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
107 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
108 | | false, /* isTypedMethod. Only relevant for methods. */ |
109 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
110 | | }; |
111 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
112 | | static_assert(0 < 1, "There is no slot for us"); |
113 | | |
114 | | static bool |
115 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
116 | 0 | { |
117 | 0 | mozilla::dom::ImageBitmapRenderingContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageBitmapRenderingContext>(obj); |
118 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
119 | 0 | // obviously can't preserve if we're not initialized. |
120 | 0 | if (self && self->GetWrapperPreserveColor()) { |
121 | 0 | PreserveWrapper(self); |
122 | 0 | } |
123 | 0 | return true; |
124 | 0 | } |
125 | | |
126 | | static void |
127 | | _finalize(js::FreeOp* fop, JSObject* obj) |
128 | 0 | { |
129 | 0 | mozilla::dom::ImageBitmapRenderingContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageBitmapRenderingContext>(obj); |
130 | 0 | if (self) { |
131 | 0 | ClearWrapper(self, self, obj); |
132 | 0 | AddForDeferredFinalization<mozilla::dom::ImageBitmapRenderingContext>(self); |
133 | 0 | } |
134 | 0 | } |
135 | | |
136 | | static size_t |
137 | | _objectMoved(JSObject* obj, JSObject* old) |
138 | 0 | { |
139 | 0 | mozilla::dom::ImageBitmapRenderingContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ImageBitmapRenderingContext>(obj); |
140 | 0 | if (self) { |
141 | 0 | UpdateWrapper(self, self, obj, old); |
142 | 0 | } |
143 | 0 |
|
144 | 0 | return 0; |
145 | 0 | } |
146 | | |
147 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
148 | | #if defined(__clang__) |
149 | | #pragma clang diagnostic push |
150 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
151 | | #endif |
152 | | static const JSFunctionSpec sMethods_specs[] = { |
153 | | JS_FNSPEC("transferFromImageBitmap", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&transferFromImageBitmap_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
154 | | JS_FNSPEC("transferImageBitmap", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&transferImageBitmap_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
155 | | JS_FS_END |
156 | | }; |
157 | | #if defined(__clang__) |
158 | | #pragma clang diagnostic pop |
159 | | #endif |
160 | | |
161 | | |
162 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
163 | | { nullptr, &sMethods_specs[0] }, |
164 | | { nullptr, nullptr } |
165 | | }; |
166 | | |
167 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
168 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
169 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
170 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
171 | | |
172 | | |
173 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
174 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
175 | | |
176 | | static const NativePropertiesN<1> sNativeProperties = { |
177 | | false, 0, |
178 | | false, 0, |
179 | | true, 0 /* sMethods */, |
180 | | false, 0, |
181 | | false, 0, |
182 | | false, 0, |
183 | | false, 0, |
184 | | -1, |
185 | | 2, |
186 | | sNativeProperties_sortedPropertyIndices, |
187 | | { |
188 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
189 | | } |
190 | | }; |
191 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
192 | | "We have a property info count that is oversized"); |
193 | | |
194 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
195 | | { |
196 | | "Function", |
197 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
198 | | &sBoringInterfaceObjectClassClassOps, |
199 | | JS_NULL_CLASS_SPEC, |
200 | | JS_NULL_CLASS_EXT, |
201 | | &sInterfaceObjectClassObjectOps |
202 | | }, |
203 | | eInterface, |
204 | | true, |
205 | | prototypes::id::ImageBitmapRenderingContext, |
206 | | PrototypeTraits<prototypes::id::ImageBitmapRenderingContext>::Depth, |
207 | | sNativePropertyHooks, |
208 | | "function ImageBitmapRenderingContext() {\n [native code]\n}", |
209 | | JS::GetRealmFunctionPrototype |
210 | | }; |
211 | | |
212 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
213 | | { |
214 | | "ImageBitmapRenderingContextPrototype", |
215 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
216 | | JS_NULL_CLASS_OPS, |
217 | | JS_NULL_CLASS_SPEC, |
218 | | JS_NULL_CLASS_EXT, |
219 | | JS_NULL_OBJECT_OPS |
220 | | }, |
221 | | eInterfacePrototype, |
222 | | false, |
223 | | prototypes::id::ImageBitmapRenderingContext, |
224 | | PrototypeTraits<prototypes::id::ImageBitmapRenderingContext>::Depth, |
225 | | sNativePropertyHooks, |
226 | | "[object ImageBitmapRenderingContextPrototype]", |
227 | | JS::GetRealmObjectPrototype |
228 | | }; |
229 | | |
230 | | static const js::ClassOps sClassOps = { |
231 | | _addProperty, /* addProperty */ |
232 | | nullptr, /* delProperty */ |
233 | | nullptr, /* enumerate */ |
234 | | nullptr, /* newEnumerate */ |
235 | | nullptr, /* resolve */ |
236 | | nullptr, /* mayResolve */ |
237 | | _finalize, /* finalize */ |
238 | | nullptr, /* call */ |
239 | | nullptr, /* hasInstance */ |
240 | | nullptr, /* construct */ |
241 | | nullptr, /* trace */ |
242 | | }; |
243 | | |
244 | | static const js::ClassExtension sClassExtension = { |
245 | | nullptr, /* weakmapKeyDelegateOp */ |
246 | | _objectMoved /* objectMovedOp */ |
247 | | }; |
248 | | |
249 | | static const DOMJSClass sClass = { |
250 | | { "ImageBitmapRenderingContext", |
251 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
252 | | &sClassOps, |
253 | | JS_NULL_CLASS_SPEC, |
254 | | &sClassExtension, |
255 | | JS_NULL_OBJECT_OPS |
256 | | }, |
257 | | { prototypes::id::ImageBitmapRenderingContext, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
258 | | IsBaseOf<nsISupports, mozilla::dom::ImageBitmapRenderingContext >::value, |
259 | | sNativePropertyHooks, |
260 | | FindAssociatedGlobalForNative<mozilla::dom::ImageBitmapRenderingContext>::Get, |
261 | | GetProtoObjectHandle, |
262 | | GetCCParticipant<mozilla::dom::ImageBitmapRenderingContext>::Get() |
263 | | }; |
264 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
265 | | "Must have the right minimal number of reserved slots."); |
266 | | static_assert(1 >= 1, |
267 | | "Must have enough reserved slots."); |
268 | | |
269 | | const JSClass* |
270 | | GetJSClass() |
271 | 0 | { |
272 | 0 | return sClass.ToJSClass(); |
273 | 0 | } |
274 | | |
275 | | bool |
276 | | Wrap(JSContext* aCx, mozilla::dom::ImageBitmapRenderingContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
277 | 0 | { |
278 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ImageBitmapRenderingContext>::value, |
279 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
280 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::ImageBitmapRenderingContext*>(aObject) == |
281 | 0 | reinterpret_cast<mozilla::dom::ImageBitmapRenderingContext*>(aObject), |
282 | 0 | "Multiple inheritance for mozilla::dom::ImageBitmapRenderingContext is broken."); |
283 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
284 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
285 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
286 | 0 | "You should probably not be using Wrap() directly; use " |
287 | 0 | "GetOrCreateDOMReflector instead"); |
288 | 0 |
|
289 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
290 | 0 | "nsISupports must be on our primary inheritance chain"); |
291 | 0 |
|
292 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
293 | 0 | if (!global) { |
294 | 0 | return false; |
295 | 0 | } |
296 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
297 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
298 | 0 |
|
299 | 0 | // That might have ended up wrapping us already, due to the wonders |
300 | 0 | // of XBL. Check for that, and bail out as needed. |
301 | 0 | aReflector.set(aCache->GetWrapper()); |
302 | 0 | if (aReflector) { |
303 | | #ifdef DEBUG |
304 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
305 | | #endif // DEBUG |
306 | | return true; |
307 | 0 | } |
308 | 0 |
|
309 | 0 | JSAutoRealm ar(aCx, global); |
310 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
311 | 0 | if (!canonicalProto) { |
312 | 0 | return false; |
313 | 0 | } |
314 | 0 | JS::Rooted<JSObject*> proto(aCx); |
315 | 0 | if (aGivenProto) { |
316 | 0 | proto = aGivenProto; |
317 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
318 | 0 | // coming in, we changed compartments to that of "parent" so may need |
319 | 0 | // to wrap the proto here. |
320 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
321 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
322 | 0 | return false; |
323 | 0 | } |
324 | 0 | } |
325 | 0 | } else { |
326 | 0 | proto = canonicalProto; |
327 | 0 | } |
328 | 0 |
|
329 | 0 | BindingJSObjectCreator<mozilla::dom::ImageBitmapRenderingContext> creator(aCx); |
330 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
331 | 0 | if (!aReflector) { |
332 | 0 | return false; |
333 | 0 | } |
334 | 0 | |
335 | 0 | aCache->SetWrapper(aReflector); |
336 | 0 | creator.InitializationSucceeded(); |
337 | 0 |
|
338 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
339 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
340 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
341 | 0 | // otherwise we won't be able to properly recreate it later, since |
342 | 0 | // we won't know what proto to use. Note that we don't check |
343 | 0 | // aGivenProto here, since it's entirely possible (and even |
344 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
345 | 0 | // same as canonicalProto. |
346 | 0 | if (proto != canonicalProto) { |
347 | 0 | PreserveWrapper(aObject); |
348 | 0 | } |
349 | 0 |
|
350 | 0 | return true; |
351 | 0 | } |
352 | | |
353 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
354 | | nullptr, |
355 | | nullptr, |
356 | | nullptr, |
357 | | { sNativeProperties.Upcast(), nullptr }, |
358 | | prototypes::id::ImageBitmapRenderingContext, |
359 | | constructors::id::ImageBitmapRenderingContext, |
360 | | nullptr, |
361 | | &DefaultXrayExpandoObjectClass |
362 | | } }; |
363 | | |
364 | | void |
365 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
366 | 0 | { |
367 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
368 | 0 | if (!parentProto) { |
369 | 0 | return; |
370 | 0 | } |
371 | 0 | |
372 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
373 | 0 | if (!constructorProto) { |
374 | 0 | return; |
375 | 0 | } |
376 | 0 | |
377 | 0 | static bool sIdsInited = false; |
378 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
379 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
380 | 0 | return; |
381 | 0 | } |
382 | 0 | sIdsInited = true; |
383 | 0 | } |
384 | 0 |
|
385 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ImageBitmapRenderingContext); |
386 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ImageBitmapRenderingContext); |
387 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
388 | 0 | &sPrototypeClass.mBase, protoCache, |
389 | 0 | nullptr, |
390 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
391 | 0 | interfaceCache, |
392 | 0 | sNativeProperties.Upcast(), |
393 | 0 | nullptr, |
394 | 0 | "ImageBitmapRenderingContext", aDefineOnGlobal, |
395 | 0 | nullptr, |
396 | 0 | false); |
397 | 0 | } |
398 | | |
399 | | JSObject* |
400 | | GetConstructorObject(JSContext* aCx) |
401 | 0 | { |
402 | 0 | return GetConstructorObjectHandle(aCx); |
403 | 0 | } |
404 | | |
405 | | } // namespace ImageBitmapRenderingContext_Binding |
406 | | |
407 | | |
408 | | |
409 | | } // namespace dom |
410 | | } // namespace mozilla |