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

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

Generated by: LCOV version 1.13