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

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

Generated by: LCOV version 1.13