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

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

Generated by: LCOV version 1.13