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

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

Generated by: LCOV version 1.13