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

Generated by: LCOV version 1.13