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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM VRDisplay.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "VRDisplayBinding.h"
       6             : #include "WindowBinding.h"
       7             : #include "WrapperFactory.h"
       8             : #include "jsapi.h"
       9             : #include "jsfriendapi.h"
      10             : #include "mozilla/FloatingPoint.h"
      11             : #include "mozilla/OwningNonNull.h"
      12             : #include "mozilla/Preferences.h"
      13             : #include "mozilla/dom/BindingUtils.h"
      14             : #include "mozilla/dom/DOMJSClass.h"
      15             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      16             : #include "mozilla/dom/Nullable.h"
      17             : #include "mozilla/dom/PrimitiveConversions.h"
      18             : #include "mozilla/dom/Promise.h"
      19             : #include "mozilla/dom/ScriptSettings.h"
      20             : #include "mozilla/dom/ToJSValue.h"
      21             : #include "mozilla/dom/TypedArray.h"
      22             : #include "mozilla/dom/VRDisplay.h"
      23             : #include "mozilla/dom/XrayExpandoClass.h"
      24             : #include "nsContentUtils.h"
      25             : 
      26             : namespace mozilla {
      27             : namespace dom {
      28             : 
      29             : namespace VREyeValues {
      30             : extern const EnumEntry strings[3] = {
      31             :   {"left", 4},
      32             :   {"right", 5},
      33             :   { nullptr, 0 }
      34             : };
      35             : } // namespace VREyeValues
      36             : 
      37             : bool
      38           0 : ToJSValue(JSContext* aCx, VREye aArgument, JS::MutableHandle<JS::Value> aValue)
      39             : {
      40           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(VREyeValues::strings));
      41             :   JSString* resultStr =
      42           0 :     JS_NewStringCopyN(aCx, VREyeValues::strings[uint32_t(aArgument)].value,
      43           0 :                       VREyeValues::strings[uint32_t(aArgument)].length);
      44           0 :   if (!resultStr) {
      45           0 :     return false;
      46             :   }
      47           0 :   aValue.setString(resultStr);
      48           0 :   return true;
      49             : }
      50             : 
      51             : 
      52             : 
      53           0 : VRLayer::VRLayer()
      54             : {
      55             :   // Safe to pass a null context if we pass a null value
      56           0 :   Init(nullptr, JS::NullHandleValue);
      57           0 : }
      58             : 
      59             : 
      60             : 
      61             : bool
      62           0 : VRLayer::InitIds(JSContext* cx, VRLayerAtoms* atomsCache)
      63             : {
      64           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      65             : 
      66             :   // Initialize these in reverse order so that any failure leaves the first one
      67             :   // uninitialized.
      68           0 :   if (!atomsCache->source_id.init(cx, "source") ||
      69           0 :       !atomsCache->rightBounds_id.init(cx, "rightBounds") ||
      70           0 :       !atomsCache->leftBounds_id.init(cx, "leftBounds")) {
      71           0 :     return false;
      72             :   }
      73           0 :   return true;
      74             : }
      75             : 
      76             : bool
      77           0 : VRLayer::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      78             : {
      79             :   // Passing a null JSContext is OK only if we're initing from null,
      80             :   // Since in that case we will not have to do any property gets
      81             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      82             :   // checkers by static analysis tools
      83           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      84           0 :   VRLayerAtoms* atomsCache = nullptr;
      85           0 :   if (cx) {
      86           0 :     atomsCache = GetAtomCache<VRLayerAtoms>(cx);
      87           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      88           0 :       return false;
      89             :     }
      90             :   }
      91             : 
      92           0 :   if (!IsConvertibleToDictionary(val)) {
      93           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      94             :   }
      95             : 
      96           0 :   bool isNull = val.isNullOrUndefined();
      97             :   // We only need these if !isNull, in which case we have |cx|.
      98           0 :   Maybe<JS::Rooted<JSObject *> > object;
      99           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     100           0 :   if (!isNull) {
     101           0 :     MOZ_ASSERT(cx);
     102           0 :     object.emplace(cx, &val.toObject());
     103           0 :     temp.emplace(cx);
     104             :   }
     105           0 :   if (!isNull) {
     106           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->leftBounds_id, temp.ptr())) {
     107           0 :       return false;
     108             :     }
     109             :   }
     110           0 :   if (!isNull && !temp->isUndefined()) {
     111           0 :     if (temp.ref().isObject()) {
     112           0 :       JS::ForOfIterator iter(cx);
     113           0 :       if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
     114           0 :         return false;
     115             :       }
     116           0 :       if (!iter.valueIsIterable()) {
     117           0 :         ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'leftBounds' member of VRLayer");
     118           0 :         return false;
     119             :       }
     120           0 :       Sequence<float> &arr = mLeftBounds;
     121           0 :       JS::Rooted<JS::Value> temp(cx);
     122             :       while (true) {
     123             :         bool done;
     124           0 :         if (!iter.next(&temp, &done)) {
     125           0 :           return false;
     126             :         }
     127           0 :         if (done) {
     128           0 :           break;
     129             :         }
     130           0 :         float* slotPtr = arr.AppendElement(mozilla::fallible);
     131           0 :         if (!slotPtr) {
     132           0 :           JS_ReportOutOfMemory(cx);
     133           0 :           return false;
     134             :         }
     135           0 :         float& slot = *slotPtr;
     136           0 :         if (!ValueToPrimitive<float, eDefault>(cx, temp, &slot)) {
     137           0 :           return false;
     138           0 :         } else if (!mozilla::IsFinite(slot)) {
     139           0 :           ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of 'leftBounds' member of VRLayer");
     140           0 :           return false;
     141             :         }
     142           0 :       }
     143             :     } else {
     144           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'leftBounds' member of VRLayer");
     145           0 :       return false;
     146             :     }
     147             :   } else {
     148             :     /* Array is already empty; nothing to do */
     149             :   }
     150           0 :   mIsAnyMemberPresent = true;
     151             : 
     152           0 :   if (!isNull) {
     153           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->rightBounds_id, temp.ptr())) {
     154           0 :       return false;
     155             :     }
     156             :   }
     157           0 :   if (!isNull && !temp->isUndefined()) {
     158           0 :     if (temp.ref().isObject()) {
     159           0 :       JS::ForOfIterator iter(cx);
     160           0 :       if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
     161           0 :         return false;
     162             :       }
     163           0 :       if (!iter.valueIsIterable()) {
     164           0 :         ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'rightBounds' member of VRLayer");
     165           0 :         return false;
     166             :       }
     167           0 :       Sequence<float> &arr = mRightBounds;
     168           0 :       JS::Rooted<JS::Value> temp(cx);
     169             :       while (true) {
     170             :         bool done;
     171           0 :         if (!iter.next(&temp, &done)) {
     172           0 :           return false;
     173             :         }
     174           0 :         if (done) {
     175           0 :           break;
     176             :         }
     177           0 :         float* slotPtr = arr.AppendElement(mozilla::fallible);
     178           0 :         if (!slotPtr) {
     179           0 :           JS_ReportOutOfMemory(cx);
     180           0 :           return false;
     181             :         }
     182           0 :         float& slot = *slotPtr;
     183           0 :         if (!ValueToPrimitive<float, eDefault>(cx, temp, &slot)) {
     184           0 :           return false;
     185           0 :         } else if (!mozilla::IsFinite(slot)) {
     186           0 :           ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of 'rightBounds' member of VRLayer");
     187           0 :           return false;
     188             :         }
     189           0 :       }
     190             :     } else {
     191           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'rightBounds' member of VRLayer");
     192           0 :       return false;
     193             :     }
     194             :   } else {
     195             :     /* Array is already empty; nothing to do */
     196             :   }
     197           0 :   mIsAnyMemberPresent = true;
     198             : 
     199           0 :   if (!isNull) {
     200           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->source_id, temp.ptr())) {
     201           0 :       return false;
     202             :     }
     203             :   }
     204           0 :   if (!isNull && !temp->isUndefined()) {
     205           0 :     if (temp.ref().isObject()) {
     206             :       static_assert(IsRefcounted<mozilla::dom::HTMLCanvasElement>::value, "We can only store refcounted classes.");{
     207           0 :         nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(temp.ptr(), mSource);
     208           0 :         if (NS_FAILED(rv)) {
     209           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'source' member of VRLayer", "HTMLCanvasElement");
     210           0 :           return false;
     211             :         }
     212             :       }
     213           0 :     } else if (temp.ref().isNullOrUndefined()) {
     214           0 :       mSource = nullptr;
     215             :     } else {
     216           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'source' member of VRLayer");
     217           0 :       return false;
     218             :     }
     219             :   } else {
     220           0 :     mSource = nullptr;
     221             :   }
     222           0 :   mIsAnyMemberPresent = true;
     223           0 :   return true;
     224             : }
     225             : 
     226             : bool
     227           0 : VRLayer::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     228             : {
     229           0 :   VRLayerAtoms* atomsCache = GetAtomCache<VRLayerAtoms>(cx);
     230           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     231           0 :     return false;
     232             :   }
     233             : 
     234           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     235           0 :   if (!obj) {
     236           0 :     return false;
     237             :   }
     238           0 :   rval.set(JS::ObjectValue(*obj));
     239             : 
     240             :   do {
     241             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     242           0 :     JS::Rooted<JS::Value> temp(cx);
     243           0 :     Sequence<float> const & currentValue = mLeftBounds;
     244             : 
     245           0 :     uint32_t length = currentValue.Length();
     246           0 :     JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     247           0 :     if (!returnArray) {
     248           0 :       return false;
     249             :     }
     250             :     // Scope for 'tmp'
     251             :     {
     252           0 :       JS::Rooted<JS::Value> tmp(cx);
     253           0 :       for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     254             :         // Control block to let us common up the JS_DefineElement calls when there
     255             :         // are different ways to succeed at wrapping the object.
     256             :         do {
     257           0 :           tmp.set(JS_NumberValue(double(currentValue[sequenceIdx0])));
     258           0 :           break;
     259             :         } while (0);
     260           0 :         if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     261             :                               JSPROP_ENUMERATE)) {
     262           0 :           return false;
     263             :         }
     264             :       }
     265             :     }
     266           0 :     temp.setObject(*returnArray);
     267           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->leftBounds_id, temp, JSPROP_ENUMERATE)) {
     268           0 :       return false;
     269             :     }
     270           0 :     break;
     271             :   } while(0);
     272             : 
     273             :   do {
     274             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     275           0 :     JS::Rooted<JS::Value> temp(cx);
     276           0 :     Sequence<float> const & currentValue = mRightBounds;
     277             : 
     278           0 :     uint32_t length = currentValue.Length();
     279           0 :     JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     280           0 :     if (!returnArray) {
     281           0 :       return false;
     282             :     }
     283             :     // Scope for 'tmp'
     284             :     {
     285           0 :       JS::Rooted<JS::Value> tmp(cx);
     286           0 :       for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     287             :         // Control block to let us common up the JS_DefineElement calls when there
     288             :         // are different ways to succeed at wrapping the object.
     289             :         do {
     290           0 :           tmp.set(JS_NumberValue(double(currentValue[sequenceIdx0])));
     291           0 :           break;
     292             :         } while (0);
     293           0 :         if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     294             :                               JSPROP_ENUMERATE)) {
     295           0 :           return false;
     296             :         }
     297             :       }
     298             :     }
     299           0 :     temp.setObject(*returnArray);
     300           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->rightBounds_id, temp, JSPROP_ENUMERATE)) {
     301           0 :       return false;
     302             :     }
     303           0 :     break;
     304             :   } while(0);
     305             : 
     306             :   do {
     307             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     308           0 :     JS::Rooted<JS::Value> temp(cx);
     309           0 :     RefPtr<mozilla::dom::HTMLCanvasElement> const & currentValue = mSource;
     310           0 :     if (!currentValue) {
     311           0 :       temp.setNull();
     312           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->source_id, temp, JSPROP_ENUMERATE)) {
     313           0 :         return false;
     314             :       }
     315           0 :       break;
     316             :     }
     317           0 :     if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     318           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     319           0 :       return false;
     320             :     }
     321           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->source_id, temp, JSPROP_ENUMERATE)) {
     322           0 :       return false;
     323             :     }
     324           0 :     break;
     325             :   } while(0);
     326             : 
     327           0 :   return true;
     328             : }
     329             : 
     330             : void
     331           0 : VRLayer::TraceDictionary(JSTracer* trc)
     332             : {
     333           0 : }
     334             : 
     335             : VRLayer&
     336           0 : VRLayer::operator=(const VRLayer& aOther)
     337             : {
     338           0 :   mLeftBounds = aOther.mLeftBounds;
     339           0 :   mRightBounds = aOther.mRightBounds;
     340           0 :   mSource = aOther.mSource;
     341           0 :   return *this;
     342             : }
     343             : 
     344             : namespace binding_detail {
     345             : } // namespace binding_detail
     346             : 
     347             : 
     348             : namespace VRDisplayBinding {
     349             : 
     350             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
     351             :               "Can't inherit from an interface with a different ownership model.");
     352             : 
     353             : static bool
     354           0 : get_presentingGroups(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     355             : {
     356           0 :   uint32_t result(self->PresentingGroups());
     357           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     358           0 :   args.rval().setNumber(result);
     359           0 :   return true;
     360             : }
     361             : 
     362             : static const JSJitInfo presentingGroups_getterinfo = {
     363             :   { (JSJitGetterOp)get_presentingGroups },
     364             :   { prototypes::id::VRDisplay },
     365             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     366             :   JSJitInfo::Getter,
     367             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     368             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     369             :   true,  /* isInfallible. False in setters. */
     370             :   false,  /* isMovable.  Not relevant for setters. */
     371             :   false, /* isEliminatable.  Not relevant for setters. */
     372             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     373             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     374             :   false,  /* isTypedMethod.  Only relevant for methods. */
     375             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     376             : };
     377             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     378             : static_assert(0 < 1, "There is no slot for us");
     379             : 
     380             : static bool
     381           0 : get_groupMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     382             : {
     383           0 :   uint32_t result(self->GroupMask());
     384           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     385           0 :   args.rval().setNumber(result);
     386           0 :   return true;
     387             : }
     388             : 
     389             : static bool
     390           0 : set_groupMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitSetterCallArgs args)
     391             : {
     392             :   uint32_t arg0;
     393           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
     394           0 :     return false;
     395             :   }
     396           0 :   self->SetGroupMask(arg0);
     397           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     398             : 
     399           0 :   return true;
     400             : }
     401             : 
     402             : static const JSJitInfo groupMask_getterinfo = {
     403             :   { (JSJitGetterOp)get_groupMask },
     404             :   { prototypes::id::VRDisplay },
     405             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     406             :   JSJitInfo::Getter,
     407             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     408             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     409             :   true,  /* isInfallible. False in setters. */
     410             :   false,  /* isMovable.  Not relevant for setters. */
     411             :   false, /* isEliminatable.  Not relevant for setters. */
     412             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     413             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     414             :   false,  /* isTypedMethod.  Only relevant for methods. */
     415             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     416             : };
     417             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     418             : static_assert(0 < 1, "There is no slot for us");
     419             : static const JSJitInfo groupMask_setterinfo = {
     420             :   { (JSJitGetterOp)set_groupMask },
     421             :   { prototypes::id::VRDisplay },
     422             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     423             :   JSJitInfo::Setter,
     424             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     425             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     426             :   false,  /* isInfallible. False in setters. */
     427             :   false,  /* isMovable.  Not relevant for setters. */
     428             :   false, /* isEliminatable.  Not relevant for setters. */
     429             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     430             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     431             :   false,  /* isTypedMethod.  Only relevant for methods. */
     432             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     433             : };
     434             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     435             : static_assert(0 < 1, "There is no slot for us");
     436             : 
     437             : static bool
     438           0 : get_isConnected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     439             : {
     440           0 :   bool result(self->IsConnected());
     441           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     442           0 :   args.rval().setBoolean(result);
     443           0 :   return true;
     444             : }
     445             : 
     446             : static const JSJitInfo isConnected_getterinfo = {
     447             :   { (JSJitGetterOp)get_isConnected },
     448             :   { prototypes::id::VRDisplay },
     449             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     450             :   JSJitInfo::Getter,
     451             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     452             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     453             :   true,  /* isInfallible. False in setters. */
     454             :   false,  /* isMovable.  Not relevant for setters. */
     455             :   false, /* isEliminatable.  Not relevant for setters. */
     456             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     457             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     458             :   false,  /* isTypedMethod.  Only relevant for methods. */
     459             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     460             : };
     461             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     462             : static_assert(0 < 1, "There is no slot for us");
     463             : 
     464             : static bool
     465           0 : get_isPresenting(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     466             : {
     467           0 :   bool result(self->IsPresenting());
     468           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     469           0 :   args.rval().setBoolean(result);
     470           0 :   return true;
     471             : }
     472             : 
     473             : static const JSJitInfo isPresenting_getterinfo = {
     474             :   { (JSJitGetterOp)get_isPresenting },
     475             :   { prototypes::id::VRDisplay },
     476             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     477             :   JSJitInfo::Getter,
     478             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     479             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     480             :   true,  /* isInfallible. False in setters. */
     481             :   false,  /* isMovable.  Not relevant for setters. */
     482             :   false, /* isEliminatable.  Not relevant for setters. */
     483             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     484             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     485             :   false,  /* isTypedMethod.  Only relevant for methods. */
     486             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     487             : };
     488             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     489             : static_assert(0 < 1, "There is no slot for us");
     490             : 
     491             : static bool
     492           0 : get_capabilities(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     493             : {
     494           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRDisplayCapabilities>(self->Capabilities()));
     495           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     496           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     497           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     498           0 :     return false;
     499             :   }
     500           0 :   return true;
     501             : }
     502             : 
     503             : static const JSJitInfo capabilities_getterinfo = {
     504             :   { (JSJitGetterOp)get_capabilities },
     505             :   { prototypes::id::VRDisplay },
     506             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     507             :   JSJitInfo::Getter,
     508             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     509             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     510             :   false,  /* isInfallible. False in setters. */
     511             :   true,  /* isMovable.  Not relevant for setters. */
     512             :   true, /* isEliminatable.  Not relevant for setters. */
     513             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     514             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     515             :   false,  /* isTypedMethod.  Only relevant for methods. */
     516             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     517             : };
     518             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     519             : static_assert(0 < 1, "There is no slot for us");
     520             : 
     521             : static bool
     522           0 : get_stageParameters(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     523             : {
     524           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRStageParameters>(self->GetStageParameters()));
     525           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     526           0 :   if (!result) {
     527           0 :     args.rval().setNull();
     528           0 :     return true;
     529             :   }
     530           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     531           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     532           0 :     return false;
     533             :   }
     534           0 :   return true;
     535             : }
     536             : 
     537             : static const JSJitInfo stageParameters_getterinfo = {
     538             :   { (JSJitGetterOp)get_stageParameters },
     539             :   { prototypes::id::VRDisplay },
     540             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     541             :   JSJitInfo::Getter,
     542             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     543             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     544             :   false,  /* isInfallible. False in setters. */
     545             :   false,  /* isMovable.  Not relevant for setters. */
     546             :   false, /* isEliminatable.  Not relevant for setters. */
     547             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     548             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     549             :   false,  /* isTypedMethod.  Only relevant for methods. */
     550             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     551             : };
     552             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     553             : static_assert(0 < 1, "There is no slot for us");
     554             : 
     555             : static bool
     556           0 : getEyeParameters(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     557             : {
     558           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     559           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.getEyeParameters");
     560             :   }
     561             :   VREye arg0;
     562             :   {
     563             :     int index;
     564           0 :     if (!FindEnumStringIndex<true>(cx, args[0], VREyeValues::strings, "VREye", "Argument 1 of VRDisplay.getEyeParameters", &index)) {
     565           0 :       return false;
     566             :     }
     567           0 :     MOZ_ASSERT(index >= 0);
     568           0 :     arg0 = static_cast<VREye>(index);
     569             :   }
     570           0 :   auto result(StrongOrRawPtr<mozilla::dom::VREyeParameters>(self->GetEyeParameters(arg0)));
     571           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     572           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     573           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     574           0 :     return false;
     575             :   }
     576           0 :   return true;
     577             : }
     578             : 
     579             : static const JSJitInfo getEyeParameters_methodinfo = {
     580             :   { (JSJitGetterOp)getEyeParameters },
     581             :   { prototypes::id::VRDisplay },
     582             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     583             :   JSJitInfo::Method,
     584             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     585             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     586             :   false,  /* isInfallible. False in setters. */
     587             :   false,  /* isMovable.  Not relevant for setters. */
     588             :   false, /* isEliminatable.  Not relevant for setters. */
     589             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     590             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     591             :   false,  /* isTypedMethod.  Only relevant for methods. */
     592             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     593             : };
     594             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     595             : static_assert(0 < 1, "There is no slot for us");
     596             : 
     597             : static bool
     598           0 : get_displayId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     599             : {
     600           0 :   uint32_t result(self->DisplayId());
     601           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     602           0 :   args.rval().setNumber(result);
     603           0 :   return true;
     604             : }
     605             : 
     606             : static const JSJitInfo displayId_getterinfo = {
     607             :   { (JSJitGetterOp)get_displayId },
     608             :   { prototypes::id::VRDisplay },
     609             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     610             :   JSJitInfo::Getter,
     611             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     612             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     613             :   true,  /* isInfallible. False in setters. */
     614             :   true,  /* isMovable.  Not relevant for setters. */
     615             :   true, /* isEliminatable.  Not relevant for setters. */
     616             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     617             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     618             :   false,  /* isTypedMethod.  Only relevant for methods. */
     619             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     620             : };
     621             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     622             : static_assert(0 < 1, "There is no slot for us");
     623             : 
     624             : static bool
     625           0 : get_displayName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     626             : {
     627           0 :   DOMString result;
     628           0 :   self->GetDisplayName(result);
     629           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     630           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     631           0 :     return false;
     632             :   }
     633           0 :   return true;
     634             : }
     635             : 
     636             : static const JSJitInfo displayName_getterinfo = {
     637             :   { (JSJitGetterOp)get_displayName },
     638             :   { prototypes::id::VRDisplay },
     639             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     640             :   JSJitInfo::Getter,
     641             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     642             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     643             :   false,  /* isInfallible. False in setters. */
     644             :   true,  /* isMovable.  Not relevant for setters. */
     645             :   true, /* isEliminatable.  Not relevant for setters. */
     646             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     647             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     648             :   false,  /* isTypedMethod.  Only relevant for methods. */
     649             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     650             : };
     651             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     652             : static_assert(0 < 1, "There is no slot for us");
     653             : 
     654             : static bool
     655           0 : getFrameData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     656             : {
     657           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     658           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.getFrameData");
     659             :   }
     660           0 :   NonNull<mozilla::dom::VRFrameData> arg0;
     661           0 :   if (args[0].isObject()) {
     662             :     {
     663           0 :       nsresult rv = UnwrapObject<prototypes::id::VRFrameData, mozilla::dom::VRFrameData>(args[0], arg0);
     664           0 :       if (NS_FAILED(rv)) {
     665           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of VRDisplay.getFrameData", "VRFrameData");
     666           0 :         return false;
     667             :       }
     668             :     }
     669             :   } else {
     670           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of VRDisplay.getFrameData");
     671           0 :     return false;
     672             :   }
     673           0 :   bool result(self->GetFrameData(NonNullHelper(arg0)));
     674           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     675           0 :   args.rval().setBoolean(result);
     676           0 :   return true;
     677             : }
     678             : 
     679             : static const JSJitInfo getFrameData_methodinfo = {
     680             :   { (JSJitGetterOp)getFrameData },
     681             :   { prototypes::id::VRDisplay },
     682             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     683             :   JSJitInfo::Method,
     684             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     685             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     686             :   false,  /* isInfallible. False in setters. */
     687             :   false,  /* isMovable.  Not relevant for setters. */
     688             :   false, /* isEliminatable.  Not relevant for setters. */
     689             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     690             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     691             :   false,  /* isTypedMethod.  Only relevant for methods. */
     692             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     693             : };
     694             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     695             : static_assert(0 < 1, "There is no slot for us");
     696             : 
     697             : static bool
     698           0 : getPose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     699             : {
     700           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRPose>(self->GetPose()));
     701           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     702             :   static_assert(!IsPointer<decltype(result)>::value,
     703             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     704           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     705           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     706           0 :     return false;
     707             :   }
     708           0 :   return true;
     709             : }
     710             : 
     711             : static const JSJitInfo getPose_methodinfo = {
     712             :   { (JSJitGetterOp)getPose },
     713             :   { prototypes::id::VRDisplay },
     714             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     715             :   JSJitInfo::Method,
     716             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     717             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     718             :   false,  /* isInfallible. False in setters. */
     719             :   false,  /* isMovable.  Not relevant for setters. */
     720             :   false, /* isEliminatable.  Not relevant for setters. */
     721             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     722             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     723             :   false,  /* isTypedMethod.  Only relevant for methods. */
     724             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     725             : };
     726             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     727             : static_assert(0 < 1, "There is no slot for us");
     728             : 
     729             : static bool
     730           0 : getSubmitFrameResult(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     731             : {
     732           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     733           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.getSubmitFrameResult");
     734             :   }
     735           0 :   NonNull<mozilla::dom::VRSubmitFrameResult> arg0;
     736           0 :   if (args[0].isObject()) {
     737             :     {
     738           0 :       nsresult rv = UnwrapObject<prototypes::id::VRSubmitFrameResult, mozilla::dom::VRSubmitFrameResult>(args[0], arg0);
     739           0 :       if (NS_FAILED(rv)) {
     740           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of VRDisplay.getSubmitFrameResult", "VRSubmitFrameResult");
     741           0 :         return false;
     742             :       }
     743             :     }
     744             :   } else {
     745           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of VRDisplay.getSubmitFrameResult");
     746           0 :     return false;
     747             :   }
     748           0 :   bool result(self->GetSubmitFrameResult(NonNullHelper(arg0)));
     749           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     750           0 :   args.rval().setBoolean(result);
     751           0 :   return true;
     752             : }
     753             : 
     754             : static const JSJitInfo getSubmitFrameResult_methodinfo = {
     755             :   { (JSJitGetterOp)getSubmitFrameResult },
     756             :   { prototypes::id::VRDisplay },
     757             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     758             :   JSJitInfo::Method,
     759             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     760             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     761             :   false,  /* isInfallible. False in setters. */
     762             :   false,  /* isMovable.  Not relevant for setters. */
     763             :   false, /* isEliminatable.  Not relevant for setters. */
     764             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     765             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     766             :   false,  /* isTypedMethod.  Only relevant for methods. */
     767             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     768             : };
     769             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     770             : static_assert(0 < 1, "There is no slot for us");
     771             : 
     772             : static bool
     773           0 : resetPose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     774             : {
     775           0 :   self->ResetPose();
     776           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     777           0 :   args.rval().setUndefined();
     778           0 :   return true;
     779             : }
     780             : 
     781             : static const JSJitInfo resetPose_methodinfo = {
     782             :   { (JSJitGetterOp)resetPose },
     783             :   { prototypes::id::VRDisplay },
     784             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     785             :   JSJitInfo::Method,
     786             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     787             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     788             :   true,  /* isInfallible. False in setters. */
     789             :   false,  /* isMovable.  Not relevant for setters. */
     790             :   false, /* isEliminatable.  Not relevant for setters. */
     791             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     792             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     793             :   false,  /* isTypedMethod.  Only relevant for methods. */
     794             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     795             : };
     796             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     797             : static_assert(0 < 1, "There is no slot for us");
     798             : 
     799             : static bool
     800           0 : get_depthNear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     801             : {
     802           0 :   double result(self->DepthNear());
     803           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     804           0 :   args.rval().set(JS_NumberValue(double(result)));
     805           0 :   return true;
     806             : }
     807             : 
     808             : static bool
     809           0 : set_depthNear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitSetterCallArgs args)
     810             : {
     811             :   double arg0;
     812           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     813           0 :     return false;
     814           0 :   } else if (!mozilla::IsFinite(arg0)) {
     815           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to VRDisplay.depthNear");
     816           0 :     return false;
     817             :   }
     818           0 :   self->SetDepthNear(arg0);
     819           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     820             : 
     821           0 :   return true;
     822             : }
     823             : 
     824             : static const JSJitInfo depthNear_getterinfo = {
     825             :   { (JSJitGetterOp)get_depthNear },
     826             :   { prototypes::id::VRDisplay },
     827             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     828             :   JSJitInfo::Getter,
     829             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     830             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     831             :   true,  /* isInfallible. False in setters. */
     832             :   false,  /* isMovable.  Not relevant for setters. */
     833             :   false, /* isEliminatable.  Not relevant for setters. */
     834             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     835             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     836             :   false,  /* isTypedMethod.  Only relevant for methods. */
     837             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     838             : };
     839             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     840             : static_assert(0 < 1, "There is no slot for us");
     841             : static const JSJitInfo depthNear_setterinfo = {
     842             :   { (JSJitGetterOp)set_depthNear },
     843             :   { prototypes::id::VRDisplay },
     844             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     845             :   JSJitInfo::Setter,
     846             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     847             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     848             :   false,  /* isInfallible. False in setters. */
     849             :   false,  /* isMovable.  Not relevant for setters. */
     850             :   false, /* isEliminatable.  Not relevant for setters. */
     851             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     852             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     853             :   false,  /* isTypedMethod.  Only relevant for methods. */
     854             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     855             : };
     856             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     857             : static_assert(0 < 1, "There is no slot for us");
     858             : 
     859             : static bool
     860           0 : get_depthFar(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
     861             : {
     862           0 :   double result(self->DepthFar());
     863           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     864           0 :   args.rval().set(JS_NumberValue(double(result)));
     865           0 :   return true;
     866             : }
     867             : 
     868             : static bool
     869           0 : set_depthFar(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitSetterCallArgs args)
     870             : {
     871             :   double arg0;
     872           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     873           0 :     return false;
     874           0 :   } else if (!mozilla::IsFinite(arg0)) {
     875           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to VRDisplay.depthFar");
     876           0 :     return false;
     877             :   }
     878           0 :   self->SetDepthFar(arg0);
     879           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     880             : 
     881           0 :   return true;
     882             : }
     883             : 
     884             : static const JSJitInfo depthFar_getterinfo = {
     885             :   { (JSJitGetterOp)get_depthFar },
     886             :   { prototypes::id::VRDisplay },
     887             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     888             :   JSJitInfo::Getter,
     889             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     890             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     891             :   true,  /* isInfallible. False in setters. */
     892             :   false,  /* isMovable.  Not relevant for setters. */
     893             :   false, /* isEliminatable.  Not relevant for setters. */
     894             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     895             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     896             :   false,  /* isTypedMethod.  Only relevant for methods. */
     897             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     898             : };
     899             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     900             : static_assert(0 < 1, "There is no slot for us");
     901             : static const JSJitInfo depthFar_setterinfo = {
     902             :   { (JSJitGetterOp)set_depthFar },
     903             :   { prototypes::id::VRDisplay },
     904             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     905             :   JSJitInfo::Setter,
     906             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     907             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     908             :   false,  /* isInfallible. False in setters. */
     909             :   false,  /* isMovable.  Not relevant for setters. */
     910             :   false, /* isEliminatable.  Not relevant for setters. */
     911             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     912             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     913             :   false,  /* isTypedMethod.  Only relevant for methods. */
     914             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     915             : };
     916             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     917             : static_assert(0 < 1, "There is no slot for us");
     918             : 
     919             : static bool
     920           0 : requestAnimationFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     921             : {
     922           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     923           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.requestAnimationFrame");
     924             :   }
     925           0 :   RootedCallback<OwningNonNull<binding_detail::FastFrameRequestCallback>> arg0(cx);
     926           0 :   if (args[0].isObject()) {
     927           0 :     if (JS::IsCallable(&args[0].toObject())) {
     928             :     { // scope for tempRoot
     929           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     930           0 :       arg0 = new binding_detail::FastFrameRequestCallback(tempRoot);
     931             :     }
     932             :     } else {
     933           0 :       ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of VRDisplay.requestAnimationFrame");
     934           0 :       return false;
     935             :     }
     936             :   } else {
     937           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of VRDisplay.requestAnimationFrame");
     938           0 :     return false;
     939             :   }
     940           0 :   binding_detail::FastErrorResult rv;
     941           0 :   int32_t result(self->RequestAnimationFrame(NonNullHelper(arg0), rv));
     942           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     943           0 :     return false;
     944             :   }
     945           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     946           0 :   args.rval().setInt32(int32_t(result));
     947           0 :   return true;
     948             : }
     949             : 
     950             : static const JSJitInfo requestAnimationFrame_methodinfo = {
     951             :   { (JSJitGetterOp)requestAnimationFrame },
     952             :   { prototypes::id::VRDisplay },
     953             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     954             :   JSJitInfo::Method,
     955             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     956             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     957             :   false,  /* isInfallible. False in setters. */
     958             :   false,  /* isMovable.  Not relevant for setters. */
     959             :   false, /* isEliminatable.  Not relevant for setters. */
     960             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     961             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     962             :   false,  /* isTypedMethod.  Only relevant for methods. */
     963             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     964             : };
     965             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     966             : static_assert(0 < 1, "There is no slot for us");
     967             : 
     968             : static bool
     969           0 : cancelAnimationFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
     970             : {
     971           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     972           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.cancelAnimationFrame");
     973             :   }
     974             :   int32_t arg0;
     975           0 :   if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
     976           0 :     return false;
     977             :   }
     978           0 :   binding_detail::FastErrorResult rv;
     979           0 :   self->CancelAnimationFrame(arg0, rv);
     980           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     981           0 :     return false;
     982             :   }
     983           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     984           0 :   args.rval().setUndefined();
     985           0 :   return true;
     986             : }
     987             : 
     988             : static const JSJitInfo cancelAnimationFrame_methodinfo = {
     989             :   { (JSJitGetterOp)cancelAnimationFrame },
     990             :   { prototypes::id::VRDisplay },
     991             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
     992             :   JSJitInfo::Method,
     993             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     994             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     995             :   false,  /* isInfallible. False in setters. */
     996             :   false,  /* isMovable.  Not relevant for setters. */
     997             :   false, /* isEliminatable.  Not relevant for setters. */
     998             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     999             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1000             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1001             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1002             : };
    1003             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1004             : static_assert(0 < 1, "There is no slot for us");
    1005             : 
    1006             : static bool
    1007           0 : requestPresent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
    1008             : {
    1009           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1010           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.requestPresent");
    1011             :   }
    1012           0 :   binding_detail::AutoSequence<VRLayer> arg0;
    1013           0 :   if (args[0].isObject()) {
    1014           0 :     JS::ForOfIterator iter(cx);
    1015           0 :     if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
    1016           0 :       return false;
    1017             :     }
    1018           0 :     if (!iter.valueIsIterable()) {
    1019           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of VRDisplay.requestPresent");
    1020           0 :       return false;
    1021             :     }
    1022           0 :     binding_detail::AutoSequence<VRLayer> &arr = arg0;
    1023           0 :     JS::Rooted<JS::Value> temp(cx);
    1024             :     while (true) {
    1025             :       bool done;
    1026           0 :       if (!iter.next(&temp, &done)) {
    1027           0 :         return false;
    1028             :       }
    1029           0 :       if (done) {
    1030           0 :         break;
    1031             :       }
    1032           0 :       VRLayer* slotPtr = arr.AppendElement(mozilla::fallible);
    1033           0 :       if (!slotPtr) {
    1034           0 :         JS_ReportOutOfMemory(cx);
    1035           0 :         return false;
    1036             :       }
    1037           0 :       VRLayer& slot = *slotPtr;
    1038           0 :       if (!slot.Init(cx, temp,  "Element of argument 1 of VRDisplay.requestPresent", false)) {
    1039           0 :         return false;
    1040             :       }
    1041           0 :     }
    1042             :   } else {
    1043           0 :     ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of VRDisplay.requestPresent");
    1044           0 :     return false;
    1045             :   }
    1046           0 :   binding_detail::FastErrorResult rv;
    1047           0 :   auto result(StrongOrRawPtr<Promise>(self->RequestPresent(Constify(arg0), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
    1048           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1049           0 :     return false;
    1050             :   }
    1051           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1052           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1053           0 :     return false;
    1054             :   }
    1055           0 :   return true;
    1056             : }
    1057             : 
    1058             : static bool
    1059           0 : requestPresent_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
    1060             : {
    1061             :   // Make sure to save the callee before someone maybe messes
    1062             :   // with rval().
    1063           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1064           0 :   bool ok = requestPresent(cx, obj, self, args);
    1065           0 :   if (ok) {
    1066           0 :     return true;
    1067             :   }
    1068           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1069           0 :                                    args.rval());
    1070             : }
    1071             : 
    1072             : static const JSJitInfo requestPresent_methodinfo = {
    1073             :   { (JSJitGetterOp)requestPresent_promiseWrapper },
    1074             :   { prototypes::id::VRDisplay },
    1075             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
    1076             :   JSJitInfo::Method,
    1077             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1078             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1079             :   false,  /* isInfallible. False in setters. */
    1080             :   false,  /* isMovable.  Not relevant for setters. */
    1081             :   false, /* isEliminatable.  Not relevant for setters. */
    1082             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1083             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1084             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1085             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1086             : };
    1087             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1088             : static_assert(0 < 1, "There is no slot for us");
    1089             : 
    1090             : static bool
    1091           0 : exitPresent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
    1092             : {
    1093           0 :   binding_detail::FastErrorResult rv;
    1094           0 :   auto result(StrongOrRawPtr<Promise>(self->ExitPresent(rv)));
    1095           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1096           0 :     return false;
    1097             :   }
    1098           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1099           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1100           0 :     return false;
    1101             :   }
    1102           0 :   return true;
    1103             : }
    1104             : 
    1105             : static bool
    1106           0 : exitPresent_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
    1107             : {
    1108             :   // Make sure to save the callee before someone maybe messes
    1109             :   // with rval().
    1110           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1111           0 :   bool ok = exitPresent(cx, obj, self, args);
    1112           0 :   if (ok) {
    1113           0 :     return true;
    1114             :   }
    1115           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1116           0 :                                    args.rval());
    1117             : }
    1118             : 
    1119             : static const JSJitInfo exitPresent_methodinfo = {
    1120             :   { (JSJitGetterOp)exitPresent_promiseWrapper },
    1121             :   { prototypes::id::VRDisplay },
    1122             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
    1123             :   JSJitInfo::Method,
    1124             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1125             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1126             :   false,  /* isInfallible. False in setters. */
    1127             :   false,  /* isMovable.  Not relevant for setters. */
    1128             :   false, /* isEliminatable.  Not relevant for setters. */
    1129             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1130             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1131             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1132             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1133             : };
    1134             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1135             : static_assert(0 < 1, "There is no slot for us");
    1136             : 
    1137             : static bool
    1138           0 : getLayers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
    1139             : {
    1140           0 :   nsTArray<VRLayer> result;
    1141           0 :   self->GetLayers(result);
    1142           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1143             : 
    1144           0 :   uint32_t length = result.Length();
    1145           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
    1146           0 :   if (!returnArray) {
    1147           0 :     return false;
    1148             :   }
    1149             :   // Scope for 'tmp'
    1150             :   {
    1151           0 :     JS::Rooted<JS::Value> tmp(cx);
    1152           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
    1153             :       // Control block to let us common up the JS_DefineElement calls when there
    1154             :       // are different ways to succeed at wrapping the object.
    1155             :       do {
    1156           0 :         if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
    1157           0 :           return false;
    1158             :         }
    1159           0 :         break;
    1160             :       } while (0);
    1161           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
    1162             :                             JSPROP_ENUMERATE)) {
    1163           0 :         return false;
    1164             :       }
    1165             :     }
    1166             :   }
    1167           0 :   args.rval().setObject(*returnArray);
    1168           0 :   return true;
    1169             : }
    1170             : 
    1171             : static const JSJitInfo getLayers_methodinfo = {
    1172             :   { (JSJitGetterOp)getLayers },
    1173             :   { prototypes::id::VRDisplay },
    1174             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
    1175             :   JSJitInfo::Method,
    1176             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1177             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1178             :   false,  /* isInfallible. False in setters. */
    1179             :   false,  /* isMovable.  Not relevant for setters. */
    1180             :   false, /* isEliminatable.  Not relevant for setters. */
    1181             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1182             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1183             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1184             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1185             : };
    1186             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1187             : static_assert(0 < 1, "There is no slot for us");
    1188             : 
    1189             : static bool
    1190           0 : submitFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
    1191             : {
    1192           0 :   self->SubmitFrame();
    1193           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1194           0 :   args.rval().setUndefined();
    1195           0 :   return true;
    1196             : }
    1197             : 
    1198             : static const JSJitInfo submitFrame_methodinfo = {
    1199             :   { (JSJitGetterOp)submitFrame },
    1200             :   { prototypes::id::VRDisplay },
    1201             :   { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
    1202             :   JSJitInfo::Method,
    1203             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1204             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1205             :   true,  /* isInfallible. False in setters. */
    1206             :   false,  /* isMovable.  Not relevant for setters. */
    1207             :   false, /* isEliminatable.  Not relevant for setters. */
    1208             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1209             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1210             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1211             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1212             : };
    1213             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1214             : static_assert(0 < 1, "There is no slot for us");
    1215             : 
    1216             : static bool
    1217           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1218             : {
    1219           0 :   mozilla::dom::VRDisplay* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplay>(obj);
    1220             :   // We don't want to preserve if we don't have a wrapper, and we
    1221             :   // obviously can't preserve if we're not initialized.
    1222           0 :   if (self && self->GetWrapperPreserveColor()) {
    1223           0 :     PreserveWrapper(self);
    1224             :   }
    1225           0 :   return true;
    1226             : }
    1227             : 
    1228             : static void
    1229           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1230             : {
    1231           0 :   mozilla::dom::VRDisplay* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplay>(obj);
    1232           0 :   if (self) {
    1233           0 :     ClearWrapper(self, self, obj);
    1234           0 :     AddForDeferredFinalization<mozilla::dom::VRDisplay>(self);
    1235             :   }
    1236           0 : }
    1237             : 
    1238             : static void
    1239           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1240             : {
    1241           0 :   mozilla::dom::VRDisplay* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplay>(obj);
    1242           0 :   if (self) {
    1243           0 :     UpdateWrapper(self, self, obj, old);
    1244             :   }
    1245           0 : }
    1246             : 
    1247             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1248             : #if defined(__clang__)
    1249             : #pragma clang diagnostic push
    1250             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1251             : #endif
    1252             : static const JSFunctionSpec sMethods_specs[] = {
    1253             :   JS_FNSPEC("getEyeParameters", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getEyeParameters_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1254             :   JS_FNSPEC("getFrameData", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getFrameData_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1255             :   JS_FNSPEC("getPose", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getPose_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1256             :   JS_FS_END,
    1257             :   JS_FNSPEC("getSubmitFrameResult", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getSubmitFrameResult_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1258             :   JS_FS_END,
    1259             :   JS_FNSPEC("resetPose", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&resetPose_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1260             :   JS_FNSPEC("requestAnimationFrame", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&requestAnimationFrame_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1261             :   JS_FNSPEC("cancelAnimationFrame", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&cancelAnimationFrame_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1262             :   JS_FNSPEC("requestPresent", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&requestPresent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1263             :   JS_FNSPEC("exitPresent", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&exitPresent_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1264             :   JS_FNSPEC("getLayers", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getLayers_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1265             :   JS_FNSPEC("submitFrame", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&submitFrame_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1266             :   JS_FS_END
    1267             : };
    1268             : #if defined(__clang__)
    1269             : #pragma clang diagnostic pop
    1270             : #endif
    1271             : 
    1272             : static PrefableDisablers sMethods_disablers4 = {
    1273             :   true, false, 0, nullptr
    1274             : };
    1275             : 
    1276             : // Can't be const because the pref-enabled boolean needs to be writable
    1277             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1278             :   { nullptr, &sMethods_specs[0] },
    1279             :   { &sMethods_disablers4, &sMethods_specs[4] },
    1280             :   { nullptr, &sMethods_specs[6] },
    1281             :   { nullptr, nullptr }
    1282             : };
    1283             : 
    1284             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1285             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1286             : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1287             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1288             : 
    1289             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1290             : #if defined(__clang__)
    1291             : #pragma clang diagnostic push
    1292             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1293             : #endif
    1294             : static const JSPropertySpec sAttributes_specs[] = {
    1295             :   { "isConnected", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isConnected_getterinfo, nullptr, nullptr },
    1296             :   { "isPresenting", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isPresenting_getterinfo, nullptr, nullptr },
    1297             :   { "capabilities", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &capabilities_getterinfo, nullptr, nullptr },
    1298             :   { "stageParameters", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &stageParameters_getterinfo, nullptr, nullptr },
    1299             :   { "displayId", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &displayId_getterinfo, nullptr, nullptr },
    1300             :   { "displayName", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &displayName_getterinfo, nullptr, nullptr },
    1301             :   { "depthNear", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &depthNear_getterinfo, GenericBindingSetter, &depthNear_setterinfo },
    1302             :   { "depthFar", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &depthFar_getterinfo, GenericBindingSetter, &depthFar_setterinfo },
    1303             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1304             : };
    1305             : #if defined(__clang__)
    1306             : #pragma clang diagnostic pop
    1307             : #endif
    1308             : 
    1309             : 
    1310             : // Can't be const because the pref-enabled boolean needs to be writable
    1311             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1312             :   { nullptr, &sAttributes_specs[0] },
    1313             :   { nullptr, nullptr }
    1314             : };
    1315             : 
    1316             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1317             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1318             : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1319             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1320             : 
    1321             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1322             : #if defined(__clang__)
    1323             : #pragma clang diagnostic push
    1324             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1325             : #endif
    1326             : static const JSPropertySpec sChromeAttributes_specs[] = {
    1327             :   { "presentingGroups", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &presentingGroups_getterinfo, nullptr, nullptr },
    1328             :   { "groupMask", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &groupMask_getterinfo, GenericBindingSetter, &groupMask_setterinfo },
    1329             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1330             : };
    1331             : #if defined(__clang__)
    1332             : #pragma clang diagnostic pop
    1333             : #endif
    1334             : 
    1335             : 
    1336             : // Can't be const because the pref-enabled boolean needs to be writable
    1337             : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
    1338             :   { nullptr, &sChromeAttributes_specs[0] },
    1339             :   { nullptr, nullptr }
    1340             : };
    1341             : 
    1342             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1343             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1344             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1345             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1346             : 
    1347             : 
    1348             : static uint16_t sNativeProperties_sortedPropertyIndices[19];
    1349             : static PropertyInfo sNativeProperties_propertyInfos[19];
    1350             : 
    1351             : static const NativePropertiesN<2> sNativeProperties = {
    1352             :   false, 0,
    1353             :   false, 0,
    1354             :   true,  0 /* sMethods */,
    1355             :   true,  1 /* sAttributes */,
    1356             :   false, 0,
    1357             :   false, 0,
    1358             :   false, 0,
    1359             :   -1,
    1360             :   19,
    1361             :   sNativeProperties_sortedPropertyIndices,
    1362             :   {
    1363             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    1364             :     { sAttributes, &sNativeProperties_propertyInfos[11] }
    1365             :   }
    1366             : };
    1367             : static_assert(19 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1368             :     "We have a property info count that is oversized");
    1369             : 
    1370             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2];
    1371             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2];
    1372             : 
    1373             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    1374             :   false, 0,
    1375             :   false, 0,
    1376             :   false, 0,
    1377             :   true,  0 /* sChromeAttributes */,
    1378             :   false, 0,
    1379             :   false, 0,
    1380             :   false, 0,
    1381             :   -1,
    1382             :   2,
    1383             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    1384             :   {
    1385             :     { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
    1386             :   }
    1387             : };
    1388             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    1389             :     "We have a property info count that is oversized");
    1390             : 
    1391             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1392             :   {
    1393             :     "Function",
    1394             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1395             :     &sBoringInterfaceObjectClassClassOps,
    1396             :     JS_NULL_CLASS_SPEC,
    1397             :     JS_NULL_CLASS_EXT,
    1398             :     &sInterfaceObjectClassObjectOps
    1399             :   },
    1400             :   eInterface,
    1401             :   true,
    1402             :   prototypes::id::VRDisplay,
    1403             :   PrototypeTraits<prototypes::id::VRDisplay>::Depth,
    1404             :   sNativePropertyHooks,
    1405             :   "function VRDisplay() {\n    [native code]\n}",
    1406             :   EventTargetBinding::GetConstructorObject
    1407             : };
    1408             : 
    1409             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1410             :   {
    1411             :     "VRDisplayPrototype",
    1412             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1413             :     JS_NULL_CLASS_OPS,
    1414             :     JS_NULL_CLASS_SPEC,
    1415             :     JS_NULL_CLASS_EXT,
    1416             :     JS_NULL_OBJECT_OPS
    1417             :   },
    1418             :   eInterfacePrototype,
    1419             :   false,
    1420             :   prototypes::id::VRDisplay,
    1421             :   PrototypeTraits<prototypes::id::VRDisplay>::Depth,
    1422             :   sNativePropertyHooks,
    1423             :   "[object VRDisplayPrototype]",
    1424             :   EventTargetBinding::GetProtoObject
    1425             : };
    1426             : 
    1427             : bool
    1428           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1429             : {
    1430             :   static bool sPrefValue;
    1431             :   static bool sPrefCacheSetUp = false;
    1432           0 :   if (!sPrefCacheSetUp) {
    1433           0 :     sPrefCacheSetUp = true;
    1434           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    1435             :   }
    1436             : 
    1437           0 :   return sPrefValue;
    1438             : }
    1439             : 
    1440             : JSObject*
    1441           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1442             : {
    1443           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1444             : }
    1445             : 
    1446             : static const js::ClassOps sClassOps = {
    1447             :   _addProperty, /* addProperty */
    1448             :   nullptr,               /* delProperty */
    1449             :   nullptr,               /* getProperty */
    1450             :   nullptr,               /* setProperty */
    1451             :   nullptr,               /* enumerate */
    1452             :   nullptr, /* newEnumerate */
    1453             :   nullptr, /* resolve */
    1454             :   nullptr, /* mayResolve */
    1455             :   _finalize, /* finalize */
    1456             :   nullptr, /* call */
    1457             :   nullptr,               /* hasInstance */
    1458             :   nullptr,               /* construct */
    1459             :   nullptr, /* trace */
    1460             : };
    1461             : 
    1462             : static const js::ClassExtension sClassExtension = {
    1463             :   nullptr, /* weakmapKeyDelegateOp */
    1464             :   _objectMoved /* objectMovedOp */
    1465             : };
    1466             : 
    1467             : static const DOMJSClass sClass = {
    1468             :   { "VRDisplay",
    1469             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1470             :     &sClassOps,
    1471             :     JS_NULL_CLASS_SPEC,
    1472             :     &sClassExtension,
    1473             :     JS_NULL_OBJECT_OPS
    1474             :   },
    1475             :   { prototypes::id::EventTarget, prototypes::id::VRDisplay, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    1476             :   IsBaseOf<nsISupports, mozilla::dom::VRDisplay >::value,
    1477             :   sNativePropertyHooks,
    1478             :   FindAssociatedGlobalForNative<mozilla::dom::VRDisplay>::Get,
    1479             :   GetProtoObjectHandle,
    1480             :   GetCCParticipant<mozilla::dom::VRDisplay>::Get()
    1481             : };
    1482             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1483             :               "Must have the right minimal number of reserved slots.");
    1484             : static_assert(1 >= 1,
    1485             :               "Must have enough reserved slots.");
    1486             : 
    1487             : const JSClass*
    1488           0 : GetJSClass()
    1489             : {
    1490           0 :   return sClass.ToJSClass();
    1491             : }
    1492             : 
    1493             : bool
    1494           0 : Wrap(JSContext* aCx, mozilla::dom::VRDisplay* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1495             : {
    1496             :   MOZ_ASSERT(static_cast<mozilla::dom::VRDisplay*>(aObject) ==
    1497             :              reinterpret_cast<mozilla::dom::VRDisplay*>(aObject),
    1498             :              "Multiple inheritance for mozilla::dom::VRDisplay is broken.");
    1499             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
    1500             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
    1501             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
    1502           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1503           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1504           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1505             :              "You should probably not be using Wrap() directly; use "
    1506             :              "GetOrCreateDOMReflector instead");
    1507             : 
    1508           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1509             :              "nsISupports must be on our primary inheritance chain");
    1510             : 
    1511           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1512           0 :   if (!global) {
    1513           0 :     return false;
    1514             :   }
    1515           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1516           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1517             : 
    1518             :   // That might have ended up wrapping us already, due to the wonders
    1519             :   // of XBL.  Check for that, and bail out as needed.
    1520           0 :   aReflector.set(aCache->GetWrapper());
    1521           0 :   if (aReflector) {
    1522             : #ifdef DEBUG
    1523           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1524             : #endif // DEBUG
    1525           0 :     return true;
    1526             :   }
    1527             : 
    1528           0 :   JSAutoCompartment ac(aCx, global);
    1529           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1530           0 :   if (!canonicalProto) {
    1531           0 :     return false;
    1532             :   }
    1533           0 :   JS::Rooted<JSObject*> proto(aCx);
    1534           0 :   if (aGivenProto) {
    1535           0 :     proto = aGivenProto;
    1536             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1537             :     // coming in, we changed compartments to that of "parent" so may need
    1538             :     // to wrap the proto here.
    1539           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1540           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1541           0 :         return false;
    1542             :       }
    1543             :     }
    1544             :   } else {
    1545           0 :     proto = canonicalProto;
    1546             :   }
    1547             : 
    1548           0 :   BindingJSObjectCreator<mozilla::dom::VRDisplay> creator(aCx);
    1549           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1550           0 :   if (!aReflector) {
    1551           0 :     return false;
    1552             :   }
    1553             : 
    1554           0 :   aCache->SetWrapper(aReflector);
    1555           0 :   creator.InitializationSucceeded();
    1556             : 
    1557           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1558             :              aCache->GetWrapperPreserveColor() == aReflector);
    1559             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1560             :   // otherwise we won't be able to properly recreate it later, since
    1561             :   // we won't know what proto to use.  Note that we don't check
    1562             :   // aGivenProto here, since it's entirely possible (and even
    1563             :   // somewhat common) to have a non-null aGivenProto which is the
    1564             :   // same as canonicalProto.
    1565           0 :   if (proto != canonicalProto) {
    1566           0 :     PreserveWrapper(aObject);
    1567             :   }
    1568             : 
    1569           0 :   return true;
    1570             : }
    1571             : 
    1572             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1573             :   nullptr,
    1574             :   nullptr,
    1575             :   nullptr,
    1576             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    1577             :   prototypes::id::VRDisplay,
    1578             :   constructors::id::VRDisplay,
    1579             :   EventTargetBinding::sNativePropertyHooks,
    1580             :   &DefaultXrayExpandoObjectClass
    1581             : } };
    1582             : 
    1583             : void
    1584           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1585             : {
    1586           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
    1587           0 :   if (!parentProto) {
    1588           0 :     return;
    1589             :   }
    1590             : 
    1591           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
    1592           0 :   if (!constructorProto) {
    1593           0 :     return;
    1594             :   }
    1595             : 
    1596             :   static bool sIdsInited = false;
    1597           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1598           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1599           0 :       return;
    1600             :     }
    1601           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    1602           0 :       return;
    1603             :     }
    1604           0 :     sIdsInited = true;
    1605             :   }
    1606             : 
    1607             :   static bool sPrefCachesInited = false;
    1608           0 :   if (!sPrefCachesInited && NS_IsMainThread()) {
    1609           0 :     sPrefCachesInited = true;
    1610           0 :     Preferences::AddBoolVarCache(&sMethods[1].disablers->enabled, "dom.vr.test.enabled");
    1611             :   }
    1612             : 
    1613           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRDisplay);
    1614           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRDisplay);
    1615           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1616             :                               &sPrototypeClass.mBase, protoCache,
    1617             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1618             :                               interfaceCache,
    1619             :                               sNativeProperties.Upcast(),
    1620           0 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    1621             :                               "VRDisplay", aDefineOnGlobal,
    1622             :                               nullptr,
    1623           0 :                               false);
    1624             : }
    1625             : 
    1626             : JS::Handle<JSObject*>
    1627           0 : GetProtoObjectHandle(JSContext* aCx)
    1628             : {
    1629             :   /* Get the interface prototype object for this class.  This will create the
    1630             :      object as needed. */
    1631           0 :   bool aDefineOnGlobal = true;
    1632             : 
    1633             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1634           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1635           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1636           0 :     return nullptr;
    1637             :   }
    1638             : 
    1639             :   /* Check to see whether the interface objects are already installed */
    1640           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1641           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRDisplay)) {
    1642           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1643           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1644             :   }
    1645             : 
    1646             :   /*
    1647             :    * The object might _still_ be null, but that's OK.
    1648             :    *
    1649             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1650             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1651             :    * changed after they have been set.
    1652             :    *
    1653             :    * Calling address() avoids the read read barrier that does gray
    1654             :    * unmarking, but it's not possible for the object to be gray here.
    1655             :    */
    1656             : 
    1657           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRDisplay);
    1658           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1659           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1660             : }
    1661             : 
    1662             : JS::Handle<JSObject*>
    1663           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1664             : {
    1665             :   /* Get the interface object for this class.  This will create the object as
    1666             :      needed. */
    1667             : 
    1668             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1669           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1670           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1671           0 :     return nullptr;
    1672             :   }
    1673             : 
    1674             :   /* Check to see whether the interface objects are already installed */
    1675           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1676           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRDisplay)) {
    1677           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1678           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1679             :   }
    1680             : 
    1681             :   /*
    1682             :    * The object might _still_ be null, but that's OK.
    1683             :    *
    1684             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1685             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1686             :    * changed after they have been set.
    1687             :    *
    1688             :    * Calling address() avoids the read read barrier that does gray
    1689             :    * unmarking, but it's not possible for the object to be gray here.
    1690             :    */
    1691             : 
    1692           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRDisplay);
    1693           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1694           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1695             : }
    1696             : 
    1697             : JSObject*
    1698           0 : GetConstructorObject(JSContext* aCx)
    1699             : {
    1700           0 :   return GetConstructorObjectHandle(aCx);
    1701             : }
    1702             : 
    1703             : } // namespace VRDisplayBinding
    1704             : 
    1705             : 
    1706             : 
    1707             : namespace VRDisplayCapabilitiesBinding {
    1708             : 
    1709             : static bool
    1710           0 : get_hasPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
    1711             : {
    1712           0 :   bool result(self->HasPosition());
    1713           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1714           0 :   args.rval().setBoolean(result);
    1715           0 :   return true;
    1716             : }
    1717             : 
    1718             : static const JSJitInfo hasPosition_getterinfo = {
    1719             :   { (JSJitGetterOp)get_hasPosition },
    1720             :   { prototypes::id::VRDisplayCapabilities },
    1721             :   { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
    1722             :   JSJitInfo::Getter,
    1723             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1724             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    1725             :   true,  /* isInfallible. False in setters. */
    1726             :   false,  /* isMovable.  Not relevant for setters. */
    1727             :   false, /* isEliminatable.  Not relevant for setters. */
    1728             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1729             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1730             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1731             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1732             : };
    1733             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1734             : static_assert(0 < 1, "There is no slot for us");
    1735             : 
    1736             : static bool
    1737           0 : get_hasOrientation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
    1738             : {
    1739           0 :   bool result(self->HasOrientation());
    1740           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1741           0 :   args.rval().setBoolean(result);
    1742           0 :   return true;
    1743             : }
    1744             : 
    1745             : static const JSJitInfo hasOrientation_getterinfo = {
    1746             :   { (JSJitGetterOp)get_hasOrientation },
    1747             :   { prototypes::id::VRDisplayCapabilities },
    1748             :   { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
    1749             :   JSJitInfo::Getter,
    1750             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1751             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    1752             :   true,  /* isInfallible. False in setters. */
    1753             :   false,  /* isMovable.  Not relevant for setters. */
    1754             :   false, /* isEliminatable.  Not relevant for setters. */
    1755             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1756             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1757             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1758             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1759             : };
    1760             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1761             : static_assert(0 < 1, "There is no slot for us");
    1762             : 
    1763             : static bool
    1764           0 : get_hasExternalDisplay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
    1765             : {
    1766           0 :   bool result(self->HasExternalDisplay());
    1767           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1768           0 :   args.rval().setBoolean(result);
    1769           0 :   return true;
    1770             : }
    1771             : 
    1772             : static const JSJitInfo hasExternalDisplay_getterinfo = {
    1773             :   { (JSJitGetterOp)get_hasExternalDisplay },
    1774             :   { prototypes::id::VRDisplayCapabilities },
    1775             :   { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
    1776             :   JSJitInfo::Getter,
    1777             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1778             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    1779             :   true,  /* isInfallible. False in setters. */
    1780             :   false,  /* isMovable.  Not relevant for setters. */
    1781             :   false, /* isEliminatable.  Not relevant for setters. */
    1782             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1783             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1784             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1785             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1786             : };
    1787             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1788             : static_assert(0 < 1, "There is no slot for us");
    1789             : 
    1790             : static bool
    1791           0 : get_canPresent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
    1792             : {
    1793           0 :   bool result(self->CanPresent());
    1794           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1795           0 :   args.rval().setBoolean(result);
    1796           0 :   return true;
    1797             : }
    1798             : 
    1799             : static const JSJitInfo canPresent_getterinfo = {
    1800             :   { (JSJitGetterOp)get_canPresent },
    1801             :   { prototypes::id::VRDisplayCapabilities },
    1802             :   { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
    1803             :   JSJitInfo::Getter,
    1804             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1805             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    1806             :   true,  /* isInfallible. False in setters. */
    1807             :   false,  /* isMovable.  Not relevant for setters. */
    1808             :   false, /* isEliminatable.  Not relevant for setters. */
    1809             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1810             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1811             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1812             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1813             : };
    1814             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1815             : static_assert(0 < 1, "There is no slot for us");
    1816             : 
    1817             : static bool
    1818           0 : get_maxLayers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
    1819             : {
    1820           0 :   uint32_t result(self->MaxLayers());
    1821           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1822           0 :   args.rval().setNumber(result);
    1823           0 :   return true;
    1824             : }
    1825             : 
    1826             : static const JSJitInfo maxLayers_getterinfo = {
    1827             :   { (JSJitGetterOp)get_maxLayers },
    1828             :   { prototypes::id::VRDisplayCapabilities },
    1829             :   { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
    1830             :   JSJitInfo::Getter,
    1831             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1832             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1833             :   true,  /* isInfallible. False in setters. */
    1834             :   false,  /* isMovable.  Not relevant for setters. */
    1835             :   false, /* isEliminatable.  Not relevant for setters. */
    1836             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1837             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1838             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1839             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1840             : };
    1841             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1842             : static_assert(0 < 1, "There is no slot for us");
    1843             : 
    1844             : static bool
    1845           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1846             : {
    1847           0 :   mozilla::dom::VRDisplayCapabilities* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplayCapabilities>(obj);
    1848             :   // We don't want to preserve if we don't have a wrapper, and we
    1849             :   // obviously can't preserve if we're not initialized.
    1850           0 :   if (self && self->GetWrapperPreserveColor()) {
    1851           0 :     PreserveWrapper(self);
    1852             :   }
    1853           0 :   return true;
    1854             : }
    1855             : 
    1856             : static void
    1857           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1858             : {
    1859           0 :   mozilla::dom::VRDisplayCapabilities* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplayCapabilities>(obj);
    1860           0 :   if (self) {
    1861           0 :     ClearWrapper(self, self, obj);
    1862           0 :     AddForDeferredFinalization<mozilla::dom::VRDisplayCapabilities>(self);
    1863             :   }
    1864           0 : }
    1865             : 
    1866             : static void
    1867           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1868             : {
    1869           0 :   mozilla::dom::VRDisplayCapabilities* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplayCapabilities>(obj);
    1870           0 :   if (self) {
    1871           0 :     UpdateWrapper(self, self, obj, old);
    1872             :   }
    1873           0 : }
    1874             : 
    1875             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1876             : #if defined(__clang__)
    1877             : #pragma clang diagnostic push
    1878             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1879             : #endif
    1880             : static const JSPropertySpec sAttributes_specs[] = {
    1881             :   { "hasPosition", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hasPosition_getterinfo, nullptr, nullptr },
    1882             :   { "hasOrientation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hasOrientation_getterinfo, nullptr, nullptr },
    1883             :   { "hasExternalDisplay", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hasExternalDisplay_getterinfo, nullptr, nullptr },
    1884             :   { "canPresent", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &canPresent_getterinfo, nullptr, nullptr },
    1885             :   { "maxLayers", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &maxLayers_getterinfo, nullptr, nullptr },
    1886             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1887             : };
    1888             : #if defined(__clang__)
    1889             : #pragma clang diagnostic pop
    1890             : #endif
    1891             : 
    1892             : 
    1893             : // Can't be const because the pref-enabled boolean needs to be writable
    1894             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1895             :   { nullptr, &sAttributes_specs[0] },
    1896             :   { nullptr, nullptr }
    1897             : };
    1898             : 
    1899             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1900             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1901             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1902             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1903             : 
    1904             : 
    1905             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
    1906             : static PropertyInfo sNativeProperties_propertyInfos[5];
    1907             : 
    1908             : static const NativePropertiesN<1> sNativeProperties = {
    1909             :   false, 0,
    1910             :   false, 0,
    1911             :   false, 0,
    1912             :   true,  0 /* sAttributes */,
    1913             :   false, 0,
    1914             :   false, 0,
    1915             :   false, 0,
    1916             :   -1,
    1917             :   5,
    1918             :   sNativeProperties_sortedPropertyIndices,
    1919             :   {
    1920             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    1921             :   }
    1922             : };
    1923             : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1924             :     "We have a property info count that is oversized");
    1925             : 
    1926             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1927             :   {
    1928             :     "Function",
    1929             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1930             :     &sBoringInterfaceObjectClassClassOps,
    1931             :     JS_NULL_CLASS_SPEC,
    1932             :     JS_NULL_CLASS_EXT,
    1933             :     &sInterfaceObjectClassObjectOps
    1934             :   },
    1935             :   eInterface,
    1936             :   true,
    1937             :   prototypes::id::VRDisplayCapabilities,
    1938             :   PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth,
    1939             :   sNativePropertyHooks,
    1940             :   "function VRDisplayCapabilities() {\n    [native code]\n}",
    1941             :   JS::GetRealmFunctionPrototype
    1942             : };
    1943             : 
    1944             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1945             :   {
    1946             :     "VRDisplayCapabilitiesPrototype",
    1947             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1948             :     JS_NULL_CLASS_OPS,
    1949             :     JS_NULL_CLASS_SPEC,
    1950             :     JS_NULL_CLASS_EXT,
    1951             :     JS_NULL_OBJECT_OPS
    1952             :   },
    1953             :   eInterfacePrototype,
    1954             :   false,
    1955             :   prototypes::id::VRDisplayCapabilities,
    1956             :   PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth,
    1957             :   sNativePropertyHooks,
    1958             :   "[object VRDisplayCapabilitiesPrototype]",
    1959             :   JS::GetRealmObjectPrototype
    1960             : };
    1961             : 
    1962             : bool
    1963           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1964             : {
    1965             :   static bool sPrefValue;
    1966             :   static bool sPrefCacheSetUp = false;
    1967           0 :   if (!sPrefCacheSetUp) {
    1968           0 :     sPrefCacheSetUp = true;
    1969           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    1970             :   }
    1971             : 
    1972           0 :   return sPrefValue;
    1973             : }
    1974             : 
    1975             : JSObject*
    1976           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1977             : {
    1978           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1979             : }
    1980             : 
    1981             : static const js::ClassOps sClassOps = {
    1982             :   _addProperty, /* addProperty */
    1983             :   nullptr,               /* delProperty */
    1984             :   nullptr,               /* getProperty */
    1985             :   nullptr,               /* setProperty */
    1986             :   nullptr,               /* enumerate */
    1987             :   nullptr, /* newEnumerate */
    1988             :   nullptr, /* resolve */
    1989             :   nullptr, /* mayResolve */
    1990             :   _finalize, /* finalize */
    1991             :   nullptr, /* call */
    1992             :   nullptr,               /* hasInstance */
    1993             :   nullptr,               /* construct */
    1994             :   nullptr, /* trace */
    1995             : };
    1996             : 
    1997             : static const js::ClassExtension sClassExtension = {
    1998             :   nullptr, /* weakmapKeyDelegateOp */
    1999             :   _objectMoved /* objectMovedOp */
    2000             : };
    2001             : 
    2002             : static const DOMJSClass sClass = {
    2003             :   { "VRDisplayCapabilities",
    2004             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    2005             :     &sClassOps,
    2006             :     JS_NULL_CLASS_SPEC,
    2007             :     &sClassExtension,
    2008             :     JS_NULL_OBJECT_OPS
    2009             :   },
    2010             :   { prototypes::id::VRDisplayCapabilities, 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 },
    2011             :   IsBaseOf<nsISupports, mozilla::dom::VRDisplayCapabilities >::value,
    2012             :   sNativePropertyHooks,
    2013             :   FindAssociatedGlobalForNative<mozilla::dom::VRDisplayCapabilities>::Get,
    2014             :   GetProtoObjectHandle,
    2015             :   GetCCParticipant<mozilla::dom::VRDisplayCapabilities>::Get()
    2016             : };
    2017             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    2018             :               "Must have the right minimal number of reserved slots.");
    2019             : static_assert(1 >= 1,
    2020             :               "Must have enough reserved slots.");
    2021             : 
    2022             : const JSClass*
    2023           0 : GetJSClass()
    2024             : {
    2025           0 :   return sClass.ToJSClass();
    2026             : }
    2027             : 
    2028             : bool
    2029           0 : Wrap(JSContext* aCx, mozilla::dom::VRDisplayCapabilities* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    2030             : {
    2031             :   MOZ_ASSERT(static_cast<mozilla::dom::VRDisplayCapabilities*>(aObject) ==
    2032             :              reinterpret_cast<mozilla::dom::VRDisplayCapabilities*>(aObject),
    2033             :              "Multiple inheritance for mozilla::dom::VRDisplayCapabilities is broken.");
    2034           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    2035           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    2036           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    2037             :              "You should probably not be using Wrap() directly; use "
    2038             :              "GetOrCreateDOMReflector instead");
    2039             : 
    2040           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    2041             :              "nsISupports must be on our primary inheritance chain");
    2042             : 
    2043           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2044           0 :   if (!global) {
    2045           0 :     return false;
    2046             :   }
    2047           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2048           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2049             : 
    2050             :   // That might have ended up wrapping us already, due to the wonders
    2051             :   // of XBL.  Check for that, and bail out as needed.
    2052           0 :   aReflector.set(aCache->GetWrapper());
    2053           0 :   if (aReflector) {
    2054             : #ifdef DEBUG
    2055           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2056             : #endif // DEBUG
    2057           0 :     return true;
    2058             :   }
    2059             : 
    2060           0 :   JSAutoCompartment ac(aCx, global);
    2061           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2062           0 :   if (!canonicalProto) {
    2063           0 :     return false;
    2064             :   }
    2065           0 :   JS::Rooted<JSObject*> proto(aCx);
    2066           0 :   if (aGivenProto) {
    2067           0 :     proto = aGivenProto;
    2068             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2069             :     // coming in, we changed compartments to that of "parent" so may need
    2070             :     // to wrap the proto here.
    2071           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2072           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2073           0 :         return false;
    2074             :       }
    2075             :     }
    2076             :   } else {
    2077           0 :     proto = canonicalProto;
    2078             :   }
    2079             : 
    2080           0 :   BindingJSObjectCreator<mozilla::dom::VRDisplayCapabilities> creator(aCx);
    2081           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    2082           0 :   if (!aReflector) {
    2083           0 :     return false;
    2084             :   }
    2085             : 
    2086           0 :   aCache->SetWrapper(aReflector);
    2087           0 :   creator.InitializationSucceeded();
    2088             : 
    2089           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2090             :              aCache->GetWrapperPreserveColor() == aReflector);
    2091             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2092             :   // otherwise we won't be able to properly recreate it later, since
    2093             :   // we won't know what proto to use.  Note that we don't check
    2094             :   // aGivenProto here, since it's entirely possible (and even
    2095             :   // somewhat common) to have a non-null aGivenProto which is the
    2096             :   // same as canonicalProto.
    2097           0 :   if (proto != canonicalProto) {
    2098           0 :     PreserveWrapper(aObject);
    2099             :   }
    2100             : 
    2101           0 :   return true;
    2102             : }
    2103             : 
    2104             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2105             :   nullptr,
    2106             :   nullptr,
    2107             :   nullptr,
    2108             :   { sNativeProperties.Upcast(), nullptr },
    2109             :   prototypes::id::VRDisplayCapabilities,
    2110             :   constructors::id::VRDisplayCapabilities,
    2111             :   nullptr,
    2112             :   &DefaultXrayExpandoObjectClass
    2113             : } };
    2114             : 
    2115             : void
    2116           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2117             : {
    2118           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    2119           0 :   if (!parentProto) {
    2120           0 :     return;
    2121             :   }
    2122             : 
    2123           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    2124           0 :   if (!constructorProto) {
    2125           0 :     return;
    2126             :   }
    2127             : 
    2128             :   static bool sIdsInited = false;
    2129           0 :   if (!sIdsInited && NS_IsMainThread()) {
    2130           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2131           0 :       return;
    2132             :     }
    2133           0 :     sIdsInited = true;
    2134             :   }
    2135             : 
    2136           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRDisplayCapabilities);
    2137           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRDisplayCapabilities);
    2138           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2139             :                               &sPrototypeClass.mBase, protoCache,
    2140             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    2141             :                               interfaceCache,
    2142             :                               sNativeProperties.Upcast(),
    2143             :                               nullptr,
    2144             :                               "VRDisplayCapabilities", aDefineOnGlobal,
    2145             :                               nullptr,
    2146           0 :                               false);
    2147             : }
    2148             : 
    2149             : JS::Handle<JSObject*>
    2150           0 : GetProtoObjectHandle(JSContext* aCx)
    2151             : {
    2152             :   /* Get the interface prototype object for this class.  This will create the
    2153             :      object as needed. */
    2154           0 :   bool aDefineOnGlobal = true;
    2155             : 
    2156             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2157           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2158           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2159           0 :     return nullptr;
    2160             :   }
    2161             : 
    2162             :   /* Check to see whether the interface objects are already installed */
    2163           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2164           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRDisplayCapabilities)) {
    2165           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2166           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2167             :   }
    2168             : 
    2169             :   /*
    2170             :    * The object might _still_ be null, but that's OK.
    2171             :    *
    2172             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2173             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2174             :    * changed after they have been set.
    2175             :    *
    2176             :    * Calling address() avoids the read read barrier that does gray
    2177             :    * unmarking, but it's not possible for the object to be gray here.
    2178             :    */
    2179             : 
    2180           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRDisplayCapabilities);
    2181           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2182           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2183             : }
    2184             : 
    2185             : JS::Handle<JSObject*>
    2186           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2187             : {
    2188             :   /* Get the interface object for this class.  This will create the object as
    2189             :      needed. */
    2190             : 
    2191             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2192           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2193           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2194           0 :     return nullptr;
    2195             :   }
    2196             : 
    2197             :   /* Check to see whether the interface objects are already installed */
    2198           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2199           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRDisplayCapabilities)) {
    2200           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2201           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2202             :   }
    2203             : 
    2204             :   /*
    2205             :    * The object might _still_ be null, but that's OK.
    2206             :    *
    2207             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2208             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2209             :    * changed after they have been set.
    2210             :    *
    2211             :    * Calling address() avoids the read read barrier that does gray
    2212             :    * unmarking, but it's not possible for the object to be gray here.
    2213             :    */
    2214             : 
    2215           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRDisplayCapabilities);
    2216           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2217           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2218             : }
    2219             : 
    2220             : JSObject*
    2221           0 : GetConstructorObject(JSContext* aCx)
    2222             : {
    2223           0 :   return GetConstructorObjectHandle(aCx);
    2224             : }
    2225             : 
    2226             : } // namespace VRDisplayCapabilitiesBinding
    2227             : 
    2228             : 
    2229             : 
    2230             : namespace VREyeParametersBinding {
    2231             : 
    2232             : static bool
    2233           0 : get_offset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
    2234             : {
    2235           0 :   binding_detail::FastErrorResult rv;
    2236           0 :   JS::Rooted<JSObject*> result(cx);
    2237           0 :   self->GetOffset(cx, &result, rv);
    2238           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2239           0 :     return false;
    2240             :   }
    2241           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2242           0 :   JS::ExposeObjectToActiveJS(result);
    2243           0 :   args.rval().setObject(*result);
    2244           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
    2245           0 :     return false;
    2246             :   }
    2247           0 :   return true;
    2248             : }
    2249             : 
    2250             : static const JSJitInfo offset_getterinfo = {
    2251             :   { (JSJitGetterOp)get_offset },
    2252             :   { prototypes::id::VREyeParameters },
    2253             :   { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
    2254             :   JSJitInfo::Getter,
    2255             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    2256             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    2257             :   false,  /* isInfallible. False in setters. */
    2258             :   false,  /* isMovable.  Not relevant for setters. */
    2259             :   false, /* isEliminatable.  Not relevant for setters. */
    2260             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2261             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2262             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2263             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2264             : };
    2265             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2266             : static_assert(0 < 1, "There is no slot for us");
    2267             : 
    2268             : static bool
    2269           0 : get_fieldOfView(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
    2270             : {
    2271           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRFieldOfView>(self->FieldOfView()));
    2272           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2273           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    2274           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2275           0 :     return false;
    2276             :   }
    2277           0 :   return true;
    2278             : }
    2279             : 
    2280             : static const JSJitInfo fieldOfView_getterinfo = {
    2281             :   { (JSJitGetterOp)get_fieldOfView },
    2282             :   { prototypes::id::VREyeParameters },
    2283             :   { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
    2284             :   JSJitInfo::Getter,
    2285             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    2286             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    2287             :   false,  /* isInfallible. False in setters. */
    2288             :   true,  /* isMovable.  Not relevant for setters. */
    2289             :   true, /* isEliminatable.  Not relevant for setters. */
    2290             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2291             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2292             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2293             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2294             : };
    2295             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2296             : static_assert(0 < 1, "There is no slot for us");
    2297             : 
    2298             : static bool
    2299           0 : get_renderWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
    2300             : {
    2301           0 :   uint32_t result(self->RenderWidth());
    2302           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2303           0 :   args.rval().setNumber(result);
    2304           0 :   return true;
    2305             : }
    2306             : 
    2307             : static const JSJitInfo renderWidth_getterinfo = {
    2308             :   { (JSJitGetterOp)get_renderWidth },
    2309             :   { prototypes::id::VREyeParameters },
    2310             :   { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
    2311             :   JSJitInfo::Getter,
    2312             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    2313             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2314             :   true,  /* isInfallible. False in setters. */
    2315             :   true,  /* isMovable.  Not relevant for setters. */
    2316             :   true, /* isEliminatable.  Not relevant for setters. */
    2317             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2318             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2319             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2320             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2321             : };
    2322             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2323             : static_assert(0 < 1, "There is no slot for us");
    2324             : 
    2325             : static bool
    2326           0 : get_renderHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
    2327             : {
    2328           0 :   uint32_t result(self->RenderHeight());
    2329           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2330           0 :   args.rval().setNumber(result);
    2331           0 :   return true;
    2332             : }
    2333             : 
    2334             : static const JSJitInfo renderHeight_getterinfo = {
    2335             :   { (JSJitGetterOp)get_renderHeight },
    2336             :   { prototypes::id::VREyeParameters },
    2337             :   { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
    2338             :   JSJitInfo::Getter,
    2339             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    2340             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2341             :   true,  /* isInfallible. False in setters. */
    2342             :   true,  /* isMovable.  Not relevant for setters. */
    2343             :   true, /* isEliminatable.  Not relevant for setters. */
    2344             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2345             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2346             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2347             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2348             : };
    2349             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2350             : static_assert(0 < 1, "There is no slot for us");
    2351             : 
    2352             : static bool
    2353           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    2354             : {
    2355           0 :   mozilla::dom::VREyeParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VREyeParameters>(obj);
    2356             :   // We don't want to preserve if we don't have a wrapper, and we
    2357             :   // obviously can't preserve if we're not initialized.
    2358           0 :   if (self && self->GetWrapperPreserveColor()) {
    2359           0 :     PreserveWrapper(self);
    2360             :   }
    2361           0 :   return true;
    2362             : }
    2363             : 
    2364             : static void
    2365           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    2366             : {
    2367           0 :   mozilla::dom::VREyeParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VREyeParameters>(obj);
    2368           0 :   if (self) {
    2369           0 :     ClearWrapper(self, self, obj);
    2370           0 :     AddForDeferredFinalization<mozilla::dom::VREyeParameters>(self);
    2371             :   }
    2372           0 : }
    2373             : 
    2374             : static void
    2375           0 : _objectMoved(JSObject* obj, const JSObject* old)
    2376             : {
    2377           0 :   mozilla::dom::VREyeParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VREyeParameters>(obj);
    2378           0 :   if (self) {
    2379           0 :     UpdateWrapper(self, self, obj, old);
    2380             :   }
    2381           0 : }
    2382             : 
    2383             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2384             : #if defined(__clang__)
    2385             : #pragma clang diagnostic push
    2386             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2387             : #endif
    2388             : static const JSPropertySpec sAttributes_specs[] = {
    2389             :   { "offset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &offset_getterinfo, nullptr, nullptr },
    2390             :   { "fieldOfView", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &fieldOfView_getterinfo, nullptr, nullptr },
    2391             :   { "renderWidth", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &renderWidth_getterinfo, nullptr, nullptr },
    2392             :   { "renderHeight", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &renderHeight_getterinfo, nullptr, nullptr },
    2393             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    2394             : };
    2395             : #if defined(__clang__)
    2396             : #pragma clang diagnostic pop
    2397             : #endif
    2398             : 
    2399             : 
    2400             : // Can't be const because the pref-enabled boolean needs to be writable
    2401             : static Prefable<const JSPropertySpec> sAttributes[] = {
    2402             :   { nullptr, &sAttributes_specs[0] },
    2403             :   { nullptr, nullptr }
    2404             : };
    2405             : 
    2406             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2407             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2408             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2409             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2410             : 
    2411             : 
    2412             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
    2413             : static PropertyInfo sNativeProperties_propertyInfos[4];
    2414             : 
    2415             : static const NativePropertiesN<1> sNativeProperties = {
    2416             :   false, 0,
    2417             :   false, 0,
    2418             :   false, 0,
    2419             :   true,  0 /* sAttributes */,
    2420             :   false, 0,
    2421             :   false, 0,
    2422             :   false, 0,
    2423             :   -1,
    2424             :   4,
    2425             :   sNativeProperties_sortedPropertyIndices,
    2426             :   {
    2427             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    2428             :   }
    2429             : };
    2430             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    2431             :     "We have a property info count that is oversized");
    2432             : 
    2433             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    2434             :   {
    2435             :     "Function",
    2436             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    2437             :     &sBoringInterfaceObjectClassClassOps,
    2438             :     JS_NULL_CLASS_SPEC,
    2439             :     JS_NULL_CLASS_EXT,
    2440             :     &sInterfaceObjectClassObjectOps
    2441             :   },
    2442             :   eInterface,
    2443             :   true,
    2444             :   prototypes::id::VREyeParameters,
    2445             :   PrototypeTraits<prototypes::id::VREyeParameters>::Depth,
    2446             :   sNativePropertyHooks,
    2447             :   "function VREyeParameters() {\n    [native code]\n}",
    2448             :   JS::GetRealmFunctionPrototype
    2449             : };
    2450             : 
    2451             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    2452             :   {
    2453             :     "VREyeParametersPrototype",
    2454             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    2455             :     JS_NULL_CLASS_OPS,
    2456             :     JS_NULL_CLASS_SPEC,
    2457             :     JS_NULL_CLASS_EXT,
    2458             :     JS_NULL_OBJECT_OPS
    2459             :   },
    2460             :   eInterfacePrototype,
    2461             :   false,
    2462             :   prototypes::id::VREyeParameters,
    2463             :   PrototypeTraits<prototypes::id::VREyeParameters>::Depth,
    2464             :   sNativePropertyHooks,
    2465             :   "[object VREyeParametersPrototype]",
    2466             :   JS::GetRealmObjectPrototype
    2467             : };
    2468             : 
    2469             : bool
    2470           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    2471             : {
    2472             :   static bool sPrefValue;
    2473             :   static bool sPrefCacheSetUp = false;
    2474           0 :   if (!sPrefCacheSetUp) {
    2475           0 :     sPrefCacheSetUp = true;
    2476           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    2477             :   }
    2478             : 
    2479           0 :   return sPrefValue;
    2480             : }
    2481             : 
    2482             : JSObject*
    2483           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    2484             : {
    2485           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    2486             : }
    2487             : 
    2488             : static const js::ClassOps sClassOps = {
    2489             :   _addProperty, /* addProperty */
    2490             :   nullptr,               /* delProperty */
    2491             :   nullptr,               /* getProperty */
    2492             :   nullptr,               /* setProperty */
    2493             :   nullptr,               /* enumerate */
    2494             :   nullptr, /* newEnumerate */
    2495             :   nullptr, /* resolve */
    2496             :   nullptr, /* mayResolve */
    2497             :   _finalize, /* finalize */
    2498             :   nullptr, /* call */
    2499             :   nullptr,               /* hasInstance */
    2500             :   nullptr,               /* construct */
    2501             :   nullptr, /* trace */
    2502             : };
    2503             : 
    2504             : static const js::ClassExtension sClassExtension = {
    2505             :   nullptr, /* weakmapKeyDelegateOp */
    2506             :   _objectMoved /* objectMovedOp */
    2507             : };
    2508             : 
    2509             : static const DOMJSClass sClass = {
    2510             :   { "VREyeParameters",
    2511             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    2512             :     &sClassOps,
    2513             :     JS_NULL_CLASS_SPEC,
    2514             :     &sClassExtension,
    2515             :     JS_NULL_OBJECT_OPS
    2516             :   },
    2517             :   { prototypes::id::VREyeParameters, 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 },
    2518             :   IsBaseOf<nsISupports, mozilla::dom::VREyeParameters >::value,
    2519             :   sNativePropertyHooks,
    2520             :   FindAssociatedGlobalForNative<mozilla::dom::VREyeParameters>::Get,
    2521             :   GetProtoObjectHandle,
    2522             :   GetCCParticipant<mozilla::dom::VREyeParameters>::Get()
    2523             : };
    2524             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    2525             :               "Must have the right minimal number of reserved slots.");
    2526             : static_assert(1 >= 1,
    2527             :               "Must have enough reserved slots.");
    2528             : 
    2529             : const JSClass*
    2530           0 : GetJSClass()
    2531             : {
    2532           0 :   return sClass.ToJSClass();
    2533             : }
    2534             : 
    2535             : bool
    2536           0 : Wrap(JSContext* aCx, mozilla::dom::VREyeParameters* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    2537             : {
    2538             :   MOZ_ASSERT(static_cast<mozilla::dom::VREyeParameters*>(aObject) ==
    2539             :              reinterpret_cast<mozilla::dom::VREyeParameters*>(aObject),
    2540             :              "Multiple inheritance for mozilla::dom::VREyeParameters is broken.");
    2541           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    2542           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    2543           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    2544             :              "You should probably not be using Wrap() directly; use "
    2545             :              "GetOrCreateDOMReflector instead");
    2546             : 
    2547           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    2548             :              "nsISupports must be on our primary inheritance chain");
    2549             : 
    2550           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2551           0 :   if (!global) {
    2552           0 :     return false;
    2553             :   }
    2554           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2555           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2556             : 
    2557             :   // That might have ended up wrapping us already, due to the wonders
    2558             :   // of XBL.  Check for that, and bail out as needed.
    2559           0 :   aReflector.set(aCache->GetWrapper());
    2560           0 :   if (aReflector) {
    2561             : #ifdef DEBUG
    2562           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2563             : #endif // DEBUG
    2564           0 :     return true;
    2565             :   }
    2566             : 
    2567           0 :   JSAutoCompartment ac(aCx, global);
    2568           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2569           0 :   if (!canonicalProto) {
    2570           0 :     return false;
    2571             :   }
    2572           0 :   JS::Rooted<JSObject*> proto(aCx);
    2573           0 :   if (aGivenProto) {
    2574           0 :     proto = aGivenProto;
    2575             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2576             :     // coming in, we changed compartments to that of "parent" so may need
    2577             :     // to wrap the proto here.
    2578           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2579           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2580           0 :         return false;
    2581             :       }
    2582             :     }
    2583             :   } else {
    2584           0 :     proto = canonicalProto;
    2585             :   }
    2586             : 
    2587           0 :   BindingJSObjectCreator<mozilla::dom::VREyeParameters> creator(aCx);
    2588           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    2589           0 :   if (!aReflector) {
    2590           0 :     return false;
    2591             :   }
    2592             : 
    2593           0 :   aCache->SetWrapper(aReflector);
    2594           0 :   creator.InitializationSucceeded();
    2595             : 
    2596           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2597             :              aCache->GetWrapperPreserveColor() == aReflector);
    2598             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2599             :   // otherwise we won't be able to properly recreate it later, since
    2600             :   // we won't know what proto to use.  Note that we don't check
    2601             :   // aGivenProto here, since it's entirely possible (and even
    2602             :   // somewhat common) to have a non-null aGivenProto which is the
    2603             :   // same as canonicalProto.
    2604           0 :   if (proto != canonicalProto) {
    2605           0 :     PreserveWrapper(aObject);
    2606             :   }
    2607             : 
    2608           0 :   return true;
    2609             : }
    2610             : 
    2611             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2612             :   nullptr,
    2613             :   nullptr,
    2614             :   nullptr,
    2615             :   { sNativeProperties.Upcast(), nullptr },
    2616             :   prototypes::id::VREyeParameters,
    2617             :   constructors::id::VREyeParameters,
    2618             :   nullptr,
    2619             :   &DefaultXrayExpandoObjectClass
    2620             : } };
    2621             : 
    2622             : void
    2623           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2624             : {
    2625           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    2626           0 :   if (!parentProto) {
    2627           0 :     return;
    2628             :   }
    2629             : 
    2630           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    2631           0 :   if (!constructorProto) {
    2632           0 :     return;
    2633             :   }
    2634             : 
    2635             :   static bool sIdsInited = false;
    2636           0 :   if (!sIdsInited && NS_IsMainThread()) {
    2637           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2638           0 :       return;
    2639             :     }
    2640           0 :     sIdsInited = true;
    2641             :   }
    2642             : 
    2643           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VREyeParameters);
    2644           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VREyeParameters);
    2645           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2646             :                               &sPrototypeClass.mBase, protoCache,
    2647             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    2648             :                               interfaceCache,
    2649             :                               sNativeProperties.Upcast(),
    2650             :                               nullptr,
    2651             :                               "VREyeParameters", aDefineOnGlobal,
    2652             :                               nullptr,
    2653           0 :                               false);
    2654             : }
    2655             : 
    2656             : JS::Handle<JSObject*>
    2657           0 : GetProtoObjectHandle(JSContext* aCx)
    2658             : {
    2659             :   /* Get the interface prototype object for this class.  This will create the
    2660             :      object as needed. */
    2661           0 :   bool aDefineOnGlobal = true;
    2662             : 
    2663             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2664           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2665           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2666           0 :     return nullptr;
    2667             :   }
    2668             : 
    2669             :   /* Check to see whether the interface objects are already installed */
    2670           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2671           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VREyeParameters)) {
    2672           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2673           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2674             :   }
    2675             : 
    2676             :   /*
    2677             :    * The object might _still_ be null, but that's OK.
    2678             :    *
    2679             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2680             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2681             :    * changed after they have been set.
    2682             :    *
    2683             :    * Calling address() avoids the read read barrier that does gray
    2684             :    * unmarking, but it's not possible for the object to be gray here.
    2685             :    */
    2686             : 
    2687           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VREyeParameters);
    2688           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2689           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2690             : }
    2691             : 
    2692             : JS::Handle<JSObject*>
    2693           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2694             : {
    2695             :   /* Get the interface object for this class.  This will create the object as
    2696             :      needed. */
    2697             : 
    2698             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2699           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2700           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2701           0 :     return nullptr;
    2702             :   }
    2703             : 
    2704             :   /* Check to see whether the interface objects are already installed */
    2705           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2706           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VREyeParameters)) {
    2707           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2708           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2709             :   }
    2710             : 
    2711             :   /*
    2712             :    * The object might _still_ be null, but that's OK.
    2713             :    *
    2714             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2715             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2716             :    * changed after they have been set.
    2717             :    *
    2718             :    * Calling address() avoids the read read barrier that does gray
    2719             :    * unmarking, but it's not possible for the object to be gray here.
    2720             :    */
    2721             : 
    2722           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VREyeParameters);
    2723           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2724           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2725             : }
    2726             : 
    2727             : JSObject*
    2728           0 : GetConstructorObject(JSContext* aCx)
    2729             : {
    2730           0 :   return GetConstructorObjectHandle(aCx);
    2731             : }
    2732             : 
    2733             : } // namespace VREyeParametersBinding
    2734             : 
    2735             : 
    2736             : 
    2737             : namespace VRFieldOfViewBinding {
    2738             : 
    2739             : static bool
    2740           0 : get_upDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
    2741             : {
    2742           0 :   double result(self->UpDegrees());
    2743           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2744           0 :   args.rval().set(JS_NumberValue(double(result)));
    2745           0 :   return true;
    2746             : }
    2747             : 
    2748             : static const JSJitInfo upDegrees_getterinfo = {
    2749             :   { (JSJitGetterOp)get_upDegrees },
    2750             :   { prototypes::id::VRFieldOfView },
    2751             :   { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
    2752             :   JSJitInfo::Getter,
    2753             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2754             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2755             :   true,  /* isInfallible. False in setters. */
    2756             :   false,  /* isMovable.  Not relevant for setters. */
    2757             :   false, /* isEliminatable.  Not relevant for setters. */
    2758             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2759             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2760             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2761             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2762             : };
    2763             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2764             : static_assert(0 < 1, "There is no slot for us");
    2765             : 
    2766             : static bool
    2767           0 : get_rightDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
    2768             : {
    2769           0 :   double result(self->RightDegrees());
    2770           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2771           0 :   args.rval().set(JS_NumberValue(double(result)));
    2772           0 :   return true;
    2773             : }
    2774             : 
    2775             : static const JSJitInfo rightDegrees_getterinfo = {
    2776             :   { (JSJitGetterOp)get_rightDegrees },
    2777             :   { prototypes::id::VRFieldOfView },
    2778             :   { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
    2779             :   JSJitInfo::Getter,
    2780             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2781             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2782             :   true,  /* isInfallible. False in setters. */
    2783             :   false,  /* isMovable.  Not relevant for setters. */
    2784             :   false, /* isEliminatable.  Not relevant for setters. */
    2785             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2786             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2787             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2788             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2789             : };
    2790             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2791             : static_assert(0 < 1, "There is no slot for us");
    2792             : 
    2793             : static bool
    2794           0 : get_downDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
    2795             : {
    2796           0 :   double result(self->DownDegrees());
    2797           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2798           0 :   args.rval().set(JS_NumberValue(double(result)));
    2799           0 :   return true;
    2800             : }
    2801             : 
    2802             : static const JSJitInfo downDegrees_getterinfo = {
    2803             :   { (JSJitGetterOp)get_downDegrees },
    2804             :   { prototypes::id::VRFieldOfView },
    2805             :   { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
    2806             :   JSJitInfo::Getter,
    2807             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2808             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2809             :   true,  /* isInfallible. False in setters. */
    2810             :   false,  /* isMovable.  Not relevant for setters. */
    2811             :   false, /* isEliminatable.  Not relevant for setters. */
    2812             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2813             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2814             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2815             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2816             : };
    2817             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2818             : static_assert(0 < 1, "There is no slot for us");
    2819             : 
    2820             : static bool
    2821           0 : get_leftDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
    2822             : {
    2823           0 :   double result(self->LeftDegrees());
    2824           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2825           0 :   args.rval().set(JS_NumberValue(double(result)));
    2826           0 :   return true;
    2827             : }
    2828             : 
    2829             : static const JSJitInfo leftDegrees_getterinfo = {
    2830             :   { (JSJitGetterOp)get_leftDegrees },
    2831             :   { prototypes::id::VRFieldOfView },
    2832             :   { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
    2833             :   JSJitInfo::Getter,
    2834             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2835             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    2836             :   true,  /* isInfallible. False in setters. */
    2837             :   false,  /* isMovable.  Not relevant for setters. */
    2838             :   false, /* isEliminatable.  Not relevant for setters. */
    2839             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2840             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2841             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2842             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2843             : };
    2844             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2845             : static_assert(0 < 1, "There is no slot for us");
    2846             : 
    2847             : static bool
    2848           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    2849             : {
    2850           0 :   mozilla::dom::VRFieldOfView* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFieldOfView>(obj);
    2851             :   // We don't want to preserve if we don't have a wrapper, and we
    2852             :   // obviously can't preserve if we're not initialized.
    2853           0 :   if (self && self->GetWrapperPreserveColor()) {
    2854           0 :     PreserveWrapper(self);
    2855             :   }
    2856           0 :   return true;
    2857             : }
    2858             : 
    2859             : static void
    2860           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    2861             : {
    2862           0 :   mozilla::dom::VRFieldOfView* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFieldOfView>(obj);
    2863           0 :   if (self) {
    2864           0 :     ClearWrapper(self, self, obj);
    2865           0 :     AddForDeferredFinalization<mozilla::dom::VRFieldOfView>(self);
    2866             :   }
    2867           0 : }
    2868             : 
    2869             : static void
    2870           0 : _objectMoved(JSObject* obj, const JSObject* old)
    2871             : {
    2872           0 :   mozilla::dom::VRFieldOfView* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFieldOfView>(obj);
    2873           0 :   if (self) {
    2874           0 :     UpdateWrapper(self, self, obj, old);
    2875             :   }
    2876           0 : }
    2877             : 
    2878             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2879             : #if defined(__clang__)
    2880             : #pragma clang diagnostic push
    2881             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2882             : #endif
    2883             : static const JSPropertySpec sAttributes_specs[] = {
    2884             :   { "upDegrees", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &upDegrees_getterinfo, nullptr, nullptr },
    2885             :   { "rightDegrees", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rightDegrees_getterinfo, nullptr, nullptr },
    2886             :   { "downDegrees", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &downDegrees_getterinfo, nullptr, nullptr },
    2887             :   { "leftDegrees", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &leftDegrees_getterinfo, nullptr, nullptr },
    2888             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    2889             : };
    2890             : #if defined(__clang__)
    2891             : #pragma clang diagnostic pop
    2892             : #endif
    2893             : 
    2894             : 
    2895             : // Can't be const because the pref-enabled boolean needs to be writable
    2896             : static Prefable<const JSPropertySpec> sAttributes[] = {
    2897             :   { nullptr, &sAttributes_specs[0] },
    2898             :   { nullptr, nullptr }
    2899             : };
    2900             : 
    2901             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2902             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2903             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2904             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2905             : 
    2906             : 
    2907             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
    2908             : static PropertyInfo sNativeProperties_propertyInfos[4];
    2909             : 
    2910             : static const NativePropertiesN<1> sNativeProperties = {
    2911             :   false, 0,
    2912             :   false, 0,
    2913             :   false, 0,
    2914             :   true,  0 /* sAttributes */,
    2915             :   false, 0,
    2916             :   false, 0,
    2917             :   false, 0,
    2918             :   -1,
    2919             :   4,
    2920             :   sNativeProperties_sortedPropertyIndices,
    2921             :   {
    2922             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    2923             :   }
    2924             : };
    2925             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    2926             :     "We have a property info count that is oversized");
    2927             : 
    2928             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    2929             :   {
    2930             :     "Function",
    2931             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    2932             :     &sBoringInterfaceObjectClassClassOps,
    2933             :     JS_NULL_CLASS_SPEC,
    2934             :     JS_NULL_CLASS_EXT,
    2935             :     &sInterfaceObjectClassObjectOps
    2936             :   },
    2937             :   eInterface,
    2938             :   true,
    2939             :   prototypes::id::VRFieldOfView,
    2940             :   PrototypeTraits<prototypes::id::VRFieldOfView>::Depth,
    2941             :   sNativePropertyHooks,
    2942             :   "function VRFieldOfView() {\n    [native code]\n}",
    2943             :   JS::GetRealmFunctionPrototype
    2944             : };
    2945             : 
    2946             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    2947             :   {
    2948             :     "VRFieldOfViewPrototype",
    2949             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    2950             :     JS_NULL_CLASS_OPS,
    2951             :     JS_NULL_CLASS_SPEC,
    2952             :     JS_NULL_CLASS_EXT,
    2953             :     JS_NULL_OBJECT_OPS
    2954             :   },
    2955             :   eInterfacePrototype,
    2956             :   false,
    2957             :   prototypes::id::VRFieldOfView,
    2958             :   PrototypeTraits<prototypes::id::VRFieldOfView>::Depth,
    2959             :   sNativePropertyHooks,
    2960             :   "[object VRFieldOfViewPrototype]",
    2961             :   JS::GetRealmObjectPrototype
    2962             : };
    2963             : 
    2964             : bool
    2965           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    2966             : {
    2967             :   static bool sPrefValue;
    2968             :   static bool sPrefCacheSetUp = false;
    2969           0 :   if (!sPrefCacheSetUp) {
    2970           0 :     sPrefCacheSetUp = true;
    2971           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    2972             :   }
    2973             : 
    2974           0 :   return sPrefValue;
    2975             : }
    2976             : 
    2977             : JSObject*
    2978           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    2979             : {
    2980           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    2981             : }
    2982             : 
    2983             : static const js::ClassOps sClassOps = {
    2984             :   _addProperty, /* addProperty */
    2985             :   nullptr,               /* delProperty */
    2986             :   nullptr,               /* getProperty */
    2987             :   nullptr,               /* setProperty */
    2988             :   nullptr,               /* enumerate */
    2989             :   nullptr, /* newEnumerate */
    2990             :   nullptr, /* resolve */
    2991             :   nullptr, /* mayResolve */
    2992             :   _finalize, /* finalize */
    2993             :   nullptr, /* call */
    2994             :   nullptr,               /* hasInstance */
    2995             :   nullptr,               /* construct */
    2996             :   nullptr, /* trace */
    2997             : };
    2998             : 
    2999             : static const js::ClassExtension sClassExtension = {
    3000             :   nullptr, /* weakmapKeyDelegateOp */
    3001             :   _objectMoved /* objectMovedOp */
    3002             : };
    3003             : 
    3004             : static const DOMJSClass sClass = {
    3005             :   { "VRFieldOfView",
    3006             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    3007             :     &sClassOps,
    3008             :     JS_NULL_CLASS_SPEC,
    3009             :     &sClassExtension,
    3010             :     JS_NULL_OBJECT_OPS
    3011             :   },
    3012             :   { prototypes::id::VRFieldOfView, 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 },
    3013             :   IsBaseOf<nsISupports, mozilla::dom::VRFieldOfView >::value,
    3014             :   sNativePropertyHooks,
    3015             :   FindAssociatedGlobalForNative<mozilla::dom::VRFieldOfView>::Get,
    3016             :   GetProtoObjectHandle,
    3017             :   GetCCParticipant<mozilla::dom::VRFieldOfView>::Get()
    3018             : };
    3019             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    3020             :               "Must have the right minimal number of reserved slots.");
    3021             : static_assert(1 >= 1,
    3022             :               "Must have enough reserved slots.");
    3023             : 
    3024             : const JSClass*
    3025           0 : GetJSClass()
    3026             : {
    3027           0 :   return sClass.ToJSClass();
    3028             : }
    3029             : 
    3030             : bool
    3031           0 : Wrap(JSContext* aCx, mozilla::dom::VRFieldOfView* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    3032             : {
    3033             :   MOZ_ASSERT(static_cast<mozilla::dom::VRFieldOfView*>(aObject) ==
    3034             :              reinterpret_cast<mozilla::dom::VRFieldOfView*>(aObject),
    3035             :              "Multiple inheritance for mozilla::dom::VRFieldOfView is broken.");
    3036           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    3037           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    3038           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    3039             :              "You should probably not be using Wrap() directly; use "
    3040             :              "GetOrCreateDOMReflector instead");
    3041             : 
    3042           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    3043             :              "nsISupports must be on our primary inheritance chain");
    3044             : 
    3045           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    3046           0 :   if (!global) {
    3047           0 :     return false;
    3048             :   }
    3049           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    3050           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    3051             : 
    3052             :   // That might have ended up wrapping us already, due to the wonders
    3053             :   // of XBL.  Check for that, and bail out as needed.
    3054           0 :   aReflector.set(aCache->GetWrapper());
    3055           0 :   if (aReflector) {
    3056             : #ifdef DEBUG
    3057           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    3058             : #endif // DEBUG
    3059           0 :     return true;
    3060             :   }
    3061             : 
    3062           0 :   JSAutoCompartment ac(aCx, global);
    3063           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    3064           0 :   if (!canonicalProto) {
    3065           0 :     return false;
    3066             :   }
    3067           0 :   JS::Rooted<JSObject*> proto(aCx);
    3068           0 :   if (aGivenProto) {
    3069           0 :     proto = aGivenProto;
    3070             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    3071             :     // coming in, we changed compartments to that of "parent" so may need
    3072             :     // to wrap the proto here.
    3073           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    3074           0 :       if (!JS_WrapObject(aCx, &proto)) {
    3075           0 :         return false;
    3076             :       }
    3077             :     }
    3078             :   } else {
    3079           0 :     proto = canonicalProto;
    3080             :   }
    3081             : 
    3082           0 :   BindingJSObjectCreator<mozilla::dom::VRFieldOfView> creator(aCx);
    3083           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    3084           0 :   if (!aReflector) {
    3085           0 :     return false;
    3086             :   }
    3087             : 
    3088           0 :   aCache->SetWrapper(aReflector);
    3089           0 :   creator.InitializationSucceeded();
    3090             : 
    3091           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    3092             :              aCache->GetWrapperPreserveColor() == aReflector);
    3093             :   // If proto != canonicalProto, we have to preserve our wrapper;
    3094             :   // otherwise we won't be able to properly recreate it later, since
    3095             :   // we won't know what proto to use.  Note that we don't check
    3096             :   // aGivenProto here, since it's entirely possible (and even
    3097             :   // somewhat common) to have a non-null aGivenProto which is the
    3098             :   // same as canonicalProto.
    3099           0 :   if (proto != canonicalProto) {
    3100           0 :     PreserveWrapper(aObject);
    3101             :   }
    3102             : 
    3103           0 :   return true;
    3104             : }
    3105             : 
    3106             : const NativePropertyHooks sNativePropertyHooks[] = { {
    3107             :   nullptr,
    3108             :   nullptr,
    3109             :   nullptr,
    3110             :   { sNativeProperties.Upcast(), nullptr },
    3111             :   prototypes::id::VRFieldOfView,
    3112             :   constructors::id::VRFieldOfView,
    3113             :   nullptr,
    3114             :   &DefaultXrayExpandoObjectClass
    3115             : } };
    3116             : 
    3117             : void
    3118           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    3119             : {
    3120           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    3121           0 :   if (!parentProto) {
    3122           0 :     return;
    3123             :   }
    3124             : 
    3125           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    3126           0 :   if (!constructorProto) {
    3127           0 :     return;
    3128             :   }
    3129             : 
    3130             :   static bool sIdsInited = false;
    3131           0 :   if (!sIdsInited && NS_IsMainThread()) {
    3132           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    3133           0 :       return;
    3134             :     }
    3135           0 :     sIdsInited = true;
    3136             :   }
    3137             : 
    3138           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRFieldOfView);
    3139           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRFieldOfView);
    3140           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    3141             :                               &sPrototypeClass.mBase, protoCache,
    3142             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    3143             :                               interfaceCache,
    3144             :                               sNativeProperties.Upcast(),
    3145             :                               nullptr,
    3146             :                               "VRFieldOfView", aDefineOnGlobal,
    3147             :                               nullptr,
    3148           0 :                               false);
    3149             : }
    3150             : 
    3151             : JS::Handle<JSObject*>
    3152           0 : GetProtoObjectHandle(JSContext* aCx)
    3153             : {
    3154             :   /* Get the interface prototype object for this class.  This will create the
    3155             :      object as needed. */
    3156           0 :   bool aDefineOnGlobal = true;
    3157             : 
    3158             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    3159           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    3160           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    3161           0 :     return nullptr;
    3162             :   }
    3163             : 
    3164             :   /* Check to see whether the interface objects are already installed */
    3165           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    3166           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRFieldOfView)) {
    3167           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    3168           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    3169             :   }
    3170             : 
    3171             :   /*
    3172             :    * The object might _still_ be null, but that's OK.
    3173             :    *
    3174             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    3175             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    3176             :    * changed after they have been set.
    3177             :    *
    3178             :    * Calling address() avoids the read read barrier that does gray
    3179             :    * unmarking, but it's not possible for the object to be gray here.
    3180             :    */
    3181             : 
    3182           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRFieldOfView);
    3183           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    3184           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    3185             : }
    3186             : 
    3187             : JS::Handle<JSObject*>
    3188           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    3189             : {
    3190             :   /* Get the interface object for this class.  This will create the object as
    3191             :      needed. */
    3192             : 
    3193             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    3194           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    3195           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    3196           0 :     return nullptr;
    3197             :   }
    3198             : 
    3199             :   /* Check to see whether the interface objects are already installed */
    3200           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    3201           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRFieldOfView)) {
    3202           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    3203           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    3204             :   }
    3205             : 
    3206             :   /*
    3207             :    * The object might _still_ be null, but that's OK.
    3208             :    *
    3209             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    3210             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    3211             :    * changed after they have been set.
    3212             :    *
    3213             :    * Calling address() avoids the read read barrier that does gray
    3214             :    * unmarking, but it's not possible for the object to be gray here.
    3215             :    */
    3216             : 
    3217           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRFieldOfView);
    3218           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    3219           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    3220             : }
    3221             : 
    3222             : JSObject*
    3223           0 : GetConstructorObject(JSContext* aCx)
    3224             : {
    3225           0 :   return GetConstructorObjectHandle(aCx);
    3226             : }
    3227             : 
    3228             : } // namespace VRFieldOfViewBinding
    3229             : 
    3230             : 
    3231             : 
    3232             : namespace VRFrameDataBinding {
    3233             : 
    3234             : static bool
    3235           0 : get_timestamp(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
    3236             : {
    3237           0 :   double result(self->Timestamp());
    3238           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3239           0 :   args.rval().set(JS_NumberValue(double(result)));
    3240           0 :   return true;
    3241             : }
    3242             : 
    3243             : static const JSJitInfo timestamp_getterinfo = {
    3244             :   { (JSJitGetterOp)get_timestamp },
    3245             :   { prototypes::id::VRFrameData },
    3246             :   { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
    3247             :   JSJitInfo::Getter,
    3248             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    3249             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    3250             :   true,  /* isInfallible. False in setters. */
    3251             :   false,  /* isMovable.  Not relevant for setters. */
    3252             :   false, /* isEliminatable.  Not relevant for setters. */
    3253             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3254             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3255             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3256             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3257             : };
    3258             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3259             : static_assert(0 < 1, "There is no slot for us");
    3260             : 
    3261             : static bool
    3262           0 : get_leftProjectionMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
    3263             : {
    3264           0 :   binding_detail::FastErrorResult rv;
    3265           0 :   JS::Rooted<JSObject*> result(cx);
    3266           0 :   self->GetLeftProjectionMatrix(cx, &result, rv);
    3267           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3268           0 :     return false;
    3269             :   }
    3270           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3271           0 :   JS::ExposeObjectToActiveJS(result);
    3272           0 :   args.rval().setObject(*result);
    3273           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
    3274           0 :     return false;
    3275             :   }
    3276           0 :   return true;
    3277             : }
    3278             : 
    3279             : static const JSJitInfo leftProjectionMatrix_getterinfo = {
    3280             :   { (JSJitGetterOp)get_leftProjectionMatrix },
    3281             :   { prototypes::id::VRFrameData },
    3282             :   { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
    3283             :   JSJitInfo::Getter,
    3284             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    3285             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3286             :   false,  /* isInfallible. False in setters. */
    3287             :   false,  /* isMovable.  Not relevant for setters. */
    3288             :   false, /* isEliminatable.  Not relevant for setters. */
    3289             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3290             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3291             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3292             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3293             : };
    3294             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3295             : static_assert(0 < 1, "There is no slot for us");
    3296             : 
    3297             : static bool
    3298           0 : get_leftViewMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
    3299             : {
    3300           0 :   binding_detail::FastErrorResult rv;
    3301           0 :   JS::Rooted<JSObject*> result(cx);
    3302           0 :   self->GetLeftViewMatrix(cx, &result, rv);
    3303           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3304           0 :     return false;
    3305             :   }
    3306           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3307           0 :   JS::ExposeObjectToActiveJS(result);
    3308           0 :   args.rval().setObject(*result);
    3309           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
    3310           0 :     return false;
    3311             :   }
    3312           0 :   return true;
    3313             : }
    3314             : 
    3315             : static const JSJitInfo leftViewMatrix_getterinfo = {
    3316             :   { (JSJitGetterOp)get_leftViewMatrix },
    3317             :   { prototypes::id::VRFrameData },
    3318             :   { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
    3319             :   JSJitInfo::Getter,
    3320             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    3321             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3322             :   false,  /* isInfallible. False in setters. */
    3323             :   false,  /* isMovable.  Not relevant for setters. */
    3324             :   false, /* isEliminatable.  Not relevant for setters. */
    3325             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3326             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3327             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3328             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3329             : };
    3330             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3331             : static_assert(0 < 1, "There is no slot for us");
    3332             : 
    3333             : static bool
    3334           0 : get_rightProjectionMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
    3335             : {
    3336           0 :   binding_detail::FastErrorResult rv;
    3337           0 :   JS::Rooted<JSObject*> result(cx);
    3338           0 :   self->GetRightProjectionMatrix(cx, &result, rv);
    3339           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3340           0 :     return false;
    3341             :   }
    3342           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3343           0 :   JS::ExposeObjectToActiveJS(result);
    3344           0 :   args.rval().setObject(*result);
    3345           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
    3346           0 :     return false;
    3347             :   }
    3348           0 :   return true;
    3349             : }
    3350             : 
    3351             : static const JSJitInfo rightProjectionMatrix_getterinfo = {
    3352             :   { (JSJitGetterOp)get_rightProjectionMatrix },
    3353             :   { prototypes::id::VRFrameData },
    3354             :   { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
    3355             :   JSJitInfo::Getter,
    3356             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    3357             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3358             :   false,  /* isInfallible. False in setters. */
    3359             :   false,  /* isMovable.  Not relevant for setters. */
    3360             :   false, /* isEliminatable.  Not relevant for setters. */
    3361             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3362             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3363             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3364             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3365             : };
    3366             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3367             : static_assert(0 < 1, "There is no slot for us");
    3368             : 
    3369             : static bool
    3370           0 : get_rightViewMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
    3371             : {
    3372           0 :   binding_detail::FastErrorResult rv;
    3373           0 :   JS::Rooted<JSObject*> result(cx);
    3374           0 :   self->GetRightViewMatrix(cx, &result, rv);
    3375           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3376           0 :     return false;
    3377             :   }
    3378           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3379           0 :   JS::ExposeObjectToActiveJS(result);
    3380           0 :   args.rval().setObject(*result);
    3381           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
    3382           0 :     return false;
    3383             :   }
    3384           0 :   return true;
    3385             : }
    3386             : 
    3387             : static const JSJitInfo rightViewMatrix_getterinfo = {
    3388             :   { (JSJitGetterOp)get_rightViewMatrix },
    3389             :   { prototypes::id::VRFrameData },
    3390             :   { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
    3391             :   JSJitInfo::Getter,
    3392             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    3393             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3394             :   false,  /* isInfallible. False in setters. */
    3395             :   false,  /* isMovable.  Not relevant for setters. */
    3396             :   false, /* isEliminatable.  Not relevant for setters. */
    3397             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3398             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3399             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3400             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3401             : };
    3402             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3403             : static_assert(0 < 1, "There is no slot for us");
    3404             : 
    3405             : static bool
    3406           0 : get_pose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
    3407             : {
    3408           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRPose>(self->Pose()));
    3409           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3410           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    3411           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3412           0 :     return false;
    3413             :   }
    3414           0 :   return true;
    3415             : }
    3416             : 
    3417             : static const JSJitInfo pose_getterinfo = {
    3418             :   { (JSJitGetterOp)get_pose },
    3419             :   { prototypes::id::VRFrameData },
    3420             :   { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
    3421             :   JSJitInfo::Getter,
    3422             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
    3423             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    3424             :   false,  /* isInfallible. False in setters. */
    3425             :   true,  /* isMovable.  Not relevant for setters. */
    3426             :   true, /* isEliminatable.  Not relevant for setters. */
    3427             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3428             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3429             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3430             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3431             : };
    3432             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3433             : static_assert(0 < 1, "There is no slot for us");
    3434             : 
    3435             : static bool
    3436           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    3437             : {
    3438           0 :   mozilla::dom::VRFrameData* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFrameData>(obj);
    3439             :   // We don't want to preserve if we don't have a wrapper, and we
    3440             :   // obviously can't preserve if we're not initialized.
    3441           0 :   if (self && self->GetWrapperPreserveColor()) {
    3442           0 :     PreserveWrapper(self);
    3443             :   }
    3444           0 :   return true;
    3445             : }
    3446             : 
    3447             : static void
    3448           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    3449             : {
    3450           0 :   mozilla::dom::VRFrameData* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFrameData>(obj);
    3451           0 :   if (self) {
    3452           0 :     ClearWrapper(self, self, obj);
    3453           0 :     AddForDeferredFinalization<mozilla::dom::VRFrameData>(self);
    3454             :   }
    3455           0 : }
    3456             : 
    3457             : static void
    3458           0 : _objectMoved(JSObject* obj, const JSObject* old)
    3459             : {
    3460           0 :   mozilla::dom::VRFrameData* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFrameData>(obj);
    3461           0 :   if (self) {
    3462           0 :     UpdateWrapper(self, self, obj, old);
    3463             :   }
    3464           0 : }
    3465             : 
    3466             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    3467             : #if defined(__clang__)
    3468             : #pragma clang diagnostic push
    3469             : #pragma clang diagnostic ignored "-Wmissing-braces"
    3470             : #endif
    3471             : static const JSPropertySpec sAttributes_specs[] = {
    3472             :   { "timestamp", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &timestamp_getterinfo, nullptr, nullptr },
    3473             :   { "leftProjectionMatrix", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &leftProjectionMatrix_getterinfo, nullptr, nullptr },
    3474             :   { "leftViewMatrix", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &leftViewMatrix_getterinfo, nullptr, nullptr },
    3475             :   { "rightProjectionMatrix", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rightProjectionMatrix_getterinfo, nullptr, nullptr },
    3476             :   { "rightViewMatrix", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rightViewMatrix_getterinfo, nullptr, nullptr },
    3477             :   { "pose", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pose_getterinfo, nullptr, nullptr },
    3478             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    3479             : };
    3480             : #if defined(__clang__)
    3481             : #pragma clang diagnostic pop
    3482             : #endif
    3483             : 
    3484             : 
    3485             : // Can't be const because the pref-enabled boolean needs to be writable
    3486             : static Prefable<const JSPropertySpec> sAttributes[] = {
    3487             :   { nullptr, &sAttributes_specs[0] },
    3488             :   { nullptr, nullptr }
    3489             : };
    3490             : 
    3491             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    3492             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    3493             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    3494             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    3495             : 
    3496             : 
    3497             : static uint16_t sNativeProperties_sortedPropertyIndices[6];
    3498             : static PropertyInfo sNativeProperties_propertyInfos[6];
    3499             : 
    3500             : static const NativePropertiesN<1> sNativeProperties = {
    3501             :   false, 0,
    3502             :   false, 0,
    3503             :   false, 0,
    3504             :   true,  0 /* sAttributes */,
    3505             :   false, 0,
    3506             :   false, 0,
    3507             :   false, 0,
    3508             :   -1,
    3509             :   6,
    3510             :   sNativeProperties_sortedPropertyIndices,
    3511             :   {
    3512             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    3513             :   }
    3514             : };
    3515             : static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    3516             :     "We have a property info count that is oversized");
    3517             : 
    3518             : static bool
    3519           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    3520             : {
    3521           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    3522           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    3523           0 :   if (!args.isConstructing()) {
    3524             :     // XXXbz wish I could get the name from the callee instead of
    3525             :     // Adding more relocations
    3526           0 :     return ThrowConstructorWithoutNew(cx, "VRFrameData");
    3527             :   }
    3528             : 
    3529           0 :   GlobalObject global(cx, obj);
    3530           0 :   if (global.Failed()) {
    3531           0 :     return false;
    3532             :   }
    3533             : 
    3534           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    3535           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    3536           0 :     return false;
    3537             :   }
    3538             : 
    3539           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    3540           0 :   Maybe<JSAutoCompartment> ac;
    3541           0 :   if (objIsXray) {
    3542           0 :     obj = js::CheckedUnwrap(obj);
    3543           0 :     if (!obj) {
    3544           0 :       return false;
    3545             :     }
    3546           0 :     ac.emplace(cx, obj);
    3547           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    3548           0 :       return false;
    3549             :     }
    3550             :   }
    3551           0 :   binding_detail::FastErrorResult rv;
    3552           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRFrameData>(mozilla::dom::VRFrameData::Constructor(global, rv)));
    3553           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3554           0 :     return false;
    3555             :   }
    3556           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3557             :   static_assert(!IsPointer<decltype(result)>::value,
    3558             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    3559           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    3560           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    3561           0 :     return false;
    3562             :   }
    3563           0 :   return true;
    3564             : }
    3565             : 
    3566             : static const js::ClassOps sInterfaceObjectClassOps = {
    3567             :     nullptr,               /* addProperty */
    3568             :     nullptr,               /* delProperty */
    3569             :     nullptr,               /* getProperty */
    3570             :     nullptr,               /* setProperty */
    3571             :     nullptr,               /* enumerate */
    3572             :     nullptr,               /* newEnumerate */
    3573             :     nullptr,               /* resolve */
    3574             :     nullptr,               /* mayResolve */
    3575             :     nullptr,               /* finalize */
    3576             :     _constructor, /* call */
    3577             :     nullptr,               /* hasInstance */
    3578             :     _constructor, /* construct */
    3579             :     nullptr,               /* trace */
    3580             : };
    3581             : 
    3582             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    3583             :   {
    3584             :     "Function",
    3585             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    3586             :     &sInterfaceObjectClassOps,
    3587             :     JS_NULL_CLASS_SPEC,
    3588             :     JS_NULL_CLASS_EXT,
    3589             :     &sInterfaceObjectClassObjectOps
    3590             :   },
    3591             :   eInterface,
    3592             :   true,
    3593             :   prototypes::id::VRFrameData,
    3594             :   PrototypeTraits<prototypes::id::VRFrameData>::Depth,
    3595             :   sNativePropertyHooks,
    3596             :   "function VRFrameData() {\n    [native code]\n}",
    3597             :   JS::GetRealmFunctionPrototype
    3598             : };
    3599             : 
    3600             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    3601             :   {
    3602             :     "VRFrameDataPrototype",
    3603             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    3604             :     JS_NULL_CLASS_OPS,
    3605             :     JS_NULL_CLASS_SPEC,
    3606             :     JS_NULL_CLASS_EXT,
    3607             :     JS_NULL_OBJECT_OPS
    3608             :   },
    3609             :   eInterfacePrototype,
    3610             :   false,
    3611             :   prototypes::id::VRFrameData,
    3612             :   PrototypeTraits<prototypes::id::VRFrameData>::Depth,
    3613             :   sNativePropertyHooks,
    3614             :   "[object VRFrameDataPrototype]",
    3615             :   JS::GetRealmObjectPrototype
    3616             : };
    3617             : 
    3618             : bool
    3619           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    3620             : {
    3621             :   static bool sPrefValue;
    3622             :   static bool sPrefCacheSetUp = false;
    3623           0 :   if (!sPrefCacheSetUp) {
    3624           0 :     sPrefCacheSetUp = true;
    3625           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    3626             :   }
    3627             : 
    3628           0 :   return sPrefValue;
    3629             : }
    3630             : 
    3631             : JSObject*
    3632           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    3633             : {
    3634           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    3635             : }
    3636             : 
    3637             : static const js::ClassOps sClassOps = {
    3638             :   _addProperty, /* addProperty */
    3639             :   nullptr,               /* delProperty */
    3640             :   nullptr,               /* getProperty */
    3641             :   nullptr,               /* setProperty */
    3642             :   nullptr,               /* enumerate */
    3643             :   nullptr, /* newEnumerate */
    3644             :   nullptr, /* resolve */
    3645             :   nullptr, /* mayResolve */
    3646             :   _finalize, /* finalize */
    3647             :   nullptr, /* call */
    3648             :   nullptr,               /* hasInstance */
    3649             :   nullptr,               /* construct */
    3650             :   nullptr, /* trace */
    3651             : };
    3652             : 
    3653             : static const js::ClassExtension sClassExtension = {
    3654             :   nullptr, /* weakmapKeyDelegateOp */
    3655             :   _objectMoved /* objectMovedOp */
    3656             : };
    3657             : 
    3658             : static const DOMJSClass sClass = {
    3659             :   { "VRFrameData",
    3660             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    3661             :     &sClassOps,
    3662             :     JS_NULL_CLASS_SPEC,
    3663             :     &sClassExtension,
    3664             :     JS_NULL_OBJECT_OPS
    3665             :   },
    3666             :   { prototypes::id::VRFrameData, 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 },
    3667             :   IsBaseOf<nsISupports, mozilla::dom::VRFrameData >::value,
    3668             :   sNativePropertyHooks,
    3669             :   FindAssociatedGlobalForNative<mozilla::dom::VRFrameData>::Get,
    3670             :   GetProtoObjectHandle,
    3671             :   GetCCParticipant<mozilla::dom::VRFrameData>::Get()
    3672             : };
    3673             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    3674             :               "Must have the right minimal number of reserved slots.");
    3675             : static_assert(1 >= 1,
    3676             :               "Must have enough reserved slots.");
    3677             : 
    3678             : const JSClass*
    3679           0 : GetJSClass()
    3680             : {
    3681           0 :   return sClass.ToJSClass();
    3682             : }
    3683             : 
    3684             : bool
    3685           0 : Wrap(JSContext* aCx, mozilla::dom::VRFrameData* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    3686             : {
    3687             :   MOZ_ASSERT(static_cast<mozilla::dom::VRFrameData*>(aObject) ==
    3688             :              reinterpret_cast<mozilla::dom::VRFrameData*>(aObject),
    3689             :              "Multiple inheritance for mozilla::dom::VRFrameData is broken.");
    3690           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    3691           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    3692           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    3693             :              "You should probably not be using Wrap() directly; use "
    3694             :              "GetOrCreateDOMReflector instead");
    3695             : 
    3696           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    3697             :              "nsISupports must be on our primary inheritance chain");
    3698             : 
    3699           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    3700           0 :   if (!global) {
    3701           0 :     return false;
    3702             :   }
    3703           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    3704           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    3705             : 
    3706             :   // That might have ended up wrapping us already, due to the wonders
    3707             :   // of XBL.  Check for that, and bail out as needed.
    3708           0 :   aReflector.set(aCache->GetWrapper());
    3709           0 :   if (aReflector) {
    3710             : #ifdef DEBUG
    3711           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    3712             : #endif // DEBUG
    3713           0 :     return true;
    3714             :   }
    3715             : 
    3716           0 :   JSAutoCompartment ac(aCx, global);
    3717           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    3718           0 :   if (!canonicalProto) {
    3719           0 :     return false;
    3720             :   }
    3721           0 :   JS::Rooted<JSObject*> proto(aCx);
    3722           0 :   if (aGivenProto) {
    3723           0 :     proto = aGivenProto;
    3724             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    3725             :     // coming in, we changed compartments to that of "parent" so may need
    3726             :     // to wrap the proto here.
    3727           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    3728           0 :       if (!JS_WrapObject(aCx, &proto)) {
    3729           0 :         return false;
    3730             :       }
    3731             :     }
    3732             :   } else {
    3733           0 :     proto = canonicalProto;
    3734             :   }
    3735             : 
    3736           0 :   BindingJSObjectCreator<mozilla::dom::VRFrameData> creator(aCx);
    3737           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    3738           0 :   if (!aReflector) {
    3739           0 :     return false;
    3740             :   }
    3741             : 
    3742           0 :   aCache->SetWrapper(aReflector);
    3743           0 :   creator.InitializationSucceeded();
    3744             : 
    3745           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    3746             :              aCache->GetWrapperPreserveColor() == aReflector);
    3747             :   // If proto != canonicalProto, we have to preserve our wrapper;
    3748             :   // otherwise we won't be able to properly recreate it later, since
    3749             :   // we won't know what proto to use.  Note that we don't check
    3750             :   // aGivenProto here, since it's entirely possible (and even
    3751             :   // somewhat common) to have a non-null aGivenProto which is the
    3752             :   // same as canonicalProto.
    3753           0 :   if (proto != canonicalProto) {
    3754           0 :     PreserveWrapper(aObject);
    3755             :   }
    3756             : 
    3757           0 :   return true;
    3758             : }
    3759             : 
    3760             : const NativePropertyHooks sNativePropertyHooks[] = { {
    3761             :   nullptr,
    3762             :   nullptr,
    3763             :   nullptr,
    3764             :   { sNativeProperties.Upcast(), nullptr },
    3765             :   prototypes::id::VRFrameData,
    3766             :   constructors::id::VRFrameData,
    3767             :   nullptr,
    3768             :   &DefaultXrayExpandoObjectClass
    3769             : } };
    3770             : 
    3771             : void
    3772           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    3773             : {
    3774           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    3775           0 :   if (!parentProto) {
    3776           0 :     return;
    3777             :   }
    3778             : 
    3779           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    3780           0 :   if (!constructorProto) {
    3781           0 :     return;
    3782             :   }
    3783             : 
    3784             :   static bool sIdsInited = false;
    3785           0 :   if (!sIdsInited && NS_IsMainThread()) {
    3786           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    3787           0 :       return;
    3788             :     }
    3789           0 :     sIdsInited = true;
    3790             :   }
    3791             : 
    3792           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRFrameData);
    3793           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRFrameData);
    3794           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    3795             :                               &sPrototypeClass.mBase, protoCache,
    3796             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    3797             :                               interfaceCache,
    3798             :                               sNativeProperties.Upcast(),
    3799             :                               nullptr,
    3800             :                               "VRFrameData", aDefineOnGlobal,
    3801             :                               nullptr,
    3802           0 :                               false);
    3803             : }
    3804             : 
    3805             : JS::Handle<JSObject*>
    3806           0 : GetProtoObjectHandle(JSContext* aCx)
    3807             : {
    3808             :   /* Get the interface prototype object for this class.  This will create the
    3809             :      object as needed. */
    3810           0 :   bool aDefineOnGlobal = true;
    3811             : 
    3812             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    3813           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    3814           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    3815           0 :     return nullptr;
    3816             :   }
    3817             : 
    3818             :   /* Check to see whether the interface objects are already installed */
    3819           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    3820           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRFrameData)) {
    3821           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    3822           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    3823             :   }
    3824             : 
    3825             :   /*
    3826             :    * The object might _still_ be null, but that's OK.
    3827             :    *
    3828             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    3829             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    3830             :    * changed after they have been set.
    3831             :    *
    3832             :    * Calling address() avoids the read read barrier that does gray
    3833             :    * unmarking, but it's not possible for the object to be gray here.
    3834             :    */
    3835             : 
    3836           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRFrameData);
    3837           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    3838           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    3839             : }
    3840             : 
    3841             : JS::Handle<JSObject*>
    3842           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    3843             : {
    3844             :   /* Get the interface object for this class.  This will create the object as
    3845             :      needed. */
    3846             : 
    3847             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    3848           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    3849           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    3850           0 :     return nullptr;
    3851             :   }
    3852             : 
    3853             :   /* Check to see whether the interface objects are already installed */
    3854           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    3855           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRFrameData)) {
    3856           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    3857           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    3858             :   }
    3859             : 
    3860             :   /*
    3861             :    * The object might _still_ be null, but that's OK.
    3862             :    *
    3863             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    3864             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    3865             :    * changed after they have been set.
    3866             :    *
    3867             :    * Calling address() avoids the read read barrier that does gray
    3868             :    * unmarking, but it's not possible for the object to be gray here.
    3869             :    */
    3870             : 
    3871           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRFrameData);
    3872           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    3873           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    3874             : }
    3875             : 
    3876             : JSObject*
    3877           0 : GetConstructorObject(JSContext* aCx)
    3878             : {
    3879           0 :   return GetConstructorObjectHandle(aCx);
    3880             : }
    3881             : 
    3882             : } // namespace VRFrameDataBinding
    3883             : 
    3884             : 
    3885             : 
    3886             : namespace VRPoseBinding {
    3887             : 
    3888             : static bool
    3889           0 : get_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
    3890             : {
    3891           0 :   binding_detail::FastErrorResult rv;
    3892           0 :   JS::Rooted<JSObject*> result(cx);
    3893           0 :   self->GetPosition(cx, &result, rv);
    3894           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3895           0 :     return false;
    3896             :   }
    3897           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3898           0 :   if (result) {
    3899           0 :                 JS::ExposeObjectToActiveJS(result);
    3900             :               }
    3901           0 :               args.rval().setObjectOrNull(result);
    3902           0 :   if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
    3903           0 :     return false;
    3904             :   }
    3905           0 :   return true;
    3906             : }
    3907             : 
    3908             : static const JSJitInfo position_getterinfo = {
    3909             :   { (JSJitGetterOp)get_position },
    3910             :   { prototypes::id::VRPose },
    3911             :   { PrototypeTraits<prototypes::id::VRPose>::Depth },
    3912             :   JSJitInfo::Getter,
    3913             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    3914             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3915             :   false,  /* isInfallible. False in setters. */
    3916             :   false,  /* isMovable.  Not relevant for setters. */
    3917             :   false, /* isEliminatable.  Not relevant for setters. */
    3918             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3919             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3920             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3921             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3922             : };
    3923             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3924             : static_assert(0 < 1, "There is no slot for us");
    3925             : 
    3926             : static bool
    3927           0 : get_linearVelocity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
    3928             : {
    3929           0 :   binding_detail::FastErrorResult rv;
    3930           0 :   JS::Rooted<JSObject*> result(cx);
    3931           0 :   self->GetLinearVelocity(cx, &result, rv);
    3932           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3933           0 :     return false;
    3934             :   }
    3935           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3936           0 :   if (result) {
    3937           0 :                 JS::ExposeObjectToActiveJS(result);
    3938             :               }
    3939           0 :               args.rval().setObjectOrNull(result);
    3940           0 :   if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
    3941           0 :     return false;
    3942             :   }
    3943           0 :   return true;
    3944             : }
    3945             : 
    3946             : static const JSJitInfo linearVelocity_getterinfo = {
    3947             :   { (JSJitGetterOp)get_linearVelocity },
    3948             :   { prototypes::id::VRPose },
    3949             :   { PrototypeTraits<prototypes::id::VRPose>::Depth },
    3950             :   JSJitInfo::Getter,
    3951             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    3952             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3953             :   false,  /* isInfallible. False in setters. */
    3954             :   false,  /* isMovable.  Not relevant for setters. */
    3955             :   false, /* isEliminatable.  Not relevant for setters. */
    3956             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3957             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3958             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3959             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3960             : };
    3961             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    3962             : static_assert(0 < 1, "There is no slot for us");
    3963             : 
    3964             : static bool
    3965           0 : get_linearAcceleration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
    3966             : {
    3967           0 :   binding_detail::FastErrorResult rv;
    3968           0 :   JS::Rooted<JSObject*> result(cx);
    3969           0 :   self->GetLinearAcceleration(cx, &result, rv);
    3970           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    3971           0 :     return false;
    3972             :   }
    3973           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    3974           0 :   if (result) {
    3975           0 :                 JS::ExposeObjectToActiveJS(result);
    3976             :               }
    3977           0 :               args.rval().setObjectOrNull(result);
    3978           0 :   if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
    3979           0 :     return false;
    3980             :   }
    3981           0 :   return true;
    3982             : }
    3983             : 
    3984             : static const JSJitInfo linearAcceleration_getterinfo = {
    3985             :   { (JSJitGetterOp)get_linearAcceleration },
    3986             :   { prototypes::id::VRPose },
    3987             :   { PrototypeTraits<prototypes::id::VRPose>::Depth },
    3988             :   JSJitInfo::Getter,
    3989             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    3990             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    3991             :   false,  /* isInfallible. False in setters. */
    3992             :   false,  /* isMovable.  Not relevant for setters. */
    3993             :   false, /* isEliminatable.  Not relevant for setters. */
    3994             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    3995             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    3996             :   false,  /* isTypedMethod.  Only relevant for methods. */
    3997             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    3998             : };
    3999             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4000             : static_assert(0 < 1, "There is no slot for us");
    4001             : 
    4002             : static bool
    4003           0 : get_orientation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
    4004             : {
    4005           0 :   binding_detail::FastErrorResult rv;
    4006           0 :   JS::Rooted<JSObject*> result(cx);
    4007           0 :   self->GetOrientation(cx, &result, rv);
    4008           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4009           0 :     return false;
    4010             :   }
    4011           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4012           0 :   if (result) {
    4013           0 :                 JS::ExposeObjectToActiveJS(result);
    4014             :               }
    4015           0 :               args.rval().setObjectOrNull(result);
    4016           0 :   if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
    4017           0 :     return false;
    4018             :   }
    4019           0 :   return true;
    4020             : }
    4021             : 
    4022             : static const JSJitInfo orientation_getterinfo = {
    4023             :   { (JSJitGetterOp)get_orientation },
    4024             :   { prototypes::id::VRPose },
    4025             :   { PrototypeTraits<prototypes::id::VRPose>::Depth },
    4026             :   JSJitInfo::Getter,
    4027             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    4028             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    4029             :   false,  /* isInfallible. False in setters. */
    4030             :   false,  /* isMovable.  Not relevant for setters. */
    4031             :   false, /* isEliminatable.  Not relevant for setters. */
    4032             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4033             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4034             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4035             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4036             : };
    4037             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4038             : static_assert(0 < 1, "There is no slot for us");
    4039             : 
    4040             : static bool
    4041           0 : get_angularVelocity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
    4042             : {
    4043           0 :   binding_detail::FastErrorResult rv;
    4044           0 :   JS::Rooted<JSObject*> result(cx);
    4045           0 :   self->GetAngularVelocity(cx, &result, rv);
    4046           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4047           0 :     return false;
    4048             :   }
    4049           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4050           0 :   if (result) {
    4051           0 :                 JS::ExposeObjectToActiveJS(result);
    4052             :               }
    4053           0 :               args.rval().setObjectOrNull(result);
    4054           0 :   if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
    4055           0 :     return false;
    4056             :   }
    4057           0 :   return true;
    4058             : }
    4059             : 
    4060             : static const JSJitInfo angularVelocity_getterinfo = {
    4061             :   { (JSJitGetterOp)get_angularVelocity },
    4062             :   { prototypes::id::VRPose },
    4063             :   { PrototypeTraits<prototypes::id::VRPose>::Depth },
    4064             :   JSJitInfo::Getter,
    4065             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    4066             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    4067             :   false,  /* isInfallible. False in setters. */
    4068             :   false,  /* isMovable.  Not relevant for setters. */
    4069             :   false, /* isEliminatable.  Not relevant for setters. */
    4070             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4071             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4072             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4073             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4074             : };
    4075             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4076             : static_assert(0 < 1, "There is no slot for us");
    4077             : 
    4078             : static bool
    4079           0 : get_angularAcceleration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
    4080             : {
    4081           0 :   binding_detail::FastErrorResult rv;
    4082           0 :   JS::Rooted<JSObject*> result(cx);
    4083           0 :   self->GetAngularAcceleration(cx, &result, rv);
    4084           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4085           0 :     return false;
    4086             :   }
    4087           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4088           0 :   if (result) {
    4089           0 :                 JS::ExposeObjectToActiveJS(result);
    4090             :               }
    4091           0 :               args.rval().setObjectOrNull(result);
    4092           0 :   if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
    4093           0 :     return false;
    4094             :   }
    4095           0 :   return true;
    4096             : }
    4097             : 
    4098             : static const JSJitInfo angularAcceleration_getterinfo = {
    4099             :   { (JSJitGetterOp)get_angularAcceleration },
    4100             :   { prototypes::id::VRPose },
    4101             :   { PrototypeTraits<prototypes::id::VRPose>::Depth },
    4102             :   JSJitInfo::Getter,
    4103             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    4104             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    4105             :   false,  /* isInfallible. False in setters. */
    4106             :   false,  /* isMovable.  Not relevant for setters. */
    4107             :   false, /* isEliminatable.  Not relevant for setters. */
    4108             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4109             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4110             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4111             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4112             : };
    4113             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4114             : static_assert(0 < 1, "There is no slot for us");
    4115             : 
    4116             : static bool
    4117           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    4118             : {
    4119           0 :   mozilla::dom::VRPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRPose>(obj);
    4120             :   // We don't want to preserve if we don't have a wrapper, and we
    4121             :   // obviously can't preserve if we're not initialized.
    4122           0 :   if (self && self->GetWrapperPreserveColor()) {
    4123           0 :     PreserveWrapper(self);
    4124             :   }
    4125           0 :   return true;
    4126             : }
    4127             : 
    4128             : static void
    4129           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    4130             : {
    4131           0 :   mozilla::dom::VRPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRPose>(obj);
    4132           0 :   if (self) {
    4133           0 :     ClearWrapper(self, self, obj);
    4134           0 :     AddForDeferredFinalization<mozilla::dom::VRPose>(self);
    4135             :   }
    4136           0 : }
    4137             : 
    4138             : static void
    4139           0 : _objectMoved(JSObject* obj, const JSObject* old)
    4140             : {
    4141           0 :   mozilla::dom::VRPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRPose>(obj);
    4142           0 :   if (self) {
    4143           0 :     UpdateWrapper(self, self, obj, old);
    4144             :   }
    4145           0 : }
    4146             : 
    4147             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    4148             : #if defined(__clang__)
    4149             : #pragma clang diagnostic push
    4150             : #pragma clang diagnostic ignored "-Wmissing-braces"
    4151             : #endif
    4152             : static const JSPropertySpec sAttributes_specs[] = {
    4153             :   { "position", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &position_getterinfo, nullptr, nullptr },
    4154             :   { "linearVelocity", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &linearVelocity_getterinfo, nullptr, nullptr },
    4155             :   { "linearAcceleration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &linearAcceleration_getterinfo, nullptr, nullptr },
    4156             :   { "orientation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &orientation_getterinfo, nullptr, nullptr },
    4157             :   { "angularVelocity", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &angularVelocity_getterinfo, nullptr, nullptr },
    4158             :   { "angularAcceleration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &angularAcceleration_getterinfo, nullptr, nullptr },
    4159             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    4160             : };
    4161             : #if defined(__clang__)
    4162             : #pragma clang diagnostic pop
    4163             : #endif
    4164             : 
    4165             : 
    4166             : // Can't be const because the pref-enabled boolean needs to be writable
    4167             : static Prefable<const JSPropertySpec> sAttributes[] = {
    4168             :   { nullptr, &sAttributes_specs[0] },
    4169             :   { nullptr, nullptr }
    4170             : };
    4171             : 
    4172             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    4173             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    4174             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    4175             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    4176             : 
    4177             : 
    4178             : static uint16_t sNativeProperties_sortedPropertyIndices[6];
    4179             : static PropertyInfo sNativeProperties_propertyInfos[6];
    4180             : 
    4181             : static const NativePropertiesN<1> sNativeProperties = {
    4182             :   false, 0,
    4183             :   false, 0,
    4184             :   false, 0,
    4185             :   true,  0 /* sAttributes */,
    4186             :   false, 0,
    4187             :   false, 0,
    4188             :   false, 0,
    4189             :   -1,
    4190             :   6,
    4191             :   sNativeProperties_sortedPropertyIndices,
    4192             :   {
    4193             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    4194             :   }
    4195             : };
    4196             : static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    4197             :     "We have a property info count that is oversized");
    4198             : 
    4199             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    4200             :   {
    4201             :     "Function",
    4202             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    4203             :     &sBoringInterfaceObjectClassClassOps,
    4204             :     JS_NULL_CLASS_SPEC,
    4205             :     JS_NULL_CLASS_EXT,
    4206             :     &sInterfaceObjectClassObjectOps
    4207             :   },
    4208             :   eInterface,
    4209             :   true,
    4210             :   prototypes::id::VRPose,
    4211             :   PrototypeTraits<prototypes::id::VRPose>::Depth,
    4212             :   sNativePropertyHooks,
    4213             :   "function VRPose() {\n    [native code]\n}",
    4214             :   JS::GetRealmFunctionPrototype
    4215             : };
    4216             : 
    4217             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    4218             :   {
    4219             :     "VRPosePrototype",
    4220             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    4221             :     JS_NULL_CLASS_OPS,
    4222             :     JS_NULL_CLASS_SPEC,
    4223             :     JS_NULL_CLASS_EXT,
    4224             :     JS_NULL_OBJECT_OPS
    4225             :   },
    4226             :   eInterfacePrototype,
    4227             :   false,
    4228             :   prototypes::id::VRPose,
    4229             :   PrototypeTraits<prototypes::id::VRPose>::Depth,
    4230             :   sNativePropertyHooks,
    4231             :   "[object VRPosePrototype]",
    4232             :   JS::GetRealmObjectPrototype
    4233             : };
    4234             : 
    4235             : bool
    4236           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    4237             : {
    4238             :   static bool sPrefValue;
    4239             :   static bool sPrefCacheSetUp = false;
    4240           0 :   if (!sPrefCacheSetUp) {
    4241           0 :     sPrefCacheSetUp = true;
    4242           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    4243             :   }
    4244             : 
    4245           0 :   return sPrefValue;
    4246             : }
    4247             : 
    4248             : JSObject*
    4249           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    4250             : {
    4251           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    4252             : }
    4253             : 
    4254             : static const js::ClassOps sClassOps = {
    4255             :   _addProperty, /* addProperty */
    4256             :   nullptr,               /* delProperty */
    4257             :   nullptr,               /* getProperty */
    4258             :   nullptr,               /* setProperty */
    4259             :   nullptr,               /* enumerate */
    4260             :   nullptr, /* newEnumerate */
    4261             :   nullptr, /* resolve */
    4262             :   nullptr, /* mayResolve */
    4263             :   _finalize, /* finalize */
    4264             :   nullptr, /* call */
    4265             :   nullptr,               /* hasInstance */
    4266             :   nullptr,               /* construct */
    4267             :   nullptr, /* trace */
    4268             : };
    4269             : 
    4270             : static const js::ClassExtension sClassExtension = {
    4271             :   nullptr, /* weakmapKeyDelegateOp */
    4272             :   _objectMoved /* objectMovedOp */
    4273             : };
    4274             : 
    4275             : static const DOMJSClass sClass = {
    4276             :   { "VRPose",
    4277             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    4278             :     &sClassOps,
    4279             :     JS_NULL_CLASS_SPEC,
    4280             :     &sClassExtension,
    4281             :     JS_NULL_OBJECT_OPS
    4282             :   },
    4283             :   { prototypes::id::VRPose, 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 },
    4284             :   IsBaseOf<nsISupports, mozilla::dom::VRPose >::value,
    4285             :   sNativePropertyHooks,
    4286             :   FindAssociatedGlobalForNative<mozilla::dom::VRPose>::Get,
    4287             :   GetProtoObjectHandle,
    4288             :   GetCCParticipant<mozilla::dom::VRPose>::Get()
    4289             : };
    4290             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    4291             :               "Must have the right minimal number of reserved slots.");
    4292             : static_assert(1 >= 1,
    4293             :               "Must have enough reserved slots.");
    4294             : 
    4295             : const JSClass*
    4296           0 : GetJSClass()
    4297             : {
    4298           0 :   return sClass.ToJSClass();
    4299             : }
    4300             : 
    4301             : bool
    4302           0 : Wrap(JSContext* aCx, mozilla::dom::VRPose* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    4303             : {
    4304             :   MOZ_ASSERT(static_cast<mozilla::dom::VRPose*>(aObject) ==
    4305             :              reinterpret_cast<mozilla::dom::VRPose*>(aObject),
    4306             :              "Multiple inheritance for mozilla::dom::VRPose is broken.");
    4307           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    4308           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    4309           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    4310             :              "You should probably not be using Wrap() directly; use "
    4311             :              "GetOrCreateDOMReflector instead");
    4312             : 
    4313           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    4314             :              "nsISupports must be on our primary inheritance chain");
    4315             : 
    4316           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    4317           0 :   if (!global) {
    4318           0 :     return false;
    4319             :   }
    4320           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    4321           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    4322             : 
    4323             :   // That might have ended up wrapping us already, due to the wonders
    4324             :   // of XBL.  Check for that, and bail out as needed.
    4325           0 :   aReflector.set(aCache->GetWrapper());
    4326           0 :   if (aReflector) {
    4327             : #ifdef DEBUG
    4328           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    4329             : #endif // DEBUG
    4330           0 :     return true;
    4331             :   }
    4332             : 
    4333           0 :   JSAutoCompartment ac(aCx, global);
    4334           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    4335           0 :   if (!canonicalProto) {
    4336           0 :     return false;
    4337             :   }
    4338           0 :   JS::Rooted<JSObject*> proto(aCx);
    4339           0 :   if (aGivenProto) {
    4340           0 :     proto = aGivenProto;
    4341             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    4342             :     // coming in, we changed compartments to that of "parent" so may need
    4343             :     // to wrap the proto here.
    4344           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    4345           0 :       if (!JS_WrapObject(aCx, &proto)) {
    4346           0 :         return false;
    4347             :       }
    4348             :     }
    4349             :   } else {
    4350           0 :     proto = canonicalProto;
    4351             :   }
    4352             : 
    4353           0 :   BindingJSObjectCreator<mozilla::dom::VRPose> creator(aCx);
    4354           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    4355           0 :   if (!aReflector) {
    4356           0 :     return false;
    4357             :   }
    4358             : 
    4359           0 :   aCache->SetWrapper(aReflector);
    4360           0 :   creator.InitializationSucceeded();
    4361             : 
    4362           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    4363             :              aCache->GetWrapperPreserveColor() == aReflector);
    4364             :   // If proto != canonicalProto, we have to preserve our wrapper;
    4365             :   // otherwise we won't be able to properly recreate it later, since
    4366             :   // we won't know what proto to use.  Note that we don't check
    4367             :   // aGivenProto here, since it's entirely possible (and even
    4368             :   // somewhat common) to have a non-null aGivenProto which is the
    4369             :   // same as canonicalProto.
    4370           0 :   if (proto != canonicalProto) {
    4371           0 :     PreserveWrapper(aObject);
    4372             :   }
    4373             : 
    4374           0 :   return true;
    4375             : }
    4376             : 
    4377             : const NativePropertyHooks sNativePropertyHooks[] = { {
    4378             :   nullptr,
    4379             :   nullptr,
    4380             :   nullptr,
    4381             :   { sNativeProperties.Upcast(), nullptr },
    4382             :   prototypes::id::VRPose,
    4383             :   constructors::id::VRPose,
    4384             :   nullptr,
    4385             :   &DefaultXrayExpandoObjectClass
    4386             : } };
    4387             : 
    4388             : void
    4389           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    4390             : {
    4391           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    4392           0 :   if (!parentProto) {
    4393           0 :     return;
    4394             :   }
    4395             : 
    4396           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    4397           0 :   if (!constructorProto) {
    4398           0 :     return;
    4399             :   }
    4400             : 
    4401             :   static bool sIdsInited = false;
    4402           0 :   if (!sIdsInited && NS_IsMainThread()) {
    4403           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    4404           0 :       return;
    4405             :     }
    4406           0 :     sIdsInited = true;
    4407             :   }
    4408             : 
    4409           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRPose);
    4410           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRPose);
    4411           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    4412             :                               &sPrototypeClass.mBase, protoCache,
    4413             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    4414             :                               interfaceCache,
    4415             :                               sNativeProperties.Upcast(),
    4416             :                               nullptr,
    4417             :                               "VRPose", aDefineOnGlobal,
    4418             :                               nullptr,
    4419           0 :                               false);
    4420             : }
    4421             : 
    4422             : JS::Handle<JSObject*>
    4423           0 : GetProtoObjectHandle(JSContext* aCx)
    4424             : {
    4425             :   /* Get the interface prototype object for this class.  This will create the
    4426             :      object as needed. */
    4427           0 :   bool aDefineOnGlobal = true;
    4428             : 
    4429             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    4430           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    4431           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    4432           0 :     return nullptr;
    4433             :   }
    4434             : 
    4435             :   /* Check to see whether the interface objects are already installed */
    4436           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    4437           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRPose)) {
    4438           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    4439           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    4440             :   }
    4441             : 
    4442             :   /*
    4443             :    * The object might _still_ be null, but that's OK.
    4444             :    *
    4445             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    4446             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    4447             :    * changed after they have been set.
    4448             :    *
    4449             :    * Calling address() avoids the read read barrier that does gray
    4450             :    * unmarking, but it's not possible for the object to be gray here.
    4451             :    */
    4452             : 
    4453           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRPose);
    4454           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    4455           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    4456             : }
    4457             : 
    4458             : JS::Handle<JSObject*>
    4459           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    4460             : {
    4461             :   /* Get the interface object for this class.  This will create the object as
    4462             :      needed. */
    4463             : 
    4464             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    4465           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    4466           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    4467           0 :     return nullptr;
    4468             :   }
    4469             : 
    4470             :   /* Check to see whether the interface objects are already installed */
    4471           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    4472           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRPose)) {
    4473           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    4474           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    4475             :   }
    4476             : 
    4477             :   /*
    4478             :    * The object might _still_ be null, but that's OK.
    4479             :    *
    4480             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    4481             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    4482             :    * changed after they have been set.
    4483             :    *
    4484             :    * Calling address() avoids the read read barrier that does gray
    4485             :    * unmarking, but it's not possible for the object to be gray here.
    4486             :    */
    4487             : 
    4488           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRPose);
    4489           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    4490           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    4491             : }
    4492             : 
    4493             : JSObject*
    4494           0 : GetConstructorObject(JSContext* aCx)
    4495             : {
    4496           0 :   return GetConstructorObjectHandle(aCx);
    4497             : }
    4498             : 
    4499             : } // namespace VRPoseBinding
    4500             : 
    4501             : 
    4502             : 
    4503             : namespace VRStageParametersBinding {
    4504             : 
    4505             : static bool
    4506           0 : get_sittingToStandingTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRStageParameters* self, JSJitGetterCallArgs args)
    4507             : {
    4508           0 :   binding_detail::FastErrorResult rv;
    4509           0 :   JS::Rooted<JSObject*> result(cx);
    4510           0 :   self->GetSittingToStandingTransform(cx, &result, rv);
    4511           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    4512           0 :     return false;
    4513             :   }
    4514           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4515           0 :   JS::ExposeObjectToActiveJS(result);
    4516           0 :   args.rval().setObject(*result);
    4517           0 :   if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
    4518           0 :     return false;
    4519             :   }
    4520           0 :   return true;
    4521             : }
    4522             : 
    4523             : static const JSJitInfo sittingToStandingTransform_getterinfo = {
    4524             :   { (JSJitGetterOp)get_sittingToStandingTransform },
    4525             :   { prototypes::id::VRStageParameters },
    4526             :   { PrototypeTraits<prototypes::id::VRStageParameters>::Depth },
    4527             :   JSJitInfo::Getter,
    4528             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4529             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    4530             :   false,  /* isInfallible. False in setters. */
    4531             :   false,  /* isMovable.  Not relevant for setters. */
    4532             :   false, /* isEliminatable.  Not relevant for setters. */
    4533             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4534             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4535             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4536             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4537             : };
    4538             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4539             : static_assert(0 < 1, "There is no slot for us");
    4540             : 
    4541             : static bool
    4542           0 : get_sizeX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRStageParameters* self, JSJitGetterCallArgs args)
    4543             : {
    4544           0 :   float result(self->SizeX());
    4545           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4546           0 :   args.rval().set(JS_NumberValue(double(result)));
    4547           0 :   return true;
    4548             : }
    4549             : 
    4550             : static const JSJitInfo sizeX_getterinfo = {
    4551             :   { (JSJitGetterOp)get_sizeX },
    4552             :   { prototypes::id::VRStageParameters },
    4553             :   { PrototypeTraits<prototypes::id::VRStageParameters>::Depth },
    4554             :   JSJitInfo::Getter,
    4555             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4556             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    4557             :   true,  /* isInfallible. False in setters. */
    4558             :   false,  /* isMovable.  Not relevant for setters. */
    4559             :   false, /* isEliminatable.  Not relevant for setters. */
    4560             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4561             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4562             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4563             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4564             : };
    4565             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4566             : static_assert(0 < 1, "There is no slot for us");
    4567             : 
    4568             : static bool
    4569           0 : get_sizeZ(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRStageParameters* self, JSJitGetterCallArgs args)
    4570             : {
    4571           0 :   float result(self->SizeZ());
    4572           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4573           0 :   args.rval().set(JS_NumberValue(double(result)));
    4574           0 :   return true;
    4575             : }
    4576             : 
    4577             : static const JSJitInfo sizeZ_getterinfo = {
    4578             :   { (JSJitGetterOp)get_sizeZ },
    4579             :   { prototypes::id::VRStageParameters },
    4580             :   { PrototypeTraits<prototypes::id::VRStageParameters>::Depth },
    4581             :   JSJitInfo::Getter,
    4582             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4583             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    4584             :   true,  /* isInfallible. False in setters. */
    4585             :   false,  /* isMovable.  Not relevant for setters. */
    4586             :   false, /* isEliminatable.  Not relevant for setters. */
    4587             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    4588             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    4589             :   false,  /* isTypedMethod.  Only relevant for methods. */
    4590             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    4591             : };
    4592             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    4593             : static_assert(0 < 1, "There is no slot for us");
    4594             : 
    4595             : static bool
    4596           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    4597             : {
    4598           0 :   mozilla::dom::VRStageParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRStageParameters>(obj);
    4599             :   // We don't want to preserve if we don't have a wrapper, and we
    4600             :   // obviously can't preserve if we're not initialized.
    4601           0 :   if (self && self->GetWrapperPreserveColor()) {
    4602           0 :     PreserveWrapper(self);
    4603             :   }
    4604           0 :   return true;
    4605             : }
    4606             : 
    4607             : static void
    4608           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    4609             : {
    4610           0 :   mozilla::dom::VRStageParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRStageParameters>(obj);
    4611           0 :   if (self) {
    4612           0 :     ClearWrapper(self, self, obj);
    4613           0 :     AddForDeferredFinalization<mozilla::dom::VRStageParameters>(self);
    4614             :   }
    4615           0 : }
    4616             : 
    4617             : static void
    4618           0 : _objectMoved(JSObject* obj, const JSObject* old)
    4619             : {
    4620           0 :   mozilla::dom::VRStageParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRStageParameters>(obj);
    4621           0 :   if (self) {
    4622           0 :     UpdateWrapper(self, self, obj, old);
    4623             :   }
    4624           0 : }
    4625             : 
    4626             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    4627             : #if defined(__clang__)
    4628             : #pragma clang diagnostic push
    4629             : #pragma clang diagnostic ignored "-Wmissing-braces"
    4630             : #endif
    4631             : static const JSPropertySpec sAttributes_specs[] = {
    4632             :   { "sittingToStandingTransform", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sittingToStandingTransform_getterinfo, nullptr, nullptr },
    4633             :   { "sizeX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sizeX_getterinfo, nullptr, nullptr },
    4634             :   { "sizeZ", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sizeZ_getterinfo, nullptr, nullptr },
    4635             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    4636             : };
    4637             : #if defined(__clang__)
    4638             : #pragma clang diagnostic pop
    4639             : #endif
    4640             : 
    4641             : 
    4642             : // Can't be const because the pref-enabled boolean needs to be writable
    4643             : static Prefable<const JSPropertySpec> sAttributes[] = {
    4644             :   { nullptr, &sAttributes_specs[0] },
    4645             :   { nullptr, nullptr }
    4646             : };
    4647             : 
    4648             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    4649             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    4650             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    4651             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    4652             : 
    4653             : 
    4654             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
    4655             : static PropertyInfo sNativeProperties_propertyInfos[3];
    4656             : 
    4657             : static const NativePropertiesN<1> sNativeProperties = {
    4658             :   false, 0,
    4659             :   false, 0,
    4660             :   false, 0,
    4661             :   true,  0 /* sAttributes */,
    4662             :   false, 0,
    4663             :   false, 0,
    4664             :   false, 0,
    4665             :   -1,
    4666             :   3,
    4667             :   sNativeProperties_sortedPropertyIndices,
    4668             :   {
    4669             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    4670             :   }
    4671             : };
    4672             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    4673             :     "We have a property info count that is oversized");
    4674             : 
    4675             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    4676             :   {
    4677             :     "Function",
    4678             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    4679             :     &sBoringInterfaceObjectClassClassOps,
    4680             :     JS_NULL_CLASS_SPEC,
    4681             :     JS_NULL_CLASS_EXT,
    4682             :     &sInterfaceObjectClassObjectOps
    4683             :   },
    4684             :   eInterface,
    4685             :   true,
    4686             :   prototypes::id::VRStageParameters,
    4687             :   PrototypeTraits<prototypes::id::VRStageParameters>::Depth,
    4688             :   sNativePropertyHooks,
    4689             :   "function VRStageParameters() {\n    [native code]\n}",
    4690             :   JS::GetRealmFunctionPrototype
    4691             : };
    4692             : 
    4693             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    4694             :   {
    4695             :     "VRStageParametersPrototype",
    4696             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    4697             :     JS_NULL_CLASS_OPS,
    4698             :     JS_NULL_CLASS_SPEC,
    4699             :     JS_NULL_CLASS_EXT,
    4700             :     JS_NULL_OBJECT_OPS
    4701             :   },
    4702             :   eInterfacePrototype,
    4703             :   false,
    4704             :   prototypes::id::VRStageParameters,
    4705             :   PrototypeTraits<prototypes::id::VRStageParameters>::Depth,
    4706             :   sNativePropertyHooks,
    4707             :   "[object VRStageParametersPrototype]",
    4708             :   JS::GetRealmObjectPrototype
    4709             : };
    4710             : 
    4711             : bool
    4712           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    4713             : {
    4714             :   static bool sPrefValue;
    4715             :   static bool sPrefCacheSetUp = false;
    4716           0 :   if (!sPrefCacheSetUp) {
    4717           0 :     sPrefCacheSetUp = true;
    4718           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
    4719             :   }
    4720             : 
    4721           0 :   return sPrefValue;
    4722             : }
    4723             : 
    4724             : JSObject*
    4725           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    4726             : {
    4727           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    4728             : }
    4729             : 
    4730             : static const js::ClassOps sClassOps = {
    4731             :   _addProperty, /* addProperty */
    4732             :   nullptr,               /* delProperty */
    4733             :   nullptr,               /* getProperty */
    4734             :   nullptr,               /* setProperty */
    4735             :   nullptr,               /* enumerate */
    4736             :   nullptr, /* newEnumerate */
    4737             :   nullptr, /* resolve */
    4738             :   nullptr, /* mayResolve */
    4739             :   _finalize, /* finalize */
    4740             :   nullptr, /* call */
    4741             :   nullptr,               /* hasInstance */
    4742             :   nullptr,               /* construct */
    4743             :   nullptr, /* trace */
    4744             : };
    4745             : 
    4746             : static const js::ClassExtension sClassExtension = {
    4747             :   nullptr, /* weakmapKeyDelegateOp */
    4748             :   _objectMoved /* objectMovedOp */
    4749             : };
    4750             : 
    4751             : static const DOMJSClass sClass = {
    4752             :   { "VRStageParameters",
    4753             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    4754             :     &sClassOps,
    4755             :     JS_NULL_CLASS_SPEC,
    4756             :     &sClassExtension,
    4757             :     JS_NULL_OBJECT_OPS
    4758             :   },
    4759             :   { prototypes::id::VRStageParameters, 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 },
    4760             :   IsBaseOf<nsISupports, mozilla::dom::VRStageParameters >::value,
    4761             :   sNativePropertyHooks,
    4762             :   FindAssociatedGlobalForNative<mozilla::dom::VRStageParameters>::Get,
    4763             :   GetProtoObjectHandle,
    4764             :   GetCCParticipant<mozilla::dom::VRStageParameters>::Get()
    4765             : };
    4766             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    4767             :               "Must have the right minimal number of reserved slots.");
    4768             : static_assert(1 >= 1,
    4769             :               "Must have enough reserved slots.");
    4770             : 
    4771             : const JSClass*
    4772           0 : GetJSClass()
    4773             : {
    4774           0 :   return sClass.ToJSClass();
    4775             : }
    4776             : 
    4777             : bool
    4778           0 : Wrap(JSContext* aCx, mozilla::dom::VRStageParameters* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    4779             : {
    4780             :   MOZ_ASSERT(static_cast<mozilla::dom::VRStageParameters*>(aObject) ==
    4781             :              reinterpret_cast<mozilla::dom::VRStageParameters*>(aObject),
    4782             :              "Multiple inheritance for mozilla::dom::VRStageParameters is broken.");
    4783           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    4784           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    4785           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    4786             :              "You should probably not be using Wrap() directly; use "
    4787             :              "GetOrCreateDOMReflector instead");
    4788             : 
    4789           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    4790             :              "nsISupports must be on our primary inheritance chain");
    4791             : 
    4792           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    4793           0 :   if (!global) {
    4794           0 :     return false;
    4795             :   }
    4796           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    4797           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    4798             : 
    4799             :   // That might have ended up wrapping us already, due to the wonders
    4800             :   // of XBL.  Check for that, and bail out as needed.
    4801           0 :   aReflector.set(aCache->GetWrapper());
    4802           0 :   if (aReflector) {
    4803             : #ifdef DEBUG
    4804           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    4805             : #endif // DEBUG
    4806           0 :     return true;
    4807             :   }
    4808             : 
    4809           0 :   JSAutoCompartment ac(aCx, global);
    4810           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    4811           0 :   if (!canonicalProto) {
    4812           0 :     return false;
    4813             :   }
    4814           0 :   JS::Rooted<JSObject*> proto(aCx);
    4815           0 :   if (aGivenProto) {
    4816           0 :     proto = aGivenProto;
    4817             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    4818             :     // coming in, we changed compartments to that of "parent" so may need
    4819             :     // to wrap the proto here.
    4820           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    4821           0 :       if (!JS_WrapObject(aCx, &proto)) {
    4822           0 :         return false;
    4823             :       }
    4824             :     }
    4825             :   } else {
    4826           0 :     proto = canonicalProto;
    4827             :   }
    4828             : 
    4829           0 :   BindingJSObjectCreator<mozilla::dom::VRStageParameters> creator(aCx);
    4830           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    4831           0 :   if (!aReflector) {
    4832           0 :     return false;
    4833             :   }
    4834             : 
    4835           0 :   aCache->SetWrapper(aReflector);
    4836           0 :   creator.InitializationSucceeded();
    4837             : 
    4838           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    4839             :              aCache->GetWrapperPreserveColor() == aReflector);
    4840             :   // If proto != canonicalProto, we have to preserve our wrapper;
    4841             :   // otherwise we won't be able to properly recreate it later, since
    4842             :   // we won't know what proto to use.  Note that we don't check
    4843             :   // aGivenProto here, since it's entirely possible (and even
    4844             :   // somewhat common) to have a non-null aGivenProto which is the
    4845             :   // same as canonicalProto.
    4846           0 :   if (proto != canonicalProto) {
    4847           0 :     PreserveWrapper(aObject);
    4848             :   }
    4849             : 
    4850           0 :   return true;
    4851             : }
    4852             : 
    4853             : const NativePropertyHooks sNativePropertyHooks[] = { {
    4854             :   nullptr,
    4855             :   nullptr,
    4856             :   nullptr,
    4857             :   { sNativeProperties.Upcast(), nullptr },
    4858             :   prototypes::id::VRStageParameters,
    4859             :   constructors::id::VRStageParameters,
    4860             :   nullptr,
    4861             :   &DefaultXrayExpandoObjectClass
    4862             : } };
    4863             : 
    4864             : void
    4865           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    4866             : {
    4867           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    4868           0 :   if (!parentProto) {
    4869           0 :     return;
    4870             :   }
    4871             : 
    4872           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    4873           0 :   if (!constructorProto) {
    4874           0 :     return;
    4875             :   }
    4876             : 
    4877             :   static bool sIdsInited = false;
    4878           0 :   if (!sIdsInited && NS_IsMainThread()) {
    4879           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    4880           0 :       return;
    4881             :     }
    4882           0 :     sIdsInited = true;
    4883             :   }
    4884             : 
    4885           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRStageParameters);
    4886           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRStageParameters);
    4887           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    4888             :                               &sPrototypeClass.mBase, protoCache,
    4889             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    4890             :                               interfaceCache,
    4891             :                               sNativeProperties.Upcast(),
    4892             :                               nullptr,
    4893             :                               "VRStageParameters", aDefineOnGlobal,
    4894             :                               nullptr,
    4895           0 :                               false);
    4896             : }
    4897             : 
    4898             : JS::Handle<JSObject*>
    4899           0 : GetProtoObjectHandle(JSContext* aCx)
    4900             : {
    4901             :   /* Get the interface prototype object for this class.  This will create the
    4902             :      object as needed. */
    4903           0 :   bool aDefineOnGlobal = true;
    4904             : 
    4905             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    4906           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    4907           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    4908           0 :     return nullptr;
    4909             :   }
    4910             : 
    4911             :   /* Check to see whether the interface objects are already installed */
    4912           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    4913           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRStageParameters)) {
    4914           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    4915           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    4916             :   }
    4917             : 
    4918             :   /*
    4919             :    * The object might _still_ be null, but that's OK.
    4920             :    *
    4921             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    4922             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    4923             :    * changed after they have been set.
    4924             :    *
    4925             :    * Calling address() avoids the read read barrier that does gray
    4926             :    * unmarking, but it's not possible for the object to be gray here.
    4927             :    */
    4928             : 
    4929           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRStageParameters);
    4930           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    4931           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    4932             : }
    4933             : 
    4934             : JS::Handle<JSObject*>
    4935           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    4936             : {
    4937             :   /* Get the interface object for this class.  This will create the object as
    4938             :      needed. */
    4939             : 
    4940             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    4941           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    4942           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    4943           0 :     return nullptr;
    4944             :   }
    4945             : 
    4946             :   /* Check to see whether the interface objects are already installed */
    4947           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    4948           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRStageParameters)) {
    4949           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    4950           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    4951             :   }
    4952             : 
    4953             :   /*
    4954             :    * The object might _still_ be null, but that's OK.
    4955             :    *
    4956             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    4957             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    4958             :    * changed after they have been set.
    4959             :    *
    4960             :    * Calling address() avoids the read read barrier that does gray
    4961             :    * unmarking, but it's not possible for the object to be gray here.
    4962             :    */
    4963             : 
    4964           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRStageParameters);
    4965           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    4966           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    4967             : }
    4968             : 
    4969             : JSObject*
    4970           0 : GetConstructorObject(JSContext* aCx)
    4971             : {
    4972           0 :   return GetConstructorObjectHandle(aCx);
    4973             : }
    4974             : 
    4975             : } // namespace VRStageParametersBinding
    4976             : 
    4977             : 
    4978             : 
    4979             : namespace VRSubmitFrameResultBinding {
    4980             : 
    4981             : static bool
    4982           0 : get_frameNum(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRSubmitFrameResult* self, JSJitGetterCallArgs args)
    4983             : {
    4984           0 :   uint32_t result(self->FrameNum());
    4985           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    4986           0 :   args.rval().setNumber(result);
    4987           0 :   return true;
    4988             : }
    4989             : 
    4990             : static const JSJitInfo frameNum_getterinfo = {
    4991             :   { (JSJitGetterOp)get_frameNum },
    4992             :   { prototypes::id::VRSubmitFrameResult },
    4993             :   { PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth },
    4994             :   JSJitInfo::Getter,
    4995             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    4996             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    4997             :   true,  /* isInfallible. False in setters. */
    4998             :   false,  /* isMovable.  Not relevant for setters. */
    4999             :   false, /* isEliminatable.  Not relevant for setters. */
    5000             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5001             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5002             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5003             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5004             : };
    5005             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5006             : static_assert(0 < 1, "There is no slot for us");
    5007             : 
    5008             : static bool
    5009           0 : get_base64Image(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRSubmitFrameResult* self, JSJitGetterCallArgs args)
    5010             : {
    5011           0 :   DOMString result;
    5012           0 :   self->GetBase64Image(result);
    5013           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5014           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
    5015           0 :     return false;
    5016             :   }
    5017           0 :   return true;
    5018             : }
    5019             : 
    5020             : static const JSJitInfo base64Image_getterinfo = {
    5021             :   { (JSJitGetterOp)get_base64Image },
    5022             :   { prototypes::id::VRSubmitFrameResult },
    5023             :   { PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth },
    5024             :   JSJitInfo::Getter,
    5025             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    5026             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    5027             :   false,  /* isInfallible. False in setters. */
    5028             :   false,  /* isMovable.  Not relevant for setters. */
    5029             :   false, /* isEliminatable.  Not relevant for setters. */
    5030             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    5031             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    5032             :   false,  /* isTypedMethod.  Only relevant for methods. */
    5033             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    5034             : };
    5035             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    5036             : static_assert(0 < 1, "There is no slot for us");
    5037             : 
    5038             : static bool
    5039           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    5040             : {
    5041           0 :   mozilla::dom::VRSubmitFrameResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRSubmitFrameResult>(obj);
    5042             :   // We don't want to preserve if we don't have a wrapper, and we
    5043             :   // obviously can't preserve if we're not initialized.
    5044           0 :   if (self && self->GetWrapperPreserveColor()) {
    5045           0 :     PreserveWrapper(self);
    5046             :   }
    5047           0 :   return true;
    5048             : }
    5049             : 
    5050             : static void
    5051           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    5052             : {
    5053           0 :   mozilla::dom::VRSubmitFrameResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRSubmitFrameResult>(obj);
    5054           0 :   if (self) {
    5055           0 :     ClearWrapper(self, self, obj);
    5056           0 :     AddForDeferredFinalization<mozilla::dom::VRSubmitFrameResult>(self);
    5057             :   }
    5058           0 : }
    5059             : 
    5060             : static void
    5061           0 : _objectMoved(JSObject* obj, const JSObject* old)
    5062             : {
    5063           0 :   mozilla::dom::VRSubmitFrameResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRSubmitFrameResult>(obj);
    5064           0 :   if (self) {
    5065           0 :     UpdateWrapper(self, self, obj, old);
    5066             :   }
    5067           0 : }
    5068             : 
    5069             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    5070             : #if defined(__clang__)
    5071             : #pragma clang diagnostic push
    5072             : #pragma clang diagnostic ignored "-Wmissing-braces"
    5073             : #endif
    5074             : static const JSPropertySpec sAttributes_specs[] = {
    5075             :   { "frameNum", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &frameNum_getterinfo, nullptr, nullptr },
    5076             :   { "base64Image", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &base64Image_getterinfo, nullptr, nullptr },
    5077             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    5078             : };
    5079             : #if defined(__clang__)
    5080             : #pragma clang diagnostic pop
    5081             : #endif
    5082             : 
    5083             : 
    5084             : // Can't be const because the pref-enabled boolean needs to be writable
    5085             : static Prefable<const JSPropertySpec> sAttributes[] = {
    5086             :   { nullptr, &sAttributes_specs[0] },
    5087             :   { nullptr, nullptr }
    5088             : };
    5089             : 
    5090             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    5091             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    5092             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    5093             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    5094             : 
    5095             : 
    5096             : static uint16_t sNativeProperties_sortedPropertyIndices[2];
    5097             : static PropertyInfo sNativeProperties_propertyInfos[2];
    5098             : 
    5099             : static const NativePropertiesN<1> sNativeProperties = {
    5100             :   false, 0,
    5101             :   false, 0,
    5102             :   false, 0,
    5103             :   true,  0 /* sAttributes */,
    5104             :   false, 0,
    5105             :   false, 0,
    5106             :   false, 0,
    5107             :   -1,
    5108             :   2,
    5109             :   sNativeProperties_sortedPropertyIndices,
    5110             :   {
    5111             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    5112             :   }
    5113             : };
    5114             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    5115             :     "We have a property info count that is oversized");
    5116             : 
    5117             : static bool
    5118           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    5119             : {
    5120           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    5121           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    5122           0 :   if (!args.isConstructing()) {
    5123             :     // XXXbz wish I could get the name from the callee instead of
    5124             :     // Adding more relocations
    5125           0 :     return ThrowConstructorWithoutNew(cx, "VRSubmitFrameResult");
    5126             :   }
    5127             : 
    5128           0 :   GlobalObject global(cx, obj);
    5129           0 :   if (global.Failed()) {
    5130           0 :     return false;
    5131             :   }
    5132             : 
    5133           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    5134           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    5135           0 :     return false;
    5136             :   }
    5137             : 
    5138           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    5139           0 :   Maybe<JSAutoCompartment> ac;
    5140           0 :   if (objIsXray) {
    5141           0 :     obj = js::CheckedUnwrap(obj);
    5142           0 :     if (!obj) {
    5143           0 :       return false;
    5144             :     }
    5145           0 :     ac.emplace(cx, obj);
    5146           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    5147           0 :       return false;
    5148             :     }
    5149             :   }
    5150           0 :   binding_detail::FastErrorResult rv;
    5151           0 :   auto result(StrongOrRawPtr<mozilla::dom::VRSubmitFrameResult>(mozilla::dom::VRSubmitFrameResult::Constructor(global, rv)));
    5152           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    5153           0 :     return false;
    5154             :   }
    5155           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    5156             :   static_assert(!IsPointer<decltype(result)>::value,
    5157             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    5158           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    5159           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    5160           0 :     return false;
    5161             :   }
    5162           0 :   return true;
    5163             : }
    5164             : 
    5165             : static const js::ClassOps sInterfaceObjectClassOps = {
    5166             :     nullptr,               /* addProperty */
    5167             :     nullptr,               /* delProperty */
    5168             :     nullptr,               /* getProperty */
    5169             :     nullptr,               /* setProperty */
    5170             :     nullptr,               /* enumerate */
    5171             :     nullptr,               /* newEnumerate */
    5172             :     nullptr,               /* resolve */
    5173             :     nullptr,               /* mayResolve */
    5174             :     nullptr,               /* finalize */
    5175             :     _constructor, /* call */
    5176             :     nullptr,               /* hasInstance */
    5177             :     _constructor, /* construct */
    5178             :     nullptr,               /* trace */
    5179             : };
    5180             : 
    5181             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    5182             :   {
    5183             :     "Function",
    5184             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    5185             :     &sInterfaceObjectClassOps,
    5186             :     JS_NULL_CLASS_SPEC,
    5187             :     JS_NULL_CLASS_EXT,
    5188             :     &sInterfaceObjectClassObjectOps
    5189             :   },
    5190             :   eInterface,
    5191             :   true,
    5192             :   prototypes::id::VRSubmitFrameResult,
    5193             :   PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth,
    5194             :   sNativePropertyHooks,
    5195             :   "function VRSubmitFrameResult() {\n    [native code]\n}",
    5196             :   JS::GetRealmFunctionPrototype
    5197             : };
    5198             : 
    5199             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    5200             :   {
    5201             :     "VRSubmitFrameResultPrototype",
    5202             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    5203             :     JS_NULL_CLASS_OPS,
    5204             :     JS_NULL_CLASS_SPEC,
    5205             :     JS_NULL_CLASS_EXT,
    5206             :     JS_NULL_OBJECT_OPS
    5207             :   },
    5208             :   eInterfacePrototype,
    5209             :   false,
    5210             :   prototypes::id::VRSubmitFrameResult,
    5211             :   PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth,
    5212             :   sNativePropertyHooks,
    5213             :   "[object VRSubmitFrameResultPrototype]",
    5214             :   JS::GetRealmObjectPrototype
    5215             : };
    5216             : 
    5217             : bool
    5218           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    5219             : {
    5220             :   static bool sPrefValue;
    5221             :   static bool sPrefCacheSetUp = false;
    5222           0 :   if (!sPrefCacheSetUp) {
    5223           0 :     sPrefCacheSetUp = true;
    5224           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.test.enabled");
    5225             :   }
    5226             : 
    5227           0 :   return sPrefValue;
    5228             : }
    5229             : 
    5230             : JSObject*
    5231           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    5232             : {
    5233           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    5234             : }
    5235             : 
    5236             : static const js::ClassOps sClassOps = {
    5237             :   _addProperty, /* addProperty */
    5238             :   nullptr,               /* delProperty */
    5239             :   nullptr,               /* getProperty */
    5240             :   nullptr,               /* setProperty */
    5241             :   nullptr,               /* enumerate */
    5242             :   nullptr, /* newEnumerate */
    5243             :   nullptr, /* resolve */
    5244             :   nullptr, /* mayResolve */
    5245             :   _finalize, /* finalize */
    5246             :   nullptr, /* call */
    5247             :   nullptr,               /* hasInstance */
    5248             :   nullptr,               /* construct */
    5249             :   nullptr, /* trace */
    5250             : };
    5251             : 
    5252             : static const js::ClassExtension sClassExtension = {
    5253             :   nullptr, /* weakmapKeyDelegateOp */
    5254             :   _objectMoved /* objectMovedOp */
    5255             : };
    5256             : 
    5257             : static const DOMJSClass sClass = {
    5258             :   { "VRSubmitFrameResult",
    5259             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    5260             :     &sClassOps,
    5261             :     JS_NULL_CLASS_SPEC,
    5262             :     &sClassExtension,
    5263             :     JS_NULL_OBJECT_OPS
    5264             :   },
    5265             :   { prototypes::id::VRSubmitFrameResult, 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 },
    5266             :   IsBaseOf<nsISupports, mozilla::dom::VRSubmitFrameResult >::value,
    5267             :   sNativePropertyHooks,
    5268             :   FindAssociatedGlobalForNative<mozilla::dom::VRSubmitFrameResult>::Get,
    5269             :   GetProtoObjectHandle,
    5270             :   GetCCParticipant<mozilla::dom::VRSubmitFrameResult>::Get()
    5271             : };
    5272             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    5273             :               "Must have the right minimal number of reserved slots.");
    5274             : static_assert(1 >= 1,
    5275             :               "Must have enough reserved slots.");
    5276             : 
    5277             : const JSClass*
    5278           0 : GetJSClass()
    5279             : {
    5280           0 :   return sClass.ToJSClass();
    5281             : }
    5282             : 
    5283             : bool
    5284           0 : Wrap(JSContext* aCx, mozilla::dom::VRSubmitFrameResult* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    5285             : {
    5286             :   MOZ_ASSERT(static_cast<mozilla::dom::VRSubmitFrameResult*>(aObject) ==
    5287             :              reinterpret_cast<mozilla::dom::VRSubmitFrameResult*>(aObject),
    5288             :              "Multiple inheritance for mozilla::dom::VRSubmitFrameResult is broken.");
    5289           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    5290           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    5291           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    5292             :              "You should probably not be using Wrap() directly; use "
    5293             :              "GetOrCreateDOMReflector instead");
    5294             : 
    5295           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    5296             :              "nsISupports must be on our primary inheritance chain");
    5297             : 
    5298           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    5299           0 :   if (!global) {
    5300           0 :     return false;
    5301             :   }
    5302           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    5303           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    5304             : 
    5305             :   // That might have ended up wrapping us already, due to the wonders
    5306             :   // of XBL.  Check for that, and bail out as needed.
    5307           0 :   aReflector.set(aCache->GetWrapper());
    5308           0 :   if (aReflector) {
    5309             : #ifdef DEBUG
    5310           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    5311             : #endif // DEBUG
    5312           0 :     return true;
    5313             :   }
    5314             : 
    5315           0 :   JSAutoCompartment ac(aCx, global);
    5316           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    5317           0 :   if (!canonicalProto) {
    5318           0 :     return false;
    5319             :   }
    5320           0 :   JS::Rooted<JSObject*> proto(aCx);
    5321           0 :   if (aGivenProto) {
    5322           0 :     proto = aGivenProto;
    5323             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    5324             :     // coming in, we changed compartments to that of "parent" so may need
    5325             :     // to wrap the proto here.
    5326           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    5327           0 :       if (!JS_WrapObject(aCx, &proto)) {
    5328           0 :         return false;
    5329             :       }
    5330             :     }
    5331             :   } else {
    5332           0 :     proto = canonicalProto;
    5333             :   }
    5334             : 
    5335           0 :   BindingJSObjectCreator<mozilla::dom::VRSubmitFrameResult> creator(aCx);
    5336           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    5337           0 :   if (!aReflector) {
    5338           0 :     return false;
    5339             :   }
    5340             : 
    5341           0 :   aCache->SetWrapper(aReflector);
    5342           0 :   creator.InitializationSucceeded();
    5343             : 
    5344           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    5345             :              aCache->GetWrapperPreserveColor() == aReflector);
    5346             :   // If proto != canonicalProto, we have to preserve our wrapper;
    5347             :   // otherwise we won't be able to properly recreate it later, since
    5348             :   // we won't know what proto to use.  Note that we don't check
    5349             :   // aGivenProto here, since it's entirely possible (and even
    5350             :   // somewhat common) to have a non-null aGivenProto which is the
    5351             :   // same as canonicalProto.
    5352           0 :   if (proto != canonicalProto) {
    5353           0 :     PreserveWrapper(aObject);
    5354             :   }
    5355             : 
    5356           0 :   return true;
    5357             : }
    5358             : 
    5359             : const NativePropertyHooks sNativePropertyHooks[] = { {
    5360             :   nullptr,
    5361             :   nullptr,
    5362             :   nullptr,
    5363             :   { sNativeProperties.Upcast(), nullptr },
    5364             :   prototypes::id::VRSubmitFrameResult,
    5365             :   constructors::id::VRSubmitFrameResult,
    5366             :   nullptr,
    5367             :   &DefaultXrayExpandoObjectClass
    5368             : } };
    5369             : 
    5370             : void
    5371           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    5372             : {
    5373           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    5374           0 :   if (!parentProto) {
    5375           0 :     return;
    5376             :   }
    5377             : 
    5378           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    5379           0 :   if (!constructorProto) {
    5380           0 :     return;
    5381             :   }
    5382             : 
    5383             :   static bool sIdsInited = false;
    5384           0 :   if (!sIdsInited && NS_IsMainThread()) {
    5385           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    5386           0 :       return;
    5387             :     }
    5388           0 :     sIdsInited = true;
    5389             :   }
    5390             : 
    5391           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRSubmitFrameResult);
    5392           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRSubmitFrameResult);
    5393           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    5394             :                               &sPrototypeClass.mBase, protoCache,
    5395             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    5396             :                               interfaceCache,
    5397             :                               sNativeProperties.Upcast(),
    5398             :                               nullptr,
    5399             :                               "VRSubmitFrameResult", aDefineOnGlobal,
    5400             :                               nullptr,
    5401           0 :                               false);
    5402             : }
    5403             : 
    5404             : JS::Handle<JSObject*>
    5405           0 : GetProtoObjectHandle(JSContext* aCx)
    5406             : {
    5407             :   /* Get the interface prototype object for this class.  This will create the
    5408             :      object as needed. */
    5409           0 :   bool aDefineOnGlobal = true;
    5410             : 
    5411             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    5412           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    5413           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    5414           0 :     return nullptr;
    5415             :   }
    5416             : 
    5417             :   /* Check to see whether the interface objects are already installed */
    5418           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    5419           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::VRSubmitFrameResult)) {
    5420           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    5421           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    5422             :   }
    5423             : 
    5424             :   /*
    5425             :    * The object might _still_ be null, but that's OK.
    5426             :    *
    5427             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    5428             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    5429             :    * changed after they have been set.
    5430             :    *
    5431             :    * Calling address() avoids the read read barrier that does gray
    5432             :    * unmarking, but it's not possible for the object to be gray here.
    5433             :    */
    5434             : 
    5435           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::VRSubmitFrameResult);
    5436           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    5437           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    5438             : }
    5439             : 
    5440             : JS::Handle<JSObject*>
    5441           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    5442             : {
    5443             :   /* Get the interface object for this class.  This will create the object as
    5444             :      needed. */
    5445             : 
    5446             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    5447           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    5448           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    5449           0 :     return nullptr;
    5450             :   }
    5451             : 
    5452             :   /* Check to see whether the interface objects are already installed */
    5453           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    5454           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::VRSubmitFrameResult)) {
    5455           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    5456           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    5457             :   }
    5458             : 
    5459             :   /*
    5460             :    * The object might _still_ be null, but that's OK.
    5461             :    *
    5462             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    5463             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    5464             :    * changed after they have been set.
    5465             :    *
    5466             :    * Calling address() avoids the read read barrier that does gray
    5467             :    * unmarking, but it's not possible for the object to be gray here.
    5468             :    */
    5469             : 
    5470           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::VRSubmitFrameResult);
    5471           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    5472           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    5473             : }
    5474             : 
    5475             : JSObject*
    5476           0 : GetConstructorObject(JSContext* aCx)
    5477             : {
    5478           0 :   return GetConstructorObjectHandle(aCx);
    5479             : }
    5480             : 
    5481             : } // namespace VRSubmitFrameResultBinding
    5482             : 
    5483             : 
    5484             : 
    5485             : } // namespace dom
    5486             : } // namespace mozilla

Generated by: LCOV version 1.13