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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Grid.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "GridBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "XrayWrapper.h"
       6             : #include "jsapi.h"
       7             : #include "mozilla/FloatingPoint.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/DOMJSProxyHandler.h"
      12             : #include "mozilla/dom/Grid.h"
      13             : #include "mozilla/dom/GridArea.h"
      14             : #include "mozilla/dom/GridDimension.h"
      15             : #include "mozilla/dom/GridLine.h"
      16             : #include "mozilla/dom/GridLines.h"
      17             : #include "mozilla/dom/GridTrack.h"
      18             : #include "mozilla/dom/GridTracks.h"
      19             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      20             : #include "mozilla/dom/Nullable.h"
      21             : #include "mozilla/dom/PrimitiveConversions.h"
      22             : #include "mozilla/dom/XrayExpandoClass.h"
      23             : #include "nsContentUtils.h"
      24             : 
      25             : namespace mozilla {
      26             : namespace dom {
      27             : 
      28             : namespace GridDeclarationValues {
      29             : extern const EnumEntry strings[3] = {
      30             :   {"explicit", 8},
      31             :   {"implicit", 8},
      32             :   { nullptr, 0 }
      33             : };
      34             : } // namespace GridDeclarationValues
      35             : 
      36             : bool
      37           0 : ToJSValue(JSContext* aCx, GridDeclaration aArgument, JS::MutableHandle<JS::Value> aValue)
      38             : {
      39           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(GridDeclarationValues::strings));
      40             :   JSString* resultStr =
      41           0 :     JS_NewStringCopyN(aCx, GridDeclarationValues::strings[uint32_t(aArgument)].value,
      42           0 :                       GridDeclarationValues::strings[uint32_t(aArgument)].length);
      43           0 :   if (!resultStr) {
      44           0 :     return false;
      45             :   }
      46           0 :   aValue.setString(resultStr);
      47           0 :   return true;
      48             : }
      49             : 
      50             : 
      51             : namespace GridTrackStateValues {
      52             : extern const EnumEntry strings[4] = {
      53             :   {"static", 6},
      54             :   {"repeat", 6},
      55             :   {"removed", 7},
      56             :   { nullptr, 0 }
      57             : };
      58             : } // namespace GridTrackStateValues
      59             : 
      60             : bool
      61           0 : ToJSValue(JSContext* aCx, GridTrackState aArgument, JS::MutableHandle<JS::Value> aValue)
      62             : {
      63           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(GridTrackStateValues::strings));
      64             :   JSString* resultStr =
      65           0 :     JS_NewStringCopyN(aCx, GridTrackStateValues::strings[uint32_t(aArgument)].value,
      66           0 :                       GridTrackStateValues::strings[uint32_t(aArgument)].length);
      67           0 :   if (!resultStr) {
      68           0 :     return false;
      69             :   }
      70           0 :   aValue.setString(resultStr);
      71           0 :   return true;
      72             : }
      73             : 
      74             : 
      75             : namespace GridBinding {
      76             : 
      77             : static bool
      78           0 : get_rows(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Grid* self, JSJitGetterCallArgs args)
      79             : {
      80           0 :   auto result(StrongOrRawPtr<mozilla::dom::GridDimension>(self->Rows()));
      81           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      82           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      83           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      84           0 :     return false;
      85             :   }
      86           0 :   return true;
      87             : }
      88             : 
      89             : static const JSJitInfo rows_getterinfo = {
      90             :   { (JSJitGetterOp)get_rows },
      91             :   { prototypes::id::Grid },
      92             :   { PrototypeTraits<prototypes::id::Grid>::Depth },
      93             :   JSJitInfo::Getter,
      94             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      95             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      96             :   false,  /* isInfallible. False in setters. */
      97             :   false,  /* isMovable.  Not relevant for setters. */
      98             :   false, /* isEliminatable.  Not relevant for setters. */
      99             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     100             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     101             :   false,  /* isTypedMethod.  Only relevant for methods. */
     102             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     103             : };
     104             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     105             : static_assert(0 < 2, "There is no slot for us");
     106             : 
     107             : static bool
     108           0 : get_cols(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Grid* self, JSJitGetterCallArgs args)
     109             : {
     110           0 :   auto result(StrongOrRawPtr<mozilla::dom::GridDimension>(self->Cols()));
     111           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     112           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     113           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     114           0 :     return false;
     115             :   }
     116           0 :   return true;
     117             : }
     118             : 
     119             : static const JSJitInfo cols_getterinfo = {
     120             :   { (JSJitGetterOp)get_cols },
     121             :   { prototypes::id::Grid },
     122             :   { PrototypeTraits<prototypes::id::Grid>::Depth },
     123             :   JSJitInfo::Getter,
     124             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     125             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     126             :   false,  /* isInfallible. False in setters. */
     127             :   false,  /* isMovable.  Not relevant for setters. */
     128             :   false, /* isEliminatable.  Not relevant for setters. */
     129             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     130             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     131             :   false,  /* isTypedMethod.  Only relevant for methods. */
     132             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     133             : };
     134             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     135             : static_assert(0 < 2, "There is no slot for us");
     136             : 
     137             : static bool
     138           0 : get_areas(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Grid* self, JSJitGetterCallArgs args)
     139             : {
     140             :   // Have to either root across the getter call or reget after.
     141             :   bool isXray;
     142           0 :   JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
     143           0 :   if (!slotStorage) {
     144           0 :     return false;
     145             :   }
     146           0 :   const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
     147           0 :   MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
     148             :   {
     149             :     // Scope for cachedVal
     150           0 :     JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
     151           0 :     if (!cachedVal.isUndefined()) {
     152           0 :       args.rval().set(cachedVal);
     153             :       // The cached value is in the compartment of slotStorage,
     154             :       // so wrap into the caller compartment as needed.
     155           0 :       return MaybeWrapNonDOMObjectValue(cx, args.rval());
     156             :     }
     157             :   }
     158             : 
     159           0 :   nsTArray<StrongPtrForMember<mozilla::dom::GridArea>::Type> result;
     160           0 :   self->GetAreas(result);
     161           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     162             :   {
     163           0 :     JS::Rooted<JSObject*> conversionScope(cx, isXray ? obj : slotStorage);
     164           0 :     JSAutoCompartment ac(cx, conversionScope);
     165             :     do { // block we break out of when done wrapping
     166             : 
     167           0 :       uint32_t length = result.Length();
     168           0 :       JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     169           0 :       if (!returnArray) {
     170           0 :         return false;
     171             :       }
     172             :       // Scope for 'tmp'
     173             :       {
     174           0 :         JS::Rooted<JS::Value> tmp(cx);
     175           0 :         for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     176             :           // Control block to let us common up the JS_DefineElement calls when there
     177             :           // are different ways to succeed at wrapping the object.
     178             :           do {
     179           0 :             if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
     180           0 :               MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     181           0 :               return false;
     182             :             }
     183           0 :             break;
     184             :           } while (0);
     185           0 :           if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     186             :                                 JSPROP_ENUMERATE)) {
     187           0 :             return false;
     188             :           }
     189             :         }
     190             :       }
     191           0 :       args.rval().setObject(*returnArray);
     192           0 :       break;
     193             :     } while (0);
     194             :   }
     195             :   { // And now store things in the compartment of our slotStorage.
     196           0 :     JSAutoCompartment ac(cx, slotStorage);
     197             :     // Make a copy so that we don't do unnecessary wrapping on args.rval().
     198           0 :     JS::Rooted<JS::Value> storedVal(cx, args.rval());
     199           0 :     if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
     200           0 :       return false;
     201             :     }
     202           0 :     js::SetReservedSlot(slotStorage, slotIndex, storedVal);
     203           0 :     if (!isXray) {
     204             :       // In the Xray case we don't need to do this, because getting the
     205             :       // expando object already preserved our wrapper.
     206           0 :       PreserveWrapper(self);
     207             :     }
     208             :   }
     209             :   // And now make sure args.rval() is in the caller compartment
     210           0 :   return MaybeWrapNonDOMObjectValue(cx, args.rval());
     211             : }
     212             : 
     213             : static const JSJitInfo areas_getterinfo = {
     214             :   { (JSJitGetterOp)get_areas },
     215             :   { prototypes::id::Grid },
     216             :   { PrototypeTraits<prototypes::id::Grid>::Depth },
     217             :   JSJitInfo::Getter,
     218             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     219             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     220             :   false,  /* isInfallible. False in setters. */
     221             :   true,  /* isMovable.  Not relevant for setters. */
     222             :   true, /* isEliminatable.  Not relevant for setters. */
     223             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     224             :   true, /* isLazilyCachedInSlot.  Only relevant for getters. */
     225             :   false,  /* isTypedMethod.  Only relevant for methods. */
     226             :   (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
     227             : };
     228             : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
     229             : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
     230             : 
     231             : static bool
     232           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     233             : {
     234           0 :   mozilla::dom::Grid* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Grid>(obj);
     235             :   // We don't want to preserve if we don't have a wrapper, and we
     236             :   // obviously can't preserve if we're not initialized.
     237           0 :   if (self && self->GetWrapperPreserveColor()) {
     238           0 :     PreserveWrapper(self);
     239             :   }
     240           0 :   return true;
     241             : }
     242             : 
     243             : static void
     244           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     245             : {
     246           0 :   mozilla::dom::Grid* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Grid>(obj);
     247           0 :   if (self) {
     248           0 :     ClearWrapper(self, self, obj);
     249           0 :     AddForDeferredFinalization<mozilla::dom::Grid>(self);
     250             :   }
     251           0 : }
     252             : 
     253             : static void
     254           0 : _objectMoved(JSObject* obj, const JSObject* old)
     255             : {
     256           0 :   mozilla::dom::Grid* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Grid>(obj);
     257           0 :   if (self) {
     258           0 :     UpdateWrapper(self, self, obj, old);
     259             :   }
     260           0 : }
     261             : 
     262             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     263             : #if defined(__clang__)
     264             : #pragma clang diagnostic push
     265             : #pragma clang diagnostic ignored "-Wmissing-braces"
     266             : #endif
     267             : static const JSPropertySpec sAttributes_specs[] = {
     268             :   { "rows", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rows_getterinfo, nullptr, nullptr },
     269             :   { "cols", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &cols_getterinfo, nullptr, nullptr },
     270             :   { "areas", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &areas_getterinfo, nullptr, nullptr },
     271             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     272             : };
     273             : #if defined(__clang__)
     274             : #pragma clang diagnostic pop
     275             : #endif
     276             : 
     277             : 
     278             : // Can't be const because the pref-enabled boolean needs to be writable
     279             : static Prefable<const JSPropertySpec> sAttributes[] = {
     280             :   { nullptr, &sAttributes_specs[0] },
     281             :   { nullptr, nullptr }
     282             : };
     283             : 
     284             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     285             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     286             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     287             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     288             : 
     289             : 
     290             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
     291             : static PropertyInfo sNativeProperties_propertyInfos[3];
     292             : 
     293             : static const NativePropertiesN<1> sNativeProperties = {
     294             :   false, 0,
     295             :   false, 0,
     296             :   false, 0,
     297             :   true,  0 /* sAttributes */,
     298             :   false, 0,
     299             :   false, 0,
     300             :   false, 0,
     301             :   -1,
     302             :   3,
     303             :   sNativeProperties_sortedPropertyIndices,
     304             :   {
     305             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     306             :   }
     307             : };
     308             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     309             :     "We have a property info count that is oversized");
     310             : 
     311             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     312             :   {
     313             :     "Function",
     314             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     315             :     &sBoringInterfaceObjectClassClassOps,
     316             :     JS_NULL_CLASS_SPEC,
     317             :     JS_NULL_CLASS_EXT,
     318             :     &sInterfaceObjectClassObjectOps
     319             :   },
     320             :   eInterface,
     321             :   true,
     322             :   prototypes::id::Grid,
     323             :   PrototypeTraits<prototypes::id::Grid>::Depth,
     324             :   sNativePropertyHooks,
     325             :   "function Grid() {\n    [native code]\n}",
     326             :   JS::GetRealmFunctionPrototype
     327             : };
     328             : 
     329             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     330             :   {
     331             :     "GridPrototype",
     332             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     333             :     JS_NULL_CLASS_OPS,
     334             :     JS_NULL_CLASS_SPEC,
     335             :     JS_NULL_CLASS_EXT,
     336             :     JS_NULL_OBJECT_OPS
     337             :   },
     338             :   eInterfacePrototype,
     339             :   false,
     340             :   prototypes::id::Grid,
     341             :   PrototypeTraits<prototypes::id::Grid>::Depth,
     342             :   sNativePropertyHooks,
     343             :   "[object GridPrototype]",
     344             :   JS::GetRealmObjectPrototype
     345             : };
     346             : 
     347             : bool
     348           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     349             : {
     350           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
     351             : }
     352             : 
     353             : JSObject*
     354           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     355             : {
     356           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     357             : }
     358             : 
     359             : static const js::ClassOps sClassOps = {
     360             :   _addProperty, /* addProperty */
     361             :   nullptr,               /* delProperty */
     362             :   nullptr,               /* getProperty */
     363             :   nullptr,               /* setProperty */
     364             :   nullptr,               /* enumerate */
     365             :   nullptr, /* newEnumerate */
     366             :   nullptr, /* resolve */
     367             :   nullptr, /* mayResolve */
     368             :   _finalize, /* finalize */
     369             :   nullptr, /* call */
     370             :   nullptr,               /* hasInstance */
     371             :   nullptr,               /* construct */
     372             :   nullptr, /* trace */
     373             : };
     374             : 
     375             : static const js::ClassExtension sClassExtension = {
     376             :   nullptr, /* weakmapKeyDelegateOp */
     377             :   _objectMoved /* objectMovedOp */
     378             : };
     379             : 
     380             : static const DOMJSClass sClass = {
     381             :   { "Grid",
     382             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
     383             :     &sClassOps,
     384             :     JS_NULL_CLASS_SPEC,
     385             :     &sClassExtension,
     386             :     JS_NULL_OBJECT_OPS
     387             :   },
     388             :   { prototypes::id::Grid, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     389             :   IsBaseOf<nsISupports, mozilla::dom::Grid >::value,
     390             :   sNativePropertyHooks,
     391             :   FindAssociatedGlobalForNative<mozilla::dom::Grid>::Get,
     392             :   GetProtoObjectHandle,
     393             :   GetCCParticipant<mozilla::dom::Grid>::Get()
     394             : };
     395             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     396             :               "Must have the right minimal number of reserved slots.");
     397             : static_assert(2 >= 2,
     398             :               "Must have enough reserved slots.");
     399             : 
     400             : const JSClass*
     401           0 : GetJSClass()
     402             : {
     403           0 :   return sClass.ToJSClass();
     404             : }
     405             : 
     406             : bool
     407           0 : Wrap(JSContext* aCx, mozilla::dom::Grid* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     408             : {
     409             :   MOZ_ASSERT(static_cast<mozilla::dom::Grid*>(aObject) ==
     410             :              reinterpret_cast<mozilla::dom::Grid*>(aObject),
     411             :              "Multiple inheritance for mozilla::dom::Grid is broken.");
     412           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     413           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     414           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     415             :              "You should probably not be using Wrap() directly; use "
     416             :              "GetOrCreateDOMReflector instead");
     417             : 
     418           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     419             :              "nsISupports must be on our primary inheritance chain");
     420             : 
     421           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     422           0 :   if (!global) {
     423           0 :     return false;
     424             :   }
     425           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     426           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     427             : 
     428             :   // That might have ended up wrapping us already, due to the wonders
     429             :   // of XBL.  Check for that, and bail out as needed.
     430           0 :   aReflector.set(aCache->GetWrapper());
     431           0 :   if (aReflector) {
     432             : #ifdef DEBUG
     433           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     434             : #endif // DEBUG
     435           0 :     return true;
     436             :   }
     437             : 
     438           0 :   JSAutoCompartment ac(aCx, global);
     439           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     440           0 :   if (!canonicalProto) {
     441           0 :     return false;
     442             :   }
     443           0 :   JS::Rooted<JSObject*> proto(aCx);
     444           0 :   if (aGivenProto) {
     445           0 :     proto = aGivenProto;
     446             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     447             :     // coming in, we changed compartments to that of "parent" so may need
     448             :     // to wrap the proto here.
     449           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     450           0 :       if (!JS_WrapObject(aCx, &proto)) {
     451           0 :         return false;
     452             :       }
     453             :     }
     454             :   } else {
     455           0 :     proto = canonicalProto;
     456             :   }
     457             : 
     458           0 :   BindingJSObjectCreator<mozilla::dom::Grid> creator(aCx);
     459           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     460           0 :   if (!aReflector) {
     461           0 :     return false;
     462             :   }
     463             : 
     464           0 :   aCache->SetWrapper(aReflector);
     465           0 :   creator.InitializationSucceeded();
     466             : 
     467           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     468             :              aCache->GetWrapperPreserveColor() == aReflector);
     469             :   // If proto != canonicalProto, we have to preserve our wrapper;
     470             :   // otherwise we won't be able to properly recreate it later, since
     471             :   // we won't know what proto to use.  Note that we don't check
     472             :   // aGivenProto here, since it's entirely possible (and even
     473             :   // somewhat common) to have a non-null aGivenProto which is the
     474             :   // same as canonicalProto.
     475           0 :   if (proto != canonicalProto) {
     476           0 :     PreserveWrapper(aObject);
     477             :   }
     478             : 
     479           0 :   return true;
     480             : }
     481             : 
     482             : // This may allocate too many slots, because we only really need
     483             : // slots for our non-interface-typed members that we cache.  But
     484             : // allocating slots only for those would make the slot index
     485             : // computations much more complicated, so let's do this the simple
     486             : // way for now.
     487             : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
     488             : 
     489             : const NativePropertyHooks sNativePropertyHooks[] = { {
     490             :   nullptr,
     491             :   nullptr,
     492             :   nullptr,
     493             :   { sNativeProperties.Upcast(), nullptr },
     494             :   prototypes::id::Grid,
     495             :   constructors::id::Grid,
     496             :   nullptr,
     497             :   &sXrayExpandoObjectClass
     498             : } };
     499             : 
     500             : void
     501           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     502             : {
     503           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     504           0 :   if (!parentProto) {
     505           0 :     return;
     506             :   }
     507             : 
     508           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     509           0 :   if (!constructorProto) {
     510           0 :     return;
     511             :   }
     512             : 
     513             :   static bool sIdsInited = false;
     514           0 :   if (!sIdsInited && NS_IsMainThread()) {
     515           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     516           0 :       return;
     517             :     }
     518           0 :     sIdsInited = true;
     519             :   }
     520             : 
     521           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Grid);
     522           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Grid);
     523           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     524             :                               &sPrototypeClass.mBase, protoCache,
     525             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     526             :                               interfaceCache,
     527             :                               sNativeProperties.Upcast(),
     528             :                               nullptr,
     529             :                               "Grid", aDefineOnGlobal,
     530             :                               nullptr,
     531           0 :                               false);
     532             : }
     533             : 
     534             : JS::Handle<JSObject*>
     535           0 : GetProtoObjectHandle(JSContext* aCx)
     536             : {
     537             :   /* Get the interface prototype object for this class.  This will create the
     538             :      object as needed. */
     539           0 :   bool aDefineOnGlobal = true;
     540             : 
     541             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     542           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     543           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     544           0 :     return nullptr;
     545             :   }
     546             : 
     547             :   /* Check to see whether the interface objects are already installed */
     548           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     549           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Grid)) {
     550           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     551           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     552             :   }
     553             : 
     554             :   /*
     555             :    * The object might _still_ be null, but that's OK.
     556             :    *
     557             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     558             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     559             :    * changed after they have been set.
     560             :    *
     561             :    * Calling address() avoids the read read barrier that does gray
     562             :    * unmarking, but it's not possible for the object to be gray here.
     563             :    */
     564             : 
     565           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Grid);
     566           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     567           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     568             : }
     569             : 
     570             : JS::Handle<JSObject*>
     571           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     572             : {
     573             :   /* Get the interface object for this class.  This will create the object as
     574             :      needed. */
     575             : 
     576             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     577           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     578           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     579           0 :     return nullptr;
     580             :   }
     581             : 
     582             :   /* Check to see whether the interface objects are already installed */
     583           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     584           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::Grid)) {
     585           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     586           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     587             :   }
     588             : 
     589             :   /*
     590             :    * The object might _still_ be null, but that's OK.
     591             :    *
     592             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     593             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     594             :    * changed after they have been set.
     595             :    *
     596             :    * Calling address() avoids the read read barrier that does gray
     597             :    * unmarking, but it's not possible for the object to be gray here.
     598             :    */
     599             : 
     600           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::Grid);
     601           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     602           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     603             : }
     604             : 
     605             : JSObject*
     606           0 : GetConstructorObject(JSContext* aCx)
     607             : {
     608           0 :   return GetConstructorObjectHandle(aCx);
     609             : }
     610             : 
     611             : } // namespace GridBinding
     612             : 
     613             : 
     614             : 
     615             : namespace GridAreaBinding {
     616             : 
     617             : static bool
     618           0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
     619             : {
     620           0 :   DOMString result;
     621           0 :   self->GetName(result);
     622           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     623           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     624           0 :     return false;
     625             :   }
     626           0 :   return true;
     627             : }
     628             : 
     629             : static const JSJitInfo name_getterinfo = {
     630             :   { (JSJitGetterOp)get_name },
     631             :   { prototypes::id::GridArea },
     632             :   { PrototypeTraits<prototypes::id::GridArea>::Depth },
     633             :   JSJitInfo::Getter,
     634             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     635             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     636             :   false,  /* isInfallible. False in setters. */
     637             :   false,  /* isMovable.  Not relevant for setters. */
     638             :   false, /* isEliminatable.  Not relevant for setters. */
     639             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     640             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     641             :   false,  /* isTypedMethod.  Only relevant for methods. */
     642             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     643             : };
     644             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     645             : static_assert(0 < 1, "There is no slot for us");
     646             : 
     647             : static bool
     648           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
     649             : {
     650           0 :   GridDeclaration result(self->Type());
     651           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     652           0 :   if (!ToJSValue(cx, result, args.rval())) {
     653           0 :     return false;
     654             :   }
     655           0 :   return true;
     656             : }
     657             : 
     658             : static const JSJitInfo type_getterinfo = {
     659             :   { (JSJitGetterOp)get_type },
     660             :   { prototypes::id::GridArea },
     661             :   { PrototypeTraits<prototypes::id::GridArea>::Depth },
     662             :   JSJitInfo::Getter,
     663             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     664             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     665             :   false,  /* isInfallible. False in setters. */
     666             :   false,  /* isMovable.  Not relevant for setters. */
     667             :   false, /* isEliminatable.  Not relevant for setters. */
     668             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     669             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     670             :   false,  /* isTypedMethod.  Only relevant for methods. */
     671             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     672             : };
     673             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     674             : static_assert(0 < 1, "There is no slot for us");
     675             : 
     676             : static bool
     677           0 : get_rowStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
     678             : {
     679           0 :   uint32_t result(self->RowStart());
     680           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     681           0 :   args.rval().setNumber(result);
     682           0 :   return true;
     683             : }
     684             : 
     685             : static const JSJitInfo rowStart_getterinfo = {
     686             :   { (JSJitGetterOp)get_rowStart },
     687             :   { prototypes::id::GridArea },
     688             :   { PrototypeTraits<prototypes::id::GridArea>::Depth },
     689             :   JSJitInfo::Getter,
     690             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     691             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     692             :   true,  /* isInfallible. False in setters. */
     693             :   false,  /* isMovable.  Not relevant for setters. */
     694             :   false, /* isEliminatable.  Not relevant for setters. */
     695             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     696             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     697             :   false,  /* isTypedMethod.  Only relevant for methods. */
     698             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     699             : };
     700             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     701             : static_assert(0 < 1, "There is no slot for us");
     702             : 
     703             : static bool
     704           0 : get_rowEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
     705             : {
     706           0 :   uint32_t result(self->RowEnd());
     707           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     708           0 :   args.rval().setNumber(result);
     709           0 :   return true;
     710             : }
     711             : 
     712             : static const JSJitInfo rowEnd_getterinfo = {
     713             :   { (JSJitGetterOp)get_rowEnd },
     714             :   { prototypes::id::GridArea },
     715             :   { PrototypeTraits<prototypes::id::GridArea>::Depth },
     716             :   JSJitInfo::Getter,
     717             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     718             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     719             :   true,  /* isInfallible. False in setters. */
     720             :   false,  /* isMovable.  Not relevant for setters. */
     721             :   false, /* isEliminatable.  Not relevant for setters. */
     722             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     723             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     724             :   false,  /* isTypedMethod.  Only relevant for methods. */
     725             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     726             : };
     727             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     728             : static_assert(0 < 1, "There is no slot for us");
     729             : 
     730             : static bool
     731           0 : get_columnStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
     732             : {
     733           0 :   uint32_t result(self->ColumnStart());
     734           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     735           0 :   args.rval().setNumber(result);
     736           0 :   return true;
     737             : }
     738             : 
     739             : static const JSJitInfo columnStart_getterinfo = {
     740             :   { (JSJitGetterOp)get_columnStart },
     741             :   { prototypes::id::GridArea },
     742             :   { PrototypeTraits<prototypes::id::GridArea>::Depth },
     743             :   JSJitInfo::Getter,
     744             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     745             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     746             :   true,  /* isInfallible. False in setters. */
     747             :   false,  /* isMovable.  Not relevant for setters. */
     748             :   false, /* isEliminatable.  Not relevant for setters. */
     749             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     750             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     751             :   false,  /* isTypedMethod.  Only relevant for methods. */
     752             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     753             : };
     754             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     755             : static_assert(0 < 1, "There is no slot for us");
     756             : 
     757             : static bool
     758           0 : get_columnEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridArea* self, JSJitGetterCallArgs args)
     759             : {
     760           0 :   uint32_t result(self->ColumnEnd());
     761           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     762           0 :   args.rval().setNumber(result);
     763           0 :   return true;
     764             : }
     765             : 
     766             : static const JSJitInfo columnEnd_getterinfo = {
     767             :   { (JSJitGetterOp)get_columnEnd },
     768             :   { prototypes::id::GridArea },
     769             :   { PrototypeTraits<prototypes::id::GridArea>::Depth },
     770             :   JSJitInfo::Getter,
     771             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     772             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     773             :   true,  /* isInfallible. False in setters. */
     774             :   false,  /* isMovable.  Not relevant for setters. */
     775             :   false, /* isEliminatable.  Not relevant for setters. */
     776             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     777             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     778             :   false,  /* isTypedMethod.  Only relevant for methods. */
     779             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     780             : };
     781             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     782             : static_assert(0 < 1, "There is no slot for us");
     783             : 
     784             : static bool
     785           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     786             : {
     787           0 :   mozilla::dom::GridArea* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridArea>(obj);
     788             :   // We don't want to preserve if we don't have a wrapper, and we
     789             :   // obviously can't preserve if we're not initialized.
     790           0 :   if (self && self->GetWrapperPreserveColor()) {
     791           0 :     PreserveWrapper(self);
     792             :   }
     793           0 :   return true;
     794             : }
     795             : 
     796             : static void
     797           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     798             : {
     799           0 :   mozilla::dom::GridArea* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridArea>(obj);
     800           0 :   if (self) {
     801           0 :     ClearWrapper(self, self, obj);
     802           0 :     AddForDeferredFinalization<mozilla::dom::GridArea>(self);
     803             :   }
     804           0 : }
     805             : 
     806             : static void
     807           0 : _objectMoved(JSObject* obj, const JSObject* old)
     808             : {
     809           0 :   mozilla::dom::GridArea* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridArea>(obj);
     810           0 :   if (self) {
     811           0 :     UpdateWrapper(self, self, obj, old);
     812             :   }
     813           0 : }
     814             : 
     815             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     816             : #if defined(__clang__)
     817             : #pragma clang diagnostic push
     818             : #pragma clang diagnostic ignored "-Wmissing-braces"
     819             : #endif
     820             : static const JSPropertySpec sAttributes_specs[] = {
     821             :   { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, nullptr, nullptr },
     822             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
     823             :   { "rowStart", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rowStart_getterinfo, nullptr, nullptr },
     824             :   { "rowEnd", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rowEnd_getterinfo, nullptr, nullptr },
     825             :   { "columnStart", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &columnStart_getterinfo, nullptr, nullptr },
     826             :   { "columnEnd", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &columnEnd_getterinfo, nullptr, nullptr },
     827             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     828             : };
     829             : #if defined(__clang__)
     830             : #pragma clang diagnostic pop
     831             : #endif
     832             : 
     833             : 
     834             : // Can't be const because the pref-enabled boolean needs to be writable
     835             : static Prefable<const JSPropertySpec> sAttributes[] = {
     836             :   { nullptr, &sAttributes_specs[0] },
     837             :   { nullptr, nullptr }
     838             : };
     839             : 
     840             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     841             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     842             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     843             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     844             : 
     845             : 
     846             : static uint16_t sNativeProperties_sortedPropertyIndices[6];
     847             : static PropertyInfo sNativeProperties_propertyInfos[6];
     848             : 
     849             : static const NativePropertiesN<1> sNativeProperties = {
     850             :   false, 0,
     851             :   false, 0,
     852             :   false, 0,
     853             :   true,  0 /* sAttributes */,
     854             :   false, 0,
     855             :   false, 0,
     856             :   false, 0,
     857             :   -1,
     858             :   6,
     859             :   sNativeProperties_sortedPropertyIndices,
     860             :   {
     861             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     862             :   }
     863             : };
     864             : static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     865             :     "We have a property info count that is oversized");
     866             : 
     867             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     868             :   {
     869             :     "Function",
     870             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     871             :     &sBoringInterfaceObjectClassClassOps,
     872             :     JS_NULL_CLASS_SPEC,
     873             :     JS_NULL_CLASS_EXT,
     874             :     &sInterfaceObjectClassObjectOps
     875             :   },
     876             :   eInterface,
     877             :   true,
     878             :   prototypes::id::GridArea,
     879             :   PrototypeTraits<prototypes::id::GridArea>::Depth,
     880             :   sNativePropertyHooks,
     881             :   "function GridArea() {\n    [native code]\n}",
     882             :   JS::GetRealmFunctionPrototype
     883             : };
     884             : 
     885             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     886             :   {
     887             :     "GridAreaPrototype",
     888             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     889             :     JS_NULL_CLASS_OPS,
     890             :     JS_NULL_CLASS_SPEC,
     891             :     JS_NULL_CLASS_EXT,
     892             :     JS_NULL_OBJECT_OPS
     893             :   },
     894             :   eInterfacePrototype,
     895             :   false,
     896             :   prototypes::id::GridArea,
     897             :   PrototypeTraits<prototypes::id::GridArea>::Depth,
     898             :   sNativePropertyHooks,
     899             :   "[object GridAreaPrototype]",
     900             :   JS::GetRealmObjectPrototype
     901             : };
     902             : 
     903             : bool
     904           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     905             : {
     906           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
     907             : }
     908             : 
     909             : JSObject*
     910           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     911             : {
     912           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     913             : }
     914             : 
     915             : static const js::ClassOps sClassOps = {
     916             :   _addProperty, /* addProperty */
     917             :   nullptr,               /* delProperty */
     918             :   nullptr,               /* getProperty */
     919             :   nullptr,               /* setProperty */
     920             :   nullptr,               /* enumerate */
     921             :   nullptr, /* newEnumerate */
     922             :   nullptr, /* resolve */
     923             :   nullptr, /* mayResolve */
     924             :   _finalize, /* finalize */
     925             :   nullptr, /* call */
     926             :   nullptr,               /* hasInstance */
     927             :   nullptr,               /* construct */
     928             :   nullptr, /* trace */
     929             : };
     930             : 
     931             : static const js::ClassExtension sClassExtension = {
     932             :   nullptr, /* weakmapKeyDelegateOp */
     933             :   _objectMoved /* objectMovedOp */
     934             : };
     935             : 
     936             : static const DOMJSClass sClass = {
     937             :   { "GridArea",
     938             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     939             :     &sClassOps,
     940             :     JS_NULL_CLASS_SPEC,
     941             :     &sClassExtension,
     942             :     JS_NULL_OBJECT_OPS
     943             :   },
     944             :   { prototypes::id::GridArea, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     945             :   IsBaseOf<nsISupports, mozilla::dom::GridArea >::value,
     946             :   sNativePropertyHooks,
     947             :   FindAssociatedGlobalForNative<mozilla::dom::GridArea>::Get,
     948             :   GetProtoObjectHandle,
     949             :   GetCCParticipant<mozilla::dom::GridArea>::Get()
     950             : };
     951             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     952             :               "Must have the right minimal number of reserved slots.");
     953             : static_assert(1 >= 1,
     954             :               "Must have enough reserved slots.");
     955             : 
     956             : const JSClass*
     957           0 : GetJSClass()
     958             : {
     959           0 :   return sClass.ToJSClass();
     960             : }
     961             : 
     962             : bool
     963           0 : Wrap(JSContext* aCx, mozilla::dom::GridArea* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     964             : {
     965             :   MOZ_ASSERT(static_cast<mozilla::dom::GridArea*>(aObject) ==
     966             :              reinterpret_cast<mozilla::dom::GridArea*>(aObject),
     967             :              "Multiple inheritance for mozilla::dom::GridArea is broken.");
     968           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     969           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     970           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     971             :              "You should probably not be using Wrap() directly; use "
     972             :              "GetOrCreateDOMReflector instead");
     973             : 
     974           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     975             :              "nsISupports must be on our primary inheritance chain");
     976             : 
     977           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     978           0 :   if (!global) {
     979           0 :     return false;
     980             :   }
     981           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     982           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     983             : 
     984             :   // That might have ended up wrapping us already, due to the wonders
     985             :   // of XBL.  Check for that, and bail out as needed.
     986           0 :   aReflector.set(aCache->GetWrapper());
     987           0 :   if (aReflector) {
     988             : #ifdef DEBUG
     989           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     990             : #endif // DEBUG
     991           0 :     return true;
     992             :   }
     993             : 
     994           0 :   JSAutoCompartment ac(aCx, global);
     995           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     996           0 :   if (!canonicalProto) {
     997           0 :     return false;
     998             :   }
     999           0 :   JS::Rooted<JSObject*> proto(aCx);
    1000           0 :   if (aGivenProto) {
    1001           0 :     proto = aGivenProto;
    1002             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1003             :     // coming in, we changed compartments to that of "parent" so may need
    1004             :     // to wrap the proto here.
    1005           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1006           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1007           0 :         return false;
    1008             :       }
    1009             :     }
    1010             :   } else {
    1011           0 :     proto = canonicalProto;
    1012             :   }
    1013             : 
    1014           0 :   BindingJSObjectCreator<mozilla::dom::GridArea> creator(aCx);
    1015           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1016           0 :   if (!aReflector) {
    1017           0 :     return false;
    1018             :   }
    1019             : 
    1020           0 :   aCache->SetWrapper(aReflector);
    1021           0 :   creator.InitializationSucceeded();
    1022             : 
    1023           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1024             :              aCache->GetWrapperPreserveColor() == aReflector);
    1025             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1026             :   // otherwise we won't be able to properly recreate it later, since
    1027             :   // we won't know what proto to use.  Note that we don't check
    1028             :   // aGivenProto here, since it's entirely possible (and even
    1029             :   // somewhat common) to have a non-null aGivenProto which is the
    1030             :   // same as canonicalProto.
    1031           0 :   if (proto != canonicalProto) {
    1032           0 :     PreserveWrapper(aObject);
    1033             :   }
    1034             : 
    1035           0 :   return true;
    1036             : }
    1037             : 
    1038             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1039             :   nullptr,
    1040             :   nullptr,
    1041             :   nullptr,
    1042             :   { sNativeProperties.Upcast(), nullptr },
    1043             :   prototypes::id::GridArea,
    1044             :   constructors::id::GridArea,
    1045             :   nullptr,
    1046             :   &DefaultXrayExpandoObjectClass
    1047             : } };
    1048             : 
    1049             : void
    1050           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1051             : {
    1052           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1053           0 :   if (!parentProto) {
    1054           0 :     return;
    1055             :   }
    1056             : 
    1057           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1058           0 :   if (!constructorProto) {
    1059           0 :     return;
    1060             :   }
    1061             : 
    1062             :   static bool sIdsInited = false;
    1063           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1064           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1065           0 :       return;
    1066             :     }
    1067           0 :     sIdsInited = true;
    1068             :   }
    1069             : 
    1070           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridArea);
    1071           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridArea);
    1072           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1073             :                               &sPrototypeClass.mBase, protoCache,
    1074             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1075             :                               interfaceCache,
    1076             :                               sNativeProperties.Upcast(),
    1077             :                               nullptr,
    1078             :                               "GridArea", aDefineOnGlobal,
    1079             :                               nullptr,
    1080           0 :                               false);
    1081             : }
    1082             : 
    1083             : JS::Handle<JSObject*>
    1084           0 : GetProtoObjectHandle(JSContext* aCx)
    1085             : {
    1086             :   /* Get the interface prototype object for this class.  This will create the
    1087             :      object as needed. */
    1088           0 :   bool aDefineOnGlobal = true;
    1089             : 
    1090             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1091           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1092           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1093           0 :     return nullptr;
    1094             :   }
    1095             : 
    1096             :   /* Check to see whether the interface objects are already installed */
    1097           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1098           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GridArea)) {
    1099           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1100           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1101             :   }
    1102             : 
    1103             :   /*
    1104             :    * The object might _still_ be null, but that's OK.
    1105             :    *
    1106             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1107             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1108             :    * changed after they have been set.
    1109             :    *
    1110             :    * Calling address() avoids the read read barrier that does gray
    1111             :    * unmarking, but it's not possible for the object to be gray here.
    1112             :    */
    1113             : 
    1114           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GridArea);
    1115           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1116           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1117             : }
    1118             : 
    1119             : JS::Handle<JSObject*>
    1120           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1121             : {
    1122             :   /* Get the interface object for this class.  This will create the object as
    1123             :      needed. */
    1124             : 
    1125             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1126           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1127           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1128           0 :     return nullptr;
    1129             :   }
    1130             : 
    1131             :   /* Check to see whether the interface objects are already installed */
    1132           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1133           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GridArea)) {
    1134           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1135           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1136             :   }
    1137             : 
    1138             :   /*
    1139             :    * The object might _still_ be null, but that's OK.
    1140             :    *
    1141             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1142             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1143             :    * changed after they have been set.
    1144             :    *
    1145             :    * Calling address() avoids the read read barrier that does gray
    1146             :    * unmarking, but it's not possible for the object to be gray here.
    1147             :    */
    1148             : 
    1149           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GridArea);
    1150           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1151           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1152             : }
    1153             : 
    1154             : JSObject*
    1155           0 : GetConstructorObject(JSContext* aCx)
    1156             : {
    1157           0 :   return GetConstructorObjectHandle(aCx);
    1158             : }
    1159             : 
    1160             : } // namespace GridAreaBinding
    1161             : 
    1162             : 
    1163             : 
    1164             : namespace GridDimensionBinding {
    1165             : 
    1166             : static bool
    1167           0 : get_lines(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridDimension* self, JSJitGetterCallArgs args)
    1168             : {
    1169           0 :   auto result(StrongOrRawPtr<mozilla::dom::GridLines>(self->Lines()));
    1170           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1171           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    1172           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1173           0 :     return false;
    1174             :   }
    1175           0 :   return true;
    1176             : }
    1177             : 
    1178             : static const JSJitInfo lines_getterinfo = {
    1179             :   { (JSJitGetterOp)get_lines },
    1180             :   { prototypes::id::GridDimension },
    1181             :   { PrototypeTraits<prototypes::id::GridDimension>::Depth },
    1182             :   JSJitInfo::Getter,
    1183             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1184             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1185             :   false,  /* isInfallible. False in setters. */
    1186             :   false,  /* isMovable.  Not relevant for setters. */
    1187             :   false, /* isEliminatable.  Not relevant for setters. */
    1188             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1189             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1190             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1191             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1192             : };
    1193             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1194             : static_assert(0 < 1, "There is no slot for us");
    1195             : 
    1196             : static bool
    1197           0 : get_tracks(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridDimension* self, JSJitGetterCallArgs args)
    1198             : {
    1199           0 :   auto result(StrongOrRawPtr<mozilla::dom::GridTracks>(self->Tracks()));
    1200           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1201           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    1202           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1203           0 :     return false;
    1204             :   }
    1205           0 :   return true;
    1206             : }
    1207             : 
    1208             : static const JSJitInfo tracks_getterinfo = {
    1209             :   { (JSJitGetterOp)get_tracks },
    1210             :   { prototypes::id::GridDimension },
    1211             :   { PrototypeTraits<prototypes::id::GridDimension>::Depth },
    1212             :   JSJitInfo::Getter,
    1213             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1214             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1215             :   false,  /* isInfallible. False in setters. */
    1216             :   false,  /* isMovable.  Not relevant for setters. */
    1217             :   false, /* isEliminatable.  Not relevant for setters. */
    1218             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1219             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1220             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1221             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1222             : };
    1223             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1224             : static_assert(0 < 1, "There is no slot for us");
    1225             : 
    1226             : static bool
    1227           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1228             : {
    1229           0 :   mozilla::dom::GridDimension* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridDimension>(obj);
    1230             :   // We don't want to preserve if we don't have a wrapper, and we
    1231             :   // obviously can't preserve if we're not initialized.
    1232           0 :   if (self && self->GetWrapperPreserveColor()) {
    1233           0 :     PreserveWrapper(self);
    1234             :   }
    1235           0 :   return true;
    1236             : }
    1237             : 
    1238             : static void
    1239           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1240             : {
    1241           0 :   mozilla::dom::GridDimension* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridDimension>(obj);
    1242           0 :   if (self) {
    1243           0 :     ClearWrapper(self, self, obj);
    1244           0 :     AddForDeferredFinalization<mozilla::dom::GridDimension>(self);
    1245             :   }
    1246           0 : }
    1247             : 
    1248             : static void
    1249           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1250             : {
    1251           0 :   mozilla::dom::GridDimension* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridDimension>(obj);
    1252           0 :   if (self) {
    1253           0 :     UpdateWrapper(self, self, obj, old);
    1254             :   }
    1255           0 : }
    1256             : 
    1257             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1258             : #if defined(__clang__)
    1259             : #pragma clang diagnostic push
    1260             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1261             : #endif
    1262             : static const JSPropertySpec sAttributes_specs[] = {
    1263             :   { "lines", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lines_getterinfo, nullptr, nullptr },
    1264             :   { "tracks", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &tracks_getterinfo, nullptr, nullptr },
    1265             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1266             : };
    1267             : #if defined(__clang__)
    1268             : #pragma clang diagnostic pop
    1269             : #endif
    1270             : 
    1271             : 
    1272             : // Can't be const because the pref-enabled boolean needs to be writable
    1273             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1274             :   { nullptr, &sAttributes_specs[0] },
    1275             :   { nullptr, nullptr }
    1276             : };
    1277             : 
    1278             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1279             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1280             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1281             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1282             : 
    1283             : 
    1284             : static uint16_t sNativeProperties_sortedPropertyIndices[2];
    1285             : static PropertyInfo sNativeProperties_propertyInfos[2];
    1286             : 
    1287             : static const NativePropertiesN<1> sNativeProperties = {
    1288             :   false, 0,
    1289             :   false, 0,
    1290             :   false, 0,
    1291             :   true,  0 /* sAttributes */,
    1292             :   false, 0,
    1293             :   false, 0,
    1294             :   false, 0,
    1295             :   -1,
    1296             :   2,
    1297             :   sNativeProperties_sortedPropertyIndices,
    1298             :   {
    1299             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    1300             :   }
    1301             : };
    1302             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1303             :     "We have a property info count that is oversized");
    1304             : 
    1305             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1306             :   {
    1307             :     "Function",
    1308             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1309             :     &sBoringInterfaceObjectClassClassOps,
    1310             :     JS_NULL_CLASS_SPEC,
    1311             :     JS_NULL_CLASS_EXT,
    1312             :     &sInterfaceObjectClassObjectOps
    1313             :   },
    1314             :   eInterface,
    1315             :   true,
    1316             :   prototypes::id::GridDimension,
    1317             :   PrototypeTraits<prototypes::id::GridDimension>::Depth,
    1318             :   sNativePropertyHooks,
    1319             :   "function GridDimension() {\n    [native code]\n}",
    1320             :   JS::GetRealmFunctionPrototype
    1321             : };
    1322             : 
    1323             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1324             :   {
    1325             :     "GridDimensionPrototype",
    1326             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1327             :     JS_NULL_CLASS_OPS,
    1328             :     JS_NULL_CLASS_SPEC,
    1329             :     JS_NULL_CLASS_EXT,
    1330             :     JS_NULL_OBJECT_OPS
    1331             :   },
    1332             :   eInterfacePrototype,
    1333             :   false,
    1334             :   prototypes::id::GridDimension,
    1335             :   PrototypeTraits<prototypes::id::GridDimension>::Depth,
    1336             :   sNativePropertyHooks,
    1337             :   "[object GridDimensionPrototype]",
    1338             :   JS::GetRealmObjectPrototype
    1339             : };
    1340             : 
    1341             : bool
    1342           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1343             : {
    1344           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
    1345             : }
    1346             : 
    1347             : JSObject*
    1348           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1349             : {
    1350           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1351             : }
    1352             : 
    1353             : static const js::ClassOps sClassOps = {
    1354             :   _addProperty, /* addProperty */
    1355             :   nullptr,               /* delProperty */
    1356             :   nullptr,               /* getProperty */
    1357             :   nullptr,               /* setProperty */
    1358             :   nullptr,               /* enumerate */
    1359             :   nullptr, /* newEnumerate */
    1360             :   nullptr, /* resolve */
    1361             :   nullptr, /* mayResolve */
    1362             :   _finalize, /* finalize */
    1363             :   nullptr, /* call */
    1364             :   nullptr,               /* hasInstance */
    1365             :   nullptr,               /* construct */
    1366             :   nullptr, /* trace */
    1367             : };
    1368             : 
    1369             : static const js::ClassExtension sClassExtension = {
    1370             :   nullptr, /* weakmapKeyDelegateOp */
    1371             :   _objectMoved /* objectMovedOp */
    1372             : };
    1373             : 
    1374             : static const DOMJSClass sClass = {
    1375             :   { "GridDimension",
    1376             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1377             :     &sClassOps,
    1378             :     JS_NULL_CLASS_SPEC,
    1379             :     &sClassExtension,
    1380             :     JS_NULL_OBJECT_OPS
    1381             :   },
    1382             :   { prototypes::id::GridDimension, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    1383             :   IsBaseOf<nsISupports, mozilla::dom::GridDimension >::value,
    1384             :   sNativePropertyHooks,
    1385             :   FindAssociatedGlobalForNative<mozilla::dom::GridDimension>::Get,
    1386             :   GetProtoObjectHandle,
    1387             :   GetCCParticipant<mozilla::dom::GridDimension>::Get()
    1388             : };
    1389             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1390             :               "Must have the right minimal number of reserved slots.");
    1391             : static_assert(1 >= 1,
    1392             :               "Must have enough reserved slots.");
    1393             : 
    1394             : const JSClass*
    1395           0 : GetJSClass()
    1396             : {
    1397           0 :   return sClass.ToJSClass();
    1398             : }
    1399             : 
    1400             : bool
    1401           0 : Wrap(JSContext* aCx, mozilla::dom::GridDimension* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1402             : {
    1403             :   MOZ_ASSERT(static_cast<mozilla::dom::GridDimension*>(aObject) ==
    1404             :              reinterpret_cast<mozilla::dom::GridDimension*>(aObject),
    1405             :              "Multiple inheritance for mozilla::dom::GridDimension is broken.");
    1406           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1407           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1408           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1409             :              "You should probably not be using Wrap() directly; use "
    1410             :              "GetOrCreateDOMReflector instead");
    1411             : 
    1412           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1413             :              "nsISupports must be on our primary inheritance chain");
    1414             : 
    1415           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1416           0 :   if (!global) {
    1417           0 :     return false;
    1418             :   }
    1419           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1420           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1421             : 
    1422             :   // That might have ended up wrapping us already, due to the wonders
    1423             :   // of XBL.  Check for that, and bail out as needed.
    1424           0 :   aReflector.set(aCache->GetWrapper());
    1425           0 :   if (aReflector) {
    1426             : #ifdef DEBUG
    1427           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1428             : #endif // DEBUG
    1429           0 :     return true;
    1430             :   }
    1431             : 
    1432           0 :   JSAutoCompartment ac(aCx, global);
    1433           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1434           0 :   if (!canonicalProto) {
    1435           0 :     return false;
    1436             :   }
    1437           0 :   JS::Rooted<JSObject*> proto(aCx);
    1438           0 :   if (aGivenProto) {
    1439           0 :     proto = aGivenProto;
    1440             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1441             :     // coming in, we changed compartments to that of "parent" so may need
    1442             :     // to wrap the proto here.
    1443           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1444           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1445           0 :         return false;
    1446             :       }
    1447             :     }
    1448             :   } else {
    1449           0 :     proto = canonicalProto;
    1450             :   }
    1451             : 
    1452           0 :   BindingJSObjectCreator<mozilla::dom::GridDimension> creator(aCx);
    1453           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1454           0 :   if (!aReflector) {
    1455           0 :     return false;
    1456             :   }
    1457             : 
    1458           0 :   aCache->SetWrapper(aReflector);
    1459           0 :   creator.InitializationSucceeded();
    1460             : 
    1461           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1462             :              aCache->GetWrapperPreserveColor() == aReflector);
    1463             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1464             :   // otherwise we won't be able to properly recreate it later, since
    1465             :   // we won't know what proto to use.  Note that we don't check
    1466             :   // aGivenProto here, since it's entirely possible (and even
    1467             :   // somewhat common) to have a non-null aGivenProto which is the
    1468             :   // same as canonicalProto.
    1469           0 :   if (proto != canonicalProto) {
    1470           0 :     PreserveWrapper(aObject);
    1471             :   }
    1472             : 
    1473           0 :   return true;
    1474             : }
    1475             : 
    1476             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1477             :   nullptr,
    1478             :   nullptr,
    1479             :   nullptr,
    1480             :   { sNativeProperties.Upcast(), nullptr },
    1481             :   prototypes::id::GridDimension,
    1482             :   constructors::id::GridDimension,
    1483             :   nullptr,
    1484             :   &DefaultXrayExpandoObjectClass
    1485             : } };
    1486             : 
    1487             : void
    1488           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1489             : {
    1490           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1491           0 :   if (!parentProto) {
    1492           0 :     return;
    1493             :   }
    1494             : 
    1495           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1496           0 :   if (!constructorProto) {
    1497           0 :     return;
    1498             :   }
    1499             : 
    1500             :   static bool sIdsInited = false;
    1501           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1502           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1503           0 :       return;
    1504             :     }
    1505           0 :     sIdsInited = true;
    1506             :   }
    1507             : 
    1508           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridDimension);
    1509           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridDimension);
    1510           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1511             :                               &sPrototypeClass.mBase, protoCache,
    1512             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1513             :                               interfaceCache,
    1514             :                               sNativeProperties.Upcast(),
    1515             :                               nullptr,
    1516             :                               "GridDimension", aDefineOnGlobal,
    1517             :                               nullptr,
    1518           0 :                               false);
    1519             : }
    1520             : 
    1521             : JS::Handle<JSObject*>
    1522           0 : GetProtoObjectHandle(JSContext* aCx)
    1523             : {
    1524             :   /* Get the interface prototype object for this class.  This will create the
    1525             :      object as needed. */
    1526           0 :   bool aDefineOnGlobal = true;
    1527             : 
    1528             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1529           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1530           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1531           0 :     return nullptr;
    1532             :   }
    1533             : 
    1534             :   /* Check to see whether the interface objects are already installed */
    1535           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1536           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GridDimension)) {
    1537           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1538           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1539             :   }
    1540             : 
    1541             :   /*
    1542             :    * The object might _still_ be null, but that's OK.
    1543             :    *
    1544             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1545             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1546             :    * changed after they have been set.
    1547             :    *
    1548             :    * Calling address() avoids the read read barrier that does gray
    1549             :    * unmarking, but it's not possible for the object to be gray here.
    1550             :    */
    1551             : 
    1552           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GridDimension);
    1553           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1554           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1555             : }
    1556             : 
    1557             : JS::Handle<JSObject*>
    1558           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1559             : {
    1560             :   /* Get the interface object for this class.  This will create the object as
    1561             :      needed. */
    1562             : 
    1563             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1564           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1565           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1566           0 :     return nullptr;
    1567             :   }
    1568             : 
    1569             :   /* Check to see whether the interface objects are already installed */
    1570           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1571           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GridDimension)) {
    1572           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1573           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1574             :   }
    1575             : 
    1576             :   /*
    1577             :    * The object might _still_ be null, but that's OK.
    1578             :    *
    1579             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1580             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1581             :    * changed after they have been set.
    1582             :    *
    1583             :    * Calling address() avoids the read read barrier that does gray
    1584             :    * unmarking, but it's not possible for the object to be gray here.
    1585             :    */
    1586             : 
    1587           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GridDimension);
    1588           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1589           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1590             : }
    1591             : 
    1592             : JSObject*
    1593           0 : GetConstructorObject(JSContext* aCx)
    1594             : {
    1595           0 :   return GetConstructorObjectHandle(aCx);
    1596             : }
    1597             : 
    1598             : } // namespace GridDimensionBinding
    1599             : 
    1600             : 
    1601             : 
    1602             : namespace GridLineBinding {
    1603             : 
    1604             : static bool
    1605           0 : get_names(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
    1606             : {
    1607             :   // Have to either root across the getter call or reget after.
    1608             :   bool isXray;
    1609           0 :   JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
    1610           0 :   if (!slotStorage) {
    1611           0 :     return false;
    1612             :   }
    1613           0 :   const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
    1614           0 :   MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
    1615             :   {
    1616             :     // Scope for cachedVal
    1617           0 :     JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
    1618           0 :     if (!cachedVal.isUndefined()) {
    1619           0 :       args.rval().set(cachedVal);
    1620             :       // The cached value is in the compartment of slotStorage,
    1621             :       // so wrap into the caller compartment as needed.
    1622           0 :       return MaybeWrapNonDOMObjectValue(cx, args.rval());
    1623             :     }
    1624             :   }
    1625             : 
    1626           0 :   nsTArray<nsString> result;
    1627           0 :   self->GetNames(result);
    1628           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1629             :   {
    1630           0 :     JS::Rooted<JSObject*> conversionScope(cx, isXray ? obj : slotStorage);
    1631           0 :     JSAutoCompartment ac(cx, conversionScope);
    1632             :     do { // block we break out of when done wrapping
    1633             : 
    1634           0 :       uint32_t length = result.Length();
    1635           0 :       JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
    1636           0 :       if (!returnArray) {
    1637           0 :         return false;
    1638             :       }
    1639             :       // Scope for 'tmp'
    1640             :       {
    1641           0 :         JS::Rooted<JS::Value> tmp(cx);
    1642           0 :         for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
    1643             :           // Control block to let us common up the JS_DefineElement calls when there
    1644             :           // are different ways to succeed at wrapping the object.
    1645             :           do {
    1646           0 :             if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
    1647           0 :               return false;
    1648             :             }
    1649           0 :             break;
    1650             :           } while (0);
    1651           0 :           if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
    1652             :                                 JSPROP_ENUMERATE)) {
    1653           0 :             return false;
    1654             :           }
    1655             :         }
    1656             :       }
    1657           0 :       args.rval().setObject(*returnArray);
    1658           0 :       break;
    1659             :     } while (0);
    1660             :   }
    1661             :   { // And now store things in the compartment of our slotStorage.
    1662           0 :     JSAutoCompartment ac(cx, slotStorage);
    1663             :     // Make a copy so that we don't do unnecessary wrapping on args.rval().
    1664           0 :     JS::Rooted<JS::Value> storedVal(cx, args.rval());
    1665           0 :     if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
    1666           0 :       return false;
    1667             :     }
    1668           0 :     js::SetReservedSlot(slotStorage, slotIndex, storedVal);
    1669           0 :     if (!isXray) {
    1670             :       // In the Xray case we don't need to do this, because getting the
    1671             :       // expando object already preserved our wrapper.
    1672           0 :       PreserveWrapper(self);
    1673             :     }
    1674             :   }
    1675             :   // And now make sure args.rval() is in the caller compartment
    1676           0 :   return MaybeWrapNonDOMObjectValue(cx, args.rval());
    1677             : }
    1678             : 
    1679             : static const JSJitInfo names_getterinfo = {
    1680             :   { (JSJitGetterOp)get_names },
    1681             :   { prototypes::id::GridLine },
    1682             :   { PrototypeTraits<prototypes::id::GridLine>::Depth },
    1683             :   JSJitInfo::Getter,
    1684             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    1685             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1686             :   false,  /* isInfallible. False in setters. */
    1687             :   true,  /* isMovable.  Not relevant for setters. */
    1688             :   true, /* isEliminatable.  Not relevant for setters. */
    1689             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1690             :   true, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1691             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1692             :   (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
    1693             : };
    1694             : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
    1695             : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
    1696             : 
    1697             : static bool
    1698           0 : get_start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
    1699             : {
    1700           0 :   double result(self->Start());
    1701           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1702           0 :   args.rval().set(JS_NumberValue(double(result)));
    1703           0 :   return true;
    1704             : }
    1705             : 
    1706             : static const JSJitInfo start_getterinfo = {
    1707             :   { (JSJitGetterOp)get_start },
    1708             :   { prototypes::id::GridLine },
    1709             :   { PrototypeTraits<prototypes::id::GridLine>::Depth },
    1710             :   JSJitInfo::Getter,
    1711             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1712             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1713             :   true,  /* isInfallible. False in setters. */
    1714             :   false,  /* isMovable.  Not relevant for setters. */
    1715             :   false, /* isEliminatable.  Not relevant for setters. */
    1716             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1717             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1718             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1719             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1720             : };
    1721             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1722             : static_assert(0 < 2, "There is no slot for us");
    1723             : 
    1724             : static bool
    1725           0 : get_breadth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
    1726             : {
    1727           0 :   double result(self->Breadth());
    1728           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1729           0 :   args.rval().set(JS_NumberValue(double(result)));
    1730           0 :   return true;
    1731             : }
    1732             : 
    1733             : static const JSJitInfo breadth_getterinfo = {
    1734             :   { (JSJitGetterOp)get_breadth },
    1735             :   { prototypes::id::GridLine },
    1736             :   { PrototypeTraits<prototypes::id::GridLine>::Depth },
    1737             :   JSJitInfo::Getter,
    1738             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1739             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1740             :   true,  /* isInfallible. False in setters. */
    1741             :   false,  /* isMovable.  Not relevant for setters. */
    1742             :   false, /* isEliminatable.  Not relevant for setters. */
    1743             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1744             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1745             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1746             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1747             : };
    1748             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1749             : static_assert(0 < 2, "There is no slot for us");
    1750             : 
    1751             : static bool
    1752           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
    1753             : {
    1754           0 :   GridDeclaration result(self->Type());
    1755           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1756           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1757           0 :     return false;
    1758             :   }
    1759           0 :   return true;
    1760             : }
    1761             : 
    1762             : static const JSJitInfo type_getterinfo = {
    1763             :   { (JSJitGetterOp)get_type },
    1764             :   { prototypes::id::GridLine },
    1765             :   { PrototypeTraits<prototypes::id::GridLine>::Depth },
    1766             :   JSJitInfo::Getter,
    1767             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1768             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1769             :   false,  /* isInfallible. False in setters. */
    1770             :   false,  /* isMovable.  Not relevant for setters. */
    1771             :   false, /* isEliminatable.  Not relevant for setters. */
    1772             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1773             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1774             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1775             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1776             : };
    1777             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1778             : static_assert(0 < 2, "There is no slot for us");
    1779             : 
    1780             : static bool
    1781           0 : get_number(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLine* self, JSJitGetterCallArgs args)
    1782             : {
    1783           0 :   uint32_t result(self->Number());
    1784           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1785           0 :   args.rval().setNumber(result);
    1786           0 :   return true;
    1787             : }
    1788             : 
    1789             : static const JSJitInfo number_getterinfo = {
    1790             :   { (JSJitGetterOp)get_number },
    1791             :   { prototypes::id::GridLine },
    1792             :   { PrototypeTraits<prototypes::id::GridLine>::Depth },
    1793             :   JSJitInfo::Getter,
    1794             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1795             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1796             :   true,  /* isInfallible. False in setters. */
    1797             :   false,  /* isMovable.  Not relevant for setters. */
    1798             :   false, /* isEliminatable.  Not relevant for setters. */
    1799             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1800             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1801             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1802             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1803             : };
    1804             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1805             : static_assert(0 < 2, "There is no slot for us");
    1806             : 
    1807             : static bool
    1808           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1809             : {
    1810           0 :   mozilla::dom::GridLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLine>(obj);
    1811             :   // We don't want to preserve if we don't have a wrapper, and we
    1812             :   // obviously can't preserve if we're not initialized.
    1813           0 :   if (self && self->GetWrapperPreserveColor()) {
    1814           0 :     PreserveWrapper(self);
    1815             :   }
    1816           0 :   return true;
    1817             : }
    1818             : 
    1819             : static void
    1820           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1821             : {
    1822           0 :   mozilla::dom::GridLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLine>(obj);
    1823           0 :   if (self) {
    1824           0 :     ClearWrapper(self, self, obj);
    1825           0 :     AddForDeferredFinalization<mozilla::dom::GridLine>(self);
    1826             :   }
    1827           0 : }
    1828             : 
    1829             : static void
    1830           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1831             : {
    1832           0 :   mozilla::dom::GridLine* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLine>(obj);
    1833           0 :   if (self) {
    1834           0 :     UpdateWrapper(self, self, obj, old);
    1835             :   }
    1836           0 : }
    1837             : 
    1838             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1839             : #if defined(__clang__)
    1840             : #pragma clang diagnostic push
    1841             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1842             : #endif
    1843             : static const JSPropertySpec sAttributes_specs[] = {
    1844             :   { "names", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &names_getterinfo, nullptr, nullptr },
    1845             :   { "start", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &start_getterinfo, nullptr, nullptr },
    1846             :   { "breadth", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &breadth_getterinfo, nullptr, nullptr },
    1847             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
    1848             :   { "number", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &number_getterinfo, nullptr, nullptr },
    1849             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1850             : };
    1851             : #if defined(__clang__)
    1852             : #pragma clang diagnostic pop
    1853             : #endif
    1854             : 
    1855             : 
    1856             : // Can't be const because the pref-enabled boolean needs to be writable
    1857             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1858             :   { nullptr, &sAttributes_specs[0] },
    1859             :   { nullptr, nullptr }
    1860             : };
    1861             : 
    1862             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1863             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1864             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1865             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1866             : 
    1867             : 
    1868             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
    1869             : static PropertyInfo sNativeProperties_propertyInfos[5];
    1870             : 
    1871             : static const NativePropertiesN<1> sNativeProperties = {
    1872             :   false, 0,
    1873             :   false, 0,
    1874             :   false, 0,
    1875             :   true,  0 /* sAttributes */,
    1876             :   false, 0,
    1877             :   false, 0,
    1878             :   false, 0,
    1879             :   -1,
    1880             :   5,
    1881             :   sNativeProperties_sortedPropertyIndices,
    1882             :   {
    1883             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    1884             :   }
    1885             : };
    1886             : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1887             :     "We have a property info count that is oversized");
    1888             : 
    1889             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1890             :   {
    1891             :     "Function",
    1892             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1893             :     &sBoringInterfaceObjectClassClassOps,
    1894             :     JS_NULL_CLASS_SPEC,
    1895             :     JS_NULL_CLASS_EXT,
    1896             :     &sInterfaceObjectClassObjectOps
    1897             :   },
    1898             :   eInterface,
    1899             :   true,
    1900             :   prototypes::id::GridLine,
    1901             :   PrototypeTraits<prototypes::id::GridLine>::Depth,
    1902             :   sNativePropertyHooks,
    1903             :   "function GridLine() {\n    [native code]\n}",
    1904             :   JS::GetRealmFunctionPrototype
    1905             : };
    1906             : 
    1907             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1908             :   {
    1909             :     "GridLinePrototype",
    1910             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1911             :     JS_NULL_CLASS_OPS,
    1912             :     JS_NULL_CLASS_SPEC,
    1913             :     JS_NULL_CLASS_EXT,
    1914             :     JS_NULL_OBJECT_OPS
    1915             :   },
    1916             :   eInterfacePrototype,
    1917             :   false,
    1918             :   prototypes::id::GridLine,
    1919             :   PrototypeTraits<prototypes::id::GridLine>::Depth,
    1920             :   sNativePropertyHooks,
    1921             :   "[object GridLinePrototype]",
    1922             :   JS::GetRealmObjectPrototype
    1923             : };
    1924             : 
    1925             : bool
    1926           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1927             : {
    1928           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
    1929             : }
    1930             : 
    1931             : JSObject*
    1932           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1933             : {
    1934           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1935             : }
    1936             : 
    1937             : static const js::ClassOps sClassOps = {
    1938             :   _addProperty, /* addProperty */
    1939             :   nullptr,               /* delProperty */
    1940             :   nullptr,               /* getProperty */
    1941             :   nullptr,               /* setProperty */
    1942             :   nullptr,               /* enumerate */
    1943             :   nullptr, /* newEnumerate */
    1944             :   nullptr, /* resolve */
    1945             :   nullptr, /* mayResolve */
    1946             :   _finalize, /* finalize */
    1947             :   nullptr, /* call */
    1948             :   nullptr,               /* hasInstance */
    1949             :   nullptr,               /* construct */
    1950             :   nullptr, /* trace */
    1951             : };
    1952             : 
    1953             : static const js::ClassExtension sClassExtension = {
    1954             :   nullptr, /* weakmapKeyDelegateOp */
    1955             :   _objectMoved /* objectMovedOp */
    1956             : };
    1957             : 
    1958             : static const DOMJSClass sClass = {
    1959             :   { "GridLine",
    1960             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
    1961             :     &sClassOps,
    1962             :     JS_NULL_CLASS_SPEC,
    1963             :     &sClassExtension,
    1964             :     JS_NULL_OBJECT_OPS
    1965             :   },
    1966             :   { prototypes::id::GridLine, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    1967             :   IsBaseOf<nsISupports, mozilla::dom::GridLine >::value,
    1968             :   sNativePropertyHooks,
    1969             :   FindAssociatedGlobalForNative<mozilla::dom::GridLine>::Get,
    1970             :   GetProtoObjectHandle,
    1971             :   GetCCParticipant<mozilla::dom::GridLine>::Get()
    1972             : };
    1973             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1974             :               "Must have the right minimal number of reserved slots.");
    1975             : static_assert(2 >= 2,
    1976             :               "Must have enough reserved slots.");
    1977             : 
    1978             : const JSClass*
    1979           0 : GetJSClass()
    1980             : {
    1981           0 :   return sClass.ToJSClass();
    1982             : }
    1983             : 
    1984             : bool
    1985           0 : Wrap(JSContext* aCx, mozilla::dom::GridLine* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1986             : {
    1987             :   MOZ_ASSERT(static_cast<mozilla::dom::GridLine*>(aObject) ==
    1988             :              reinterpret_cast<mozilla::dom::GridLine*>(aObject),
    1989             :              "Multiple inheritance for mozilla::dom::GridLine is broken.");
    1990           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1991           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1992           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1993             :              "You should probably not be using Wrap() directly; use "
    1994             :              "GetOrCreateDOMReflector instead");
    1995             : 
    1996           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1997             :              "nsISupports must be on our primary inheritance chain");
    1998             : 
    1999           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2000           0 :   if (!global) {
    2001           0 :     return false;
    2002             :   }
    2003           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2004           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2005             : 
    2006             :   // That might have ended up wrapping us already, due to the wonders
    2007             :   // of XBL.  Check for that, and bail out as needed.
    2008           0 :   aReflector.set(aCache->GetWrapper());
    2009           0 :   if (aReflector) {
    2010             : #ifdef DEBUG
    2011           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2012             : #endif // DEBUG
    2013           0 :     return true;
    2014             :   }
    2015             : 
    2016           0 :   JSAutoCompartment ac(aCx, global);
    2017           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2018           0 :   if (!canonicalProto) {
    2019           0 :     return false;
    2020             :   }
    2021           0 :   JS::Rooted<JSObject*> proto(aCx);
    2022           0 :   if (aGivenProto) {
    2023           0 :     proto = aGivenProto;
    2024             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2025             :     // coming in, we changed compartments to that of "parent" so may need
    2026             :     // to wrap the proto here.
    2027           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2028           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2029           0 :         return false;
    2030             :       }
    2031             :     }
    2032             :   } else {
    2033           0 :     proto = canonicalProto;
    2034             :   }
    2035             : 
    2036           0 :   BindingJSObjectCreator<mozilla::dom::GridLine> creator(aCx);
    2037           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    2038           0 :   if (!aReflector) {
    2039           0 :     return false;
    2040             :   }
    2041             : 
    2042           0 :   aCache->SetWrapper(aReflector);
    2043           0 :   creator.InitializationSucceeded();
    2044             : 
    2045           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2046             :              aCache->GetWrapperPreserveColor() == aReflector);
    2047             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2048             :   // otherwise we won't be able to properly recreate it later, since
    2049             :   // we won't know what proto to use.  Note that we don't check
    2050             :   // aGivenProto here, since it's entirely possible (and even
    2051             :   // somewhat common) to have a non-null aGivenProto which is the
    2052             :   // same as canonicalProto.
    2053           0 :   if (proto != canonicalProto) {
    2054           0 :     PreserveWrapper(aObject);
    2055             :   }
    2056             : 
    2057           0 :   return true;
    2058             : }
    2059             : 
    2060             : // This may allocate too many slots, because we only really need
    2061             : // slots for our non-interface-typed members that we cache.  But
    2062             : // allocating slots only for those would make the slot index
    2063             : // computations much more complicated, so let's do this the simple
    2064             : // way for now.
    2065             : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
    2066             : 
    2067             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2068             :   nullptr,
    2069             :   nullptr,
    2070             :   nullptr,
    2071             :   { sNativeProperties.Upcast(), nullptr },
    2072             :   prototypes::id::GridLine,
    2073             :   constructors::id::GridLine,
    2074             :   nullptr,
    2075             :   &sXrayExpandoObjectClass
    2076             : } };
    2077             : 
    2078             : void
    2079           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2080             : {
    2081           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    2082           0 :   if (!parentProto) {
    2083           0 :     return;
    2084             :   }
    2085             : 
    2086           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    2087           0 :   if (!constructorProto) {
    2088           0 :     return;
    2089             :   }
    2090             : 
    2091             :   static bool sIdsInited = false;
    2092           0 :   if (!sIdsInited && NS_IsMainThread()) {
    2093           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2094           0 :       return;
    2095             :     }
    2096           0 :     sIdsInited = true;
    2097             :   }
    2098             : 
    2099           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridLine);
    2100           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridLine);
    2101           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2102             :                               &sPrototypeClass.mBase, protoCache,
    2103             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    2104             :                               interfaceCache,
    2105             :                               sNativeProperties.Upcast(),
    2106             :                               nullptr,
    2107             :                               "GridLine", aDefineOnGlobal,
    2108             :                               nullptr,
    2109           0 :                               false);
    2110             : }
    2111             : 
    2112             : JS::Handle<JSObject*>
    2113           0 : GetProtoObjectHandle(JSContext* aCx)
    2114             : {
    2115             :   /* Get the interface prototype object for this class.  This will create the
    2116             :      object as needed. */
    2117           0 :   bool aDefineOnGlobal = true;
    2118             : 
    2119             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2120           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2121           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2122           0 :     return nullptr;
    2123             :   }
    2124             : 
    2125             :   /* Check to see whether the interface objects are already installed */
    2126           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2127           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GridLine)) {
    2128           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2129           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2130             :   }
    2131             : 
    2132             :   /*
    2133             :    * The object might _still_ be null, but that's OK.
    2134             :    *
    2135             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2136             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2137             :    * changed after they have been set.
    2138             :    *
    2139             :    * Calling address() avoids the read read barrier that does gray
    2140             :    * unmarking, but it's not possible for the object to be gray here.
    2141             :    */
    2142             : 
    2143           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GridLine);
    2144           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2145           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2146             : }
    2147             : 
    2148             : JS::Handle<JSObject*>
    2149           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2150             : {
    2151             :   /* Get the interface object for this class.  This will create the object as
    2152             :      needed. */
    2153             : 
    2154             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2155           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2156           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2157           0 :     return nullptr;
    2158             :   }
    2159             : 
    2160             :   /* Check to see whether the interface objects are already installed */
    2161           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2162           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GridLine)) {
    2163           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2164           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2165             :   }
    2166             : 
    2167             :   /*
    2168             :    * The object might _still_ be null, but that's OK.
    2169             :    *
    2170             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2171             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2172             :    * changed after they have been set.
    2173             :    *
    2174             :    * Calling address() avoids the read read barrier that does gray
    2175             :    * unmarking, but it's not possible for the object to be gray here.
    2176             :    */
    2177             : 
    2178           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GridLine);
    2179           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2180           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2181             : }
    2182             : 
    2183             : JSObject*
    2184           0 : GetConstructorObject(JSContext* aCx)
    2185             : {
    2186           0 :   return GetConstructorObjectHandle(aCx);
    2187             : }
    2188             : 
    2189             : } // namespace GridLineBinding
    2190             : 
    2191             : 
    2192             : 
    2193             : namespace GridLinesBinding {
    2194             : 
    2195             : static bool
    2196           0 : get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLines* self, JSJitGetterCallArgs args)
    2197             : {
    2198           0 :   uint32_t result(self->Length());
    2199           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2200           0 :   args.rval().setNumber(result);
    2201           0 :   return true;
    2202             : }
    2203             : 
    2204             : static const JSJitInfo length_getterinfo = {
    2205             :   { (JSJitGetterOp)get_length },
    2206             :   { prototypes::id::GridLines },
    2207             :   { PrototypeTraits<prototypes::id::GridLines>::Depth },
    2208             :   JSJitInfo::Getter,
    2209             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2210             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2211             :   true,  /* isInfallible. False in setters. */
    2212             :   false,  /* isMovable.  Not relevant for setters. */
    2213             :   false, /* isEliminatable.  Not relevant for setters. */
    2214             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2215             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2216             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2217             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2218             : };
    2219             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2220             : static_assert(0 < 1, "There is no slot for us");
    2221             : 
    2222             : static bool
    2223           0 : item(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridLines* self, const JSJitMethodCallArgs& args)
    2224             : {
    2225           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    2226           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "GridLines.item");
    2227             :   }
    2228             :   uint32_t arg0;
    2229           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
    2230           0 :     return false;
    2231             :   }
    2232           0 :   auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->Item(arg0)));
    2233           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2234           0 :   if (!result) {
    2235           0 :     args.rval().setNull();
    2236           0 :     return true;
    2237             :   }
    2238           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    2239           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2240           0 :     return false;
    2241             :   }
    2242           0 :   return true;
    2243             : }
    2244             : 
    2245             : static const JSJitInfo item_methodinfo = {
    2246             :   { (JSJitGetterOp)item },
    2247             :   { prototypes::id::GridLines },
    2248             :   { PrototypeTraits<prototypes::id::GridLines>::Depth },
    2249             :   JSJitInfo::Method,
    2250             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2251             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    2252             :   false,  /* isInfallible. False in setters. */
    2253             :   false,  /* isMovable.  Not relevant for setters. */
    2254             :   false, /* isEliminatable.  Not relevant for setters. */
    2255             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2256             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2257             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2258             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2259             : };
    2260             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2261             : static_assert(0 < 1, "There is no slot for us");
    2262             : 
    2263             : static void
    2264           0 : _objectMoved(JSObject* obj, const JSObject* old)
    2265             : {
    2266           0 :   mozilla::dom::GridLines* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLines>(obj);
    2267           0 :   if (self) {
    2268           0 :     UpdateWrapper(self, self, obj, old);
    2269             :   }
    2270           0 : }
    2271             : 
    2272             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2273             : #if defined(__clang__)
    2274             : #pragma clang diagnostic push
    2275             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2276             : #endif
    2277             : static const JSFunctionSpec sMethods_specs[] = {
    2278             :   JS_FNSPEC("item", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&item_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    2279             :   JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
    2280             :   JS_FS_END
    2281             : };
    2282             : #if defined(__clang__)
    2283             : #pragma clang diagnostic pop
    2284             : #endif
    2285             : 
    2286             : 
    2287             : // Can't be const because the pref-enabled boolean needs to be writable
    2288             : static Prefable<const JSFunctionSpec> sMethods[] = {
    2289             :   { nullptr, &sMethods_specs[0] },
    2290             :   { nullptr, nullptr }
    2291             : };
    2292             : 
    2293             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2294             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2295             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2296             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2297             : 
    2298             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2299             : #if defined(__clang__)
    2300             : #pragma clang diagnostic push
    2301             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2302             : #endif
    2303             : static const JSPropertySpec sAttributes_specs[] = {
    2304             :   { "length", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &length_getterinfo, nullptr, nullptr },
    2305             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    2306             : };
    2307             : #if defined(__clang__)
    2308             : #pragma clang diagnostic pop
    2309             : #endif
    2310             : 
    2311             : 
    2312             : // Can't be const because the pref-enabled boolean needs to be writable
    2313             : static Prefable<const JSPropertySpec> sAttributes[] = {
    2314             :   { nullptr, &sAttributes_specs[0] },
    2315             :   { nullptr, nullptr }
    2316             : };
    2317             : 
    2318             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2319             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2320             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2321             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2322             : 
    2323             : 
    2324             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
    2325             : static PropertyInfo sNativeProperties_propertyInfos[3];
    2326             : 
    2327             : static const NativePropertiesN<2> sNativeProperties = {
    2328             :   false, 0,
    2329             :   false, 0,
    2330             :   true,  0 /* sMethods */,
    2331             :   true,  1 /* sAttributes */,
    2332             :   false, 0,
    2333             :   false, 0,
    2334             :   false, 0,
    2335             :   -1,
    2336             :   3,
    2337             :   sNativeProperties_sortedPropertyIndices,
    2338             :   {
    2339             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    2340             :     { sAttributes, &sNativeProperties_propertyInfos[2] }
    2341             :   }
    2342             : };
    2343             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    2344             :     "We have a property info count that is oversized");
    2345             : 
    2346             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    2347             :   {
    2348             :     "Function",
    2349             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    2350             :     &sBoringInterfaceObjectClassClassOps,
    2351             :     JS_NULL_CLASS_SPEC,
    2352             :     JS_NULL_CLASS_EXT,
    2353             :     &sInterfaceObjectClassObjectOps
    2354             :   },
    2355             :   eInterface,
    2356             :   true,
    2357             :   prototypes::id::GridLines,
    2358             :   PrototypeTraits<prototypes::id::GridLines>::Depth,
    2359             :   sNativePropertyHooks,
    2360             :   "function GridLines() {\n    [native code]\n}",
    2361             :   JS::GetRealmFunctionPrototype
    2362             : };
    2363             : 
    2364             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    2365             :   {
    2366             :     "GridLinesPrototype",
    2367             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    2368             :     JS_NULL_CLASS_OPS,
    2369             :     JS_NULL_CLASS_SPEC,
    2370             :     JS_NULL_CLASS_EXT,
    2371             :     JS_NULL_OBJECT_OPS
    2372             :   },
    2373             :   eInterfacePrototype,
    2374             :   false,
    2375             :   prototypes::id::GridLines,
    2376             :   PrototypeTraits<prototypes::id::GridLines>::Depth,
    2377             :   sNativePropertyHooks,
    2378             :   "[object GridLinesPrototype]",
    2379             :   JS::GetRealmObjectPrototype
    2380             : };
    2381             : 
    2382             : bool
    2383           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    2384             : {
    2385           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
    2386             : }
    2387             : 
    2388             : JSObject*
    2389           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    2390             : {
    2391           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    2392             : }
    2393             : 
    2394             : static_assert(IsBaseOf<nsISupports, mozilla::dom::GridLines >::value,
    2395             :                   "We don't support non-nsISupports native classes for "
    2396             :                   "proxy-based bindings yet");
    2397             : 
    2398             : 
    2399             : class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
    2400             : {
    2401             : public:
    2402             :   explicit constexpr DOMProxyHandler()
    2403             :   {
    2404             :   }
    2405             : 
    2406             :   virtual bool
    2407             :   getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
    2408             : 
    2409             :   virtual bool
    2410             :   defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
    2411             : 
    2412             :   using mozilla::dom::DOMProxyHandler::defineProperty;
    2413             : 
    2414             :   virtual bool
    2415             :   ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
    2416             : 
    2417             :   virtual bool
    2418             :   hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
    2419             : 
    2420             :   virtual bool
    2421             :   get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
    2422             : 
    2423             :   virtual const char*
    2424             :   className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
    2425             : 
    2426             :   virtual bool
    2427             :   finalizeInBackground(const JS::Value& priv) const override;
    2428             : 
    2429             :   virtual void
    2430             :   finalize(JSFreeOp* fop, JSObject* proxy) const override;
    2431             : 
    2432             :   static const DOMProxyHandler*
    2433             :   getInstance();
    2434             : 
    2435             :   virtual bool
    2436             :   delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
    2437             : 
    2438             :   virtual bool
    2439             :   getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
    2440             : };
    2441             : 
    2442             : MOZ_ALWAYS_INLINE bool
    2443           0 : IsProxy(JSObject* obj)
    2444             : {
    2445           0 :   return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
    2446             : }
    2447             : 
    2448             : MOZ_ALWAYS_INLINE mozilla::dom::GridLines*
    2449           0 : UnwrapProxy(JSObject* obj)
    2450             : {
    2451           0 :   MOZ_ASSERT(js::IsProxy(obj));
    2452           0 :   if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
    2453           0 :     MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
    2454           0 :     obj = js::UncheckedUnwrap(obj);
    2455             :   }
    2456           0 :   MOZ_ASSERT(IsProxy(obj));
    2457           0 :   return static_cast<mozilla::dom::GridLines*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
    2458             : }
    2459             : 
    2460             : bool
    2461           0 : DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
    2462             : {
    2463           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
    2464           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    2465           0 :   if (IsArrayIndex(index)) {
    2466           0 :     mozilla::dom::GridLines* self = UnwrapProxy(proxy);
    2467           0 :     bool found = false;
    2468           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
    2469           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2470             : 
    2471           0 :     if (found) {
    2472           0 :       if (!result) {
    2473           0 :         desc.value().setNull();
    2474           0 :         FillPropertyDescriptor(desc, proxy, true);
    2475           0 :         return true;
    2476             :       }
    2477           0 :       if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
    2478           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2479           0 :         return false;
    2480             :       }
    2481           0 :       FillPropertyDescriptor(desc, proxy, true);
    2482           0 :       return true;
    2483             :     }
    2484             :   }
    2485             : 
    2486           0 :   JS::Rooted<JSObject*> expando(cx);
    2487           0 :   if (!isXray && (expando = GetExpandoObject(proxy))) {
    2488           0 :     if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
    2489           0 :       return false;
    2490             :     }
    2491           0 :     if (desc.object()) {
    2492             :       // Pretend the property lives on the wrapper.
    2493           0 :       desc.object().set(proxy);
    2494           0 :       return true;
    2495             :     }
    2496             :   }
    2497             : 
    2498           0 :   desc.object().set(nullptr);
    2499           0 :   return true;
    2500             : }
    2501             : 
    2502             : bool
    2503           0 : DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
    2504             : {
    2505           0 :   if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
    2506           0 :     *defined = true;
    2507           0 :     return opresult.failNoIndexedSetter();
    2508             :   }
    2509           0 :   return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
    2510             : }
    2511             : 
    2512             : 
    2513             : bool
    2514           0 : DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
    2515             : {
    2516           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
    2517             : 
    2518           0 :   uint32_t length = UnwrapProxy(proxy)->Length();
    2519           0 :   MOZ_ASSERT(int32_t(length) >= 0);
    2520           0 :   for (int32_t i = 0; i < int32_t(length); ++i) {
    2521           0 :     if (!props.append(INT_TO_JSID(i))) {
    2522           0 :       return false;
    2523             :     }
    2524             :   }
    2525             : 
    2526           0 :   JS::Rooted<JSObject*> expando(cx);
    2527           0 :   if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
    2528           0 :       !js::GetPropertyKeys(cx, expando, flags, &props)) {
    2529           0 :     return false;
    2530             :   }
    2531             : 
    2532           0 :   return true;
    2533             : }
    2534             : 
    2535             : bool
    2536           0 : DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
    2537             : {
    2538           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    2539             :             "Should not have a XrayWrapper here");
    2540             : 
    2541           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    2542           0 :   if (IsArrayIndex(index)) {
    2543           0 :     bool found = false;
    2544           0 :     mozilla::dom::GridLines* self = UnwrapProxy(proxy);
    2545           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
    2546           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2547             :     (void)result;
    2548             : 
    2549           0 :     *bp = found;
    2550           0 :     return true;
    2551             :   }
    2552             : 
    2553             : 
    2554           0 :   JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
    2555           0 :   if (expando) {
    2556           0 :     bool b = true;
    2557           0 :     bool ok = JS_HasPropertyById(cx, expando, id, &b);
    2558           0 :     *bp = !!b;
    2559           0 :     if (!ok || *bp) {
    2560           0 :       return ok;
    2561             :     }
    2562             :   }
    2563             : 
    2564           0 :   *bp = false;
    2565           0 :   return true;
    2566             : }
    2567             : 
    2568             : bool
    2569           0 : DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
    2570             : {
    2571           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    2572             :               "Should not have a XrayWrapper here");
    2573             : 
    2574           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    2575           0 :   if (IsArrayIndex(index)) {
    2576           0 :     mozilla::dom::GridLines* self = UnwrapProxy(proxy);
    2577           0 :     bool found = false;
    2578           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
    2579           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2580             : 
    2581           0 :     if (found) {
    2582           0 :       if (!result) {
    2583           0 :         vp.setNull();
    2584           0 :         return true;
    2585             :       }
    2586           0 :       if (!GetOrCreateDOMReflector(cx, result, vp)) {
    2587           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2588           0 :         return false;
    2589             :       }
    2590           0 :       return true;
    2591             :     }
    2592             :     // Even if we don't have this index, we don't forward the
    2593             :     // get on to our expando object.
    2594             :   } else {
    2595             :     { // Scope for expando
    2596           0 :       JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
    2597           0 :       if (expando) {
    2598             :         bool hasProp;
    2599           0 :         if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
    2600           0 :           return false;
    2601             :         }
    2602             : 
    2603           0 :         if (hasProp) {
    2604             :           // Forward the get to the expando object, but our receiver is whatever our
    2605             :           // receiver is.
    2606           0 :           return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
    2607             :         }
    2608             :       }
    2609             :     }
    2610             :   }
    2611             : 
    2612             :   bool foundOnPrototype;
    2613           0 :   if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
    2614           0 :     return false;
    2615             :   }
    2616             : 
    2617           0 :   if (foundOnPrototype) {
    2618           0 :     return true;
    2619             :   }
    2620             : 
    2621           0 :   vp.setUndefined();
    2622           0 :   return true;
    2623             : }
    2624             : 
    2625             : const char*
    2626           0 : DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
    2627             : {
    2628           0 :   return "GridLines";
    2629             : }
    2630             : 
    2631             : bool
    2632           0 : DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
    2633             : {
    2634           0 :   return false;
    2635             : }
    2636             : 
    2637             : void
    2638           0 : DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
    2639             : {
    2640           0 :   mozilla::dom::GridLines* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridLines>(proxy);
    2641           0 :   if (self) {
    2642           0 :     ClearWrapper(self, self, proxy);
    2643           0 :     AddForDeferredFinalization<mozilla::dom::GridLines>(self);
    2644             :   }
    2645           0 : }
    2646             : 
    2647             : const DOMProxyHandler*
    2648           0 : DOMProxyHandler::getInstance()
    2649             : {
    2650             :   static const DOMProxyHandler instance;
    2651           0 :   return &instance;
    2652             : }
    2653             : 
    2654             : bool
    2655           0 : DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
    2656             : {
    2657           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    2658             :             "Should not have a XrayWrapper here");
    2659             : 
    2660           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    2661           0 :   if (IsArrayIndex(index)) {
    2662             :     bool deleteSucceeded;
    2663           0 :     bool found = false;
    2664           0 :     mozilla::dom::GridLines* self = UnwrapProxy(proxy);
    2665           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
    2666           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2667             :     (void)result;
    2668           0 :     deleteSucceeded = !found;
    2669           0 :     return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
    2670             :   }
    2671             : 
    2672           0 :   return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
    2673             : }
    2674             : 
    2675             : bool
    2676           0 : DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
    2677             : {
    2678           0 :   JS::Rooted<JS::Value> temp(cx);
    2679           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    2680             :              "Should not have a XrayWrapper here");
    2681             : 
    2682           0 :   mozilla::dom::GridLines* self = UnwrapProxy(proxy);
    2683           0 :   uint32_t length = self->Length();
    2684             :   // Compute the end of the indices we'll get ourselves
    2685           0 :   uint32_t ourEnd = std::max(begin, std::min(end, length));
    2686             : 
    2687           0 :   for (uint32_t index = begin; index < ourEnd; ++index) {
    2688           0 :     bool found = false;
    2689           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridLine>(self->IndexedGetter(index, found)));
    2690           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2691             : 
    2692           0 :     MOZ_ASSERT(found);
    2693           0 :     if (!result) {
    2694           0 :       temp.setNull();
    2695           0 :       if (!adder->append(cx, temp)) return false;
    2696           0 :       continue;
    2697             :     }
    2698           0 :     if (!GetOrCreateDOMReflector(cx, result, &temp)) {
    2699           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2700           0 :       return false;
    2701             :     }
    2702           0 :     if (!adder->append(cx, temp)) return false;
    2703           0 :     continue;
    2704             :   }
    2705             : 
    2706           0 :   if (end > ourEnd) {
    2707           0 :     JS::Rooted<JSObject*> proto(cx);
    2708           0 :     if (!js::GetObjectProto(cx, proxy, &proto)) {
    2709           0 :       return false;
    2710             :     }
    2711           0 :     return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
    2712             :   }
    2713             : 
    2714           0 :   return true;
    2715             : }
    2716             : 
    2717             : static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
    2718             :     _objectMoved
    2719             : );
    2720             : 
    2721             : static const DOMJSClass sClass = {
    2722             :   PROXY_CLASS_WITH_EXT("GridLines",
    2723             :                        JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
    2724             :                        &sClassExtension),
    2725             :   { prototypes::id::GridLines, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    2726             :   IsBaseOf<nsISupports, mozilla::dom::GridLines >::value,
    2727             :   sNativePropertyHooks,
    2728             :   FindAssociatedGlobalForNative<mozilla::dom::GridLines>::Get,
    2729             :   GetProtoObjectHandle,
    2730             :   GetCCParticipant<mozilla::dom::GridLines>::Get()
    2731             : };
    2732             : 
    2733             : bool
    2734           0 : Wrap(JSContext* aCx, mozilla::dom::GridLines* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    2735             : {
    2736             :   MOZ_ASSERT(static_cast<mozilla::dom::GridLines*>(aObject) ==
    2737             :              reinterpret_cast<mozilla::dom::GridLines*>(aObject),
    2738             :              "Multiple inheritance for mozilla::dom::GridLines is broken.");
    2739           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    2740           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    2741           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    2742             :              "You should probably not be using Wrap() directly; use "
    2743             :              "GetOrCreateDOMReflector instead");
    2744             : 
    2745           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    2746             :              "nsISupports must be on our primary inheritance chain");
    2747             : 
    2748           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2749           0 :   if (!global) {
    2750           0 :     return false;
    2751             :   }
    2752           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2753           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2754             : 
    2755             :   // That might have ended up wrapping us already, due to the wonders
    2756             :   // of XBL.  Check for that, and bail out as needed.
    2757           0 :   aReflector.set(aCache->GetWrapper());
    2758           0 :   if (aReflector) {
    2759             : #ifdef DEBUG
    2760           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2761             : #endif // DEBUG
    2762           0 :     return true;
    2763             :   }
    2764             : 
    2765           0 :   JSAutoCompartment ac(aCx, global);
    2766           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2767           0 :   if (!canonicalProto) {
    2768           0 :     return false;
    2769             :   }
    2770           0 :   JS::Rooted<JSObject*> proto(aCx);
    2771           0 :   if (aGivenProto) {
    2772           0 :     proto = aGivenProto;
    2773             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2774             :     // coming in, we changed compartments to that of "parent" so may need
    2775             :     // to wrap the proto here.
    2776           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2777           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2778           0 :         return false;
    2779             :       }
    2780             :     }
    2781             :   } else {
    2782           0 :     proto = canonicalProto;
    2783             :   }
    2784             : 
    2785           0 :   BindingJSObjectCreator<mozilla::dom::GridLines> creator(aCx);
    2786           0 :   JS::Rooted<JS::Value> expandoValue(aCx, JS::UndefinedValue());
    2787           0 :   creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
    2788           0 :                             proto, aObject, expandoValue, aReflector);
    2789           0 :   if (!aReflector) {
    2790           0 :     return false;
    2791             :   }
    2792             : 
    2793             : 
    2794           0 :   aCache->SetWrapper(aReflector);
    2795           0 :   creator.InitializationSucceeded();
    2796             : 
    2797           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2798             :              aCache->GetWrapperPreserveColor() == aReflector);
    2799             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2800             :   // otherwise we won't be able to properly recreate it later, since
    2801             :   // we won't know what proto to use.  Note that we don't check
    2802             :   // aGivenProto here, since it's entirely possible (and even
    2803             :   // somewhat common) to have a non-null aGivenProto which is the
    2804             :   // same as canonicalProto.
    2805           0 :   if (proto != canonicalProto) {
    2806           0 :     PreserveWrapper(aObject);
    2807             :   }
    2808             : 
    2809           0 :   return true;
    2810             : }
    2811             : 
    2812             : static bool
    2813           0 : ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
    2814             : {
    2815           0 :   return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
    2816             : }
    2817             : 
    2818             : static bool
    2819           0 : EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
    2820             : {
    2821           0 :   return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
    2822             : }
    2823             : 
    2824             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2825             :   ResolveOwnProperty,
    2826             :   EnumerateOwnProperties,
    2827             :   nullptr,
    2828             :   { sNativeProperties.Upcast(), nullptr },
    2829             :   prototypes::id::GridLines,
    2830             :   constructors::id::GridLines,
    2831             :   nullptr,
    2832             :   &DefaultXrayExpandoObjectClass
    2833             : } };
    2834             : 
    2835             : void
    2836           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2837             : {
    2838           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    2839           0 :   if (!parentProto) {
    2840           0 :     return;
    2841             :   }
    2842             : 
    2843           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    2844           0 :   if (!constructorProto) {
    2845           0 :     return;
    2846             :   }
    2847             : 
    2848             :   static bool sIdsInited = false;
    2849           0 :   if (!sIdsInited && NS_IsMainThread()) {
    2850           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2851           0 :       return;
    2852             :     }
    2853           0 :     sIdsInited = true;
    2854             :   }
    2855             : 
    2856           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridLines);
    2857           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridLines);
    2858           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2859             :                               &sPrototypeClass.mBase, protoCache,
    2860             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    2861             :                               interfaceCache,
    2862             :                               sNativeProperties.Upcast(),
    2863             :                               nullptr,
    2864             :                               "GridLines", aDefineOnGlobal,
    2865             :                               nullptr,
    2866           0 :                               false);
    2867             : }
    2868             : 
    2869             : JS::Handle<JSObject*>
    2870           0 : GetProtoObjectHandle(JSContext* aCx)
    2871             : {
    2872             :   /* Get the interface prototype object for this class.  This will create the
    2873             :      object as needed. */
    2874           0 :   bool aDefineOnGlobal = true;
    2875             : 
    2876             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2877           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2878           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2879           0 :     return nullptr;
    2880             :   }
    2881             : 
    2882             :   /* Check to see whether the interface objects are already installed */
    2883           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2884           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GridLines)) {
    2885           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2886           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2887             :   }
    2888             : 
    2889             :   /*
    2890             :    * The object might _still_ be null, but that's OK.
    2891             :    *
    2892             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2893             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2894             :    * changed after they have been set.
    2895             :    *
    2896             :    * Calling address() avoids the read read barrier that does gray
    2897             :    * unmarking, but it's not possible for the object to be gray here.
    2898             :    */
    2899             : 
    2900           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GridLines);
    2901           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2902           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2903             : }
    2904             : 
    2905             : JS::Handle<JSObject*>
    2906           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2907             : {
    2908             :   /* Get the interface object for this class.  This will create the object as
    2909             :      needed. */
    2910             : 
    2911             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2912           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2913           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2914           0 :     return nullptr;
    2915             :   }
    2916             : 
    2917             :   /* Check to see whether the interface objects are already installed */
    2918           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2919           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GridLines)) {
    2920           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2921           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2922             :   }
    2923             : 
    2924             :   /*
    2925             :    * The object might _still_ be null, but that's OK.
    2926             :    *
    2927             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2928             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2929             :    * changed after they have been set.
    2930             :    *
    2931             :    * Calling address() avoids the read read barrier that does gray
    2932             :    * unmarking, but it's not possible for the object to be gray here.
    2933             :    */
    2934             : 
    2935           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GridLines);
    2936           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2937           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2938             : }
    2939             : 
    2940             : JSObject*
    2941           0 : GetConstructorObject(JSContext* aCx)
    2942             : {
    2943           0 :   return GetConstructorObjectHandle(aCx);
    2944             : }
    2945             : 
    2946             : } // namespace GridLinesBinding
    2947             : 
    2948             : 
    2949             : 
    2950             : namespace GridTrackBinding {
    2951             : 
    2952             : static bool
    2953           0 : get_start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
    2954             : {
    2955           0 :   double result(self->Start());
    2956           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2957           0 :   args.rval().set(JS_NumberValue(double(result)));
    2958           0 :   return true;
    2959             : }
    2960             : 
    2961             : static const JSJitInfo start_getterinfo = {
    2962             :   { (JSJitGetterOp)get_start },
    2963             :   { prototypes::id::GridTrack },
    2964             :   { PrototypeTraits<prototypes::id::GridTrack>::Depth },
    2965             :   JSJitInfo::Getter,
    2966             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2967             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2968             :   true,  /* isInfallible. False in setters. */
    2969             :   false,  /* isMovable.  Not relevant for setters. */
    2970             :   false, /* isEliminatable.  Not relevant for setters. */
    2971             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2972             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2973             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2974             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2975             : };
    2976             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2977             : static_assert(0 < 1, "There is no slot for us");
    2978             : 
    2979             : static bool
    2980           0 : get_breadth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
    2981             : {
    2982           0 :   double result(self->Breadth());
    2983           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2984           0 :   args.rval().set(JS_NumberValue(double(result)));
    2985           0 :   return true;
    2986             : }
    2987             : 
    2988             : static const JSJitInfo breadth_getterinfo = {
    2989             :   { (JSJitGetterOp)get_breadth },
    2990             :   { prototypes::id::GridTrack },
    2991             :   { PrototypeTraits<prototypes::id::GridTrack>::Depth },
    2992             :   JSJitInfo::Getter,
    2993             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2994             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2995             :   true,  /* isInfallible. False in setters. */
    2996             :   false,  /* isMovable.  Not relevant for setters. */
    2997             :   false, /* isEliminatable.  Not relevant for setters. */
    2998             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2999             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3000             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3001             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3002             : };
    3003             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3004             : static_assert(0 < 1, "There is no slot for us");
    3005             : 
    3006             : static bool
    3007           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
    3008             : {
    3009           0 :   GridDeclaration result(self->Type());
    3010           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3011           0 :   if (!ToJSValue(cx, result, args.rval())) {
    3012           0 :     return false;
    3013             :   }
    3014           0 :   return true;
    3015             : }
    3016             : 
    3017             : static const JSJitInfo type_getterinfo = {
    3018             :   { (JSJitGetterOp)get_type },
    3019             :   { prototypes::id::GridTrack },
    3020             :   { PrototypeTraits<prototypes::id::GridTrack>::Depth },
    3021             :   JSJitInfo::Getter,
    3022             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3023             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    3024             :   false,  /* isInfallible. False in setters. */
    3025             :   false,  /* isMovable.  Not relevant for setters. */
    3026             :   false, /* isEliminatable.  Not relevant for setters. */
    3027             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3028             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3029             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3030             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3031             : };
    3032             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3033             : static_assert(0 < 1, "There is no slot for us");
    3034             : 
    3035             : static bool
    3036           0 : get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTrack* self, JSJitGetterCallArgs args)
    3037             : {
    3038           0 :   GridTrackState result(self->State());
    3039           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3040           0 :   if (!ToJSValue(cx, result, args.rval())) {
    3041           0 :     return false;
    3042             :   }
    3043           0 :   return true;
    3044             : }
    3045             : 
    3046             : static const JSJitInfo state_getterinfo = {
    3047             :   { (JSJitGetterOp)get_state },
    3048             :   { prototypes::id::GridTrack },
    3049             :   { PrototypeTraits<prototypes::id::GridTrack>::Depth },
    3050             :   JSJitInfo::Getter,
    3051             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3052             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    3053             :   false,  /* isInfallible. False in setters. */
    3054             :   false,  /* isMovable.  Not relevant for setters. */
    3055             :   false, /* isEliminatable.  Not relevant for setters. */
    3056             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3057             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3058             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3059             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3060             : };
    3061             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3062             : static_assert(0 < 1, "There is no slot for us");
    3063             : 
    3064             : static bool
    3065           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    3066             : {
    3067           0 :   mozilla::dom::GridTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTrack>(obj);
    3068             :   // We don't want to preserve if we don't have a wrapper, and we
    3069             :   // obviously can't preserve if we're not initialized.
    3070           0 :   if (self && self->GetWrapperPreserveColor()) {
    3071           0 :     PreserveWrapper(self);
    3072             :   }
    3073           0 :   return true;
    3074             : }
    3075             : 
    3076             : static void
    3077           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    3078             : {
    3079           0 :   mozilla::dom::GridTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTrack>(obj);
    3080           0 :   if (self) {
    3081           0 :     ClearWrapper(self, self, obj);
    3082           0 :     AddForDeferredFinalization<mozilla::dom::GridTrack>(self);
    3083             :   }
    3084           0 : }
    3085             : 
    3086             : static void
    3087           0 : _objectMoved(JSObject* obj, const JSObject* old)
    3088             : {
    3089           0 :   mozilla::dom::GridTrack* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTrack>(obj);
    3090           0 :   if (self) {
    3091           0 :     UpdateWrapper(self, self, obj, old);
    3092             :   }
    3093           0 : }
    3094             : 
    3095             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    3096             : #if defined(__clang__)
    3097             : #pragma clang diagnostic push
    3098             : #pragma clang diagnostic ignored "-Wmissing-braces"
    3099             : #endif
    3100             : static const JSPropertySpec sAttributes_specs[] = {
    3101             :   { "start", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &start_getterinfo, nullptr, nullptr },
    3102             :   { "breadth", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &breadth_getterinfo, nullptr, nullptr },
    3103             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
    3104             :   { "state", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &state_getterinfo, nullptr, nullptr },
    3105             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    3106             : };
    3107             : #if defined(__clang__)
    3108             : #pragma clang diagnostic pop
    3109             : #endif
    3110             : 
    3111             : 
    3112             : // Can't be const because the pref-enabled boolean needs to be writable
    3113             : static Prefable<const JSPropertySpec> sAttributes[] = {
    3114             :   { nullptr, &sAttributes_specs[0] },
    3115             :   { nullptr, nullptr }
    3116             : };
    3117             : 
    3118             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    3119             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    3120             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    3121             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    3122             : 
    3123             : 
    3124             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
    3125             : static PropertyInfo sNativeProperties_propertyInfos[4];
    3126             : 
    3127             : static const NativePropertiesN<1> sNativeProperties = {
    3128             :   false, 0,
    3129             :   false, 0,
    3130             :   false, 0,
    3131             :   true,  0 /* sAttributes */,
    3132             :   false, 0,
    3133             :   false, 0,
    3134             :   false, 0,
    3135             :   -1,
    3136             :   4,
    3137             :   sNativeProperties_sortedPropertyIndices,
    3138             :   {
    3139             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    3140             :   }
    3141             : };
    3142             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    3143             :     "We have a property info count that is oversized");
    3144             : 
    3145             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    3146             :   {
    3147             :     "Function",
    3148             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    3149             :     &sBoringInterfaceObjectClassClassOps,
    3150             :     JS_NULL_CLASS_SPEC,
    3151             :     JS_NULL_CLASS_EXT,
    3152             :     &sInterfaceObjectClassObjectOps
    3153             :   },
    3154             :   eInterface,
    3155             :   true,
    3156             :   prototypes::id::GridTrack,
    3157             :   PrototypeTraits<prototypes::id::GridTrack>::Depth,
    3158             :   sNativePropertyHooks,
    3159             :   "function GridTrack() {\n    [native code]\n}",
    3160             :   JS::GetRealmFunctionPrototype
    3161             : };
    3162             : 
    3163             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    3164             :   {
    3165             :     "GridTrackPrototype",
    3166             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    3167             :     JS_NULL_CLASS_OPS,
    3168             :     JS_NULL_CLASS_SPEC,
    3169             :     JS_NULL_CLASS_EXT,
    3170             :     JS_NULL_OBJECT_OPS
    3171             :   },
    3172             :   eInterfacePrototype,
    3173             :   false,
    3174             :   prototypes::id::GridTrack,
    3175             :   PrototypeTraits<prototypes::id::GridTrack>::Depth,
    3176             :   sNativePropertyHooks,
    3177             :   "[object GridTrackPrototype]",
    3178             :   JS::GetRealmObjectPrototype
    3179             : };
    3180             : 
    3181             : bool
    3182           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    3183             : {
    3184           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
    3185             : }
    3186             : 
    3187             : JSObject*
    3188           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    3189             : {
    3190           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    3191             : }
    3192             : 
    3193             : static const js::ClassOps sClassOps = {
    3194             :   _addProperty, /* addProperty */
    3195             :   nullptr,               /* delProperty */
    3196             :   nullptr,               /* getProperty */
    3197             :   nullptr,               /* setProperty */
    3198             :   nullptr,               /* enumerate */
    3199             :   nullptr, /* newEnumerate */
    3200             :   nullptr, /* resolve */
    3201             :   nullptr, /* mayResolve */
    3202             :   _finalize, /* finalize */
    3203             :   nullptr, /* call */
    3204             :   nullptr,               /* hasInstance */
    3205             :   nullptr,               /* construct */
    3206             :   nullptr, /* trace */
    3207             : };
    3208             : 
    3209             : static const js::ClassExtension sClassExtension = {
    3210             :   nullptr, /* weakmapKeyDelegateOp */
    3211             :   _objectMoved /* objectMovedOp */
    3212             : };
    3213             : 
    3214             : static const DOMJSClass sClass = {
    3215             :   { "GridTrack",
    3216             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    3217             :     &sClassOps,
    3218             :     JS_NULL_CLASS_SPEC,
    3219             :     &sClassExtension,
    3220             :     JS_NULL_OBJECT_OPS
    3221             :   },
    3222             :   { prototypes::id::GridTrack, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    3223             :   IsBaseOf<nsISupports, mozilla::dom::GridTrack >::value,
    3224             :   sNativePropertyHooks,
    3225             :   FindAssociatedGlobalForNative<mozilla::dom::GridTrack>::Get,
    3226             :   GetProtoObjectHandle,
    3227             :   GetCCParticipant<mozilla::dom::GridTrack>::Get()
    3228             : };
    3229             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    3230             :               "Must have the right minimal number of reserved slots.");
    3231             : static_assert(1 >= 1,
    3232             :               "Must have enough reserved slots.");
    3233             : 
    3234             : const JSClass*
    3235           0 : GetJSClass()
    3236             : {
    3237           0 :   return sClass.ToJSClass();
    3238             : }
    3239             : 
    3240             : bool
    3241           0 : Wrap(JSContext* aCx, mozilla::dom::GridTrack* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    3242             : {
    3243             :   MOZ_ASSERT(static_cast<mozilla::dom::GridTrack*>(aObject) ==
    3244             :              reinterpret_cast<mozilla::dom::GridTrack*>(aObject),
    3245             :              "Multiple inheritance for mozilla::dom::GridTrack is broken.");
    3246           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    3247           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    3248           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    3249             :              "You should probably not be using Wrap() directly; use "
    3250             :              "GetOrCreateDOMReflector instead");
    3251             : 
    3252           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    3253             :              "nsISupports must be on our primary inheritance chain");
    3254             : 
    3255           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    3256           0 :   if (!global) {
    3257           0 :     return false;
    3258             :   }
    3259           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    3260           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    3261             : 
    3262             :   // That might have ended up wrapping us already, due to the wonders
    3263             :   // of XBL.  Check for that, and bail out as needed.
    3264           0 :   aReflector.set(aCache->GetWrapper());
    3265           0 :   if (aReflector) {
    3266             : #ifdef DEBUG
    3267           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    3268             : #endif // DEBUG
    3269           0 :     return true;
    3270             :   }
    3271             : 
    3272           0 :   JSAutoCompartment ac(aCx, global);
    3273           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    3274           0 :   if (!canonicalProto) {
    3275           0 :     return false;
    3276             :   }
    3277           0 :   JS::Rooted<JSObject*> proto(aCx);
    3278           0 :   if (aGivenProto) {
    3279           0 :     proto = aGivenProto;
    3280             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    3281             :     // coming in, we changed compartments to that of "parent" so may need
    3282             :     // to wrap the proto here.
    3283           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    3284           0 :       if (!JS_WrapObject(aCx, &proto)) {
    3285           0 :         return false;
    3286             :       }
    3287             :     }
    3288             :   } else {
    3289           0 :     proto = canonicalProto;
    3290             :   }
    3291             : 
    3292           0 :   BindingJSObjectCreator<mozilla::dom::GridTrack> creator(aCx);
    3293           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    3294           0 :   if (!aReflector) {
    3295           0 :     return false;
    3296             :   }
    3297             : 
    3298           0 :   aCache->SetWrapper(aReflector);
    3299           0 :   creator.InitializationSucceeded();
    3300             : 
    3301           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    3302             :              aCache->GetWrapperPreserveColor() == aReflector);
    3303             :   // If proto != canonicalProto, we have to preserve our wrapper;
    3304             :   // otherwise we won't be able to properly recreate it later, since
    3305             :   // we won't know what proto to use.  Note that we don't check
    3306             :   // aGivenProto here, since it's entirely possible (and even
    3307             :   // somewhat common) to have a non-null aGivenProto which is the
    3308             :   // same as canonicalProto.
    3309           0 :   if (proto != canonicalProto) {
    3310           0 :     PreserveWrapper(aObject);
    3311             :   }
    3312             : 
    3313           0 :   return true;
    3314             : }
    3315             : 
    3316             : const NativePropertyHooks sNativePropertyHooks[] = { {
    3317             :   nullptr,
    3318             :   nullptr,
    3319             :   nullptr,
    3320             :   { sNativeProperties.Upcast(), nullptr },
    3321             :   prototypes::id::GridTrack,
    3322             :   constructors::id::GridTrack,
    3323             :   nullptr,
    3324             :   &DefaultXrayExpandoObjectClass
    3325             : } };
    3326             : 
    3327             : void
    3328           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    3329             : {
    3330           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    3331           0 :   if (!parentProto) {
    3332           0 :     return;
    3333             :   }
    3334             : 
    3335           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    3336           0 :   if (!constructorProto) {
    3337           0 :     return;
    3338             :   }
    3339             : 
    3340             :   static bool sIdsInited = false;
    3341           0 :   if (!sIdsInited && NS_IsMainThread()) {
    3342           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    3343           0 :       return;
    3344             :     }
    3345           0 :     sIdsInited = true;
    3346             :   }
    3347             : 
    3348           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridTrack);
    3349           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridTrack);
    3350           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    3351             :                               &sPrototypeClass.mBase, protoCache,
    3352             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    3353             :                               interfaceCache,
    3354             :                               sNativeProperties.Upcast(),
    3355             :                               nullptr,
    3356             :                               "GridTrack", aDefineOnGlobal,
    3357             :                               nullptr,
    3358           0 :                               false);
    3359             : }
    3360             : 
    3361             : JS::Handle<JSObject*>
    3362           0 : GetProtoObjectHandle(JSContext* aCx)
    3363             : {
    3364             :   /* Get the interface prototype object for this class.  This will create the
    3365             :      object as needed. */
    3366           0 :   bool aDefineOnGlobal = true;
    3367             : 
    3368             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    3369           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    3370           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    3371           0 :     return nullptr;
    3372             :   }
    3373             : 
    3374             :   /* Check to see whether the interface objects are already installed */
    3375           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    3376           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GridTrack)) {
    3377           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    3378           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    3379             :   }
    3380             : 
    3381             :   /*
    3382             :    * The object might _still_ be null, but that's OK.
    3383             :    *
    3384             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    3385             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    3386             :    * changed after they have been set.
    3387             :    *
    3388             :    * Calling address() avoids the read read barrier that does gray
    3389             :    * unmarking, but it's not possible for the object to be gray here.
    3390             :    */
    3391             : 
    3392           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GridTrack);
    3393           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    3394           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    3395             : }
    3396             : 
    3397             : JS::Handle<JSObject*>
    3398           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    3399             : {
    3400             :   /* Get the interface object for this class.  This will create the object as
    3401             :      needed. */
    3402             : 
    3403             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    3404           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    3405           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    3406           0 :     return nullptr;
    3407             :   }
    3408             : 
    3409             :   /* Check to see whether the interface objects are already installed */
    3410           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    3411           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GridTrack)) {
    3412           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    3413           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    3414             :   }
    3415             : 
    3416             :   /*
    3417             :    * The object might _still_ be null, but that's OK.
    3418             :    *
    3419             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    3420             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    3421             :    * changed after they have been set.
    3422             :    *
    3423             :    * Calling address() avoids the read read barrier that does gray
    3424             :    * unmarking, but it's not possible for the object to be gray here.
    3425             :    */
    3426             : 
    3427           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GridTrack);
    3428           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    3429           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    3430             : }
    3431             : 
    3432             : JSObject*
    3433           0 : GetConstructorObject(JSContext* aCx)
    3434             : {
    3435           0 :   return GetConstructorObjectHandle(aCx);
    3436             : }
    3437             : 
    3438             : } // namespace GridTrackBinding
    3439             : 
    3440             : 
    3441             : 
    3442             : namespace GridTracksBinding {
    3443             : 
    3444             : static bool
    3445           0 : get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTracks* self, JSJitGetterCallArgs args)
    3446             : {
    3447           0 :   uint32_t result(self->Length());
    3448           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3449           0 :   args.rval().setNumber(result);
    3450           0 :   return true;
    3451             : }
    3452             : 
    3453             : static const JSJitInfo length_getterinfo = {
    3454             :   { (JSJitGetterOp)get_length },
    3455             :   { prototypes::id::GridTracks },
    3456             :   { PrototypeTraits<prototypes::id::GridTracks>::Depth },
    3457             :   JSJitInfo::Getter,
    3458             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3459             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    3460             :   true,  /* isInfallible. False in setters. */
    3461             :   false,  /* isMovable.  Not relevant for setters. */
    3462             :   false, /* isEliminatable.  Not relevant for setters. */
    3463             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3464             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3465             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3466             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3467             : };
    3468             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3469             : static_assert(0 < 1, "There is no slot for us");
    3470             : 
    3471             : static bool
    3472           0 : item(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GridTracks* self, const JSJitMethodCallArgs& args)
    3473             : {
    3474           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    3475           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "GridTracks.item");
    3476             :   }
    3477             :   uint32_t arg0;
    3478           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
    3479           0 :     return false;
    3480             :   }
    3481           0 :   auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->Item(arg0)));
    3482           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3483           0 :   if (!result) {
    3484           0 :     args.rval().setNull();
    3485           0 :     return true;
    3486             :   }
    3487           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    3488           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3489           0 :     return false;
    3490             :   }
    3491           0 :   return true;
    3492             : }
    3493             : 
    3494             : static const JSJitInfo item_methodinfo = {
    3495             :   { (JSJitGetterOp)item },
    3496             :   { prototypes::id::GridTracks },
    3497             :   { PrototypeTraits<prototypes::id::GridTracks>::Depth },
    3498             :   JSJitInfo::Method,
    3499             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3500             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3501             :   false,  /* isInfallible. False in setters. */
    3502             :   false,  /* isMovable.  Not relevant for setters. */
    3503             :   false, /* isEliminatable.  Not relevant for setters. */
    3504             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3505             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3506             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3507             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3508             : };
    3509             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3510             : static_assert(0 < 1, "There is no slot for us");
    3511             : 
    3512             : static void
    3513           0 : _objectMoved(JSObject* obj, const JSObject* old)
    3514             : {
    3515           0 :   mozilla::dom::GridTracks* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTracks>(obj);
    3516           0 :   if (self) {
    3517           0 :     UpdateWrapper(self, self, obj, old);
    3518             :   }
    3519           0 : }
    3520             : 
    3521             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    3522             : #if defined(__clang__)
    3523             : #pragma clang diagnostic push
    3524             : #pragma clang diagnostic ignored "-Wmissing-braces"
    3525             : #endif
    3526             : static const JSFunctionSpec sMethods_specs[] = {
    3527             :   JS_FNSPEC("item", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&item_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    3528             :   JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
    3529             :   JS_FS_END
    3530             : };
    3531             : #if defined(__clang__)
    3532             : #pragma clang diagnostic pop
    3533             : #endif
    3534             : 
    3535             : 
    3536             : // Can't be const because the pref-enabled boolean needs to be writable
    3537             : static Prefable<const JSFunctionSpec> sMethods[] = {
    3538             :   { nullptr, &sMethods_specs[0] },
    3539             :   { nullptr, nullptr }
    3540             : };
    3541             : 
    3542             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    3543             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    3544             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    3545             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    3546             : 
    3547             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    3548             : #if defined(__clang__)
    3549             : #pragma clang diagnostic push
    3550             : #pragma clang diagnostic ignored "-Wmissing-braces"
    3551             : #endif
    3552             : static const JSPropertySpec sAttributes_specs[] = {
    3553             :   { "length", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &length_getterinfo, nullptr, nullptr },
    3554             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    3555             : };
    3556             : #if defined(__clang__)
    3557             : #pragma clang diagnostic pop
    3558             : #endif
    3559             : 
    3560             : 
    3561             : // Can't be const because the pref-enabled boolean needs to be writable
    3562             : static Prefable<const JSPropertySpec> sAttributes[] = {
    3563             :   { nullptr, &sAttributes_specs[0] },
    3564             :   { nullptr, nullptr }
    3565             : };
    3566             : 
    3567             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    3568             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    3569             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    3570             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    3571             : 
    3572             : 
    3573             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
    3574             : static PropertyInfo sNativeProperties_propertyInfos[3];
    3575             : 
    3576             : static const NativePropertiesN<2> sNativeProperties = {
    3577             :   false, 0,
    3578             :   false, 0,
    3579             :   true,  0 /* sMethods */,
    3580             :   true,  1 /* sAttributes */,
    3581             :   false, 0,
    3582             :   false, 0,
    3583             :   false, 0,
    3584             :   -1,
    3585             :   3,
    3586             :   sNativeProperties_sortedPropertyIndices,
    3587             :   {
    3588             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    3589             :     { sAttributes, &sNativeProperties_propertyInfos[2] }
    3590             :   }
    3591             : };
    3592             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    3593             :     "We have a property info count that is oversized");
    3594             : 
    3595             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    3596             :   {
    3597             :     "Function",
    3598             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    3599             :     &sBoringInterfaceObjectClassClassOps,
    3600             :     JS_NULL_CLASS_SPEC,
    3601             :     JS_NULL_CLASS_EXT,
    3602             :     &sInterfaceObjectClassObjectOps
    3603             :   },
    3604             :   eInterface,
    3605             :   true,
    3606             :   prototypes::id::GridTracks,
    3607             :   PrototypeTraits<prototypes::id::GridTracks>::Depth,
    3608             :   sNativePropertyHooks,
    3609             :   "function GridTracks() {\n    [native code]\n}",
    3610             :   JS::GetRealmFunctionPrototype
    3611             : };
    3612             : 
    3613             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    3614             :   {
    3615             :     "GridTracksPrototype",
    3616             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    3617             :     JS_NULL_CLASS_OPS,
    3618             :     JS_NULL_CLASS_SPEC,
    3619             :     JS_NULL_CLASS_EXT,
    3620             :     JS_NULL_OBJECT_OPS
    3621             :   },
    3622             :   eInterfacePrototype,
    3623             :   false,
    3624             :   prototypes::id::GridTracks,
    3625             :   PrototypeTraits<prototypes::id::GridTracks>::Depth,
    3626             :   sNativePropertyHooks,
    3627             :   "[object GridTracksPrototype]",
    3628             :   JS::GetRealmObjectPrototype
    3629             : };
    3630             : 
    3631             : bool
    3632           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    3633             : {
    3634           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
    3635             : }
    3636             : 
    3637             : JSObject*
    3638           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    3639             : {
    3640           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    3641             : }
    3642             : 
    3643             : static_assert(IsBaseOf<nsISupports, mozilla::dom::GridTracks >::value,
    3644             :                   "We don't support non-nsISupports native classes for "
    3645             :                   "proxy-based bindings yet");
    3646             : 
    3647             : 
    3648             : class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
    3649             : {
    3650             : public:
    3651             :   explicit constexpr DOMProxyHandler()
    3652             :   {
    3653             :   }
    3654             : 
    3655             :   virtual bool
    3656             :   getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
    3657             : 
    3658             :   virtual bool
    3659             :   defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
    3660             : 
    3661             :   using mozilla::dom::DOMProxyHandler::defineProperty;
    3662             : 
    3663             :   virtual bool
    3664             :   ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
    3665             : 
    3666             :   virtual bool
    3667             :   hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
    3668             : 
    3669             :   virtual bool
    3670             :   get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
    3671             : 
    3672             :   virtual const char*
    3673             :   className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
    3674             : 
    3675             :   virtual bool
    3676             :   finalizeInBackground(const JS::Value& priv) const override;
    3677             : 
    3678             :   virtual void
    3679             :   finalize(JSFreeOp* fop, JSObject* proxy) const override;
    3680             : 
    3681             :   static const DOMProxyHandler*
    3682             :   getInstance();
    3683             : 
    3684             :   virtual bool
    3685             :   delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
    3686             : 
    3687             :   virtual bool
    3688             :   getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
    3689             : };
    3690             : 
    3691             : MOZ_ALWAYS_INLINE bool
    3692           0 : IsProxy(JSObject* obj)
    3693             : {
    3694           0 :   return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
    3695             : }
    3696             : 
    3697             : MOZ_ALWAYS_INLINE mozilla::dom::GridTracks*
    3698           0 : UnwrapProxy(JSObject* obj)
    3699             : {
    3700           0 :   MOZ_ASSERT(js::IsProxy(obj));
    3701           0 :   if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
    3702           0 :     MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
    3703           0 :     obj = js::UncheckedUnwrap(obj);
    3704             :   }
    3705           0 :   MOZ_ASSERT(IsProxy(obj));
    3706           0 :   return static_cast<mozilla::dom::GridTracks*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
    3707             : }
    3708             : 
    3709             : bool
    3710           0 : DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
    3711             : {
    3712           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
    3713           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    3714           0 :   if (IsArrayIndex(index)) {
    3715           0 :     mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
    3716           0 :     bool found = false;
    3717           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
    3718           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3719             : 
    3720           0 :     if (found) {
    3721           0 :       if (!result) {
    3722           0 :         desc.value().setNull();
    3723           0 :         FillPropertyDescriptor(desc, proxy, true);
    3724           0 :         return true;
    3725             :       }
    3726           0 :       if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
    3727           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3728           0 :         return false;
    3729             :       }
    3730           0 :       FillPropertyDescriptor(desc, proxy, true);
    3731           0 :       return true;
    3732             :     }
    3733             :   }
    3734             : 
    3735           0 :   JS::Rooted<JSObject*> expando(cx);
    3736           0 :   if (!isXray && (expando = GetExpandoObject(proxy))) {
    3737           0 :     if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
    3738           0 :       return false;
    3739             :     }
    3740           0 :     if (desc.object()) {
    3741             :       // Pretend the property lives on the wrapper.
    3742           0 :       desc.object().set(proxy);
    3743           0 :       return true;
    3744             :     }
    3745             :   }
    3746             : 
    3747           0 :   desc.object().set(nullptr);
    3748           0 :   return true;
    3749             : }
    3750             : 
    3751             : bool
    3752           0 : DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
    3753             : {
    3754           0 :   if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
    3755           0 :     *defined = true;
    3756           0 :     return opresult.failNoIndexedSetter();
    3757             :   }
    3758           0 :   return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
    3759             : }
    3760             : 
    3761             : 
    3762             : bool
    3763           0 : DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
    3764             : {
    3765           0 :   bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
    3766             : 
    3767           0 :   uint32_t length = UnwrapProxy(proxy)->Length();
    3768           0 :   MOZ_ASSERT(int32_t(length) >= 0);
    3769           0 :   for (int32_t i = 0; i < int32_t(length); ++i) {
    3770           0 :     if (!props.append(INT_TO_JSID(i))) {
    3771           0 :       return false;
    3772             :     }
    3773             :   }
    3774             : 
    3775           0 :   JS::Rooted<JSObject*> expando(cx);
    3776           0 :   if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
    3777           0 :       !js::GetPropertyKeys(cx, expando, flags, &props)) {
    3778           0 :     return false;
    3779             :   }
    3780             : 
    3781           0 :   return true;
    3782             : }
    3783             : 
    3784             : bool
    3785           0 : DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
    3786             : {
    3787           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    3788             :             "Should not have a XrayWrapper here");
    3789             : 
    3790           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    3791           0 :   if (IsArrayIndex(index)) {
    3792           0 :     bool found = false;
    3793           0 :     mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
    3794           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
    3795           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3796             :     (void)result;
    3797             : 
    3798           0 :     *bp = found;
    3799           0 :     return true;
    3800             :   }
    3801             : 
    3802             : 
    3803           0 :   JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
    3804           0 :   if (expando) {
    3805           0 :     bool b = true;
    3806           0 :     bool ok = JS_HasPropertyById(cx, expando, id, &b);
    3807           0 :     *bp = !!b;
    3808           0 :     if (!ok || *bp) {
    3809           0 :       return ok;
    3810             :     }
    3811             :   }
    3812             : 
    3813           0 :   *bp = false;
    3814           0 :   return true;
    3815             : }
    3816             : 
    3817             : bool
    3818           0 : DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
    3819             : {
    3820           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    3821             :               "Should not have a XrayWrapper here");
    3822             : 
    3823           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    3824           0 :   if (IsArrayIndex(index)) {
    3825           0 :     mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
    3826           0 :     bool found = false;
    3827           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
    3828           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3829             : 
    3830           0 :     if (found) {
    3831           0 :       if (!result) {
    3832           0 :         vp.setNull();
    3833           0 :         return true;
    3834             :       }
    3835           0 :       if (!GetOrCreateDOMReflector(cx, result, vp)) {
    3836           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3837           0 :         return false;
    3838             :       }
    3839           0 :       return true;
    3840             :     }
    3841             :     // Even if we don't have this index, we don't forward the
    3842             :     // get on to our expando object.
    3843             :   } else {
    3844             :     { // Scope for expando
    3845           0 :       JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
    3846           0 :       if (expando) {
    3847             :         bool hasProp;
    3848           0 :         if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
    3849           0 :           return false;
    3850             :         }
    3851             : 
    3852           0 :         if (hasProp) {
    3853             :           // Forward the get to the expando object, but our receiver is whatever our
    3854             :           // receiver is.
    3855           0 :           return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
    3856             :         }
    3857             :       }
    3858             :     }
    3859             :   }
    3860             : 
    3861             :   bool foundOnPrototype;
    3862           0 :   if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
    3863           0 :     return false;
    3864             :   }
    3865             : 
    3866           0 :   if (foundOnPrototype) {
    3867           0 :     return true;
    3868             :   }
    3869             : 
    3870           0 :   vp.setUndefined();
    3871           0 :   return true;
    3872             : }
    3873             : 
    3874             : const char*
    3875           0 : DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
    3876             : {
    3877           0 :   return "GridTracks";
    3878             : }
    3879             : 
    3880             : bool
    3881           0 : DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
    3882             : {
    3883           0 :   return false;
    3884             : }
    3885             : 
    3886             : void
    3887           0 : DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
    3888             : {
    3889           0 :   mozilla::dom::GridTracks* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GridTracks>(proxy);
    3890           0 :   if (self) {
    3891           0 :     ClearWrapper(self, self, proxy);
    3892           0 :     AddForDeferredFinalization<mozilla::dom::GridTracks>(self);
    3893             :   }
    3894           0 : }
    3895             : 
    3896             : const DOMProxyHandler*
    3897           0 : DOMProxyHandler::getInstance()
    3898             : {
    3899             :   static const DOMProxyHandler instance;
    3900           0 :   return &instance;
    3901             : }
    3902             : 
    3903             : bool
    3904           0 : DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
    3905             : {
    3906           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    3907             :             "Should not have a XrayWrapper here");
    3908             : 
    3909           0 :   uint32_t index = GetArrayIndexFromId(cx, id);
    3910           0 :   if (IsArrayIndex(index)) {
    3911             :     bool deleteSucceeded;
    3912           0 :     bool found = false;
    3913           0 :     mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
    3914           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
    3915           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3916             :     (void)result;
    3917           0 :     deleteSucceeded = !found;
    3918           0 :     return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
    3919             :   }
    3920             : 
    3921           0 :   return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
    3922             : }
    3923             : 
    3924             : bool
    3925           0 : DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
    3926             : {
    3927           0 :   JS::Rooted<JS::Value> temp(cx);
    3928           0 :   MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
    3929             :              "Should not have a XrayWrapper here");
    3930             : 
    3931           0 :   mozilla::dom::GridTracks* self = UnwrapProxy(proxy);
    3932           0 :   uint32_t length = self->Length();
    3933             :   // Compute the end of the indices we'll get ourselves
    3934           0 :   uint32_t ourEnd = std::max(begin, std::min(end, length));
    3935             : 
    3936           0 :   for (uint32_t index = begin; index < ourEnd; ++index) {
    3937           0 :     bool found = false;
    3938           0 :     auto result(StrongOrRawPtr<mozilla::dom::GridTrack>(self->IndexedGetter(index, found)));
    3939           0 :     MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3940             : 
    3941           0 :     MOZ_ASSERT(found);
    3942           0 :     if (!result) {
    3943           0 :       temp.setNull();
    3944           0 :       if (!adder->append(cx, temp)) return false;
    3945           0 :       continue;
    3946             :     }
    3947           0 :     if (!GetOrCreateDOMReflector(cx, result, &temp)) {
    3948           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3949           0 :       return false;
    3950             :     }
    3951           0 :     if (!adder->append(cx, temp)) return false;
    3952           0 :     continue;
    3953             :   }
    3954             : 
    3955           0 :   if (end > ourEnd) {
    3956           0 :     JS::Rooted<JSObject*> proto(cx);
    3957           0 :     if (!js::GetObjectProto(cx, proxy, &proto)) {
    3958           0 :       return false;
    3959             :     }
    3960           0 :     return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
    3961             :   }
    3962             : 
    3963           0 :   return true;
    3964             : }
    3965             : 
    3966             : static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
    3967             :     _objectMoved
    3968             : );
    3969             : 
    3970             : static const DOMJSClass sClass = {
    3971             :   PROXY_CLASS_WITH_EXT("GridTracks",
    3972             :                        JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
    3973             :                        &sClassExtension),
    3974             :   { prototypes::id::GridTracks, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    3975             :   IsBaseOf<nsISupports, mozilla::dom::GridTracks >::value,
    3976             :   sNativePropertyHooks,
    3977             :   FindAssociatedGlobalForNative<mozilla::dom::GridTracks>::Get,
    3978             :   GetProtoObjectHandle,
    3979             :   GetCCParticipant<mozilla::dom::GridTracks>::Get()
    3980             : };
    3981             : 
    3982             : bool
    3983           0 : Wrap(JSContext* aCx, mozilla::dom::GridTracks* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    3984             : {
    3985             :   MOZ_ASSERT(static_cast<mozilla::dom::GridTracks*>(aObject) ==
    3986             :              reinterpret_cast<mozilla::dom::GridTracks*>(aObject),
    3987             :              "Multiple inheritance for mozilla::dom::GridTracks is broken.");
    3988           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    3989           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    3990           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    3991             :              "You should probably not be using Wrap() directly; use "
    3992             :              "GetOrCreateDOMReflector instead");
    3993             : 
    3994           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    3995             :              "nsISupports must be on our primary inheritance chain");
    3996             : 
    3997           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    3998           0 :   if (!global) {
    3999           0 :     return false;
    4000             :   }
    4001           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    4002           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    4003             : 
    4004             :   // That might have ended up wrapping us already, due to the wonders
    4005             :   // of XBL.  Check for that, and bail out as needed.
    4006           0 :   aReflector.set(aCache->GetWrapper());
    4007           0 :   if (aReflector) {
    4008             : #ifdef DEBUG
    4009           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    4010             : #endif // DEBUG
    4011           0 :     return true;
    4012             :   }
    4013             : 
    4014           0 :   JSAutoCompartment ac(aCx, global);
    4015           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    4016           0 :   if (!canonicalProto) {
    4017           0 :     return false;
    4018             :   }
    4019           0 :   JS::Rooted<JSObject*> proto(aCx);
    4020           0 :   if (aGivenProto) {
    4021           0 :     proto = aGivenProto;
    4022             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    4023             :     // coming in, we changed compartments to that of "parent" so may need
    4024             :     // to wrap the proto here.
    4025           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    4026           0 :       if (!JS_WrapObject(aCx, &proto)) {
    4027           0 :         return false;
    4028             :       }
    4029             :     }
    4030             :   } else {
    4031           0 :     proto = canonicalProto;
    4032             :   }
    4033             : 
    4034           0 :   BindingJSObjectCreator<mozilla::dom::GridTracks> creator(aCx);
    4035           0 :   JS::Rooted<JS::Value> expandoValue(aCx, JS::UndefinedValue());
    4036           0 :   creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
    4037           0 :                             proto, aObject, expandoValue, aReflector);
    4038           0 :   if (!aReflector) {
    4039           0 :     return false;
    4040             :   }
    4041             : 
    4042             : 
    4043           0 :   aCache->SetWrapper(aReflector);
    4044           0 :   creator.InitializationSucceeded();
    4045             : 
    4046           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    4047             :              aCache->GetWrapperPreserveColor() == aReflector);
    4048             :   // If proto != canonicalProto, we have to preserve our wrapper;
    4049             :   // otherwise we won't be able to properly recreate it later, since
    4050             :   // we won't know what proto to use.  Note that we don't check
    4051             :   // aGivenProto here, since it's entirely possible (and even
    4052             :   // somewhat common) to have a non-null aGivenProto which is the
    4053             :   // same as canonicalProto.
    4054           0 :   if (proto != canonicalProto) {
    4055           0 :     PreserveWrapper(aObject);
    4056             :   }
    4057             : 
    4058           0 :   return true;
    4059             : }
    4060             : 
    4061             : static bool
    4062           0 : ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
    4063             : {
    4064           0 :   return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
    4065             : }
    4066             : 
    4067             : static bool
    4068           0 : EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
    4069             : {
    4070           0 :   return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
    4071             : }
    4072             : 
    4073             : const NativePropertyHooks sNativePropertyHooks[] = { {
    4074             :   ResolveOwnProperty,
    4075             :   EnumerateOwnProperties,
    4076             :   nullptr,
    4077             :   { sNativeProperties.Upcast(), nullptr },
    4078             :   prototypes::id::GridTracks,
    4079             :   constructors::id::GridTracks,
    4080             :   nullptr,
    4081             :   &DefaultXrayExpandoObjectClass
    4082             : } };
    4083             : 
    4084             : void
    4085           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    4086             : {
    4087           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    4088           0 :   if (!parentProto) {
    4089           0 :     return;
    4090             :   }
    4091             : 
    4092           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    4093           0 :   if (!constructorProto) {
    4094           0 :     return;
    4095             :   }
    4096             : 
    4097             :   static bool sIdsInited = false;
    4098           0 :   if (!sIdsInited && NS_IsMainThread()) {
    4099           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    4100           0 :       return;
    4101             :     }
    4102           0 :     sIdsInited = true;
    4103             :   }
    4104             : 
    4105           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GridTracks);
    4106           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GridTracks);
    4107           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    4108             :                               &sPrototypeClass.mBase, protoCache,
    4109             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    4110             :                               interfaceCache,
    4111             :                               sNativeProperties.Upcast(),
    4112             :                               nullptr,
    4113             :                               "GridTracks", aDefineOnGlobal,
    4114             :                               nullptr,
    4115           0 :                               false);
    4116             : }
    4117             : 
    4118             : JS::Handle<JSObject*>
    4119           0 : GetProtoObjectHandle(JSContext* aCx)
    4120             : {
    4121             :   /* Get the interface prototype object for this class.  This will create the
    4122             :      object as needed. */
    4123           0 :   bool aDefineOnGlobal = true;
    4124             : 
    4125             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    4126           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    4127           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    4128           0 :     return nullptr;
    4129             :   }
    4130             : 
    4131             :   /* Check to see whether the interface objects are already installed */
    4132           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    4133           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GridTracks)) {
    4134           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    4135           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    4136             :   }
    4137             : 
    4138             :   /*
    4139             :    * The object might _still_ be null, but that's OK.
    4140             :    *
    4141             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    4142             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    4143             :    * changed after they have been set.
    4144             :    *
    4145             :    * Calling address() avoids the read read barrier that does gray
    4146             :    * unmarking, but it's not possible for the object to be gray here.
    4147             :    */
    4148             : 
    4149           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GridTracks);
    4150           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    4151           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    4152             : }
    4153             : 
    4154             : JS::Handle<JSObject*>
    4155           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    4156             : {
    4157             :   /* Get the interface object for this class.  This will create the object as
    4158             :      needed. */
    4159             : 
    4160             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    4161           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    4162           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    4163           0 :     return nullptr;
    4164             :   }
    4165             : 
    4166             :   /* Check to see whether the interface objects are already installed */
    4167           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    4168           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GridTracks)) {
    4169           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    4170           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    4171             :   }
    4172             : 
    4173             :   /*
    4174             :    * The object might _still_ be null, but that's OK.
    4175             :    *
    4176             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    4177             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    4178             :    * changed after they have been set.
    4179             :    *
    4180             :    * Calling address() avoids the read read barrier that does gray
    4181             :    * unmarking, but it's not possible for the object to be gray here.
    4182             :    */
    4183             : 
    4184           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GridTracks);
    4185           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    4186           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    4187             : }
    4188             : 
    4189             : JSObject*
    4190           0 : GetConstructorObject(JSContext* aCx)
    4191             : {
    4192           0 :   return GetConstructorObjectHandle(aCx);
    4193             : }
    4194             : 
    4195             : } // namespace GridTracksBinding
    4196             : 
    4197             : 
    4198             : 
    4199             : } // namespace dom
    4200             : } // namespace mozilla

Generated by: LCOV version 1.13