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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM HTMLAudioElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "HTMLAudioElementBinding.h"
       4             : #include "HTMLMediaElementBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/HTMLAudioElement.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/XrayExpandoClass.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace dom {
      15             : 
      16             : namespace HTMLAudioElementBinding {
      17             : 
      18             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLMediaElementBinding::NativeType>::value,
      19             :               "Can't inherit from an interface with a different ownership model.");
      20             : 
      21             : static bool
      22           0 : _Audio(JSContext* cx, unsigned argc, JS::Value* vp)
      23             : {
      24           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
      25           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
      26           0 :   if (!args.isConstructing()) {
      27             :     // XXXbz wish I could get the name from the callee instead of
      28             :     // Adding more relocations
      29           0 :     return ThrowConstructorWithoutNew(cx, "Audio");
      30             :   }
      31             : 
      32           0 :   GlobalObject global(cx, obj);
      33           0 :   if (global.Failed()) {
      34           0 :     return false;
      35             :   }
      36             : 
      37           0 :   JS::Rooted<JSObject*> desiredProto(cx);
      38           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
      39           0 :     return false;
      40             :   }
      41             : 
      42           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
      43           0 :   Optional<nsAString> arg0;
      44           0 :   binding_detail::FakeString arg0_holder;
      45           0 :   if (args.hasDefined(0)) {
      46           0 :     if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0_holder)) {
      47           0 :       return false;
      48             :     }
      49           0 :     arg0 = &arg0_holder;
      50             :   }
      51           0 :   Maybe<JSAutoCompartment> ac;
      52           0 :   if (objIsXray) {
      53           0 :     obj = js::CheckedUnwrap(obj);
      54           0 :     if (!obj) {
      55           0 :       return false;
      56             :     }
      57           0 :     ac.emplace(cx, obj);
      58           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
      59           0 :       return false;
      60             :     }
      61             :   }
      62           0 :   binding_detail::FastErrorResult rv;
      63           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLAudioElement>(mozilla::dom::HTMLAudioElement::Audio(global, NonNullHelper(Constify(arg0)), rv)));
      64           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      65           0 :     return false;
      66             :   }
      67           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      68             :   static_assert(!IsPointer<decltype(result)>::value,
      69             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
      70           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
      71           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      72           0 :     return false;
      73             :   }
      74           0 :   return true;
      75             : }
      76             : 
      77             : static bool
      78           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      79             : {
      80           0 :   mozilla::dom::HTMLAudioElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLAudioElement>(obj);
      81             :   // We don't want to preserve if we don't have a wrapper, and we
      82             :   // obviously can't preserve if we're not initialized.
      83           0 :   if (self && self->GetWrapperPreserveColor()) {
      84           0 :     PreserveWrapper(self);
      85             :   }
      86           0 :   return true;
      87             : }
      88             : 
      89             : static void
      90           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      91             : {
      92           0 :   mozilla::dom::HTMLAudioElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLAudioElement>(obj);
      93           0 :   if (self) {
      94           0 :     ClearWrapper(self, self, obj);
      95           0 :     AddForDeferredFinalization<mozilla::dom::HTMLAudioElement>(self);
      96             :   }
      97           0 : }
      98             : 
      99             : static void
     100           0 : _objectMoved(JSObject* obj, const JSObject* old)
     101             : {
     102           0 :   mozilla::dom::HTMLAudioElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLAudioElement>(obj);
     103           0 :   if (self) {
     104           0 :     UpdateWrapper(self, self, obj, old);
     105             :   }
     106           0 : }
     107             : 
     108             : static bool
     109           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     110             : {
     111           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     112           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     113           0 :   if (!args.isConstructing()) {
     114             :     // XXXbz wish I could get the name from the callee instead of
     115             :     // Adding more relocations
     116           0 :     return ThrowConstructorWithoutNew(cx, "HTMLAudioElement");
     117             :   }
     118             : 
     119           0 :   GlobalObject global(cx, obj);
     120           0 :   if (global.Failed()) {
     121           0 :     return false;
     122             :   }
     123             : 
     124             :   // The newTarget might be a cross-compartment wrapper. Get the underlying object
     125             :   // so we can do the spec's object-identity checks.
     126           0 :   JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
     127           0 :   if (!newTarget) {
     128           0 :     return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     129             :   }
     130             : 
     131             :   // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     132             :   // Enter the compartment of our underlying newTarget object, so we end
     133             :   // up comparing to the constructor object for our interface from that global.
     134             :   {
     135           0 :     JSAutoCompartment ac(cx, newTarget);
     136           0 :     JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
     137           0 :     if (!constructor) {
     138           0 :       return false;
     139             :     }
     140           0 :     if (newTarget == constructor) {
     141           0 :       return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     142             :     }
     143             :   }
     144             : 
     145           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     146           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     147           0 :     return false;
     148             :   }
     149           0 :   if (!desiredProto) {
     150             :     // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     151             :     // This fallback behavior is designed to match analogous behavior for the
     152             :     // JavaScript built-ins. So we enter the compartment of our underlying
     153             :     // newTarget object and fall back to the prototype object from that global.
     154             :     // XXX The spec says to use GetFunctionRealm(), which is not actually
     155             :     // the same thing as what we have here (e.g. in the case of scripted callable proxies
     156             :     // whose target is not same-compartment with the proxy, or bound functions, etc).
     157             :     // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
     158             :     {
     159           0 :       JSAutoCompartment ac(cx, newTarget);
     160           0 :       desiredProto = GetProtoObjectHandle(cx);
     161           0 :       if (!desiredProto) {
     162           0 :           return false;
     163             :       }
     164             :     }
     165             : 
     166             :     // desiredProto is in the compartment of the underlying newTarget object.
     167             :     // Wrap it into the context compartment.
     168           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     169           0 :       return false;
     170             :     }
     171             :   }
     172             : 
     173           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     174           0 :   Maybe<JSAutoCompartment> ac;
     175           0 :   if (objIsXray) {
     176           0 :     obj = js::CheckedUnwrap(obj);
     177           0 :     if (!obj) {
     178           0 :       return false;
     179             :     }
     180           0 :     ac.emplace(cx, obj);
     181           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     182           0 :       return false;
     183             :     }
     184             :   }
     185           0 :   binding_detail::FastErrorResult rv;
     186           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLAudioElement>(CreateHTMLElement(global, args, rv)));
     187           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     188           0 :     return false;
     189             :   }
     190           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     191             :   static_assert(!IsPointer<decltype(result)>::value,
     192             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     193           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     194           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     195           0 :     return false;
     196             :   }
     197           0 :   return true;
     198             : }
     199             : 
     200             : static const js::ClassOps sInterfaceObjectClassOps = {
     201             :     nullptr,               /* addProperty */
     202             :     nullptr,               /* delProperty */
     203             :     nullptr,               /* getProperty */
     204             :     nullptr,               /* setProperty */
     205             :     nullptr,               /* enumerate */
     206             :     nullptr,               /* newEnumerate */
     207             :     nullptr,               /* resolve */
     208             :     nullptr,               /* mayResolve */
     209             :     nullptr,               /* finalize */
     210             :     _constructor, /* call */
     211             :     nullptr,               /* hasInstance */
     212             :     _constructor, /* construct */
     213             :     nullptr,               /* trace */
     214             : };
     215             : 
     216             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     217             :   {
     218             :     "Function",
     219             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE + 1 /* slots for the named constructors */),
     220             :     &sInterfaceObjectClassOps,
     221             :     JS_NULL_CLASS_SPEC,
     222             :     JS_NULL_CLASS_EXT,
     223             :     &sInterfaceObjectClassObjectOps
     224             :   },
     225             :   eInterface,
     226             :   true,
     227             :   prototypes::id::HTMLAudioElement,
     228             :   PrototypeTraits<prototypes::id::HTMLAudioElement>::Depth,
     229             :   sNativePropertyHooks,
     230             :   "function HTMLAudioElement() {\n    [native code]\n}",
     231             :   HTMLMediaElementBinding::GetConstructorObject
     232             : };
     233             : 
     234             : const NativePropertyHooks sNamedConstructorNativePropertyHooks = {
     235             :     nullptr,
     236             :     nullptr,
     237             :     nullptr,
     238             :     { nullptr, nullptr },
     239             :     prototypes::id::HTMLAudioElement,
     240             :     constructors::id::HTMLAudioElement,
     241             :     nullptr
     242             : };
     243             : 
     244             : static const NamedConstructor namedConstructors[] = {
     245             :   { "Audio", { _Audio, &sNamedConstructorNativePropertyHooks }, 0 },
     246             :   { nullptr, { nullptr, nullptr }, 0 }
     247             : };
     248             : 
     249             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     250             :   {
     251             :     "HTMLAudioElementPrototype",
     252             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     253             :     JS_NULL_CLASS_OPS,
     254             :     JS_NULL_CLASS_SPEC,
     255             :     JS_NULL_CLASS_EXT,
     256             :     JS_NULL_OBJECT_OPS
     257             :   },
     258             :   eInterfacePrototype,
     259             :   false,
     260             :   prototypes::id::HTMLAudioElement,
     261             :   PrototypeTraits<prototypes::id::HTMLAudioElement>::Depth,
     262             :   sNativePropertyHooks,
     263             :   "[object HTMLAudioElementPrototype]",
     264             :   HTMLMediaElementBinding::GetProtoObject
     265             : };
     266             : 
     267             : JSObject*
     268           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     269             : {
     270           0 :   JSObject* interfaceObject = GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     271           0 :   if (!interfaceObject) {
     272           0 :     return nullptr;
     273             :   }
     274           0 :   for (unsigned slot = DOM_INTERFACE_SLOTS_BASE; slot < JSCLASS_RESERVED_SLOTS(&sInterfaceObjectClass.mBase); ++slot) {
     275           0 :     JSObject* constructor = &js::GetReservedSlot(interfaceObject, slot).toObject();
     276           0 :     if (JS_GetFunctionId(JS_GetObjectFunction(constructor)) == JSID_TO_STRING(id)) {
     277           0 :       return constructor;
     278             :     }
     279             :   }
     280           0 :   return interfaceObject;
     281             : }
     282             : 
     283             : static const js::ClassOps sClassOps = {
     284             :   _addProperty, /* addProperty */
     285             :   nullptr,               /* delProperty */
     286             :   nullptr,               /* getProperty */
     287             :   nullptr,               /* setProperty */
     288             :   nullptr,               /* enumerate */
     289             :   nullptr, /* newEnumerate */
     290             :   nullptr, /* resolve */
     291             :   nullptr, /* mayResolve */
     292             :   _finalize, /* finalize */
     293             :   nullptr, /* call */
     294             :   nullptr,               /* hasInstance */
     295             :   nullptr,               /* construct */
     296             :   nullptr, /* trace */
     297             : };
     298             : 
     299             : static const js::ClassExtension sClassExtension = {
     300             :   nullptr, /* weakmapKeyDelegateOp */
     301             :   _objectMoved /* objectMovedOp */
     302             : };
     303             : 
     304             : static const DOMJSClass sClass = {
     305             :   { "HTMLAudioElement",
     306             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     307             :     &sClassOps,
     308             :     JS_NULL_CLASS_SPEC,
     309             :     &sClassExtension,
     310             :     JS_NULL_OBJECT_OPS
     311             :   },
     312             :   { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLMediaElement, prototypes::id::HTMLAudioElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     313             :   IsBaseOf<nsISupports, mozilla::dom::HTMLAudioElement >::value,
     314             :   sNativePropertyHooks,
     315             :   FindAssociatedGlobalForNative<mozilla::dom::HTMLAudioElement>::Get,
     316             :   GetProtoObjectHandle,
     317             :   GetCCParticipant<mozilla::dom::HTMLAudioElement>::Get()
     318             : };
     319             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     320             :               "Must have the right minimal number of reserved slots.");
     321             : static_assert(1 >= 1,
     322             :               "Must have enough reserved slots.");
     323             : 
     324             : const JSClass*
     325           0 : GetJSClass()
     326             : {
     327           0 :   return sClass.ToJSClass();
     328             : }
     329             : 
     330             : bool
     331           0 : Wrap(JSContext* aCx, mozilla::dom::HTMLAudioElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     332             : {
     333             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLAudioElement*>(aObject) ==
     334             :              reinterpret_cast<mozilla::dom::HTMLAudioElement*>(aObject),
     335             :              "Multiple inheritance for mozilla::dom::HTMLAudioElement is broken.");
     336             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLMediaElement*>(aObject) ==
     337             :              reinterpret_cast<mozilla::dom::HTMLMediaElement*>(aObject),
     338             :              "Multiple inheritance for mozilla::dom::HTMLMediaElement is broken.");
     339             :   MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
     340             :              reinterpret_cast<nsGenericHTMLElement*>(aObject),
     341             :              "Multiple inheritance for nsGenericHTMLElement is broken.");
     342             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     343             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     344             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     345             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     346             :              reinterpret_cast<nsINode*>(aObject),
     347             :              "Multiple inheritance for nsINode is broken.");
     348             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     349             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     350             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     351           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     352           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     353           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     354             :              "You should probably not be using Wrap() directly; use "
     355             :              "GetOrCreateDOMReflector instead");
     356             : 
     357           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     358             :              "nsISupports must be on our primary inheritance chain");
     359             : 
     360           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     361           0 :   if (!global) {
     362           0 :     return false;
     363             :   }
     364           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     365           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     366             : 
     367             :   // That might have ended up wrapping us already, due to the wonders
     368             :   // of XBL.  Check for that, and bail out as needed.
     369           0 :   aReflector.set(aCache->GetWrapper());
     370           0 :   if (aReflector) {
     371             : #ifdef DEBUG
     372           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     373             : #endif // DEBUG
     374           0 :     return true;
     375             :   }
     376             : 
     377           0 :   JSAutoCompartment ac(aCx, global);
     378           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     379           0 :   if (!canonicalProto) {
     380           0 :     return false;
     381             :   }
     382           0 :   JS::Rooted<JSObject*> proto(aCx);
     383           0 :   if (aGivenProto) {
     384           0 :     proto = aGivenProto;
     385             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     386             :     // coming in, we changed compartments to that of "parent" so may need
     387             :     // to wrap the proto here.
     388           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     389           0 :       if (!JS_WrapObject(aCx, &proto)) {
     390           0 :         return false;
     391             :       }
     392             :     }
     393             :   } else {
     394           0 :     proto = canonicalProto;
     395             :   }
     396             : 
     397           0 :   BindingJSObjectCreator<mozilla::dom::HTMLAudioElement> creator(aCx);
     398           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     399           0 :   if (!aReflector) {
     400           0 :     return false;
     401             :   }
     402             : 
     403           0 :   aCache->SetWrapper(aReflector);
     404           0 :   creator.InitializationSucceeded();
     405             : 
     406           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     407             :              aCache->GetWrapperPreserveColor() == aReflector);
     408             :   // If proto != canonicalProto, we have to preserve our wrapper;
     409             :   // otherwise we won't be able to properly recreate it later, since
     410             :   // we won't know what proto to use.  Note that we don't check
     411             :   // aGivenProto here, since it's entirely possible (and even
     412             :   // somewhat common) to have a non-null aGivenProto which is the
     413             :   // same as canonicalProto.
     414           0 :   if (proto != canonicalProto) {
     415           0 :     PreserveWrapper(aObject);
     416             :   }
     417             : 
     418           0 :   return true;
     419             : }
     420             : 
     421             : const NativePropertyHooks sNativePropertyHooks[] = { {
     422             :   nullptr,
     423             :   nullptr,
     424             :   nullptr,
     425             :   { nullptr, nullptr },
     426             :   prototypes::id::HTMLAudioElement,
     427             :   constructors::id::HTMLAudioElement,
     428             :   HTMLMediaElementBinding::sNativePropertyHooks,
     429             :   &DefaultXrayExpandoObjectClass
     430             : } };
     431             : 
     432             : void
     433           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     434             : {
     435           0 :   JS::Handle<JSObject*> parentProto(HTMLMediaElementBinding::GetProtoObjectHandle(aCx));
     436           0 :   if (!parentProto) {
     437           0 :     return;
     438             :   }
     439             : 
     440           0 :   JS::Handle<JSObject*> constructorProto(HTMLMediaElementBinding::GetConstructorObjectHandle(aCx));
     441           0 :   if (!constructorProto) {
     442           0 :     return;
     443             :   }
     444             : 
     445           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLAudioElement);
     446           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLAudioElement);
     447           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     448             :                               &sPrototypeClass.mBase, protoCache,
     449             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, namedConstructors,
     450             :                               interfaceCache,
     451             :                               nullptr,
     452             :                               nullptr,
     453             :                               "HTMLAudioElement", aDefineOnGlobal,
     454             :                               nullptr,
     455           0 :                               false);
     456             : }
     457             : 
     458             : JS::Handle<JSObject*>
     459           0 : GetProtoObjectHandle(JSContext* aCx)
     460             : {
     461             :   /* Get the interface prototype object for this class.  This will create the
     462             :      object as needed. */
     463           0 :   bool aDefineOnGlobal = true;
     464             : 
     465             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     466           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     467           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     468           0 :     return nullptr;
     469             :   }
     470             : 
     471             :   /* Check to see whether the interface objects are already installed */
     472           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     473           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLAudioElement)) {
     474           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     475           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     476             :   }
     477             : 
     478             :   /*
     479             :    * The object might _still_ be null, but that's OK.
     480             :    *
     481             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     482             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     483             :    * changed after they have been set.
     484             :    *
     485             :    * Calling address() avoids the read read barrier that does gray
     486             :    * unmarking, but it's not possible for the object to be gray here.
     487             :    */
     488             : 
     489           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLAudioElement);
     490           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     491           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     492             : }
     493             : 
     494             : JS::Handle<JSObject*>
     495           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     496             : {
     497             :   /* Get the interface object for this class.  This will create the object as
     498             :      needed. */
     499             : 
     500             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     501           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     502           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     503           0 :     return nullptr;
     504             :   }
     505             : 
     506             :   /* Check to see whether the interface objects are already installed */
     507           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     508           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLAudioElement)) {
     509           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     510           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     511             :   }
     512             : 
     513             :   /*
     514             :    * The object might _still_ be null, but that's OK.
     515             :    *
     516             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     517             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     518             :    * changed after they have been set.
     519             :    *
     520             :    * Calling address() avoids the read read barrier that does gray
     521             :    * unmarking, but it's not possible for the object to be gray here.
     522             :    */
     523             : 
     524           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLAudioElement);
     525           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     526           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     527             : }
     528             : 
     529             : JSObject*
     530           0 : GetConstructorObject(JSContext* aCx)
     531             : {
     532           0 :   return GetConstructorObjectHandle(aCx);
     533             : }
     534             : 
     535             : } // namespace HTMLAudioElementBinding
     536             : 
     537             : 
     538             : 
     539             : } // namespace dom
     540             : } // namespace mozilla

Generated by: LCOV version 1.13