LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - BeforeUnloadEventBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 135 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13