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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM PresentationConnectionCloseEvent.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "EventBinding.h"
       5             : #include "PresentationConnectionCloseEventBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "jsapi.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/Preferences.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/DOMJSClass.h"
      12             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      13             : #include "mozilla/dom/PresentationConnectionCloseEvent.h"
      14             : #include "mozilla/dom/PrimitiveConversions.h"
      15             : #include "mozilla/dom/ScriptSettings.h"
      16             : #include "mozilla/dom/SimpleGlobalObject.h"
      17             : #include "mozilla/dom/XrayExpandoClass.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace PresentationConnectionClosedReasonValues {
      23             : extern const EnumEntry strings[4] = {
      24             :   {"error", 5},
      25             :   {"closed", 6},
      26             :   {"wentaway", 8},
      27             :   { nullptr, 0 }
      28             : };
      29             : } // namespace PresentationConnectionClosedReasonValues
      30             : 
      31             : bool
      32           0 : ToJSValue(JSContext* aCx, PresentationConnectionClosedReason aArgument, JS::MutableHandle<JS::Value> aValue)
      33             : {
      34           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PresentationConnectionClosedReasonValues::strings));
      35             :   JSString* resultStr =
      36           0 :     JS_NewStringCopyN(aCx, PresentationConnectionClosedReasonValues::strings[uint32_t(aArgument)].value,
      37           0 :                       PresentationConnectionClosedReasonValues::strings[uint32_t(aArgument)].length);
      38           0 :   if (!resultStr) {
      39           0 :     return false;
      40             :   }
      41           0 :   aValue.setString(resultStr);
      42           0 :   return true;
      43             : }
      44             : 
      45             : 
      46             : 
      47           0 : PresentationConnectionCloseEventInit::PresentationConnectionCloseEventInit()
      48           0 :   : EventInit(FastDictionaryInitializer())
      49             : {
      50             :   // Safe to pass a null context if we pass a null value
      51           0 :   Init(nullptr, JS::NullHandleValue);
      52           0 : }
      53             : 
      54             : 
      55             : 
      56             : bool
      57           0 : PresentationConnectionCloseEventInit::InitIds(JSContext* cx, PresentationConnectionCloseEventInitAtoms* atomsCache)
      58             : {
      59           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      60             : 
      61             :   // Initialize these in reverse order so that any failure leaves the first one
      62             :   // uninitialized.
      63           0 :   if (!atomsCache->reason_id.init(cx, "reason") ||
      64           0 :       !atomsCache->message_id.init(cx, "message")) {
      65           0 :     return false;
      66             :   }
      67           0 :   return true;
      68             : }
      69             : 
      70             : bool
      71           0 : PresentationConnectionCloseEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      72             : {
      73             :   // Passing a null JSContext is OK only if we're initing from null,
      74             :   // Since in that case we will not have to do any property gets
      75             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      76             :   // checkers by static analysis tools
      77           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      78           0 :   PresentationConnectionCloseEventInitAtoms* atomsCache = nullptr;
      79           0 :   if (cx) {
      80           0 :     atomsCache = GetAtomCache<PresentationConnectionCloseEventInitAtoms>(cx);
      81           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      82           0 :       return false;
      83             :     }
      84             :   }
      85             : 
      86             :   // Per spec, we init the parent's members first
      87           0 :   if (!EventInit::Init(cx, val)) {
      88           0 :     return false;
      89             :   }
      90             : 
      91           0 :   bool isNull = val.isNullOrUndefined();
      92             :   // We only need these if !isNull, in which case we have |cx|.
      93           0 :   Maybe<JS::Rooted<JSObject *> > object;
      94           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      95           0 :   if (!isNull) {
      96           0 :     MOZ_ASSERT(cx);
      97           0 :     object.emplace(cx, &val.toObject());
      98           0 :     temp.emplace(cx);
      99             :   }
     100           0 :   if (!isNull) {
     101           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->message_id, temp.ptr())) {
     102           0 :       return false;
     103             :     }
     104             :   }
     105           0 :   if (!isNull && !temp->isUndefined()) {
     106           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mMessage)) {
     107           0 :       return false;
     108             :     }
     109             :   } else {
     110             :     static const char16_t data[] = { 0 };
     111           0 :     mMessage.Rebind(data, ArrayLength(data) - 1);
     112             :   }
     113           0 :   mIsAnyMemberPresent = true;
     114             : 
     115           0 :   if (!isNull) {
     116           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->reason_id, temp.ptr())) {
     117           0 :       return false;
     118             :     }
     119             :   }
     120           0 :   if (!isNull && !temp->isUndefined()) {
     121             :     {
     122             :       int index;
     123           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), PresentationConnectionClosedReasonValues::strings, "PresentationConnectionClosedReason", "'reason' member of PresentationConnectionCloseEventInit", &index)) {
     124           0 :         return false;
     125             :       }
     126           0 :       MOZ_ASSERT(index >= 0);
     127           0 :       mReason = static_cast<PresentationConnectionClosedReason>(index);
     128             :     }
     129           0 :     mIsAnyMemberPresent = true;
     130           0 :   } else if (cx) {
     131             :     // Don't error out if we have no cx.  In that
     132             :     // situation the caller is default-constructing us and we'll
     133             :     // just assume they know what they're doing.
     134           0 :     return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
     135           0 :                              "'reason' member of PresentationConnectionCloseEventInit");
     136             :   }
     137           0 :   return true;
     138             : }
     139             : 
     140             : bool
     141           0 : PresentationConnectionCloseEventInit::Init(const nsAString& aJSON)
     142             : {
     143           0 :   AutoJSAPI jsapi;
     144           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     145           0 :   if (!cleanGlobal) {
     146           0 :     return false;
     147             :   }
     148           0 :   if (!jsapi.Init(cleanGlobal)) {
     149           0 :     return false;
     150             :   }
     151           0 :   JSContext* cx = jsapi.cx();
     152           0 :   JS::Rooted<JS::Value> json(cx);
     153           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     154           0 :   NS_ENSURE_TRUE(ok, false);
     155           0 :   return Init(cx, json);
     156             : }
     157             : 
     158             : bool
     159           0 : PresentationConnectionCloseEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     160             : {
     161           0 :   PresentationConnectionCloseEventInitAtoms* atomsCache = GetAtomCache<PresentationConnectionCloseEventInitAtoms>(cx);
     162           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     163           0 :     return false;
     164             :   }
     165             : 
     166             :   // Per spec, we define the parent's members first
     167           0 :   if (!EventInit::ToObjectInternal(cx, rval)) {
     168           0 :     return false;
     169             :   }
     170           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     171             : 
     172             :   do {
     173             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     174           0 :     JS::Rooted<JS::Value> temp(cx);
     175           0 :     nsString const & currentValue = mMessage;
     176           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     177           0 :       return false;
     178             :     }
     179           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->message_id, temp, JSPROP_ENUMERATE)) {
     180           0 :       return false;
     181             :     }
     182           0 :     break;
     183             :   } while(0);
     184             : 
     185             :   do {
     186             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     187           0 :     JS::Rooted<JS::Value> temp(cx);
     188           0 :     PresentationConnectionClosedReason const & currentValue = mReason;
     189           0 :     if (!ToJSValue(cx, currentValue, &temp)) {
     190           0 :       return false;
     191             :     }
     192           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->reason_id, temp, JSPROP_ENUMERATE)) {
     193           0 :       return false;
     194             :     }
     195           0 :     break;
     196             :   } while(0);
     197             : 
     198           0 :   return true;
     199             : }
     200             : 
     201             : bool
     202           0 : PresentationConnectionCloseEventInit::ToJSON(nsAString& aJSON) const
     203             : {
     204           0 :   AutoJSAPI jsapi;
     205           0 :   jsapi.Init();
     206           0 :   JSContext *cx = jsapi.cx();
     207             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     208             :   // because we'll only be creating objects, in ways that have no
     209             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     210             :   // which likewise guarantees no side-effects for the sorts of
     211             :   // things we will pass it.
     212           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     213           0 :   JS::Rooted<JS::Value> val(cx);
     214           0 :   if (!ToObjectInternal(cx, &val)) {
     215           0 :     return false;
     216             :   }
     217           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     218           0 :   return StringifyToJSON(cx, obj, aJSON);
     219             : }
     220             : 
     221             : void
     222           0 : PresentationConnectionCloseEventInit::TraceDictionary(JSTracer* trc)
     223             : {
     224           0 :   EventInit::TraceDictionary(trc);
     225           0 : }
     226             : 
     227             : PresentationConnectionCloseEventInit&
     228           0 : PresentationConnectionCloseEventInit::operator=(const PresentationConnectionCloseEventInit& aOther)
     229             : {
     230           0 :   EventInit::operator=(aOther);
     231           0 :   mMessage = aOther.mMessage;
     232           0 :   mReason = aOther.mReason;
     233           0 :   return *this;
     234             : }
     235             : 
     236             : namespace binding_detail {
     237             : } // namespace binding_detail
     238             : 
     239             : 
     240             : namespace PresentationConnectionCloseEventBinding {
     241             : 
     242             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventBinding::NativeType>::value,
     243             :               "Can't inherit from an interface with a different ownership model.");
     244             : 
     245             : static bool
     246           0 : get_reason(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnectionCloseEvent* self, JSJitGetterCallArgs args)
     247             : {
     248           0 :   PresentationConnectionClosedReason result(self->Reason());
     249           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     250           0 :   if (!ToJSValue(cx, result, args.rval())) {
     251           0 :     return false;
     252             :   }
     253           0 :   return true;
     254             : }
     255             : 
     256             : static const JSJitInfo reason_getterinfo = {
     257             :   { (JSJitGetterOp)get_reason },
     258             :   { prototypes::id::PresentationConnectionCloseEvent },
     259             :   { PrototypeTraits<prototypes::id::PresentationConnectionCloseEvent>::Depth },
     260             :   JSJitInfo::Getter,
     261             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     262             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     263             :   false,  /* isInfallible. False in setters. */
     264             :   false,  /* isMovable.  Not relevant for setters. */
     265             :   false, /* isEliminatable.  Not relevant for setters. */
     266             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     267             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     268             :   false,  /* isTypedMethod.  Only relevant for methods. */
     269             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     270             : };
     271             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     272             : static_assert(0 < 1, "There is no slot for us");
     273             : 
     274             : static bool
     275           0 : get_message(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnectionCloseEvent* self, JSJitGetterCallArgs args)
     276             : {
     277           0 :   DOMString result;
     278           0 :   self->GetMessage(result);
     279           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     280           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     281           0 :     return false;
     282             :   }
     283           0 :   return true;
     284             : }
     285             : 
     286             : static const JSJitInfo message_getterinfo = {
     287             :   { (JSJitGetterOp)get_message },
     288             :   { prototypes::id::PresentationConnectionCloseEvent },
     289             :   { PrototypeTraits<prototypes::id::PresentationConnectionCloseEvent>::Depth },
     290             :   JSJitInfo::Getter,
     291             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     292             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     293             :   false,  /* isInfallible. False in setters. */
     294             :   false,  /* isMovable.  Not relevant for setters. */
     295             :   false, /* isEliminatable.  Not relevant for setters. */
     296             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     297             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     298             :   false,  /* isTypedMethod.  Only relevant for methods. */
     299             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     300             : };
     301             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     302             : static_assert(0 < 1, "There is no slot for us");
     303             : 
     304             : static bool
     305           0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnectionCloseEvent* self, JSJitGetterCallArgs args)
     306             : {
     307           0 :   bool result(self->IsTrusted());
     308           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     309           0 :   args.rval().setBoolean(result);
     310           0 :   return true;
     311             : }
     312             : 
     313             : static const JSJitInfo isTrusted_getterinfo = {
     314             :   { (JSJitGetterOp)get_isTrusted },
     315             :   { prototypes::id::PresentationConnectionCloseEvent },
     316             :   { PrototypeTraits<prototypes::id::PresentationConnectionCloseEvent>::Depth },
     317             :   JSJitInfo::Getter,
     318             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     319             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     320             :   true,  /* isInfallible. False in setters. */
     321             :   true,  /* isMovable.  Not relevant for setters. */
     322             :   true, /* isEliminatable.  Not relevant for setters. */
     323             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     324             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     325             :   false,  /* isTypedMethod.  Only relevant for methods. */
     326             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     327             : };
     328             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     329             : static_assert(0 < 1, "There is no slot for us");
     330             : 
     331             : static bool
     332           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     333             : {
     334           0 :   mozilla::dom::PresentationConnectionCloseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnectionCloseEvent>(obj);
     335             :   // We don't want to preserve if we don't have a wrapper, and we
     336             :   // obviously can't preserve if we're not initialized.
     337           0 :   if (self && self->GetWrapperPreserveColor()) {
     338           0 :     PreserveWrapper(self);
     339             :   }
     340           0 :   return true;
     341             : }
     342             : 
     343             : static void
     344           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     345             : {
     346           0 :   mozilla::dom::PresentationConnectionCloseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnectionCloseEvent>(obj);
     347           0 :   if (self) {
     348           0 :     ClearWrapper(self, self, obj);
     349           0 :     AddForDeferredFinalization<mozilla::dom::PresentationConnectionCloseEvent>(self);
     350             :   }
     351           0 : }
     352             : 
     353             : static void
     354           0 : _objectMoved(JSObject* obj, const JSObject* old)
     355             : {
     356           0 :   mozilla::dom::PresentationConnectionCloseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnectionCloseEvent>(obj);
     357           0 :   if (self) {
     358           0 :     UpdateWrapper(self, self, obj, old);
     359             :   }
     360           0 : }
     361             : 
     362             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     363             : #if defined(__clang__)
     364             : #pragma clang diagnostic push
     365             : #pragma clang diagnostic ignored "-Wmissing-braces"
     366             : #endif
     367             : static const JSPropertySpec sAttributes_specs[] = {
     368             :   { "reason", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &reason_getterinfo, nullptr, nullptr },
     369             :   { "message", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &message_getterinfo, nullptr, nullptr },
     370             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     371             : };
     372             : #if defined(__clang__)
     373             : #pragma clang diagnostic pop
     374             : #endif
     375             : 
     376             : 
     377             : // Can't be const because the pref-enabled boolean needs to be writable
     378             : static Prefable<const JSPropertySpec> sAttributes[] = {
     379             :   { nullptr, &sAttributes_specs[0] },
     380             :   { nullptr, nullptr }
     381             : };
     382             : 
     383             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     384             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     385             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     386             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     387             : 
     388             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     389             : #if defined(__clang__)
     390             : #pragma clang diagnostic push
     391             : #pragma clang diagnostic ignored "-Wmissing-braces"
     392             : #endif
     393             : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
     394             :   { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
     395             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     396             : };
     397             : #if defined(__clang__)
     398             : #pragma clang diagnostic pop
     399             : #endif
     400             : 
     401             : 
     402             : // Can't be const because the pref-enabled boolean needs to be writable
     403             : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
     404             :   { nullptr, &sUnforgeableAttributes_specs[0] },
     405             :   { nullptr, nullptr }
     406             : };
     407             : 
     408             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     409             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     410             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     411             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     412             : 
     413             : 
     414             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
     415             : static PropertyInfo sNativeProperties_propertyInfos[3];
     416             : 
     417             : static const NativePropertiesN<2> sNativeProperties = {
     418             :   false, 0,
     419             :   false, 0,
     420             :   false, 0,
     421             :   true,  0 /* sAttributes */,
     422             :   false, 0,
     423             :   true,  1 /* sUnforgeableAttributes */,
     424             :   false, 0,
     425             :   -1,
     426             :   3,
     427             :   sNativeProperties_sortedPropertyIndices,
     428             :   {
     429             :     { sAttributes, &sNativeProperties_propertyInfos[0] },
     430             :     { sUnforgeableAttributes, &sNativeProperties_propertyInfos[2] }
     431             :   }
     432             : };
     433             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     434             :     "We have a property info count that is oversized");
     435             : 
     436             : static bool
     437           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     438             : {
     439           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     440           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     441           0 :   if (!args.isConstructing()) {
     442             :     // XXXbz wish I could get the name from the callee instead of
     443             :     // Adding more relocations
     444           0 :     return ThrowConstructorWithoutNew(cx, "PresentationConnectionCloseEvent");
     445             :   }
     446             : 
     447           0 :   GlobalObject global(cx, obj);
     448           0 :   if (global.Failed()) {
     449           0 :     return false;
     450             :   }
     451             : 
     452           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     453           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     454           0 :     return false;
     455             :   }
     456             : 
     457           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     458           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PresentationConnectionCloseEvent");
     459             :   }
     460           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     461           0 :   binding_detail::FakeString arg0;
     462           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     463           0 :     return false;
     464             :   }
     465           0 :   binding_detail::FastPresentationConnectionCloseEventInit arg1;
     466           0 :   if (!arg1.Init(cx, args[1],  "Argument 2 of PresentationConnectionCloseEvent.constructor", false)) {
     467           0 :     return false;
     468             :   }
     469           0 :   Maybe<JSAutoCompartment> ac;
     470           0 :   if (objIsXray) {
     471           0 :     obj = js::CheckedUnwrap(obj);
     472           0 :     if (!obj) {
     473           0 :       return false;
     474             :     }
     475           0 :     ac.emplace(cx, obj);
     476           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     477           0 :       return false;
     478             :     }
     479             :   }
     480           0 :   binding_detail::FastErrorResult rv;
     481           0 :   auto result(StrongOrRawPtr<mozilla::dom::PresentationConnectionCloseEvent>(mozilla::dom::PresentationConnectionCloseEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
     482           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     483           0 :     return false;
     484             :   }
     485           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     486             :   static_assert(!IsPointer<decltype(result)>::value,
     487             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     488           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     489           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     490           0 :     return false;
     491             :   }
     492           0 :   return true;
     493             : }
     494             : 
     495             : static const js::ClassOps sInterfaceObjectClassOps = {
     496             :     nullptr,               /* addProperty */
     497             :     nullptr,               /* delProperty */
     498             :     nullptr,               /* getProperty */
     499             :     nullptr,               /* setProperty */
     500             :     nullptr,               /* enumerate */
     501             :     nullptr,               /* newEnumerate */
     502             :     nullptr,               /* resolve */
     503             :     nullptr,               /* mayResolve */
     504             :     nullptr,               /* finalize */
     505             :     _constructor, /* call */
     506             :     nullptr,               /* hasInstance */
     507             :     _constructor, /* construct */
     508             :     nullptr,               /* trace */
     509             : };
     510             : 
     511             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     512             :   {
     513             :     "Function",
     514             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     515             :     &sInterfaceObjectClassOps,
     516             :     JS_NULL_CLASS_SPEC,
     517             :     JS_NULL_CLASS_EXT,
     518             :     &sInterfaceObjectClassObjectOps
     519             :   },
     520             :   eInterface,
     521             :   true,
     522             :   prototypes::id::PresentationConnectionCloseEvent,
     523             :   PrototypeTraits<prototypes::id::PresentationConnectionCloseEvent>::Depth,
     524             :   sNativePropertyHooks,
     525             :   "function PresentationConnectionCloseEvent() {\n    [native code]\n}",
     526             :   EventBinding::GetConstructorObject
     527             : };
     528             : 
     529             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     530             :   {
     531             :     "PresentationConnectionCloseEventPrototype",
     532             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
     533             :     JS_NULL_CLASS_OPS,
     534             :     JS_NULL_CLASS_SPEC,
     535             :     JS_NULL_CLASS_EXT,
     536             :     JS_NULL_OBJECT_OPS
     537             :   },
     538             :   eInterfacePrototype,
     539             :   false,
     540             :   prototypes::id::PresentationConnectionCloseEvent,
     541             :   PrototypeTraits<prototypes::id::PresentationConnectionCloseEvent>::Depth,
     542             :   sNativePropertyHooks,
     543             :   "[object PresentationConnectionCloseEventPrototype]",
     544             :   EventBinding::GetProtoObject
     545             : };
     546             : 
     547             : bool
     548           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     549             : {
     550             :   static bool sPrefValue;
     551             :   static bool sPrefCacheSetUp = false;
     552           0 :   if (!sPrefCacheSetUp) {
     553           0 :     sPrefCacheSetUp = true;
     554           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.presentation.enabled");
     555             :   }
     556             : 
     557           0 :   return sPrefValue;
     558             : }
     559             : 
     560             : JSObject*
     561           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     562             : {
     563           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     564             : }
     565             : 
     566             : static const js::ClassOps sClassOps = {
     567             :   _addProperty, /* addProperty */
     568             :   nullptr,               /* delProperty */
     569             :   nullptr,               /* getProperty */
     570             :   nullptr,               /* setProperty */
     571             :   nullptr,               /* enumerate */
     572             :   nullptr, /* newEnumerate */
     573             :   nullptr, /* resolve */
     574             :   nullptr, /* mayResolve */
     575             :   _finalize, /* finalize */
     576             :   nullptr, /* call */
     577             :   nullptr,               /* hasInstance */
     578             :   nullptr,               /* construct */
     579             :   nullptr, /* trace */
     580             : };
     581             : 
     582             : static const js::ClassExtension sClassExtension = {
     583             :   nullptr, /* weakmapKeyDelegateOp */
     584             :   _objectMoved /* objectMovedOp */
     585             : };
     586             : 
     587             : static const DOMJSClass sClass = {
     588             :   { "PresentationConnectionCloseEvent",
     589             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
     590             :     &sClassOps,
     591             :     JS_NULL_CLASS_SPEC,
     592             :     &sClassExtension,
     593             :     JS_NULL_OBJECT_OPS
     594             :   },
     595             :   { prototypes::id::Event, prototypes::id::PresentationConnectionCloseEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     596             :   IsBaseOf<nsISupports, mozilla::dom::PresentationConnectionCloseEvent >::value,
     597             :   sNativePropertyHooks,
     598             :   FindAssociatedGlobalForNative<mozilla::dom::PresentationConnectionCloseEvent>::Get,
     599             :   GetProtoObjectHandle,
     600             :   GetCCParticipant<mozilla::dom::PresentationConnectionCloseEvent>::Get()
     601             : };
     602             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     603             :               "Must have the right minimal number of reserved slots.");
     604             : static_assert(1 >= 1,
     605             :               "Must have enough reserved slots.");
     606             : 
     607             : const JSClass*
     608           0 : GetJSClass()
     609             : {
     610           0 :   return sClass.ToJSClass();
     611             : }
     612             : 
     613             : bool
     614           0 : Wrap(JSContext* aCx, mozilla::dom::PresentationConnectionCloseEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     615             : {
     616             :   MOZ_ASSERT(static_cast<mozilla::dom::PresentationConnectionCloseEvent*>(aObject) ==
     617             :              reinterpret_cast<mozilla::dom::PresentationConnectionCloseEvent*>(aObject),
     618             :              "Multiple inheritance for mozilla::dom::PresentationConnectionCloseEvent is broken.");
     619             :   MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
     620             :              reinterpret_cast<mozilla::dom::Event*>(aObject),
     621             :              "Multiple inheritance for mozilla::dom::Event is broken.");
     622           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     623           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     624           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     625             :              "You should probably not be using Wrap() directly; use "
     626             :              "GetOrCreateDOMReflector instead");
     627             : 
     628           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     629             :              "nsISupports must be on our primary inheritance chain");
     630             : 
     631           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     632           0 :   if (!global) {
     633           0 :     return false;
     634             :   }
     635           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     636           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     637             : 
     638             :   // That might have ended up wrapping us already, due to the wonders
     639             :   // of XBL.  Check for that, and bail out as needed.
     640           0 :   aReflector.set(aCache->GetWrapper());
     641           0 :   if (aReflector) {
     642             : #ifdef DEBUG
     643           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     644             : #endif // DEBUG
     645           0 :     return true;
     646             :   }
     647             : 
     648           0 :   JSAutoCompartment ac(aCx, global);
     649           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     650           0 :   if (!canonicalProto) {
     651           0 :     return false;
     652             :   }
     653           0 :   JS::Rooted<JSObject*> proto(aCx);
     654           0 :   if (aGivenProto) {
     655           0 :     proto = aGivenProto;
     656             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     657             :     // coming in, we changed compartments to that of "parent" so may need
     658             :     // to wrap the proto here.
     659           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     660           0 :       if (!JS_WrapObject(aCx, &proto)) {
     661           0 :         return false;
     662             :       }
     663             :     }
     664             :   } else {
     665           0 :     proto = canonicalProto;
     666             :   }
     667             : 
     668           0 :   BindingJSObjectCreator<mozilla::dom::PresentationConnectionCloseEvent> creator(aCx);
     669           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     670           0 :   if (!aReflector) {
     671           0 :     return false;
     672             :   }
     673             : 
     674           0 :   aCache->SetWrapper(aReflector);
     675             : 
     676             :   // Important: do unforgeable property setup after we have handed
     677             :   // over ownership of the C++ object to obj as needed, so that if
     678             :   // we fail and it ends up GCed it won't have problems in the
     679             :   // finalizer trying to drop its ownership of the C++ object.
     680             :   JS::Rooted<JSObject*> unforgeableHolder(aCx,
     681           0 :     &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
     682           0 :   if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
     683           0 :     aCache->ReleaseWrapper(aObject);
     684           0 :     aCache->ClearWrapper();
     685           0 :     return false;
     686             :   }
     687           0 :   creator.InitializationSucceeded();
     688             : 
     689           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     690             :              aCache->GetWrapperPreserveColor() == aReflector);
     691             :   // If proto != canonicalProto, we have to preserve our wrapper;
     692             :   // otherwise we won't be able to properly recreate it later, since
     693             :   // we won't know what proto to use.  Note that we don't check
     694             :   // aGivenProto here, since it's entirely possible (and even
     695             :   // somewhat common) to have a non-null aGivenProto which is the
     696             :   // same as canonicalProto.
     697           0 :   if (proto != canonicalProto) {
     698           0 :     PreserveWrapper(aObject);
     699             :   }
     700             : 
     701           0 :   return true;
     702             : }
     703             : 
     704             : const NativePropertyHooks sNativePropertyHooks[] = { {
     705             :   nullptr,
     706             :   nullptr,
     707             :   nullptr,
     708             :   { sNativeProperties.Upcast(), nullptr },
     709             :   prototypes::id::PresentationConnectionCloseEvent,
     710             :   constructors::id::PresentationConnectionCloseEvent,
     711             :   EventBinding::sNativePropertyHooks,
     712             :   &DefaultXrayExpandoObjectClass
     713             : } };
     714             : 
     715             : void
     716           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     717             : {
     718           0 :   JS::Handle<JSObject*> parentProto(EventBinding::GetProtoObjectHandle(aCx));
     719           0 :   if (!parentProto) {
     720           0 :     return;
     721             :   }
     722             : 
     723           0 :   JS::Handle<JSObject*> constructorProto(EventBinding::GetConstructorObjectHandle(aCx));
     724           0 :   if (!constructorProto) {
     725           0 :     return;
     726             :   }
     727             : 
     728             :   static bool sIdsInited = false;
     729           0 :   if (!sIdsInited && NS_IsMainThread()) {
     730           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     731           0 :       return;
     732             :     }
     733           0 :     sIdsInited = true;
     734             :   }
     735             : 
     736           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PresentationConnectionCloseEvent);
     737           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PresentationConnectionCloseEvent);
     738           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     739             :                               &sPrototypeClass.mBase, protoCache,
     740             :                               constructorProto, &sInterfaceObjectClass.mBase, 2, nullptr,
     741             :                               interfaceCache,
     742             :                               sNativeProperties.Upcast(),
     743             :                               nullptr,
     744             :                               "PresentationConnectionCloseEvent", aDefineOnGlobal,
     745             :                               nullptr,
     746           0 :                               false);
     747             : 
     748           0 :   JS::Rooted<JSObject*> unforgeableHolder(aCx);
     749             :   {
     750           0 :     JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
     751           0 :     unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
     752           0 :     if (!unforgeableHolder) {
     753           0 :       *protoCache = nullptr;
     754           0 :       if (interfaceCache) {
     755           0 :         *interfaceCache = nullptr;
     756             :       }
     757           0 :       return;
     758             :     }
     759             :   }
     760             : 
     761           0 :   if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
     762           0 :     *protoCache = nullptr;
     763           0 :     if (interfaceCache) {
     764           0 :       *interfaceCache = nullptr;
     765             :     }
     766           0 :     return;
     767             :   }
     768             : 
     769           0 :   if (*protoCache) {
     770           0 :     js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
     771           0 :                         JS::ObjectValue(*unforgeableHolder));
     772             :   }
     773             : }
     774             : 
     775             : JS::Handle<JSObject*>
     776           0 : GetProtoObjectHandle(JSContext* aCx)
     777             : {
     778             :   /* Get the interface prototype object for this class.  This will create the
     779             :      object as needed. */
     780           0 :   bool aDefineOnGlobal = true;
     781             : 
     782             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     783           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     784           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     785           0 :     return nullptr;
     786             :   }
     787             : 
     788             :   /* Check to see whether the interface objects are already installed */
     789           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     790           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PresentationConnectionCloseEvent)) {
     791           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     792           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     793             :   }
     794             : 
     795             :   /*
     796             :    * The object might _still_ be null, but that's OK.
     797             :    *
     798             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     799             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     800             :    * changed after they have been set.
     801             :    *
     802             :    * Calling address() avoids the read read barrier that does gray
     803             :    * unmarking, but it's not possible for the object to be gray here.
     804             :    */
     805             : 
     806           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PresentationConnectionCloseEvent);
     807           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     808           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     809             : }
     810             : 
     811             : JS::Handle<JSObject*>
     812           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     813             : {
     814             :   /* Get the interface object for this class.  This will create the object as
     815             :      needed. */
     816             : 
     817             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     818           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     819           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     820           0 :     return nullptr;
     821             :   }
     822             : 
     823             :   /* Check to see whether the interface objects are already installed */
     824           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     825           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::PresentationConnectionCloseEvent)) {
     826           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     827           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     828             :   }
     829             : 
     830             :   /*
     831             :    * The object might _still_ be null, but that's OK.
     832             :    *
     833             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     834             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     835             :    * changed after they have been set.
     836             :    *
     837             :    * Calling address() avoids the read read barrier that does gray
     838             :    * unmarking, but it's not possible for the object to be gray here.
     839             :    */
     840             : 
     841           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::PresentationConnectionCloseEvent);
     842           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     843           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     844             : }
     845             : 
     846             : JSObject*
     847           0 : GetConstructorObject(JSContext* aCx)
     848             : {
     849           0 :   return GetConstructorObjectHandle(aCx);
     850             : }
     851             : 
     852             : } // namespace PresentationConnectionCloseEventBinding
     853             : 
     854             : 
     855             : 
     856             : } // namespace dom
     857             : } // namespace mozilla

Generated by: LCOV version 1.13