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

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

Generated by: LCOV version 1.13