Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM FetchSignal.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "EventHandlerBinding.h"
4 : #include "EventTargetBinding.h"
5 : #include "FetchController.h"
6 : #include "FetchSignalBinding.h"
7 : #include "WrapperFactory.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/FetchSignal.h"
12 : #include "mozilla/dom/NonRefcountedDOMObject.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/PrimitiveConversions.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : namespace FetchSignalBinding {
21 :
22 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
23 : "Can't inherit from an interface with a different ownership model.");
24 :
25 : static bool
26 0 : get_aborted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FetchSignal* self, JSJitGetterCallArgs args)
27 : {
28 0 : bool result(self->Aborted());
29 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
30 0 : args.rval().setBoolean(result);
31 0 : return true;
32 : }
33 :
34 : static const JSJitInfo aborted_getterinfo = {
35 : { (JSJitGetterOp)get_aborted },
36 : { prototypes::id::FetchSignal },
37 : { PrototypeTraits<prototypes::id::FetchSignal>::Depth },
38 : JSJitInfo::Getter,
39 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
40 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
41 : true, /* isInfallible. False in setters. */
42 : false, /* isMovable. Not relevant for setters. */
43 : false, /* isEliminatable. Not relevant for setters. */
44 : false, /* isAlwaysInSlot. Only relevant for getters. */
45 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
46 : false, /* isTypedMethod. Only relevant for methods. */
47 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
48 : };
49 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
50 : static_assert(0 < 1, "There is no slot for us");
51 :
52 : static bool
53 0 : get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FetchSignal* self, JSJitGetterCallArgs args)
54 : {
55 0 : RefPtr<EventHandlerNonNull> result(self->GetOnabort());
56 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
57 0 : if (result) {
58 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
59 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
60 0 : return false;
61 : }
62 0 : return true;
63 : } else {
64 0 : args.rval().setNull();
65 0 : return true;
66 : }
67 : }
68 :
69 : static bool
70 0 : set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FetchSignal* self, JSJitSetterCallArgs args)
71 : {
72 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
73 0 : if (args[0].isObject()) {
74 : { // scope for tempRoot
75 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
76 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
77 : }
78 : } else {
79 0 : arg0 = nullptr;
80 : }
81 0 : self->SetOnabort(Constify(arg0));
82 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
83 :
84 0 : return true;
85 : }
86 :
87 : static const JSJitInfo onabort_getterinfo = {
88 : { (JSJitGetterOp)get_onabort },
89 : { prototypes::id::FetchSignal },
90 : { PrototypeTraits<prototypes::id::FetchSignal>::Depth },
91 : JSJitInfo::Getter,
92 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
93 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
94 : false, /* isInfallible. False in setters. */
95 : false, /* isMovable. Not relevant for setters. */
96 : false, /* isEliminatable. Not relevant for setters. */
97 : false, /* isAlwaysInSlot. Only relevant for getters. */
98 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
99 : false, /* isTypedMethod. Only relevant for methods. */
100 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
101 : };
102 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
103 : static_assert(0 < 1, "There is no slot for us");
104 : static const JSJitInfo onabort_setterinfo = {
105 : { (JSJitGetterOp)set_onabort },
106 : { prototypes::id::FetchSignal },
107 : { PrototypeTraits<prototypes::id::FetchSignal>::Depth },
108 : JSJitInfo::Setter,
109 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
110 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
111 : false, /* isInfallible. False in setters. */
112 : false, /* isMovable. Not relevant for setters. */
113 : false, /* isEliminatable. Not relevant for setters. */
114 : false, /* isAlwaysInSlot. Only relevant for getters. */
115 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
116 : false, /* isTypedMethod. Only relevant for methods. */
117 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
118 : };
119 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
120 : static_assert(0 < 1, "There is no slot for us");
121 :
122 : static bool
123 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
124 : {
125 0 : mozilla::dom::FetchSignal* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FetchSignal>(obj);
126 : // We don't want to preserve if we don't have a wrapper, and we
127 : // obviously can't preserve if we're not initialized.
128 0 : if (self && self->GetWrapperPreserveColor()) {
129 0 : PreserveWrapper(self);
130 : }
131 0 : return true;
132 : }
133 :
134 : static void
135 0 : _finalize(js::FreeOp* fop, JSObject* obj)
136 : {
137 0 : mozilla::dom::FetchSignal* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FetchSignal>(obj);
138 0 : if (self) {
139 0 : ClearWrapper(self, self, obj);
140 0 : AddForDeferredFinalization<mozilla::dom::FetchSignal>(self);
141 : }
142 0 : }
143 :
144 : static void
145 0 : _objectMoved(JSObject* obj, const JSObject* old)
146 : {
147 0 : mozilla::dom::FetchSignal* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FetchSignal>(obj);
148 0 : if (self) {
149 0 : UpdateWrapper(self, self, obj, old);
150 : }
151 0 : }
152 :
153 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
154 : #if defined(__clang__)
155 : #pragma clang diagnostic push
156 : #pragma clang diagnostic ignored "-Wmissing-braces"
157 : #endif
158 : static const JSPropertySpec sAttributes_specs[] = {
159 : { "aborted", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &aborted_getterinfo, nullptr, nullptr },
160 : { "onabort", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onabort_getterinfo, GenericBindingSetter, &onabort_setterinfo },
161 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
162 : };
163 : #if defined(__clang__)
164 : #pragma clang diagnostic pop
165 : #endif
166 :
167 :
168 : // Can't be const because the pref-enabled boolean needs to be writable
169 : static Prefable<const JSPropertySpec> sAttributes[] = {
170 : { nullptr, &sAttributes_specs[0] },
171 : { nullptr, nullptr }
172 : };
173 :
174 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
175 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
176 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
177 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
178 :
179 :
180 : static uint16_t sNativeProperties_sortedPropertyIndices[2];
181 : static PropertyInfo sNativeProperties_propertyInfos[2];
182 :
183 : static const NativePropertiesN<1> sNativeProperties = {
184 : false, 0,
185 : false, 0,
186 : false, 0,
187 : true, 0 /* sAttributes */,
188 : false, 0,
189 : false, 0,
190 : false, 0,
191 : -1,
192 : 2,
193 : sNativeProperties_sortedPropertyIndices,
194 : {
195 : { sAttributes, &sNativeProperties_propertyInfos[0] }
196 : }
197 : };
198 : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
199 : "We have a property info count that is oversized");
200 :
201 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
202 : {
203 : "Function",
204 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
205 : &sBoringInterfaceObjectClassClassOps,
206 : JS_NULL_CLASS_SPEC,
207 : JS_NULL_CLASS_EXT,
208 : &sInterfaceObjectClassObjectOps
209 : },
210 : eInterface,
211 : true,
212 : prototypes::id::FetchSignal,
213 : PrototypeTraits<prototypes::id::FetchSignal>::Depth,
214 : sNativePropertyHooks,
215 : "function FetchSignal() {\n [native code]\n}",
216 : EventTargetBinding::GetConstructorObject
217 : };
218 :
219 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
220 : {
221 : "FetchSignalPrototype",
222 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
223 : JS_NULL_CLASS_OPS,
224 : JS_NULL_CLASS_SPEC,
225 : JS_NULL_CLASS_EXT,
226 : JS_NULL_OBJECT_OPS
227 : },
228 : eInterfacePrototype,
229 : false,
230 : prototypes::id::FetchSignal,
231 : PrototypeTraits<prototypes::id::FetchSignal>::Depth,
232 : sNativePropertyHooks,
233 : "[object FetchSignalPrototype]",
234 : EventTargetBinding::GetProtoObject
235 : };
236 :
237 : bool
238 1 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
239 : {
240 1 : return FetchController::IsEnabled(aCx, aObj);
241 : }
242 :
243 : JSObject*
244 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
245 : {
246 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
247 : }
248 :
249 : static const js::ClassOps sClassOps = {
250 : _addProperty, /* addProperty */
251 : nullptr, /* delProperty */
252 : nullptr, /* getProperty */
253 : nullptr, /* setProperty */
254 : nullptr, /* enumerate */
255 : nullptr, /* newEnumerate */
256 : nullptr, /* resolve */
257 : nullptr, /* mayResolve */
258 : _finalize, /* finalize */
259 : nullptr, /* call */
260 : nullptr, /* hasInstance */
261 : nullptr, /* construct */
262 : nullptr, /* trace */
263 : };
264 :
265 : static const js::ClassExtension sClassExtension = {
266 : nullptr, /* weakmapKeyDelegateOp */
267 : _objectMoved /* objectMovedOp */
268 : };
269 :
270 : static const DOMJSClass sClass = {
271 : { "FetchSignal",
272 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
273 : &sClassOps,
274 : JS_NULL_CLASS_SPEC,
275 : &sClassExtension,
276 : JS_NULL_OBJECT_OPS
277 : },
278 : { prototypes::id::EventTarget, prototypes::id::FetchSignal, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
279 : IsBaseOf<nsISupports, mozilla::dom::FetchSignal >::value,
280 : sNativePropertyHooks,
281 : FindAssociatedGlobalForNative<mozilla::dom::FetchSignal>::Get,
282 : GetProtoObjectHandle,
283 : GetCCParticipant<mozilla::dom::FetchSignal>::Get()
284 : };
285 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
286 : "Must have the right minimal number of reserved slots.");
287 : static_assert(1 >= 1,
288 : "Must have enough reserved slots.");
289 :
290 : const JSClass*
291 0 : GetJSClass()
292 : {
293 0 : return sClass.ToJSClass();
294 : }
295 :
296 : bool
297 0 : Wrap(JSContext* aCx, mozilla::dom::FetchSignal* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
298 : {
299 : MOZ_ASSERT(static_cast<mozilla::dom::FetchSignal*>(aObject) ==
300 : reinterpret_cast<mozilla::dom::FetchSignal*>(aObject),
301 : "Multiple inheritance for mozilla::dom::FetchSignal is broken.");
302 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
303 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
304 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
305 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
306 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
307 0 : MOZ_ASSERT(!aCache->GetWrapper(),
308 : "You should probably not be using Wrap() directly; use "
309 : "GetOrCreateDOMReflector instead");
310 :
311 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
312 : "nsISupports must be on our primary inheritance chain");
313 :
314 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
315 0 : if (!global) {
316 0 : return false;
317 : }
318 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
319 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
320 :
321 : // That might have ended up wrapping us already, due to the wonders
322 : // of XBL. Check for that, and bail out as needed.
323 0 : aReflector.set(aCache->GetWrapper());
324 0 : if (aReflector) {
325 : #ifdef DEBUG
326 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
327 : #endif // DEBUG
328 0 : return true;
329 : }
330 :
331 0 : JSAutoCompartment ac(aCx, global);
332 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
333 0 : if (!canonicalProto) {
334 0 : return false;
335 : }
336 0 : JS::Rooted<JSObject*> proto(aCx);
337 0 : if (aGivenProto) {
338 0 : proto = aGivenProto;
339 : // Unfortunately, while aGivenProto was in the compartment of aCx
340 : // coming in, we changed compartments to that of "parent" so may need
341 : // to wrap the proto here.
342 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
343 0 : if (!JS_WrapObject(aCx, &proto)) {
344 0 : return false;
345 : }
346 : }
347 : } else {
348 0 : proto = canonicalProto;
349 : }
350 :
351 0 : BindingJSObjectCreator<mozilla::dom::FetchSignal> creator(aCx);
352 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
353 0 : if (!aReflector) {
354 0 : return false;
355 : }
356 :
357 0 : aCache->SetWrapper(aReflector);
358 0 : creator.InitializationSucceeded();
359 :
360 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
361 : aCache->GetWrapperPreserveColor() == aReflector);
362 : // If proto != canonicalProto, we have to preserve our wrapper;
363 : // otherwise we won't be able to properly recreate it later, since
364 : // we won't know what proto to use. Note that we don't check
365 : // aGivenProto here, since it's entirely possible (and even
366 : // somewhat common) to have a non-null aGivenProto which is the
367 : // same as canonicalProto.
368 0 : if (proto != canonicalProto) {
369 0 : PreserveWrapper(aObject);
370 : }
371 :
372 0 : return true;
373 : }
374 :
375 : const NativePropertyHooks sNativePropertyHooks[] = { {
376 : nullptr,
377 : nullptr,
378 : nullptr,
379 : { sNativeProperties.Upcast(), nullptr },
380 : prototypes::id::FetchSignal,
381 : constructors::id::FetchSignal,
382 : EventTargetBinding::sNativePropertyHooks,
383 : &DefaultXrayExpandoObjectClass
384 : } };
385 :
386 : void
387 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
388 : {
389 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
390 0 : if (!parentProto) {
391 0 : return;
392 : }
393 :
394 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
395 0 : if (!constructorProto) {
396 0 : return;
397 : }
398 :
399 : static bool sIdsInited = false;
400 0 : if (!sIdsInited && NS_IsMainThread()) {
401 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
402 0 : return;
403 : }
404 0 : sIdsInited = true;
405 : }
406 :
407 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FetchSignal);
408 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FetchSignal);
409 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
410 : &sPrototypeClass.mBase, protoCache,
411 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
412 : interfaceCache,
413 : sNativeProperties.Upcast(),
414 : nullptr,
415 : "FetchSignal", aDefineOnGlobal,
416 : nullptr,
417 0 : false);
418 : }
419 :
420 : JS::Handle<JSObject*>
421 0 : GetProtoObjectHandle(JSContext* aCx)
422 : {
423 : /* Get the interface prototype object for this class. This will create the
424 : object as needed. */
425 0 : bool aDefineOnGlobal = true;
426 :
427 : /* Make sure our global is sane. Hopefully we can remove this sometime */
428 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
429 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
430 0 : return nullptr;
431 : }
432 :
433 : /* Check to see whether the interface objects are already installed */
434 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
435 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::FetchSignal)) {
436 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
437 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
438 : }
439 :
440 : /*
441 : * The object might _still_ be null, but that's OK.
442 : *
443 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
444 : * traced by TraceProtoAndIfaceCache() and its contents are never
445 : * changed after they have been set.
446 : *
447 : * Calling address() avoids the read read barrier that does gray
448 : * unmarking, but it's not possible for the object to be gray here.
449 : */
450 :
451 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::FetchSignal);
452 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
453 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
454 : }
455 :
456 : JS::Handle<JSObject*>
457 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
458 : {
459 : /* Get the interface object for this class. This will create the object as
460 : needed. */
461 :
462 : /* Make sure our global is sane. Hopefully we can remove this sometime */
463 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
464 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
465 0 : return nullptr;
466 : }
467 :
468 : /* Check to see whether the interface objects are already installed */
469 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
470 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::FetchSignal)) {
471 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
472 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
473 : }
474 :
475 : /*
476 : * The object might _still_ be null, but that's OK.
477 : *
478 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
479 : * traced by TraceProtoAndIfaceCache() and its contents are never
480 : * changed after they have been set.
481 : *
482 : * Calling address() avoids the read read barrier that does gray
483 : * unmarking, but it's not possible for the object to be gray here.
484 : */
485 :
486 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::FetchSignal);
487 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
488 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
489 : }
490 :
491 : JSObject*
492 0 : GetConstructorObject(JSContext* aCx)
493 : {
494 0 : return GetConstructorObjectHandle(aCx);
495 : }
496 :
497 : } // namespace FetchSignalBinding
498 :
499 :
500 :
501 : } // namespace dom
502 : } // namespace mozilla
|