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

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

Generated by: LCOV version 1.13