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

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

Generated by: LCOV version 1.13