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

Generated by: LCOV version 1.13