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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM MediaStreamList.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DOMMediaStream.h"
       4             : #include "MediaStreamList.h"
       5             : #include "MediaStreamListBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/DOMJSProxyHandler.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/Nullable.h"
      13             : #include "mozilla/dom/PrimitiveConversions.h"
      14             : #include "mozilla/dom/XrayExpandoClass.h"
      15             : #include "nsContentUtils.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : namespace MediaStreamListBinding {
      21             : 
      22             : static bool
      23           0 : get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaStreamList* self, JSJitGetterCallArgs args)
      24             : {
      25           0 :   uint32_t result(self->Length());
      26           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      27           0 :   args.rval().setNumber(result);
      28           0 :   return true;
      29             : }
      30             : 
      31             : static const JSJitInfo length_getterinfo = {
      32             :   { (JSJitGetterOp)get_length },
      33             :   { prototypes::id::MediaStreamList },
      34             :   { PrototypeTraits<prototypes::id::MediaStreamList>::Depth },
      35             :   JSJitInfo::Getter,
      36             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      37             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      38             :   true,  /* 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 void
      50           0 : _objectMoved(JSObject* obj, const JSObject* old)
      51             : {
      52           0 :   mozilla::dom::MediaStreamList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaStreamList>(obj);
      53           0 :   if (self) {
      54           0 :     UpdateWrapper(self, self, obj, old);
      55             :   }
      56           0 : }
      57             : 
      58             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
      59             : #if defined(__clang__)
      60             : #pragma clang diagnostic push
      61             : #pragma clang diagnostic ignored "-Wmissing-braces"
      62             : #endif
      63             : static const JSFunctionSpec sMethods_specs[] = {
      64             :   JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
      65             :   JS_FS_END
      66             : };
      67             : #if defined(__clang__)
      68             : #pragma clang diagnostic pop
      69             : #endif
      70             : 
      71             : 
      72             : // Can't be const because the pref-enabled boolean needs to be writable
      73             : static Prefable<const JSFunctionSpec> sMethods[] = {
      74             :   { nullptr, &sMethods_specs[0] },
      75             :   { nullptr, nullptr }
      76             : };
      77             : 
      78             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
      79             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
      80             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
      81             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
      82             : 
      83             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
      84             : #if defined(__clang__)
      85             : #pragma clang diagnostic push
      86             : #pragma clang diagnostic ignored "-Wmissing-braces"
      87             : #endif
      88             : static const JSPropertySpec sAttributes_specs[] = {
      89             :   { "length", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &length_getterinfo, nullptr, nullptr },
      90             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
      91             : };
      92             : #if defined(__clang__)
      93             : #pragma clang diagnostic pop
      94             : #endif
      95             : 
      96             : 
      97             : // Can't be const because the pref-enabled boolean needs to be writable
      98             : static Prefable<const JSPropertySpec> sAttributes[] = {
      99             :   { nullptr, &sAttributes_specs[0] },
     100             :   { nullptr, nullptr }
     101             : };
     102             : 
     103             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     104             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     105             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     106             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     107             : 
     108             : 
     109             : static uint16_t sNativeProperties_sortedPropertyIndices[2];
     110             : static PropertyInfo sNativeProperties_propertyInfos[2];
     111             : 
     112             : static const NativePropertiesN<2> sNativeProperties = {
     113             :   false, 0,
     114             :   false, 0,
     115             :   true,  0 /* sMethods */,
     116             :   true,  1 /* sAttributes */,
     117             :   false, 0,
     118             :   false, 0,
     119             :   false, 0,
     120             :   -1,
     121             :   2,
     122             :   sNativeProperties_sortedPropertyIndices,
     123             :   {
     124             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     125             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
     126             :   }
     127             : };
     128             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     129             :     "We have a property info count that is oversized");
     130             : 
     131             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     132             :   {
     133             :     "Function",
     134             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     135             :     &sBoringInterfaceObjectClassClassOps,
     136             :     JS_NULL_CLASS_SPEC,
     137             :     JS_NULL_CLASS_EXT,
     138             :     &sInterfaceObjectClassObjectOps
     139             :   },
     140             :   eInterface,
     141             :   true,
     142             :   prototypes::id::MediaStreamList,
     143             :   PrototypeTraits<prototypes::id::MediaStreamList>::Depth,
     144             :   sNativePropertyHooks,
     145             :   "function MediaStreamList() {\n    [native code]\n}",
     146             :   JS::GetRealmFunctionPrototype
     147             : };
     148             : 
     149             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     150             :   {
     151             :     "MediaStreamListPrototype",
     152             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     153             :     JS_NULL_CLASS_OPS,
     154             :     JS_NULL_CLASS_SPEC,
     155             :     JS_NULL_CLASS_EXT,
     156             :     JS_NULL_OBJECT_OPS
     157             :   },
     158             :   eInterfacePrototype,
     159             :   false,
     160             :   prototypes::id::MediaStreamList,
     161             :   PrototypeTraits<prototypes::id::MediaStreamList>::Depth,
     162             :   sNativePropertyHooks,
     163             :   "[object MediaStreamListPrototype]",
     164             :   JS::GetRealmObjectPrototype
     165             : };
     166             : 
     167             : bool
     168           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     169             : {
     170           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
     171             : }
     172             : 
     173             : JSObject*
     174           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     175             : {
     176           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     177             : }
     178             : 
     179             : static_assert(IsBaseOf<nsISupports, mozilla::dom::MediaStreamList >::value,
     180             :                   "We don't support non-nsISupports native classes for "
     181             :                   "proxy-based bindings yet");
     182             : 
     183             : 
     184             : class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
     185             : {
     186             : public:
     187             :   explicit constexpr DOMProxyHandler()
     188             :   {
     189             :   }
     190             : 
     191             :   virtual bool
     192             :   getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
     193             : 
     194             :   virtual bool
     195             :   defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
     196             : 
     197             :   using mozilla::dom::DOMProxyHandler::defineProperty;
     198             : 
     199             :   virtual bool
     200             :   ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
     201             : 
     202             :   virtual bool
     203             :   hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
     204             : 
     205             :   virtual bool
     206             :   get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
     207             : 
     208             :   virtual const char*
     209             :   className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
     210             : 
     211             :   virtual bool
     212             :   finalizeInBackground(const JS::Value& priv) const override;
     213             : 
     214             :   virtual void
     215             :   finalize(JSFreeOp* fop, JSObject* proxy) const override;
     216             : 
     217             :   static const DOMProxyHandler*
     218             :   getInstance();
     219             : 
     220             :   virtual bool
     221             :   delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
     222             : 
     223             :   virtual bool
     224             :   getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
     225             : };
     226             : 
     227             : MOZ_ALWAYS_INLINE bool
     228           0 : IsProxy(JSObject* obj)
     229             : {
     230           0 :   return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
     231             : }
     232             : 
     233             : MOZ_ALWAYS_INLINE mozilla::dom::MediaStreamList*
     234           0 : UnwrapProxy(JSObject* obj)
     235             : {
     236           0 :   MOZ_ASSERT(js::IsProxy(obj));
     237           0 :   if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
     238           0 :     MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
     239           0 :     obj = js::UncheckedUnwrap(obj);
     240             :   }
     241           0 :   MOZ_ASSERT(IsProxy(obj));
     242           0 :   return static_cast<mozilla::dom::MediaStreamList*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
     243             : }
     244             : 
     245             : bool
     246           0 : DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
     247             : {
     248           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
     249           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     250           0 :   if (IsArrayIndex(index)) {
     251           0 :     mozilla::dom::MediaStreamList* self = UnwrapProxy(proxy);
     252           0 :     bool found = false;
     253           0 :     auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->IndexedGetter(index, found)));
     254           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     255             : 
     256           0 :     if (found) {
     257           0 :       if (!result) {
     258           0 :         desc.value().setNull();
     259           0 :         FillPropertyDescriptor(desc, proxy, true);
     260           0 :         return true;
     261             :       }
     262           0 :       if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
     263           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     264           0 :         return false;
     265             :       }
     266           0 :       FillPropertyDescriptor(desc, proxy, true);
     267           0 :       return true;
     268             :     }
     269             :   }
     270             : 
     271           0 :   JS::Rooted<JSObject*> expando(cx);
     272           0 :   if (!isXray && (expando = GetExpandoObject(proxy))) {
     273           0 :     if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
     274           0 :       return false;
     275             :     }
     276           0 :     if (desc.object()) {
     277             :       // Pretend the property lives on the wrapper.
     278           0 :       desc.object().set(proxy);
     279           0 :       return true;
     280             :     }
     281             :   }
     282             : 
     283           0 :   desc.object().set(nullptr);
     284           0 :   return true;
     285             : }
     286             : 
     287             : bool
     288           0 : DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
     289             : {
     290           0 :   if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
     291           0 :     *defined = true;
     292           0 :     return opresult.failNoIndexedSetter();
     293             :   }
     294           0 :   return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
     295             : }
     296             : 
     297             : 
     298             : bool
     299           0 : DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
     300             : {
     301           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
     302             : 
     303           0 :   uint32_t length = UnwrapProxy(proxy)->Length();
     304           0 :   MOZ_ASSERT(int32_t(length) >= 0);
     305           0 :   for (int32_t i = 0; i < int32_t(length); ++i) {
     306           0 :     if (!props.append(INT_TO_JSID(i))) {
     307           0 :       return false;
     308             :     }
     309             :   }
     310             : 
     311           0 :   JS::Rooted<JSObject*> expando(cx);
     312           0 :   if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
     313           0 :       !js::GetPropertyKeys(cx, expando, flags, &props)) {
     314           0 :     return false;
     315             :   }
     316             : 
     317           0 :   return true;
     318             : }
     319             : 
     320             : bool
     321           0 : DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
     322             : {
     323           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     324             :             "Should not have a XrayWrapper here");
     325             : 
     326           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     327           0 :   if (IsArrayIndex(index)) {
     328           0 :     bool found = false;
     329           0 :     mozilla::dom::MediaStreamList* self = UnwrapProxy(proxy);
     330           0 :     auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->IndexedGetter(index, found)));
     331           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     332             :     (void)result;
     333             : 
     334           0 :     *bp = found;
     335           0 :     return true;
     336             :   }
     337             : 
     338             : 
     339           0 :   JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
     340           0 :   if (expando) {
     341           0 :     bool b = true;
     342           0 :     bool ok = JS_HasPropertyById(cx, expando, id, &b);
     343           0 :     *bp = !!b;
     344           0 :     if (!ok || *bp) {
     345           0 :       return ok;
     346             :     }
     347             :   }
     348             : 
     349           0 :   *bp = false;
     350           0 :   return true;
     351             : }
     352             : 
     353             : bool
     354           0 : DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
     355             : {
     356           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     357             :               "Should not have a XrayWrapper here");
     358             : 
     359           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     360           0 :   if (IsArrayIndex(index)) {
     361           0 :     mozilla::dom::MediaStreamList* self = UnwrapProxy(proxy);
     362           0 :     bool found = false;
     363           0 :     auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->IndexedGetter(index, found)));
     364           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     365             : 
     366           0 :     if (found) {
     367           0 :       if (!result) {
     368           0 :         vp.setNull();
     369           0 :         return true;
     370             :       }
     371           0 :       if (!GetOrCreateDOMReflector(cx, result, vp)) {
     372           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     373           0 :         return false;
     374             :       }
     375           0 :       return true;
     376             :     }
     377             :     // Even if we don't have this index, we don't forward the
     378             :     // get on to our expando object.
     379             :   } else {
     380             :     { // Scope for expando
     381           0 :       JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
     382           0 :       if (expando) {
     383             :         bool hasProp;
     384           0 :         if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
     385           0 :           return false;
     386             :         }
     387             : 
     388           0 :         if (hasProp) {
     389             :           // Forward the get to the expando object, but our receiver is whatever our
     390             :           // receiver is.
     391           0 :           return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
     392             :         }
     393             :       }
     394             :     }
     395             :   }
     396             : 
     397             :   bool foundOnPrototype;
     398           0 :   if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
     399           0 :     return false;
     400             :   }
     401             : 
     402           0 :   if (foundOnPrototype) {
     403           0 :     return true;
     404             :   }
     405             : 
     406           0 :   vp.setUndefined();
     407           0 :   return true;
     408             : }
     409             : 
     410             : const char*
     411           0 : DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
     412             : {
     413           0 :   return "MediaStreamList";
     414             : }
     415             : 
     416             : bool
     417           0 : DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
     418             : {
     419           0 :   return false;
     420             : }
     421             : 
     422             : void
     423           0 : DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
     424             : {
     425           0 :   mozilla::dom::MediaStreamList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaStreamList>(proxy);
     426           0 :   if (self) {
     427           0 :     ClearWrapper(self, self, proxy);
     428           0 :     AddForDeferredFinalization<mozilla::dom::MediaStreamList>(self);
     429             :   }
     430           0 : }
     431             : 
     432             : const DOMProxyHandler*
     433           0 : DOMProxyHandler::getInstance()
     434             : {
     435             :   static const DOMProxyHandler instance;
     436           0 :   return &instance;
     437             : }
     438             : 
     439             : bool
     440           0 : DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
     441             : {
     442           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     443             :             "Should not have a XrayWrapper here");
     444             : 
     445           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
     446           0 :   if (IsArrayIndex(index)) {
     447             :     bool deleteSucceeded;
     448           0 :     bool found = false;
     449           0 :     mozilla::dom::MediaStreamList* self = UnwrapProxy(proxy);
     450           0 :     auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->IndexedGetter(index, found)));
     451           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     452             :     (void)result;
     453           0 :     deleteSucceeded = !found;
     454           0 :     return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
     455             :   }
     456             : 
     457           0 :   return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
     458             : }
     459             : 
     460             : bool
     461           0 : DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
     462             : {
     463           0 :   JS::Rooted<JS::Value> temp(cx);
     464           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
     465             :              "Should not have a XrayWrapper here");
     466             : 
     467           0 :   mozilla::dom::MediaStreamList* self = UnwrapProxy(proxy);
     468           0 :   uint32_t length = self->Length();
     469             :   // Compute the end of the indices we'll get ourselves
     470           0 :   uint32_t ourEnd = std::max(begin, std::min(end, length));
     471             : 
     472           0 :   for (uint32_t index = begin; index < ourEnd; ++index) {
     473           0 :     bool found = false;
     474           0 :     auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->IndexedGetter(index, found)));
     475           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
     476             : 
     477           0 :     MOZ_ASSERT(found);
     478           0 :     if (!result) {
     479           0 :       temp.setNull();
     480           0 :       if (!adder->append(cx, temp)) return false;
     481           0 :       continue;
     482             :     }
     483           0 :     if (!GetOrCreateDOMReflector(cx, result, &temp)) {
     484           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     485           0 :       return false;
     486             :     }
     487           0 :     if (!adder->append(cx, temp)) return false;
     488           0 :     continue;
     489             :   }
     490             : 
     491           0 :   if (end > ourEnd) {
     492           0 :     JS::Rooted<JSObject*> proto(cx);
     493           0 :     if (!js::GetObjectProto(cx, proxy, &proto)) {
     494           0 :       return false;
     495             :     }
     496           0 :     return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
     497             :   }
     498             : 
     499           0 :   return true;
     500             : }
     501             : 
     502             : static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
     503             :     _objectMoved
     504             : );
     505             : 
     506             : static const DOMJSClass sClass = {
     507             :   PROXY_CLASS_WITH_EXT("MediaStreamList",
     508             :                        JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
     509             :                        &sClassExtension),
     510             :   { prototypes::id::MediaStreamList, 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 },
     511             :   IsBaseOf<nsISupports, mozilla::dom::MediaStreamList >::value,
     512             :   sNativePropertyHooks,
     513             :   FindAssociatedGlobalForNative<mozilla::dom::MediaStreamList>::Get,
     514             :   GetProtoObjectHandle,
     515             :   GetCCParticipant<mozilla::dom::MediaStreamList>::Get()
     516             : };
     517             : 
     518             : bool
     519           0 : Wrap(JSContext* aCx, mozilla::dom::MediaStreamList* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     520             : {
     521             :   MOZ_ASSERT(static_cast<mozilla::dom::MediaStreamList*>(aObject) ==
     522             :              reinterpret_cast<mozilla::dom::MediaStreamList*>(aObject),
     523             :              "Multiple inheritance for mozilla::dom::MediaStreamList is broken.");
     524           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     525           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     526           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     527             :              "You should probably not be using Wrap() directly; use "
     528             :              "GetOrCreateDOMReflector instead");
     529             : 
     530           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     531             :              "nsISupports must be on our primary inheritance chain");
     532             : 
     533           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     534           0 :   if (!global) {
     535           0 :     return false;
     536             :   }
     537           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     538           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     539             : 
     540             :   // That might have ended up wrapping us already, due to the wonders
     541             :   // of XBL.  Check for that, and bail out as needed.
     542           0 :   aReflector.set(aCache->GetWrapper());
     543           0 :   if (aReflector) {
     544             : #ifdef DEBUG
     545           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     546             : #endif // DEBUG
     547           0 :     return true;
     548             :   }
     549             : 
     550           0 :   JSAutoCompartment ac(aCx, global);
     551           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     552           0 :   if (!canonicalProto) {
     553           0 :     return false;
     554             :   }
     555           0 :   JS::Rooted<JSObject*> proto(aCx);
     556           0 :   if (aGivenProto) {
     557           0 :     proto = aGivenProto;
     558             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     559             :     // coming in, we changed compartments to that of "parent" so may need
     560             :     // to wrap the proto here.
     561           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     562           0 :       if (!JS_WrapObject(aCx, &proto)) {
     563           0 :         return false;
     564             :       }
     565             :     }
     566             :   } else {
     567           0 :     proto = canonicalProto;
     568             :   }
     569             : 
     570           0 :   BindingJSObjectCreator<mozilla::dom::MediaStreamList> creator(aCx);
     571           0 :   JS::Rooted<JS::Value> expandoValue(aCx, JS::UndefinedValue());
     572           0 :   creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
     573           0 :                             proto, aObject, expandoValue, aReflector);
     574           0 :   if (!aReflector) {
     575           0 :     return false;
     576             :   }
     577             : 
     578             : 
     579           0 :   aCache->SetWrapper(aReflector);
     580           0 :   creator.InitializationSucceeded();
     581             : 
     582           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     583             :              aCache->GetWrapperPreserveColor() == aReflector);
     584             :   // If proto != canonicalProto, we have to preserve our wrapper;
     585             :   // otherwise we won't be able to properly recreate it later, since
     586             :   // we won't know what proto to use.  Note that we don't check
     587             :   // aGivenProto here, since it's entirely possible (and even
     588             :   // somewhat common) to have a non-null aGivenProto which is the
     589             :   // same as canonicalProto.
     590           0 :   if (proto != canonicalProto) {
     591           0 :     PreserveWrapper(aObject);
     592             :   }
     593             : 
     594           0 :   return true;
     595             : }
     596             : 
     597             : static bool
     598           0 : ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
     599             : {
     600           0 :   return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
     601             : }
     602             : 
     603             : static bool
     604           0 : EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
     605             : {
     606           0 :   return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
     607             : }
     608             : 
     609             : const NativePropertyHooks sNativePropertyHooks[] = { {
     610             :   ResolveOwnProperty,
     611             :   EnumerateOwnProperties,
     612             :   nullptr,
     613             :   { sNativeProperties.Upcast(), nullptr },
     614             :   prototypes::id::MediaStreamList,
     615             :   constructors::id::MediaStreamList,
     616             :   nullptr,
     617             :   &DefaultXrayExpandoObjectClass
     618             : } };
     619             : 
     620             : void
     621           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     622             : {
     623           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     624           0 :   if (!parentProto) {
     625           0 :     return;
     626             :   }
     627             : 
     628           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     629           0 :   if (!constructorProto) {
     630           0 :     return;
     631             :   }
     632             : 
     633             :   static bool sIdsInited = false;
     634           0 :   if (!sIdsInited && NS_IsMainThread()) {
     635           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     636           0 :       return;
     637             :     }
     638           0 :     sIdsInited = true;
     639             :   }
     640             : 
     641           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaStreamList);
     642           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaStreamList);
     643           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     644             :                               &sPrototypeClass.mBase, protoCache,
     645             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     646             :                               interfaceCache,
     647             :                               sNativeProperties.Upcast(),
     648             :                               nullptr,
     649             :                               "MediaStreamList", aDefineOnGlobal,
     650             :                               nullptr,
     651           0 :                               false);
     652             : }
     653             : 
     654             : JS::Handle<JSObject*>
     655           0 : GetProtoObjectHandle(JSContext* aCx)
     656             : {
     657             :   /* Get the interface prototype object for this class.  This will create the
     658             :      object as needed. */
     659           0 :   bool aDefineOnGlobal = true;
     660             : 
     661             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     662           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     663           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     664           0 :     return nullptr;
     665             :   }
     666             : 
     667             :   /* Check to see whether the interface objects are already installed */
     668           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     669           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MediaStreamList)) {
     670           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     671           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     672             :   }
     673             : 
     674             :   /*
     675             :    * The object might _still_ be null, but that's OK.
     676             :    *
     677             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     678             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     679             :    * changed after they have been set.
     680             :    *
     681             :    * Calling address() avoids the read read barrier that does gray
     682             :    * unmarking, but it's not possible for the object to be gray here.
     683             :    */
     684             : 
     685           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MediaStreamList);
     686           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     687           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     688             : }
     689             : 
     690             : JS::Handle<JSObject*>
     691           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     692             : {
     693             :   /* Get the interface object for this class.  This will create the object as
     694             :      needed. */
     695             : 
     696             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     697           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     698           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     699           0 :     return nullptr;
     700             :   }
     701             : 
     702             :   /* Check to see whether the interface objects are already installed */
     703           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     704           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::MediaStreamList)) {
     705           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     706           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     707             :   }
     708             : 
     709             :   /*
     710             :    * The object might _still_ be null, but that's OK.
     711             :    *
     712             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     713             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     714             :    * changed after they have been set.
     715             :    *
     716             :    * Calling address() avoids the read read barrier that does gray
     717             :    * unmarking, but it's not possible for the object to be gray here.
     718             :    */
     719             : 
     720           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::MediaStreamList);
     721           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     722           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     723             : }
     724             : 
     725             : JSObject*
     726           0 : GetConstructorObject(JSContext* aCx)
     727             : {
     728           0 :   return GetConstructorObjectHandle(aCx);
     729             : }
     730             : 
     731             : } // namespace MediaStreamListBinding
     732             : 
     733             : 
     734             : 
     735             : } // namespace dom
     736             : } // namespace mozilla

Generated by: LCOV version 1.13