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

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

Generated by: LCOV version 1.13