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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM HTMLOListElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "HTMLElementBinding.h"
       4             : #include "HTMLOListElementBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/CustomElementRegistry.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/HTMLSharedListElement.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : namespace HTMLOListElementBinding {
      19             : 
      20             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
      21             :               "Can't inherit from an interface with a different ownership model.");
      22             : 
      23             : static bool
      24           0 : get_reversed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitGetterCallArgs args)
      25             : {
      26           0 :   bool result(self->Reversed());
      27           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      28           0 :   args.rval().setBoolean(result);
      29           0 :   return true;
      30             : }
      31             : 
      32             : static bool
      33           0 : set_reversed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitSetterCallArgs args)
      34             : {
      35             :   bool arg0;
      36           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
      37           0 :     return false;
      38             :   }
      39           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
      40           0 :   Maybe<AutoCEReaction> ceReaction;
      41           0 :   if (reactionsStack) {
      42           0 :     ceReaction.emplace(reactionsStack);
      43             :   }
      44           0 :   binding_detail::FastErrorResult rv;
      45           0 :   self->SetReversed(arg0, rv);
      46           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      47           0 :     return false;
      48             :   }
      49           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      50             : 
      51           0 :   return true;
      52             : }
      53             : 
      54             : static const JSJitInfo reversed_getterinfo = {
      55             :   { (JSJitGetterOp)get_reversed },
      56             :   { prototypes::id::HTMLOListElement },
      57             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
      58             :   JSJitInfo::Getter,
      59             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      60             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
      61             :   true,  /* isInfallible. False in setters. */
      62             :   false,  /* isMovable.  Not relevant for setters. */
      63             :   false, /* isEliminatable.  Not relevant for setters. */
      64             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      65             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      66             :   false,  /* isTypedMethod.  Only relevant for methods. */
      67             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      68             : };
      69             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      70             : static_assert(0 < 1, "There is no slot for us");
      71             : static const JSJitInfo reversed_setterinfo = {
      72             :   { (JSJitGetterOp)set_reversed },
      73             :   { prototypes::id::HTMLOListElement },
      74             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
      75             :   JSJitInfo::Setter,
      76             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      77             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
      78             :   false,  /* isInfallible. False in setters. */
      79             :   false,  /* isMovable.  Not relevant for setters. */
      80             :   false, /* isEliminatable.  Not relevant for setters. */
      81             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      82             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      83             :   false,  /* isTypedMethod.  Only relevant for methods. */
      84             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      85             : };
      86             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      87             : static_assert(0 < 1, "There is no slot for us");
      88             : 
      89             : static bool
      90           0 : get_start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitGetterCallArgs args)
      91             : {
      92           0 :   int32_t result(self->Start());
      93           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      94           0 :   args.rval().setInt32(int32_t(result));
      95           0 :   return true;
      96             : }
      97             : 
      98             : static bool
      99           0 : set_start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitSetterCallArgs args)
     100             : {
     101             :   int32_t arg0;
     102           0 :   if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
     103           0 :     return false;
     104             :   }
     105           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     106           0 :   Maybe<AutoCEReaction> ceReaction;
     107           0 :   if (reactionsStack) {
     108           0 :     ceReaction.emplace(reactionsStack);
     109             :   }
     110           0 :   binding_detail::FastErrorResult rv;
     111           0 :   self->SetStart(arg0, rv);
     112           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     113           0 :     return false;
     114             :   }
     115           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     116             : 
     117           0 :   return true;
     118             : }
     119             : 
     120             : static const JSJitInfo start_getterinfo = {
     121             :   { (JSJitGetterOp)get_start },
     122             :   { prototypes::id::HTMLOListElement },
     123             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
     124             :   JSJitInfo::Getter,
     125             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     126             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     127             :   true,  /* isInfallible. False in setters. */
     128             :   false,  /* isMovable.  Not relevant for setters. */
     129             :   false, /* isEliminatable.  Not relevant for setters. */
     130             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     131             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     132             :   false,  /* isTypedMethod.  Only relevant for methods. */
     133             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     134             : };
     135             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     136             : static_assert(0 < 1, "There is no slot for us");
     137             : static const JSJitInfo start_setterinfo = {
     138             :   { (JSJitGetterOp)set_start },
     139             :   { prototypes::id::HTMLOListElement },
     140             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
     141             :   JSJitInfo::Setter,
     142             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     143             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     144             :   false,  /* isInfallible. False in setters. */
     145             :   false,  /* isMovable.  Not relevant for setters. */
     146             :   false, /* isEliminatable.  Not relevant for setters. */
     147             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     148             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     149             :   false,  /* isTypedMethod.  Only relevant for methods. */
     150             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     151             : };
     152             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     153             : static_assert(0 < 1, "There is no slot for us");
     154             : 
     155             : static bool
     156           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitGetterCallArgs args)
     157             : {
     158           0 :   DOMString result;
     159           0 :   self->GetType(result);
     160           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     161           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     162           0 :     return false;
     163             :   }
     164           0 :   return true;
     165             : }
     166             : 
     167             : static bool
     168           0 : set_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitSetterCallArgs args)
     169             : {
     170           0 :   binding_detail::FakeString arg0;
     171           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     172           0 :     return false;
     173             :   }
     174           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     175           0 :   Maybe<AutoCEReaction> ceReaction;
     176           0 :   if (reactionsStack) {
     177           0 :     ceReaction.emplace(reactionsStack);
     178             :   }
     179           0 :   binding_detail::FastErrorResult rv;
     180           0 :   self->SetType(NonNullHelper(Constify(arg0)), rv);
     181           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     182           0 :     return false;
     183             :   }
     184           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     185             : 
     186           0 :   return true;
     187             : }
     188             : 
     189             : static const JSJitInfo type_getterinfo = {
     190             :   { (JSJitGetterOp)get_type },
     191             :   { prototypes::id::HTMLOListElement },
     192             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
     193             :   JSJitInfo::Getter,
     194             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     195             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     196             :   false,  /* isInfallible. False in setters. */
     197             :   false,  /* isMovable.  Not relevant for setters. */
     198             :   false, /* isEliminatable.  Not relevant for setters. */
     199             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     200             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     201             :   false,  /* isTypedMethod.  Only relevant for methods. */
     202             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     203             : };
     204             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     205             : static_assert(0 < 1, "There is no slot for us");
     206             : static const JSJitInfo type_setterinfo = {
     207             :   { (JSJitGetterOp)set_type },
     208             :   { prototypes::id::HTMLOListElement },
     209             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
     210             :   JSJitInfo::Setter,
     211             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     212             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     213             :   false,  /* isInfallible. False in setters. */
     214             :   false,  /* isMovable.  Not relevant for setters. */
     215             :   false, /* isEliminatable.  Not relevant for setters. */
     216             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     217             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     218             :   false,  /* isTypedMethod.  Only relevant for methods. */
     219             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     220             : };
     221             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     222             : static_assert(0 < 1, "There is no slot for us");
     223             : 
     224             : static bool
     225           0 : get_compact(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitGetterCallArgs args)
     226             : {
     227           0 :   bool result(self->Compact());
     228           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     229           0 :   args.rval().setBoolean(result);
     230           0 :   return true;
     231             : }
     232             : 
     233             : static bool
     234           0 : set_compact(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLSharedListElement* self, JSJitSetterCallArgs args)
     235             : {
     236             :   bool arg0;
     237           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
     238           0 :     return false;
     239             :   }
     240           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     241           0 :   Maybe<AutoCEReaction> ceReaction;
     242           0 :   if (reactionsStack) {
     243           0 :     ceReaction.emplace(reactionsStack);
     244             :   }
     245           0 :   binding_detail::FastErrorResult rv;
     246           0 :   self->SetCompact(arg0, rv);
     247           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     248           0 :     return false;
     249             :   }
     250           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     251             : 
     252           0 :   return true;
     253             : }
     254             : 
     255             : static const JSJitInfo compact_getterinfo = {
     256             :   { (JSJitGetterOp)get_compact },
     257             :   { prototypes::id::HTMLOListElement },
     258             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
     259             :   JSJitInfo::Getter,
     260             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     261             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     262             :   true,  /* isInfallible. False in setters. */
     263             :   false,  /* isMovable.  Not relevant for setters. */
     264             :   false, /* isEliminatable.  Not relevant for setters. */
     265             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     266             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     267             :   false,  /* isTypedMethod.  Only relevant for methods. */
     268             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     269             : };
     270             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     271             : static_assert(0 < 1, "There is no slot for us");
     272             : static const JSJitInfo compact_setterinfo = {
     273             :   { (JSJitGetterOp)set_compact },
     274             :   { prototypes::id::HTMLOListElement },
     275             :   { PrototypeTraits<prototypes::id::HTMLOListElement>::Depth },
     276             :   JSJitInfo::Setter,
     277             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     278             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     279             :   false,  /* isInfallible. False in setters. */
     280             :   false,  /* isMovable.  Not relevant for setters. */
     281             :   false, /* isEliminatable.  Not relevant for setters. */
     282             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     283             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     284             :   false,  /* isTypedMethod.  Only relevant for methods. */
     285             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     286             : };
     287             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     288             : static_assert(0 < 1, "There is no slot for us");
     289             : 
     290             : static bool
     291           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     292             : {
     293           0 :   mozilla::dom::HTMLSharedListElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedListElement>(obj);
     294             :   // We don't want to preserve if we don't have a wrapper, and we
     295             :   // obviously can't preserve if we're not initialized.
     296           0 :   if (self && self->GetWrapperPreserveColor()) {
     297           0 :     PreserveWrapper(self);
     298             :   }
     299           0 :   return true;
     300             : }
     301             : 
     302             : static void
     303           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     304             : {
     305           0 :   mozilla::dom::HTMLSharedListElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedListElement>(obj);
     306           0 :   if (self) {
     307           0 :     ClearWrapper(self, self, obj);
     308           0 :     AddForDeferredFinalization<mozilla::dom::HTMLSharedListElement>(self);
     309             :   }
     310           0 : }
     311             : 
     312             : static void
     313           0 : _objectMoved(JSObject* obj, const JSObject* old)
     314             : {
     315           0 :   mozilla::dom::HTMLSharedListElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLSharedListElement>(obj);
     316           0 :   if (self) {
     317           0 :     UpdateWrapper(self, self, obj, old);
     318             :   }
     319           0 : }
     320             : 
     321             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     322             : #if defined(__clang__)
     323             : #pragma clang diagnostic push
     324             : #pragma clang diagnostic ignored "-Wmissing-braces"
     325             : #endif
     326             : static const JSPropertySpec sAttributes_specs[] = {
     327             :   { "reversed", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &reversed_getterinfo, GenericBindingSetter, &reversed_setterinfo },
     328             :   { "start", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &start_getterinfo, GenericBindingSetter, &start_setterinfo },
     329             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, GenericBindingSetter, &type_setterinfo },
     330             :   { "compact", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &compact_getterinfo, GenericBindingSetter, &compact_setterinfo },
     331             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     332             : };
     333             : #if defined(__clang__)
     334             : #pragma clang diagnostic pop
     335             : #endif
     336             : 
     337             : 
     338             : // Can't be const because the pref-enabled boolean needs to be writable
     339             : static Prefable<const JSPropertySpec> sAttributes[] = {
     340             :   { nullptr, &sAttributes_specs[0] },
     341             :   { nullptr, nullptr }
     342             : };
     343             : 
     344             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     345             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     346             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     347             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     348             : 
     349             : 
     350             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
     351             : static PropertyInfo sNativeProperties_propertyInfos[4];
     352             : 
     353             : static const NativePropertiesN<1> sNativeProperties = {
     354             :   false, 0,
     355             :   false, 0,
     356             :   false, 0,
     357             :   true,  0 /* sAttributes */,
     358             :   false, 0,
     359             :   false, 0,
     360             :   false, 0,
     361             :   -1,
     362             :   4,
     363             :   sNativeProperties_sortedPropertyIndices,
     364             :   {
     365             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     366             :   }
     367             : };
     368             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     369             :     "We have a property info count that is oversized");
     370             : 
     371             : static bool
     372           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     373             : {
     374           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     375           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     376           0 :   if (!args.isConstructing()) {
     377             :     // XXXbz wish I could get the name from the callee instead of
     378             :     // Adding more relocations
     379           0 :     return ThrowConstructorWithoutNew(cx, "HTMLOListElement");
     380             :   }
     381             : 
     382           0 :   GlobalObject global(cx, obj);
     383           0 :   if (global.Failed()) {
     384           0 :     return false;
     385             :   }
     386             : 
     387             :   // The newTarget might be a cross-compartment wrapper. Get the underlying object
     388             :   // so we can do the spec's object-identity checks.
     389           0 :   JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
     390           0 :   if (!newTarget) {
     391           0 :     return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     392             :   }
     393             : 
     394             :   // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     395             :   // Enter the compartment of our underlying newTarget object, so we end
     396             :   // up comparing to the constructor object for our interface from that global.
     397             :   {
     398           0 :     JSAutoCompartment ac(cx, newTarget);
     399           0 :     JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
     400           0 :     if (!constructor) {
     401           0 :       return false;
     402             :     }
     403           0 :     if (newTarget == constructor) {
     404           0 :       return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     405             :     }
     406             :   }
     407             : 
     408           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     409           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     410           0 :     return false;
     411             :   }
     412           0 :   if (!desiredProto) {
     413             :     // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     414             :     // This fallback behavior is designed to match analogous behavior for the
     415             :     // JavaScript built-ins. So we enter the compartment of our underlying
     416             :     // newTarget object and fall back to the prototype object from that global.
     417             :     // XXX The spec says to use GetFunctionRealm(), which is not actually
     418             :     // the same thing as what we have here (e.g. in the case of scripted callable proxies
     419             :     // whose target is not same-compartment with the proxy, or bound functions, etc).
     420             :     // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
     421             :     {
     422           0 :       JSAutoCompartment ac(cx, newTarget);
     423           0 :       desiredProto = GetProtoObjectHandle(cx);
     424           0 :       if (!desiredProto) {
     425           0 :           return false;
     426             :       }
     427             :     }
     428             : 
     429             :     // desiredProto is in the compartment of the underlying newTarget object.
     430             :     // Wrap it into the context compartment.
     431           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     432           0 :       return false;
     433             :     }
     434             :   }
     435             : 
     436           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     437           0 :   Maybe<JSAutoCompartment> ac;
     438           0 :   if (objIsXray) {
     439           0 :     obj = js::CheckedUnwrap(obj);
     440           0 :     if (!obj) {
     441           0 :       return false;
     442             :     }
     443           0 :     ac.emplace(cx, obj);
     444           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     445           0 :       return false;
     446             :     }
     447             :   }
     448           0 :   binding_detail::FastErrorResult rv;
     449           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLSharedListElement>(CreateHTMLElement(global, args, rv)));
     450           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     451           0 :     return false;
     452             :   }
     453           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     454             :   static_assert(!IsPointer<decltype(result)>::value,
     455             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     456           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     457           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     458           0 :     return false;
     459             :   }
     460           0 :   return true;
     461             : }
     462             : 
     463             : static const js::ClassOps sInterfaceObjectClassOps = {
     464             :     nullptr,               /* addProperty */
     465             :     nullptr,               /* delProperty */
     466             :     nullptr,               /* getProperty */
     467             :     nullptr,               /* setProperty */
     468             :     nullptr,               /* enumerate */
     469             :     nullptr,               /* newEnumerate */
     470             :     nullptr,               /* resolve */
     471             :     nullptr,               /* mayResolve */
     472             :     nullptr,               /* finalize */
     473             :     _constructor, /* call */
     474             :     nullptr,               /* hasInstance */
     475             :     _constructor, /* construct */
     476             :     nullptr,               /* trace */
     477             : };
     478             : 
     479             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     480             :   {
     481             :     "Function",
     482             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     483             :     &sInterfaceObjectClassOps,
     484             :     JS_NULL_CLASS_SPEC,
     485             :     JS_NULL_CLASS_EXT,
     486             :     &sInterfaceObjectClassObjectOps
     487             :   },
     488             :   eInterface,
     489             :   true,
     490             :   prototypes::id::HTMLOListElement,
     491             :   PrototypeTraits<prototypes::id::HTMLOListElement>::Depth,
     492             :   sNativePropertyHooks,
     493             :   "function HTMLOListElement() {\n    [native code]\n}",
     494             :   HTMLElementBinding::GetConstructorObject
     495             : };
     496             : 
     497             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     498             :   {
     499             :     "HTMLOListElementPrototype",
     500             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     501             :     JS_NULL_CLASS_OPS,
     502             :     JS_NULL_CLASS_SPEC,
     503             :     JS_NULL_CLASS_EXT,
     504             :     JS_NULL_OBJECT_OPS
     505             :   },
     506             :   eInterfacePrototype,
     507             :   false,
     508             :   prototypes::id::HTMLOListElement,
     509             :   PrototypeTraits<prototypes::id::HTMLOListElement>::Depth,
     510             :   sNativePropertyHooks,
     511             :   "[object HTMLOListElementPrototype]",
     512             :   HTMLElementBinding::GetProtoObject
     513             : };
     514             : 
     515             : JSObject*
     516           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     517             : {
     518           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     519             : }
     520             : 
     521             : static const js::ClassOps sClassOps = {
     522             :   _addProperty, /* addProperty */
     523             :   nullptr,               /* delProperty */
     524             :   nullptr,               /* getProperty */
     525             :   nullptr,               /* setProperty */
     526             :   nullptr,               /* enumerate */
     527             :   nullptr, /* newEnumerate */
     528             :   nullptr, /* resolve */
     529             :   nullptr, /* mayResolve */
     530             :   _finalize, /* finalize */
     531             :   nullptr, /* call */
     532             :   nullptr,               /* hasInstance */
     533             :   nullptr,               /* construct */
     534             :   nullptr, /* trace */
     535             : };
     536             : 
     537             : static const js::ClassExtension sClassExtension = {
     538             :   nullptr, /* weakmapKeyDelegateOp */
     539             :   _objectMoved /* objectMovedOp */
     540             : };
     541             : 
     542             : static const DOMJSClass sClass = {
     543             :   { "HTMLOListElement",
     544             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     545             :     &sClassOps,
     546             :     JS_NULL_CLASS_SPEC,
     547             :     &sClassExtension,
     548             :     JS_NULL_OBJECT_OPS
     549             :   },
     550             :   { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLOListElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     551             :   IsBaseOf<nsISupports, mozilla::dom::HTMLSharedListElement >::value,
     552             :   sNativePropertyHooks,
     553             :   FindAssociatedGlobalForNative<mozilla::dom::HTMLSharedListElement>::Get,
     554             :   GetProtoObjectHandle,
     555             :   GetCCParticipant<mozilla::dom::HTMLSharedListElement>::Get()
     556             : };
     557             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     558             :               "Must have the right minimal number of reserved slots.");
     559             : static_assert(1 >= 1,
     560             :               "Must have enough reserved slots.");
     561             : 
     562             : const JSClass*
     563           0 : GetJSClass()
     564             : {
     565           0 :   return sClass.ToJSClass();
     566             : }
     567             : 
     568             : bool
     569           0 : Wrap(JSContext* aCx, mozilla::dom::HTMLSharedListElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     570             : {
     571             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLSharedListElement*>(aObject) ==
     572             :              reinterpret_cast<mozilla::dom::HTMLSharedListElement*>(aObject),
     573             :              "Multiple inheritance for mozilla::dom::HTMLSharedListElement is broken.");
     574             :   MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
     575             :              reinterpret_cast<nsGenericHTMLElement*>(aObject),
     576             :              "Multiple inheritance for nsGenericHTMLElement is broken.");
     577             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     578             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     579             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     580             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     581             :              reinterpret_cast<nsINode*>(aObject),
     582             :              "Multiple inheritance for nsINode is broken.");
     583             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     584             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     585             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     586           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     587           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     588           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     589             :              "You should probably not be using Wrap() directly; use "
     590             :              "GetOrCreateDOMReflector instead");
     591             : 
     592           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     593             :              "nsISupports must be on our primary inheritance chain");
     594             : 
     595           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     596           0 :   if (!global) {
     597           0 :     return false;
     598             :   }
     599           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     600           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     601             : 
     602             :   // That might have ended up wrapping us already, due to the wonders
     603             :   // of XBL.  Check for that, and bail out as needed.
     604           0 :   aReflector.set(aCache->GetWrapper());
     605           0 :   if (aReflector) {
     606             : #ifdef DEBUG
     607           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     608             : #endif // DEBUG
     609           0 :     return true;
     610             :   }
     611             : 
     612           0 :   JSAutoCompartment ac(aCx, global);
     613           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     614           0 :   if (!canonicalProto) {
     615           0 :     return false;
     616             :   }
     617           0 :   JS::Rooted<JSObject*> proto(aCx);
     618           0 :   if (aGivenProto) {
     619           0 :     proto = aGivenProto;
     620             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     621             :     // coming in, we changed compartments to that of "parent" so may need
     622             :     // to wrap the proto here.
     623           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     624           0 :       if (!JS_WrapObject(aCx, &proto)) {
     625           0 :         return false;
     626             :       }
     627             :     }
     628             :   } else {
     629           0 :     proto = canonicalProto;
     630             :   }
     631             : 
     632           0 :   BindingJSObjectCreator<mozilla::dom::HTMLSharedListElement> creator(aCx);
     633           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     634           0 :   if (!aReflector) {
     635           0 :     return false;
     636             :   }
     637             : 
     638           0 :   aCache->SetWrapper(aReflector);
     639           0 :   creator.InitializationSucceeded();
     640             : 
     641           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     642             :              aCache->GetWrapperPreserveColor() == aReflector);
     643             :   // If proto != canonicalProto, we have to preserve our wrapper;
     644             :   // otherwise we won't be able to properly recreate it later, since
     645             :   // we won't know what proto to use.  Note that we don't check
     646             :   // aGivenProto here, since it's entirely possible (and even
     647             :   // somewhat common) to have a non-null aGivenProto which is the
     648             :   // same as canonicalProto.
     649           0 :   if (proto != canonicalProto) {
     650           0 :     PreserveWrapper(aObject);
     651             :   }
     652             : 
     653           0 :   return true;
     654             : }
     655             : 
     656             : const NativePropertyHooks sNativePropertyHooks[] = { {
     657             :   nullptr,
     658             :   nullptr,
     659             :   nullptr,
     660             :   { sNativeProperties.Upcast(), nullptr },
     661             :   prototypes::id::HTMLOListElement,
     662             :   constructors::id::HTMLOListElement,
     663             :   HTMLElementBinding::sNativePropertyHooks,
     664             :   &DefaultXrayExpandoObjectClass
     665             : } };
     666             : 
     667             : void
     668           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     669             : {
     670           0 :   JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
     671           0 :   if (!parentProto) {
     672           0 :     return;
     673             :   }
     674             : 
     675           0 :   JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
     676           0 :   if (!constructorProto) {
     677           0 :     return;
     678             :   }
     679             : 
     680             :   static bool sIdsInited = false;
     681           0 :   if (!sIdsInited && NS_IsMainThread()) {
     682           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     683           0 :       return;
     684             :     }
     685           0 :     sIdsInited = true;
     686             :   }
     687             : 
     688           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLOListElement);
     689           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLOListElement);
     690           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     691             :                               &sPrototypeClass.mBase, protoCache,
     692             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     693             :                               interfaceCache,
     694             :                               sNativeProperties.Upcast(),
     695             :                               nullptr,
     696             :                               "HTMLOListElement", aDefineOnGlobal,
     697             :                               nullptr,
     698           0 :                               false);
     699             : }
     700             : 
     701             : JS::Handle<JSObject*>
     702           0 : GetProtoObjectHandle(JSContext* aCx)
     703             : {
     704             :   /* Get the interface prototype object for this class.  This will create the
     705             :      object as needed. */
     706           0 :   bool aDefineOnGlobal = true;
     707             : 
     708             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     709           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     710           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     711           0 :     return nullptr;
     712             :   }
     713             : 
     714             :   /* Check to see whether the interface objects are already installed */
     715           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     716           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLOListElement)) {
     717           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     718           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     719             :   }
     720             : 
     721             :   /*
     722             :    * The object might _still_ be null, but that's OK.
     723             :    *
     724             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     725             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     726             :    * changed after they have been set.
     727             :    *
     728             :    * Calling address() avoids the read read barrier that does gray
     729             :    * unmarking, but it's not possible for the object to be gray here.
     730             :    */
     731             : 
     732           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLOListElement);
     733           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     734           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     735             : }
     736             : 
     737             : JS::Handle<JSObject*>
     738           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     739             : {
     740             :   /* Get the interface object for this class.  This will create the object as
     741             :      needed. */
     742             : 
     743             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     744           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     745           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     746           0 :     return nullptr;
     747             :   }
     748             : 
     749             :   /* Check to see whether the interface objects are already installed */
     750           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     751           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLOListElement)) {
     752           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     753           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     754             :   }
     755             : 
     756             :   /*
     757             :    * The object might _still_ be null, but that's OK.
     758             :    *
     759             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     760             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     761             :    * changed after they have been set.
     762             :    *
     763             :    * Calling address() avoids the read read barrier that does gray
     764             :    * unmarking, but it's not possible for the object to be gray here.
     765             :    */
     766             : 
     767           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLOListElement);
     768           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     769           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     770             : }
     771             : 
     772             : JSObject*
     773           0 : GetConstructorObject(JSContext* aCx)
     774             : {
     775           0 :   return GetConstructorObjectHandle(aCx);
     776             : }
     777             : 
     778             : } // namespace HTMLOListElementBinding
     779             : 
     780             : 
     781             : 
     782             : } // namespace dom
     783             : } // namespace mozilla

Generated by: LCOV version 1.13