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

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

Generated by: LCOV version 1.13