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

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

Generated by: LCOV version 1.13