Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM DesktopNotification.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "DesktopNotificationBinding.h"
4 : #include "EventHandlerBinding.h"
5 : #include "EventTargetBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/DesktopNotification.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/XrayExpandoClass.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : namespace DesktopNotificationBinding {
19 :
20 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
21 : "Can't inherit from an interface with a different ownership model.");
22 :
23 : static bool
24 0 : show(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DesktopNotification* self, const JSJitMethodCallArgs& args)
25 : {
26 0 : binding_detail::FastErrorResult rv;
27 0 : self->Show(rv);
28 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
29 0 : return false;
30 : }
31 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
32 0 : args.rval().setUndefined();
33 0 : return true;
34 : }
35 :
36 : static const JSJitInfo show_methodinfo = {
37 : { (JSJitGetterOp)show },
38 : { prototypes::id::DesktopNotification },
39 : { PrototypeTraits<prototypes::id::DesktopNotification>::Depth },
40 : JSJitInfo::Method,
41 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
42 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
43 : false, /* isInfallible. False in setters. */
44 : false, /* isMovable. Not relevant for setters. */
45 : false, /* isEliminatable. Not relevant for setters. */
46 : false, /* isAlwaysInSlot. Only relevant for getters. */
47 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
48 : false, /* isTypedMethod. Only relevant for methods. */
49 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
50 : };
51 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
52 : static_assert(0 < 1, "There is no slot for us");
53 :
54 : static bool
55 0 : get_onclick(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DesktopNotification* self, JSJitGetterCallArgs args)
56 : {
57 0 : RefPtr<EventHandlerNonNull> result(self->GetOnclick());
58 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
59 0 : if (result) {
60 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
61 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
62 0 : return false;
63 : }
64 0 : return true;
65 : } else {
66 0 : args.rval().setNull();
67 0 : return true;
68 : }
69 : }
70 :
71 : static bool
72 0 : set_onclick(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DesktopNotification* self, JSJitSetterCallArgs args)
73 : {
74 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
75 0 : if (args[0].isObject()) {
76 : { // scope for tempRoot
77 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
78 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
79 : }
80 : } else {
81 0 : arg0 = nullptr;
82 : }
83 0 : self->SetOnclick(Constify(arg0));
84 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
85 :
86 0 : return true;
87 : }
88 :
89 : static const JSJitInfo onclick_getterinfo = {
90 : { (JSJitGetterOp)get_onclick },
91 : { prototypes::id::DesktopNotification },
92 : { PrototypeTraits<prototypes::id::DesktopNotification>::Depth },
93 : JSJitInfo::Getter,
94 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
95 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
96 : false, /* isInfallible. False in setters. */
97 : false, /* isMovable. Not relevant for setters. */
98 : false, /* isEliminatable. Not relevant for setters. */
99 : false, /* isAlwaysInSlot. Only relevant for getters. */
100 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
101 : false, /* isTypedMethod. Only relevant for methods. */
102 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
103 : };
104 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
105 : static_assert(0 < 1, "There is no slot for us");
106 : static const JSJitInfo onclick_setterinfo = {
107 : { (JSJitGetterOp)set_onclick },
108 : { prototypes::id::DesktopNotification },
109 : { PrototypeTraits<prototypes::id::DesktopNotification>::Depth },
110 : JSJitInfo::Setter,
111 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
112 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
113 : false, /* isInfallible. False in setters. */
114 : false, /* isMovable. Not relevant for setters. */
115 : false, /* isEliminatable. Not relevant for setters. */
116 : false, /* isAlwaysInSlot. Only relevant for getters. */
117 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
118 : false, /* isTypedMethod. Only relevant for methods. */
119 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
120 : };
121 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
122 : static_assert(0 < 1, "There is no slot for us");
123 :
124 : static bool
125 0 : get_onclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DesktopNotification* self, JSJitGetterCallArgs args)
126 : {
127 0 : RefPtr<EventHandlerNonNull> result(self->GetOnclose());
128 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
129 0 : if (result) {
130 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
131 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
132 0 : return false;
133 : }
134 0 : return true;
135 : } else {
136 0 : args.rval().setNull();
137 0 : return true;
138 : }
139 : }
140 :
141 : static bool
142 0 : set_onclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DesktopNotification* self, JSJitSetterCallArgs args)
143 : {
144 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
145 0 : if (args[0].isObject()) {
146 : { // scope for tempRoot
147 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
148 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
149 : }
150 : } else {
151 0 : arg0 = nullptr;
152 : }
153 0 : self->SetOnclose(Constify(arg0));
154 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
155 :
156 0 : return true;
157 : }
158 :
159 : static const JSJitInfo onclose_getterinfo = {
160 : { (JSJitGetterOp)get_onclose },
161 : { prototypes::id::DesktopNotification },
162 : { PrototypeTraits<prototypes::id::DesktopNotification>::Depth },
163 : JSJitInfo::Getter,
164 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
165 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
166 : false, /* isInfallible. False in setters. */
167 : false, /* isMovable. Not relevant for setters. */
168 : false, /* isEliminatable. Not relevant for setters. */
169 : false, /* isAlwaysInSlot. Only relevant for getters. */
170 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
171 : false, /* isTypedMethod. Only relevant for methods. */
172 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
173 : };
174 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
175 : static_assert(0 < 1, "There is no slot for us");
176 : static const JSJitInfo onclose_setterinfo = {
177 : { (JSJitGetterOp)set_onclose },
178 : { prototypes::id::DesktopNotification },
179 : { PrototypeTraits<prototypes::id::DesktopNotification>::Depth },
180 : JSJitInfo::Setter,
181 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
182 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
183 : false, /* isInfallible. False in setters. */
184 : false, /* isMovable. Not relevant for setters. */
185 : false, /* isEliminatable. Not relevant for setters. */
186 : false, /* isAlwaysInSlot. Only relevant for getters. */
187 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
188 : false, /* isTypedMethod. Only relevant for methods. */
189 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
190 : };
191 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
192 : static_assert(0 < 1, "There is no slot for us");
193 :
194 : static bool
195 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
196 : {
197 0 : mozilla::dom::DesktopNotification* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DesktopNotification>(obj);
198 : // We don't want to preserve if we don't have a wrapper, and we
199 : // obviously can't preserve if we're not initialized.
200 0 : if (self && self->GetWrapperPreserveColor()) {
201 0 : PreserveWrapper(self);
202 : }
203 0 : return true;
204 : }
205 :
206 : static void
207 0 : _finalize(js::FreeOp* fop, JSObject* obj)
208 : {
209 0 : mozilla::dom::DesktopNotification* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DesktopNotification>(obj);
210 0 : if (self) {
211 0 : ClearWrapper(self, self, obj);
212 0 : AddForDeferredFinalization<mozilla::dom::DesktopNotification>(self);
213 : }
214 0 : }
215 :
216 : static void
217 0 : _objectMoved(JSObject* obj, const JSObject* old)
218 : {
219 0 : mozilla::dom::DesktopNotification* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DesktopNotification>(obj);
220 0 : if (self) {
221 0 : UpdateWrapper(self, self, obj, old);
222 : }
223 0 : }
224 :
225 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
226 : #if defined(__clang__)
227 : #pragma clang diagnostic push
228 : #pragma clang diagnostic ignored "-Wmissing-braces"
229 : #endif
230 : static const JSFunctionSpec sMethods_specs[] = {
231 : JS_FNSPEC("show", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&show_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
232 : JS_FS_END
233 : };
234 : #if defined(__clang__)
235 : #pragma clang diagnostic pop
236 : #endif
237 :
238 :
239 : // Can't be const because the pref-enabled boolean needs to be writable
240 : static Prefable<const JSFunctionSpec> sMethods[] = {
241 : { nullptr, &sMethods_specs[0] },
242 : { nullptr, nullptr }
243 : };
244 :
245 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
246 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
247 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
248 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
249 :
250 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
251 : #if defined(__clang__)
252 : #pragma clang diagnostic push
253 : #pragma clang diagnostic ignored "-Wmissing-braces"
254 : #endif
255 : static const JSPropertySpec sAttributes_specs[] = {
256 : { "onclick", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onclick_getterinfo, GenericBindingSetter, &onclick_setterinfo },
257 : { "onclose", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onclose_getterinfo, GenericBindingSetter, &onclose_setterinfo },
258 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
259 : };
260 : #if defined(__clang__)
261 : #pragma clang diagnostic pop
262 : #endif
263 :
264 :
265 : // Can't be const because the pref-enabled boolean needs to be writable
266 : static Prefable<const JSPropertySpec> sAttributes[] = {
267 : { nullptr, &sAttributes_specs[0] },
268 : { nullptr, nullptr }
269 : };
270 :
271 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
272 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
273 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
274 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
275 :
276 :
277 : static uint16_t sNativeProperties_sortedPropertyIndices[3];
278 : static PropertyInfo sNativeProperties_propertyInfos[3];
279 :
280 : static const NativePropertiesN<2> sNativeProperties = {
281 : false, 0,
282 : false, 0,
283 : true, 0 /* sMethods */,
284 : true, 1 /* sAttributes */,
285 : false, 0,
286 : false, 0,
287 : false, 0,
288 : -1,
289 : 3,
290 : sNativeProperties_sortedPropertyIndices,
291 : {
292 : { sMethods, &sNativeProperties_propertyInfos[0] },
293 : { sAttributes, &sNativeProperties_propertyInfos[1] }
294 : }
295 : };
296 : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
297 : "We have a property info count that is oversized");
298 :
299 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
300 : {
301 : "Function",
302 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
303 : &sBoringInterfaceObjectClassClassOps,
304 : JS_NULL_CLASS_SPEC,
305 : JS_NULL_CLASS_EXT,
306 : &sInterfaceObjectClassObjectOps
307 : },
308 : eInterface,
309 : true,
310 : prototypes::id::DesktopNotification,
311 : PrototypeTraits<prototypes::id::DesktopNotification>::Depth,
312 : sNativePropertyHooks,
313 : "function DesktopNotification() {\n [native code]\n}",
314 : EventTargetBinding::GetConstructorObject
315 : };
316 :
317 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
318 : {
319 : "DesktopNotificationPrototype",
320 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
321 : JS_NULL_CLASS_OPS,
322 : JS_NULL_CLASS_SPEC,
323 : JS_NULL_CLASS_EXT,
324 : JS_NULL_OBJECT_OPS
325 : },
326 : eInterfacePrototype,
327 : false,
328 : prototypes::id::DesktopNotification,
329 : PrototypeTraits<prototypes::id::DesktopNotification>::Depth,
330 : sNativePropertyHooks,
331 : "[object DesktopNotificationPrototype]",
332 : EventTargetBinding::GetProtoObject
333 : };
334 :
335 : JSObject*
336 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
337 : {
338 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
339 : }
340 :
341 : static const js::ClassOps sClassOps = {
342 : _addProperty, /* addProperty */
343 : nullptr, /* delProperty */
344 : nullptr, /* getProperty */
345 : nullptr, /* setProperty */
346 : nullptr, /* enumerate */
347 : nullptr, /* newEnumerate */
348 : nullptr, /* resolve */
349 : nullptr, /* mayResolve */
350 : _finalize, /* finalize */
351 : nullptr, /* call */
352 : nullptr, /* hasInstance */
353 : nullptr, /* construct */
354 : nullptr, /* trace */
355 : };
356 :
357 : static const js::ClassExtension sClassExtension = {
358 : nullptr, /* weakmapKeyDelegateOp */
359 : _objectMoved /* objectMovedOp */
360 : };
361 :
362 : static const DOMJSClass sClass = {
363 : { "DesktopNotification",
364 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
365 : &sClassOps,
366 : JS_NULL_CLASS_SPEC,
367 : &sClassExtension,
368 : JS_NULL_OBJECT_OPS
369 : },
370 : { prototypes::id::EventTarget, prototypes::id::DesktopNotification, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
371 : IsBaseOf<nsISupports, mozilla::dom::DesktopNotification >::value,
372 : sNativePropertyHooks,
373 : FindAssociatedGlobalForNative<mozilla::dom::DesktopNotification>::Get,
374 : GetProtoObjectHandle,
375 : GetCCParticipant<mozilla::dom::DesktopNotification>::Get()
376 : };
377 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
378 : "Must have the right minimal number of reserved slots.");
379 : static_assert(1 >= 1,
380 : "Must have enough reserved slots.");
381 :
382 : const JSClass*
383 0 : GetJSClass()
384 : {
385 0 : return sClass.ToJSClass();
386 : }
387 :
388 : bool
389 0 : Wrap(JSContext* aCx, mozilla::dom::DesktopNotification* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
390 : {
391 : MOZ_ASSERT(static_cast<mozilla::dom::DesktopNotification*>(aObject) ==
392 : reinterpret_cast<mozilla::dom::DesktopNotification*>(aObject),
393 : "Multiple inheritance for mozilla::dom::DesktopNotification is broken.");
394 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
395 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
396 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
397 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
398 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
399 0 : MOZ_ASSERT(!aCache->GetWrapper(),
400 : "You should probably not be using Wrap() directly; use "
401 : "GetOrCreateDOMReflector instead");
402 :
403 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
404 : "nsISupports must be on our primary inheritance chain");
405 :
406 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
407 0 : if (!global) {
408 0 : return false;
409 : }
410 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
411 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
412 :
413 : // That might have ended up wrapping us already, due to the wonders
414 : // of XBL. Check for that, and bail out as needed.
415 0 : aReflector.set(aCache->GetWrapper());
416 0 : if (aReflector) {
417 : #ifdef DEBUG
418 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
419 : #endif // DEBUG
420 0 : return true;
421 : }
422 :
423 0 : JSAutoCompartment ac(aCx, global);
424 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
425 0 : if (!canonicalProto) {
426 0 : return false;
427 : }
428 0 : JS::Rooted<JSObject*> proto(aCx);
429 0 : if (aGivenProto) {
430 0 : proto = aGivenProto;
431 : // Unfortunately, while aGivenProto was in the compartment of aCx
432 : // coming in, we changed compartments to that of "parent" so may need
433 : // to wrap the proto here.
434 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
435 0 : if (!JS_WrapObject(aCx, &proto)) {
436 0 : return false;
437 : }
438 : }
439 : } else {
440 0 : proto = canonicalProto;
441 : }
442 :
443 0 : BindingJSObjectCreator<mozilla::dom::DesktopNotification> creator(aCx);
444 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
445 0 : if (!aReflector) {
446 0 : return false;
447 : }
448 :
449 0 : aCache->SetWrapper(aReflector);
450 0 : creator.InitializationSucceeded();
451 :
452 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
453 : aCache->GetWrapperPreserveColor() == aReflector);
454 : // If proto != canonicalProto, we have to preserve our wrapper;
455 : // otherwise we won't be able to properly recreate it later, since
456 : // we won't know what proto to use. Note that we don't check
457 : // aGivenProto here, since it's entirely possible (and even
458 : // somewhat common) to have a non-null aGivenProto which is the
459 : // same as canonicalProto.
460 0 : if (proto != canonicalProto) {
461 0 : PreserveWrapper(aObject);
462 : }
463 :
464 0 : return true;
465 : }
466 :
467 : const NativePropertyHooks sNativePropertyHooks[] = { {
468 : nullptr,
469 : nullptr,
470 : nullptr,
471 : { sNativeProperties.Upcast(), nullptr },
472 : prototypes::id::DesktopNotification,
473 : constructors::id::DesktopNotification,
474 : EventTargetBinding::sNativePropertyHooks,
475 : &DefaultXrayExpandoObjectClass
476 : } };
477 :
478 : void
479 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
480 : {
481 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
482 0 : if (!parentProto) {
483 0 : return;
484 : }
485 :
486 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
487 0 : if (!constructorProto) {
488 0 : return;
489 : }
490 :
491 : static bool sIdsInited = false;
492 0 : if (!sIdsInited && NS_IsMainThread()) {
493 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
494 0 : return;
495 : }
496 0 : sIdsInited = true;
497 : }
498 :
499 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DesktopNotification);
500 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DesktopNotification);
501 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
502 : &sPrototypeClass.mBase, protoCache,
503 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
504 : interfaceCache,
505 : sNativeProperties.Upcast(),
506 : nullptr,
507 : "DesktopNotification", aDefineOnGlobal,
508 : nullptr,
509 0 : false);
510 : }
511 :
512 : JS::Handle<JSObject*>
513 0 : GetProtoObjectHandle(JSContext* aCx)
514 : {
515 : /* Get the interface prototype object for this class. This will create the
516 : object as needed. */
517 0 : bool aDefineOnGlobal = true;
518 :
519 : /* Make sure our global is sane. Hopefully we can remove this sometime */
520 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
521 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
522 0 : return nullptr;
523 : }
524 :
525 : /* Check to see whether the interface objects are already installed */
526 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
527 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DesktopNotification)) {
528 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
529 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
530 : }
531 :
532 : /*
533 : * The object might _still_ be null, but that's OK.
534 : *
535 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
536 : * traced by TraceProtoAndIfaceCache() and its contents are never
537 : * changed after they have been set.
538 : *
539 : * Calling address() avoids the read read barrier that does gray
540 : * unmarking, but it's not possible for the object to be gray here.
541 : */
542 :
543 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DesktopNotification);
544 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
545 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
546 : }
547 :
548 : JS::Handle<JSObject*>
549 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
550 : {
551 : /* Get the interface object for this class. This will create the object as
552 : needed. */
553 :
554 : /* Make sure our global is sane. Hopefully we can remove this sometime */
555 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
556 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
557 0 : return nullptr;
558 : }
559 :
560 : /* Check to see whether the interface objects are already installed */
561 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
562 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DesktopNotification)) {
563 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
564 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
565 : }
566 :
567 : /*
568 : * The object might _still_ be null, but that's OK.
569 : *
570 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
571 : * traced by TraceProtoAndIfaceCache() and its contents are never
572 : * changed after they have been set.
573 : *
574 : * Calling address() avoids the read read barrier that does gray
575 : * unmarking, but it's not possible for the object to be gray here.
576 : */
577 :
578 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DesktopNotification);
579 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
580 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
581 : }
582 :
583 : JSObject*
584 0 : GetConstructorObject(JSContext* aCx)
585 : {
586 0 : return GetConstructorObjectHandle(aCx);
587 : }
588 :
589 : } // namespace DesktopNotificationBinding
590 :
591 :
592 :
593 : namespace DesktopNotificationCenterBinding {
594 :
595 : static bool
596 0 : createNotification(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DesktopNotificationCenter* self, const JSJitMethodCallArgs& args)
597 : {
598 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
599 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DesktopNotificationCenter.createNotification");
600 : }
601 0 : binding_detail::FakeString arg0;
602 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
603 0 : return false;
604 : }
605 0 : binding_detail::FakeString arg1;
606 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
607 0 : return false;
608 : }
609 0 : binding_detail::FakeString arg2;
610 0 : if (args.hasDefined(2)) {
611 0 : if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
612 0 : return false;
613 : }
614 : } else {
615 : static const char16_t data[] = { 0 };
616 0 : arg2.Rebind(data, ArrayLength(data) - 1);
617 : }
618 0 : auto result(StrongOrRawPtr<mozilla::dom::DesktopNotification>(self->CreateNotification(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)))));
619 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
620 : static_assert(!IsPointer<decltype(result)>::value,
621 : "NewObject implies that we need to keep the object alive with a strong reference.");
622 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
623 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
624 0 : return false;
625 : }
626 0 : return true;
627 : }
628 :
629 : static const JSJitInfo createNotification_methodinfo = {
630 : { (JSJitGetterOp)createNotification },
631 : { prototypes::id::DesktopNotificationCenter },
632 : { PrototypeTraits<prototypes::id::DesktopNotificationCenter>::Depth },
633 : JSJitInfo::Method,
634 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
635 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
636 : false, /* isInfallible. False in setters. */
637 : false, /* isMovable. Not relevant for setters. */
638 : false, /* isEliminatable. Not relevant for setters. */
639 : false, /* isAlwaysInSlot. Only relevant for getters. */
640 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
641 : false, /* isTypedMethod. Only relevant for methods. */
642 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
643 : };
644 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
645 : static_assert(0 < 1, "There is no slot for us");
646 :
647 : static bool
648 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
649 : {
650 0 : mozilla::dom::DesktopNotificationCenter* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DesktopNotificationCenter>(obj);
651 : // We don't want to preserve if we don't have a wrapper, and we
652 : // obviously can't preserve if we're not initialized.
653 0 : if (self && self->GetWrapperPreserveColor()) {
654 0 : PreserveWrapper(self);
655 : }
656 0 : return true;
657 : }
658 :
659 : static void
660 0 : _finalize(js::FreeOp* fop, JSObject* obj)
661 : {
662 0 : mozilla::dom::DesktopNotificationCenter* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DesktopNotificationCenter>(obj);
663 0 : if (self) {
664 0 : ClearWrapper(self, self, obj);
665 0 : AddForDeferredFinalization<mozilla::dom::DesktopNotificationCenter>(self);
666 : }
667 0 : }
668 :
669 : static void
670 0 : _objectMoved(JSObject* obj, const JSObject* old)
671 : {
672 0 : mozilla::dom::DesktopNotificationCenter* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DesktopNotificationCenter>(obj);
673 0 : if (self) {
674 0 : UpdateWrapper(self, self, obj, old);
675 : }
676 0 : }
677 :
678 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
679 : #if defined(__clang__)
680 : #pragma clang diagnostic push
681 : #pragma clang diagnostic ignored "-Wmissing-braces"
682 : #endif
683 : static const JSFunctionSpec sMethods_specs[] = {
684 : JS_FNSPEC("createNotification", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createNotification_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
685 : JS_FS_END
686 : };
687 : #if defined(__clang__)
688 : #pragma clang diagnostic pop
689 : #endif
690 :
691 :
692 : // Can't be const because the pref-enabled boolean needs to be writable
693 : static Prefable<const JSFunctionSpec> sMethods[] = {
694 : { nullptr, &sMethods_specs[0] },
695 : { nullptr, nullptr }
696 : };
697 :
698 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
699 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
700 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
701 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
702 :
703 :
704 : static uint16_t sNativeProperties_sortedPropertyIndices[1];
705 : static PropertyInfo sNativeProperties_propertyInfos[1];
706 :
707 : static const NativePropertiesN<1> sNativeProperties = {
708 : false, 0,
709 : false, 0,
710 : true, 0 /* sMethods */,
711 : false, 0,
712 : false, 0,
713 : false, 0,
714 : false, 0,
715 : -1,
716 : 1,
717 : sNativeProperties_sortedPropertyIndices,
718 : {
719 : { sMethods, &sNativeProperties_propertyInfos[0] }
720 : }
721 : };
722 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
723 : "We have a property info count that is oversized");
724 :
725 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
726 : {
727 : "Function",
728 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
729 : &sBoringInterfaceObjectClassClassOps,
730 : JS_NULL_CLASS_SPEC,
731 : JS_NULL_CLASS_EXT,
732 : &sInterfaceObjectClassObjectOps
733 : },
734 : eInterface,
735 : true,
736 : prototypes::id::DesktopNotificationCenter,
737 : PrototypeTraits<prototypes::id::DesktopNotificationCenter>::Depth,
738 : sNativePropertyHooks,
739 : "function DesktopNotificationCenter() {\n [native code]\n}",
740 : JS::GetRealmFunctionPrototype
741 : };
742 :
743 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
744 : {
745 : "DesktopNotificationCenterPrototype",
746 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
747 : JS_NULL_CLASS_OPS,
748 : JS_NULL_CLASS_SPEC,
749 : JS_NULL_CLASS_EXT,
750 : JS_NULL_OBJECT_OPS
751 : },
752 : eInterfacePrototype,
753 : false,
754 : prototypes::id::DesktopNotificationCenter,
755 : PrototypeTraits<prototypes::id::DesktopNotificationCenter>::Depth,
756 : sNativePropertyHooks,
757 : "[object DesktopNotificationCenterPrototype]",
758 : JS::GetRealmObjectPrototype
759 : };
760 :
761 : JSObject*
762 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
763 : {
764 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
765 : }
766 :
767 : static const js::ClassOps sClassOps = {
768 : _addProperty, /* addProperty */
769 : nullptr, /* delProperty */
770 : nullptr, /* getProperty */
771 : nullptr, /* setProperty */
772 : nullptr, /* enumerate */
773 : nullptr, /* newEnumerate */
774 : nullptr, /* resolve */
775 : nullptr, /* mayResolve */
776 : _finalize, /* finalize */
777 : nullptr, /* call */
778 : nullptr, /* hasInstance */
779 : nullptr, /* construct */
780 : nullptr, /* trace */
781 : };
782 :
783 : static const js::ClassExtension sClassExtension = {
784 : nullptr, /* weakmapKeyDelegateOp */
785 : _objectMoved /* objectMovedOp */
786 : };
787 :
788 : static const DOMJSClass sClass = {
789 : { "DesktopNotificationCenter",
790 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
791 : &sClassOps,
792 : JS_NULL_CLASS_SPEC,
793 : &sClassExtension,
794 : JS_NULL_OBJECT_OPS
795 : },
796 : { prototypes::id::DesktopNotificationCenter, 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 },
797 : IsBaseOf<nsISupports, mozilla::dom::DesktopNotificationCenter >::value,
798 : sNativePropertyHooks,
799 : FindAssociatedGlobalForNative<mozilla::dom::DesktopNotificationCenter>::Get,
800 : GetProtoObjectHandle,
801 : GetCCParticipant<mozilla::dom::DesktopNotificationCenter>::Get()
802 : };
803 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
804 : "Must have the right minimal number of reserved slots.");
805 : static_assert(1 >= 1,
806 : "Must have enough reserved slots.");
807 :
808 : const JSClass*
809 0 : GetJSClass()
810 : {
811 0 : return sClass.ToJSClass();
812 : }
813 :
814 : bool
815 0 : Wrap(JSContext* aCx, mozilla::dom::DesktopNotificationCenter* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
816 : {
817 : MOZ_ASSERT(static_cast<mozilla::dom::DesktopNotificationCenter*>(aObject) ==
818 : reinterpret_cast<mozilla::dom::DesktopNotificationCenter*>(aObject),
819 : "Multiple inheritance for mozilla::dom::DesktopNotificationCenter is broken.");
820 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
821 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
822 0 : MOZ_ASSERT(!aCache->GetWrapper(),
823 : "You should probably not be using Wrap() directly; use "
824 : "GetOrCreateDOMReflector instead");
825 :
826 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
827 : "nsISupports must be on our primary inheritance chain");
828 :
829 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
830 0 : if (!global) {
831 0 : return false;
832 : }
833 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
834 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
835 :
836 : // That might have ended up wrapping us already, due to the wonders
837 : // of XBL. Check for that, and bail out as needed.
838 0 : aReflector.set(aCache->GetWrapper());
839 0 : if (aReflector) {
840 : #ifdef DEBUG
841 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
842 : #endif // DEBUG
843 0 : return true;
844 : }
845 :
846 0 : JSAutoCompartment ac(aCx, global);
847 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
848 0 : if (!canonicalProto) {
849 0 : return false;
850 : }
851 0 : JS::Rooted<JSObject*> proto(aCx);
852 0 : if (aGivenProto) {
853 0 : proto = aGivenProto;
854 : // Unfortunately, while aGivenProto was in the compartment of aCx
855 : // coming in, we changed compartments to that of "parent" so may need
856 : // to wrap the proto here.
857 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
858 0 : if (!JS_WrapObject(aCx, &proto)) {
859 0 : return false;
860 : }
861 : }
862 : } else {
863 0 : proto = canonicalProto;
864 : }
865 :
866 0 : BindingJSObjectCreator<mozilla::dom::DesktopNotificationCenter> creator(aCx);
867 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
868 0 : if (!aReflector) {
869 0 : return false;
870 : }
871 :
872 0 : aCache->SetWrapper(aReflector);
873 0 : creator.InitializationSucceeded();
874 :
875 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
876 : aCache->GetWrapperPreserveColor() == aReflector);
877 : // If proto != canonicalProto, we have to preserve our wrapper;
878 : // otherwise we won't be able to properly recreate it later, since
879 : // we won't know what proto to use. Note that we don't check
880 : // aGivenProto here, since it's entirely possible (and even
881 : // somewhat common) to have a non-null aGivenProto which is the
882 : // same as canonicalProto.
883 0 : if (proto != canonicalProto) {
884 0 : PreserveWrapper(aObject);
885 : }
886 :
887 0 : return true;
888 : }
889 :
890 : const NativePropertyHooks sNativePropertyHooks[] = { {
891 : nullptr,
892 : nullptr,
893 : nullptr,
894 : { sNativeProperties.Upcast(), nullptr },
895 : prototypes::id::DesktopNotificationCenter,
896 : constructors::id::DesktopNotificationCenter,
897 : nullptr,
898 : &DefaultXrayExpandoObjectClass
899 : } };
900 :
901 : void
902 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
903 : {
904 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
905 0 : if (!parentProto) {
906 0 : return;
907 : }
908 :
909 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
910 0 : if (!constructorProto) {
911 0 : return;
912 : }
913 :
914 : static bool sIdsInited = false;
915 0 : if (!sIdsInited && NS_IsMainThread()) {
916 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
917 0 : return;
918 : }
919 0 : sIdsInited = true;
920 : }
921 :
922 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DesktopNotificationCenter);
923 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DesktopNotificationCenter);
924 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
925 : &sPrototypeClass.mBase, protoCache,
926 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
927 : interfaceCache,
928 : sNativeProperties.Upcast(),
929 : nullptr,
930 : "DesktopNotificationCenter", aDefineOnGlobal,
931 : nullptr,
932 0 : false);
933 : }
934 :
935 : JS::Handle<JSObject*>
936 0 : GetProtoObjectHandle(JSContext* aCx)
937 : {
938 : /* Get the interface prototype object for this class. This will create the
939 : object as needed. */
940 0 : bool aDefineOnGlobal = true;
941 :
942 : /* Make sure our global is sane. Hopefully we can remove this sometime */
943 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
944 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
945 0 : return nullptr;
946 : }
947 :
948 : /* Check to see whether the interface objects are already installed */
949 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
950 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DesktopNotificationCenter)) {
951 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
952 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
953 : }
954 :
955 : /*
956 : * The object might _still_ be null, but that's OK.
957 : *
958 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
959 : * traced by TraceProtoAndIfaceCache() and its contents are never
960 : * changed after they have been set.
961 : *
962 : * Calling address() avoids the read read barrier that does gray
963 : * unmarking, but it's not possible for the object to be gray here.
964 : */
965 :
966 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DesktopNotificationCenter);
967 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
968 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
969 : }
970 :
971 : JS::Handle<JSObject*>
972 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
973 : {
974 : /* Get the interface object for this class. This will create the object as
975 : needed. */
976 :
977 : /* Make sure our global is sane. Hopefully we can remove this sometime */
978 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
979 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
980 0 : return nullptr;
981 : }
982 :
983 : /* Check to see whether the interface objects are already installed */
984 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
985 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DesktopNotificationCenter)) {
986 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
987 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
988 : }
989 :
990 : /*
991 : * The object might _still_ be null, but that's OK.
992 : *
993 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
994 : * traced by TraceProtoAndIfaceCache() and its contents are never
995 : * changed after they have been set.
996 : *
997 : * Calling address() avoids the read read barrier that does gray
998 : * unmarking, but it's not possible for the object to be gray here.
999 : */
1000 :
1001 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DesktopNotificationCenter);
1002 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1003 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1004 : }
1005 :
1006 : JSObject*
1007 0 : GetConstructorObject(JSContext* aCx)
1008 : {
1009 0 : return GetConstructorObjectHandle(aCx);
1010 : }
1011 :
1012 : } // namespace DesktopNotificationCenterBinding
1013 :
1014 :
1015 :
1016 : } // namespace dom
1017 : } // namespace mozilla
|