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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM KeyboardEvent.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "KeyboardEventBinding.h"
       5             : #include "UIEventBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "XrayWrapper.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/KeyboardEvent.h"
      12             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      13             : #include "mozilla/dom/Nullable.h"
      14             : #include "mozilla/dom/PrimitiveConversions.h"
      15             : #include "mozilla/dom/ScriptSettings.h"
      16             : #include "mozilla/dom/SimpleGlobalObject.h"
      17             : #include "mozilla/dom/XrayExpandoClass.h"
      18             : #include "nsContentUtils.h"
      19             : #include "nsGlobalWindow.h"
      20             : 
      21             : namespace mozilla {
      22             : namespace dom {
      23             : 
      24             : 
      25           0 : KeyboardEventInit::KeyboardEventInit()
      26           0 :   : EventModifierInit(FastDictionaryInitializer())
      27             : {
      28             :   // Safe to pass a null context if we pass a null value
      29           0 :   Init(nullptr, JS::NullHandleValue);
      30           0 : }
      31             : 
      32             : 
      33             : 
      34             : bool
      35           0 : KeyboardEventInit::InitIds(JSContext* cx, KeyboardEventInitAtoms* atomsCache)
      36             : {
      37           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      38             : 
      39             :   // Initialize these in reverse order so that any failure leaves the first one
      40             :   // uninitialized.
      41           0 :   if (!atomsCache->which_id.init(cx, "which") ||
      42           0 :       !atomsCache->repeat_id.init(cx, "repeat") ||
      43           0 :       !atomsCache->location_id.init(cx, "location") ||
      44           0 :       !atomsCache->keyCode_id.init(cx, "keyCode") ||
      45           0 :       !atomsCache->key_id.init(cx, "key") ||
      46           0 :       !atomsCache->isComposing_id.init(cx, "isComposing") ||
      47           0 :       !atomsCache->code_id.init(cx, "code") ||
      48           0 :       !atomsCache->charCode_id.init(cx, "charCode")) {
      49           0 :     return false;
      50             :   }
      51           0 :   return true;
      52             : }
      53             : 
      54             : bool
      55           0 : KeyboardEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      56             : {
      57             :   // Passing a null JSContext is OK only if we're initing from null,
      58             :   // Since in that case we will not have to do any property gets
      59             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      60             :   // checkers by static analysis tools
      61           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      62           0 :   KeyboardEventInitAtoms* atomsCache = nullptr;
      63           0 :   if (cx) {
      64           0 :     atomsCache = GetAtomCache<KeyboardEventInitAtoms>(cx);
      65           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      66           0 :       return false;
      67             :     }
      68             :   }
      69             : 
      70             :   // Per spec, we init the parent's members first
      71           0 :   if (!EventModifierInit::Init(cx, val)) {
      72           0 :     return false;
      73             :   }
      74             : 
      75           0 :   bool isNull = val.isNullOrUndefined();
      76             :   // We only need these if !isNull, in which case we have |cx|.
      77           0 :   Maybe<JS::Rooted<JSObject *> > object;
      78           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      79           0 :   if (!isNull) {
      80           0 :     MOZ_ASSERT(cx);
      81           0 :     object.emplace(cx, &val.toObject());
      82           0 :     temp.emplace(cx);
      83             :   }
      84           0 :   if (!isNull) {
      85           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->charCode_id, temp.ptr())) {
      86           0 :       return false;
      87             :     }
      88             :   }
      89           0 :   if (!isNull && !temp->isUndefined()) {
      90           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mCharCode)) {
      91           0 :       return false;
      92             :     }
      93             :   } else {
      94           0 :     mCharCode = 0U;
      95             :   }
      96           0 :   mIsAnyMemberPresent = true;
      97             : 
      98           0 :   if (!isNull) {
      99           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->code_id, temp.ptr())) {
     100           0 :       return false;
     101             :     }
     102             :   }
     103           0 :   if (!isNull && !temp->isUndefined()) {
     104           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mCode)) {
     105           0 :       return false;
     106             :     }
     107             :   } else {
     108             :     static const char16_t data[] = { 0 };
     109           0 :     mCode.Rebind(data, ArrayLength(data) - 1);
     110             :   }
     111           0 :   mIsAnyMemberPresent = true;
     112             : 
     113           0 :   if (!isNull) {
     114           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->isComposing_id, temp.ptr())) {
     115           0 :       return false;
     116             :     }
     117             :   }
     118           0 :   if (!isNull && !temp->isUndefined()) {
     119           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIsComposing)) {
     120           0 :       return false;
     121             :     }
     122             :   } else {
     123           0 :     mIsComposing = false;
     124             :   }
     125           0 :   mIsAnyMemberPresent = true;
     126             : 
     127           0 :   if (!isNull) {
     128           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->key_id, temp.ptr())) {
     129           0 :       return false;
     130             :     }
     131             :   }
     132           0 :   if (!isNull && !temp->isUndefined()) {
     133           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mKey)) {
     134           0 :       return false;
     135             :     }
     136             :   } else {
     137             :     static const char16_t data[] = { 0 };
     138           0 :     mKey.Rebind(data, ArrayLength(data) - 1);
     139             :   }
     140           0 :   mIsAnyMemberPresent = true;
     141             : 
     142           0 :   if (!isNull) {
     143           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->keyCode_id, temp.ptr())) {
     144           0 :       return false;
     145             :     }
     146             :   }
     147           0 :   if (!isNull && !temp->isUndefined()) {
     148           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mKeyCode)) {
     149           0 :       return false;
     150             :     }
     151             :   } else {
     152           0 :     mKeyCode = 0U;
     153             :   }
     154           0 :   mIsAnyMemberPresent = true;
     155             : 
     156           0 :   if (!isNull) {
     157           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->location_id, temp.ptr())) {
     158           0 :       return false;
     159             :     }
     160             :   }
     161           0 :   if (!isNull && !temp->isUndefined()) {
     162           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mLocation)) {
     163           0 :       return false;
     164             :     }
     165             :   } else {
     166           0 :     mLocation = 0U;
     167             :   }
     168           0 :   mIsAnyMemberPresent = true;
     169             : 
     170           0 :   if (!isNull) {
     171           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->repeat_id, temp.ptr())) {
     172           0 :       return false;
     173             :     }
     174             :   }
     175           0 :   if (!isNull && !temp->isUndefined()) {
     176           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mRepeat)) {
     177           0 :       return false;
     178             :     }
     179             :   } else {
     180           0 :     mRepeat = false;
     181             :   }
     182           0 :   mIsAnyMemberPresent = true;
     183             : 
     184           0 :   if (!isNull) {
     185           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->which_id, temp.ptr())) {
     186           0 :       return false;
     187             :     }
     188             :   }
     189           0 :   if (!isNull && !temp->isUndefined()) {
     190           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mWhich)) {
     191           0 :       return false;
     192             :     }
     193             :   } else {
     194           0 :     mWhich = 0U;
     195             :   }
     196           0 :   mIsAnyMemberPresent = true;
     197           0 :   return true;
     198             : }
     199             : 
     200             : bool
     201           0 : KeyboardEventInit::Init(const nsAString& aJSON)
     202             : {
     203           0 :   AutoJSAPI jsapi;
     204           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     205           0 :   if (!cleanGlobal) {
     206           0 :     return false;
     207             :   }
     208           0 :   if (!jsapi.Init(cleanGlobal)) {
     209           0 :     return false;
     210             :   }
     211           0 :   JSContext* cx = jsapi.cx();
     212           0 :   JS::Rooted<JS::Value> json(cx);
     213           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     214           0 :   NS_ENSURE_TRUE(ok, false);
     215           0 :   return Init(cx, json);
     216             : }
     217             : 
     218             : bool
     219           0 : KeyboardEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     220             : {
     221           0 :   KeyboardEventInitAtoms* atomsCache = GetAtomCache<KeyboardEventInitAtoms>(cx);
     222           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     223           0 :     return false;
     224             :   }
     225             : 
     226             :   // Per spec, we define the parent's members first
     227           0 :   if (!EventModifierInit::ToObjectInternal(cx, rval)) {
     228           0 :     return false;
     229             :   }
     230           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     231             : 
     232             :   do {
     233             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     234           0 :     JS::Rooted<JS::Value> temp(cx);
     235           0 :     uint32_t const & currentValue = mCharCode;
     236           0 :     temp.setNumber(currentValue);
     237           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->charCode_id, temp, JSPROP_ENUMERATE)) {
     238           0 :       return false;
     239             :     }
     240           0 :     break;
     241             :   } while(0);
     242             : 
     243             :   do {
     244             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     245           0 :     JS::Rooted<JS::Value> temp(cx);
     246           0 :     nsString const & currentValue = mCode;
     247           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     248           0 :       return false;
     249             :     }
     250           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->code_id, temp, JSPROP_ENUMERATE)) {
     251           0 :       return false;
     252             :     }
     253           0 :     break;
     254             :   } while(0);
     255             : 
     256             :   do {
     257             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     258           0 :     JS::Rooted<JS::Value> temp(cx);
     259           0 :     bool const & currentValue = mIsComposing;
     260           0 :     temp.setBoolean(currentValue);
     261           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->isComposing_id, temp, JSPROP_ENUMERATE)) {
     262           0 :       return false;
     263             :     }
     264           0 :     break;
     265             :   } while(0);
     266             : 
     267             :   do {
     268             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     269           0 :     JS::Rooted<JS::Value> temp(cx);
     270           0 :     nsString const & currentValue = mKey;
     271           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     272           0 :       return false;
     273             :     }
     274           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->key_id, temp, JSPROP_ENUMERATE)) {
     275           0 :       return false;
     276             :     }
     277           0 :     break;
     278             :   } while(0);
     279             : 
     280             :   do {
     281             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     282           0 :     JS::Rooted<JS::Value> temp(cx);
     283           0 :     uint32_t const & currentValue = mKeyCode;
     284           0 :     temp.setNumber(currentValue);
     285           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->keyCode_id, temp, JSPROP_ENUMERATE)) {
     286           0 :       return false;
     287             :     }
     288           0 :     break;
     289             :   } while(0);
     290             : 
     291             :   do {
     292             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     293           0 :     JS::Rooted<JS::Value> temp(cx);
     294           0 :     uint32_t const & currentValue = mLocation;
     295           0 :     temp.setNumber(currentValue);
     296           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->location_id, temp, JSPROP_ENUMERATE)) {
     297           0 :       return false;
     298             :     }
     299           0 :     break;
     300             :   } while(0);
     301             : 
     302             :   do {
     303             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     304           0 :     JS::Rooted<JS::Value> temp(cx);
     305           0 :     bool const & currentValue = mRepeat;
     306           0 :     temp.setBoolean(currentValue);
     307           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->repeat_id, temp, JSPROP_ENUMERATE)) {
     308           0 :       return false;
     309             :     }
     310           0 :     break;
     311             :   } while(0);
     312             : 
     313             :   do {
     314             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     315           0 :     JS::Rooted<JS::Value> temp(cx);
     316           0 :     uint32_t const & currentValue = mWhich;
     317           0 :     temp.setNumber(currentValue);
     318           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->which_id, temp, JSPROP_ENUMERATE)) {
     319           0 :       return false;
     320             :     }
     321           0 :     break;
     322             :   } while(0);
     323             : 
     324           0 :   return true;
     325             : }
     326             : 
     327             : bool
     328           0 : KeyboardEventInit::ToJSON(nsAString& aJSON) const
     329             : {
     330           0 :   AutoJSAPI jsapi;
     331           0 :   jsapi.Init();
     332           0 :   JSContext *cx = jsapi.cx();
     333             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     334             :   // because we'll only be creating objects, in ways that have no
     335             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     336             :   // which likewise guarantees no side-effects for the sorts of
     337             :   // things we will pass it.
     338           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     339           0 :   JS::Rooted<JS::Value> val(cx);
     340           0 :   if (!ToObjectInternal(cx, &val)) {
     341           0 :     return false;
     342             :   }
     343           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     344           0 :   return StringifyToJSON(cx, obj, aJSON);
     345             : }
     346             : 
     347             : void
     348           0 : KeyboardEventInit::TraceDictionary(JSTracer* trc)
     349             : {
     350           0 :   EventModifierInit::TraceDictionary(trc);
     351           0 : }
     352             : 
     353             : KeyboardEventInit&
     354           0 : KeyboardEventInit::operator=(const KeyboardEventInit& aOther)
     355             : {
     356           0 :   EventModifierInit::operator=(aOther);
     357           0 :   mCharCode = aOther.mCharCode;
     358           0 :   mCode = aOther.mCode;
     359           0 :   mIsComposing = aOther.mIsComposing;
     360           0 :   mKey = aOther.mKey;
     361           0 :   mKeyCode = aOther.mKeyCode;
     362           0 :   mLocation = aOther.mLocation;
     363           0 :   mRepeat = aOther.mRepeat;
     364           0 :   mWhich = aOther.mWhich;
     365           0 :   return *this;
     366             : }
     367             : 
     368             : namespace binding_detail {
     369             : } // namespace binding_detail
     370             : 
     371             : 
     372             : namespace KeyboardEventBinding {
     373             : 
     374             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<UIEventBinding::NativeType>::value,
     375             :               "Can't inherit from an interface with a different ownership model.");
     376             : 
     377             : static bool
     378           0 : get_charCode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     379             : {
     380           0 :   uint32_t result(self->CharCode());
     381           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     382           0 :   args.rval().setNumber(result);
     383           0 :   return true;
     384             : }
     385             : 
     386             : static const JSJitInfo charCode_getterinfo = {
     387             :   { (JSJitGetterOp)get_charCode },
     388             :   { prototypes::id::KeyboardEvent },
     389             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     390             :   JSJitInfo::Getter,
     391             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     392             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     393             :   true,  /* isInfallible. False in setters. */
     394             :   false,  /* isMovable.  Not relevant for setters. */
     395             :   false, /* isEliminatable.  Not relevant for setters. */
     396             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     397             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     398             :   false,  /* isTypedMethod.  Only relevant for methods. */
     399             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     400             : };
     401             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     402             : static_assert(0 < 2, "There is no slot for us");
     403             : 
     404             : static bool
     405           0 : get_keyCode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     406             : {
     407           0 :   uint32_t result(self->KeyCode());
     408           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     409           0 :   args.rval().setNumber(result);
     410           0 :   return true;
     411             : }
     412             : 
     413             : static const JSJitInfo keyCode_getterinfo = {
     414             :   { (JSJitGetterOp)get_keyCode },
     415             :   { prototypes::id::KeyboardEvent },
     416             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     417             :   JSJitInfo::Getter,
     418             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     419             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     420             :   true,  /* isInfallible. False in setters. */
     421             :   false,  /* isMovable.  Not relevant for setters. */
     422             :   false, /* isEliminatable.  Not relevant for setters. */
     423             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     424             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     425             :   false,  /* isTypedMethod.  Only relevant for methods. */
     426             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     427             : };
     428             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     429             : static_assert(0 < 2, "There is no slot for us");
     430             : 
     431             : static bool
     432           0 : get_altKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     433             : {
     434           0 :   bool result(self->AltKey());
     435           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     436           0 :   args.rval().setBoolean(result);
     437           0 :   return true;
     438             : }
     439             : 
     440             : static const JSJitInfo altKey_getterinfo = {
     441             :   { (JSJitGetterOp)get_altKey },
     442             :   { prototypes::id::KeyboardEvent },
     443             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     444             :   JSJitInfo::Getter,
     445             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     446             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     447             :   true,  /* isInfallible. False in setters. */
     448             :   false,  /* isMovable.  Not relevant for setters. */
     449             :   false, /* isEliminatable.  Not relevant for setters. */
     450             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     451             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     452             :   false,  /* isTypedMethod.  Only relevant for methods. */
     453             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     454             : };
     455             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     456             : static_assert(0 < 2, "There is no slot for us");
     457             : 
     458             : static bool
     459           0 : get_ctrlKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     460             : {
     461           0 :   bool result(self->CtrlKey());
     462           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     463           0 :   args.rval().setBoolean(result);
     464           0 :   return true;
     465             : }
     466             : 
     467             : static const JSJitInfo ctrlKey_getterinfo = {
     468             :   { (JSJitGetterOp)get_ctrlKey },
     469             :   { prototypes::id::KeyboardEvent },
     470             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     471             :   JSJitInfo::Getter,
     472             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     473             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     474             :   true,  /* isInfallible. False in setters. */
     475             :   false,  /* isMovable.  Not relevant for setters. */
     476             :   false, /* isEliminatable.  Not relevant for setters. */
     477             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     478             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     479             :   false,  /* isTypedMethod.  Only relevant for methods. */
     480             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     481             : };
     482             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     483             : static_assert(0 < 2, "There is no slot for us");
     484             : 
     485             : static bool
     486           0 : get_shiftKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     487             : {
     488           0 :   bool result(self->ShiftKey());
     489           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     490           0 :   args.rval().setBoolean(result);
     491           0 :   return true;
     492             : }
     493             : 
     494             : static const JSJitInfo shiftKey_getterinfo = {
     495             :   { (JSJitGetterOp)get_shiftKey },
     496             :   { prototypes::id::KeyboardEvent },
     497             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     498             :   JSJitInfo::Getter,
     499             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     500             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     501             :   true,  /* isInfallible. False in setters. */
     502             :   false,  /* isMovable.  Not relevant for setters. */
     503             :   false, /* isEliminatable.  Not relevant for setters. */
     504             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     505             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     506             :   false,  /* isTypedMethod.  Only relevant for methods. */
     507             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     508             : };
     509             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     510             : static_assert(0 < 2, "There is no slot for us");
     511             : 
     512             : static bool
     513           0 : get_metaKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     514             : {
     515           0 :   bool result(self->MetaKey());
     516           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     517           0 :   args.rval().setBoolean(result);
     518           0 :   return true;
     519             : }
     520             : 
     521             : static const JSJitInfo metaKey_getterinfo = {
     522             :   { (JSJitGetterOp)get_metaKey },
     523             :   { prototypes::id::KeyboardEvent },
     524             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     525             :   JSJitInfo::Getter,
     526             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     527             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     528             :   true,  /* isInfallible. False in setters. */
     529             :   false,  /* isMovable.  Not relevant for setters. */
     530             :   false, /* isEliminatable.  Not relevant for setters. */
     531             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     532             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     533             :   false,  /* isTypedMethod.  Only relevant for methods. */
     534             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     535             : };
     536             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     537             : static_assert(0 < 2, "There is no slot for us");
     538             : 
     539             : static bool
     540           0 : getModifierState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, const JSJitMethodCallArgs& args)
     541             : {
     542           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     543           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "KeyboardEvent.getModifierState");
     544             :   }
     545           0 :   binding_detail::FakeString arg0;
     546           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     547           0 :     return false;
     548             :   }
     549           0 :   bool result(self->GetModifierState(NonNullHelper(Constify(arg0))));
     550           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     551           0 :   args.rval().setBoolean(result);
     552           0 :   return true;
     553             : }
     554             : 
     555             : static const JSJitInfo getModifierState_methodinfo = {
     556             :   { (JSJitGetterOp)getModifierState },
     557             :   { prototypes::id::KeyboardEvent },
     558             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     559             :   JSJitInfo::Method,
     560             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     561             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     562             :   false,  /* isInfallible. False in setters. */
     563             :   false,  /* isMovable.  Not relevant for setters. */
     564             :   false, /* isEliminatable.  Not relevant for setters. */
     565             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     566             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     567             :   false,  /* isTypedMethod.  Only relevant for methods. */
     568             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     569             : };
     570             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     571             : static_assert(0 < 2, "There is no slot for us");
     572             : 
     573             : static bool
     574           0 : get_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     575             : {
     576           0 :   uint32_t result(self->Location());
     577           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     578           0 :   args.rval().setNumber(result);
     579           0 :   return true;
     580             : }
     581             : 
     582             : static const JSJitInfo location_getterinfo = {
     583             :   { (JSJitGetterOp)get_location },
     584             :   { prototypes::id::KeyboardEvent },
     585             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     586             :   JSJitInfo::Getter,
     587             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     588             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     589             :   true,  /* isInfallible. False in setters. */
     590             :   false,  /* isMovable.  Not relevant for setters. */
     591             :   false, /* isEliminatable.  Not relevant for setters. */
     592             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     593             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     594             :   false,  /* isTypedMethod.  Only relevant for methods. */
     595             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     596             : };
     597             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     598             : static_assert(0 < 2, "There is no slot for us");
     599             : 
     600             : static bool
     601           0 : get_repeat(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     602             : {
     603           0 :   bool result(self->Repeat());
     604           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     605           0 :   args.rval().setBoolean(result);
     606           0 :   return true;
     607             : }
     608             : 
     609             : static const JSJitInfo repeat_getterinfo = {
     610             :   { (JSJitGetterOp)get_repeat },
     611             :   { prototypes::id::KeyboardEvent },
     612             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     613             :   JSJitInfo::Getter,
     614             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     615             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     616             :   true,  /* isInfallible. False in setters. */
     617             :   false,  /* isMovable.  Not relevant for setters. */
     618             :   false, /* isEliminatable.  Not relevant for setters. */
     619             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     620             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     621             :   false,  /* isTypedMethod.  Only relevant for methods. */
     622             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     623             : };
     624             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     625             : static_assert(0 < 2, "There is no slot for us");
     626             : 
     627             : static bool
     628           0 : get_isComposing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     629             : {
     630           0 :   bool result(self->IsComposing());
     631           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     632           0 :   args.rval().setBoolean(result);
     633           0 :   return true;
     634             : }
     635             : 
     636             : static const JSJitInfo isComposing_getterinfo = {
     637             :   { (JSJitGetterOp)get_isComposing },
     638             :   { prototypes::id::KeyboardEvent },
     639             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     640             :   JSJitInfo::Getter,
     641             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     642             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     643             :   true,  /* isInfallible. False in setters. */
     644             :   false,  /* isMovable.  Not relevant for setters. */
     645             :   false, /* 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 < 2, "There is no slot for us");
     653             : 
     654             : static bool
     655           0 : get_key(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     656             : {
     657           0 :   DOMString result;
     658           0 :   self->GetKey(result);
     659           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     660           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     661           0 :     return false;
     662             :   }
     663           0 :   return true;
     664             : }
     665             : 
     666             : static const JSJitInfo key_getterinfo = {
     667             :   { (JSJitGetterOp)get_key },
     668             :   { prototypes::id::KeyboardEvent },
     669             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     670             :   JSJitInfo::Getter,
     671             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     672             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     673             :   false,  /* isInfallible. False in setters. */
     674             :   false,  /* isMovable.  Not relevant for setters. */
     675             :   false, /* isEliminatable.  Not relevant for setters. */
     676             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     677             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     678             :   false,  /* isTypedMethod.  Only relevant for methods. */
     679             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     680             : };
     681             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     682             : static_assert(0 < 2, "There is no slot for us");
     683             : 
     684             : static bool
     685           0 : get_code(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     686             : {
     687           0 :   DOMString result;
     688           0 :   self->GetCode(result);
     689           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     690           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     691           0 :     return false;
     692             :   }
     693           0 :   return true;
     694             : }
     695             : 
     696             : static const JSJitInfo code_getterinfo = {
     697             :   { (JSJitGetterOp)get_code },
     698             :   { prototypes::id::KeyboardEvent },
     699             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     700             :   JSJitInfo::Getter,
     701             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     702             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     703             :   false,  /* isInfallible. False in setters. */
     704             :   false,  /* isMovable.  Not relevant for setters. */
     705             :   false, /* isEliminatable.  Not relevant for setters. */
     706             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     707             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     708             :   false,  /* isTypedMethod.  Only relevant for methods. */
     709             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     710             : };
     711             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     712             : static_assert(0 < 2, "There is no slot for us");
     713             : 
     714             : static bool
     715           0 : get_initDict(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     716             : {
     717             :   // Have to either root across the getter call or reget after.
     718             :   bool isXray;
     719           0 :   JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
     720           0 :   if (!slotStorage) {
     721           0 :     return false;
     722             :   }
     723           0 :   const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
     724           0 :   MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
     725             :   {
     726             :     // Scope for cachedVal
     727           0 :     JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
     728           0 :     if (!cachedVal.isUndefined()) {
     729           0 :       args.rval().set(cachedVal);
     730             :       // The cached value is in the compartment of slotStorage,
     731             :       // so wrap into the caller compartment as needed.
     732           0 :       return MaybeWrapNonDOMObjectValue(cx, args.rval());
     733             :     }
     734             :   }
     735             : 
     736           0 :   KeyboardEventInit result;
     737           0 :   self->GetInitDict(result);
     738           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     739             :   {
     740           0 :     JS::Rooted<JSObject*> conversionScope(cx, isXray ? obj : slotStorage);
     741           0 :     JSAutoCompartment ac(cx, conversionScope);
     742             :     do { // block we break out of when done wrapping
     743           0 :       if (!result.ToObjectInternal(cx, args.rval())) {
     744           0 :         return false;
     745             :       }
     746           0 :       break;
     747             :     } while (0);
     748             :   }
     749             :   { // And now store things in the compartment of our slotStorage.
     750           0 :     JSAutoCompartment ac(cx, slotStorage);
     751             :     // Make a copy so that we don't do unnecessary wrapping on args.rval().
     752           0 :     JS::Rooted<JS::Value> storedVal(cx, args.rval());
     753           0 :     if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
     754           0 :       return false;
     755             :     }
     756           0 :     js::SetReservedSlot(slotStorage, slotIndex, storedVal);
     757           0 :     if (!isXray) {
     758             :       // In the Xray case we don't need to do this, because getting the
     759             :       // expando object already preserved our wrapper.
     760           0 :       PreserveWrapper(self);
     761             :     }
     762             :   }
     763             :   // And now make sure args.rval() is in the caller compartment
     764           0 :   return MaybeWrapNonDOMObjectValue(cx, args.rval());
     765             : }
     766             : 
     767             : static const JSJitInfo initDict_getterinfo = {
     768             :   { (JSJitGetterOp)get_initDict },
     769             :   { prototypes::id::KeyboardEvent },
     770             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     771             :   JSJitInfo::Getter,
     772             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     773             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     774             :   false,  /* isInfallible. False in setters. */
     775             :   true,  /* isMovable.  Not relevant for setters. */
     776             :   true, /* isEliminatable.  Not relevant for setters. */
     777             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     778             :   true, /* isLazilyCachedInSlot.  Only relevant for getters. */
     779             :   false,  /* isTypedMethod.  Only relevant for methods. */
     780             :   (DOM_INSTANCE_RESERVED_SLOTS + 0)   /* Reserved slot index, if we're stored in a slot, else 0. */
     781             : };
     782             : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
     783             : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
     784             : 
     785             : static bool
     786           0 : initKeyEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, const JSJitMethodCallArgs& args)
     787             : {
     788           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     789           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "KeyboardEvent.initKeyEvent");
     790             :   }
     791           0 :   binding_detail::FakeString arg0;
     792           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     793           0 :     return false;
     794             :   }
     795             :   bool arg1;
     796           0 :   if (args.hasDefined(1)) {
     797           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
     798           0 :       return false;
     799             :     }
     800             :   } else {
     801           0 :     arg1 = false;
     802             :   }
     803             :   bool arg2;
     804           0 :   if (args.hasDefined(2)) {
     805           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
     806           0 :       return false;
     807             :     }
     808             :   } else {
     809           0 :     arg2 = false;
     810             :   }
     811             :   nsGlobalWindow* arg3;
     812           0 :   if (args.hasDefined(3)) {
     813           0 :     if (args[3].isObject()) {
     814             :       {
     815           0 :         nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[3], arg3);
     816           0 :         if (NS_FAILED(rv)) {
     817           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of KeyboardEvent.initKeyEvent", "Window");
     818           0 :           return false;
     819             :         }
     820             :       }
     821           0 :     } else if (args[3].isNullOrUndefined()) {
     822           0 :       arg3 = nullptr;
     823             :     } else {
     824           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of KeyboardEvent.initKeyEvent");
     825           0 :       return false;
     826             :     }
     827             :   } else {
     828           0 :     arg3 = nullptr;
     829             :   }
     830             :   bool arg4;
     831           0 :   if (args.hasDefined(4)) {
     832           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[4], &arg4)) {
     833           0 :       return false;
     834             :     }
     835             :   } else {
     836           0 :     arg4 = false;
     837             :   }
     838             :   bool arg5;
     839           0 :   if (args.hasDefined(5)) {
     840           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) {
     841           0 :       return false;
     842             :     }
     843             :   } else {
     844           0 :     arg5 = false;
     845             :   }
     846             :   bool arg6;
     847           0 :   if (args.hasDefined(6)) {
     848           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[6], &arg6)) {
     849           0 :       return false;
     850             :     }
     851             :   } else {
     852           0 :     arg6 = false;
     853             :   }
     854             :   bool arg7;
     855           0 :   if (args.hasDefined(7)) {
     856           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) {
     857           0 :       return false;
     858             :     }
     859             :   } else {
     860           0 :     arg7 = false;
     861             :   }
     862             :   uint32_t arg8;
     863           0 :   if (args.hasDefined(8)) {
     864           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[8], &arg8)) {
     865           0 :       return false;
     866             :     }
     867             :   } else {
     868           0 :     arg8 = 0U;
     869             :   }
     870             :   uint32_t arg9;
     871           0 :   if (args.hasDefined(9)) {
     872           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[9], &arg9)) {
     873           0 :       return false;
     874             :     }
     875             :   } else {
     876           0 :     arg9 = 0U;
     877             :   }
     878           0 :   self->InitKeyEvent(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), arg4, arg5, arg6, arg7, arg8, arg9);
     879           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     880           0 :   args.rval().setUndefined();
     881           0 :   return true;
     882             : }
     883             : 
     884             : static const JSJitInfo initKeyEvent_methodinfo = {
     885             :   { (JSJitGetterOp)initKeyEvent },
     886             :   { prototypes::id::KeyboardEvent },
     887             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     888             :   JSJitInfo::Method,
     889             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     890             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     891             :   false,  /* 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 < 2, "There is no slot for us");
     901             : 
     902             : static bool
     903           0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyboardEvent* self, JSJitGetterCallArgs args)
     904             : {
     905           0 :   bool result(self->IsTrusted());
     906           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     907           0 :   args.rval().setBoolean(result);
     908           0 :   return true;
     909             : }
     910             : 
     911             : static const JSJitInfo isTrusted_getterinfo = {
     912             :   { (JSJitGetterOp)get_isTrusted },
     913             :   { prototypes::id::KeyboardEvent },
     914             :   { PrototypeTraits<prototypes::id::KeyboardEvent>::Depth },
     915             :   JSJitInfo::Getter,
     916             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     917             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     918             :   true,  /* isInfallible. False in setters. */
     919             :   true,  /* isMovable.  Not relevant for setters. */
     920             :   true, /* isEliminatable.  Not relevant for setters. */
     921             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     922             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     923             :   false,  /* isTypedMethod.  Only relevant for methods. */
     924             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     925             : };
     926             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     927             : static_assert(0 < 2, "There is no slot for us");
     928             : 
     929             : static bool
     930           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     931             : {
     932           0 :   mozilla::dom::KeyboardEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyboardEvent>(obj);
     933             :   // We don't want to preserve if we don't have a wrapper, and we
     934             :   // obviously can't preserve if we're not initialized.
     935           0 :   if (self && self->GetWrapperPreserveColor()) {
     936           0 :     PreserveWrapper(self);
     937             :   }
     938           0 :   return true;
     939             : }
     940             : 
     941             : static void
     942           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     943             : {
     944           0 :   mozilla::dom::KeyboardEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyboardEvent>(obj);
     945           0 :   if (self) {
     946           0 :     ClearWrapper(self, self, obj);
     947           0 :     AddForDeferredFinalization<mozilla::dom::KeyboardEvent>(self);
     948             :   }
     949           0 : }
     950             : 
     951             : static void
     952           0 : _objectMoved(JSObject* obj, const JSObject* old)
     953             : {
     954           0 :   mozilla::dom::KeyboardEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyboardEvent>(obj);
     955           0 :   if (self) {
     956           0 :     UpdateWrapper(self, self, obj, old);
     957             :   }
     958           0 : }
     959             : 
     960             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     961             : #if defined(__clang__)
     962             : #pragma clang diagnostic push
     963             : #pragma clang diagnostic ignored "-Wmissing-braces"
     964             : #endif
     965             : static const JSFunctionSpec sMethods_specs[] = {
     966             :   JS_FNSPEC("getModifierState", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getModifierState_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     967             :   JS_FNSPEC("initKeyEvent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initKeyEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     968             :   JS_FS_END
     969             : };
     970             : #if defined(__clang__)
     971             : #pragma clang diagnostic pop
     972             : #endif
     973             : 
     974             : 
     975             : // Can't be const because the pref-enabled boolean needs to be writable
     976             : static Prefable<const JSFunctionSpec> sMethods[] = {
     977             :   { nullptr, &sMethods_specs[0] },
     978             :   { nullptr, nullptr }
     979             : };
     980             : 
     981             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     982             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     983             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     984             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     985             : 
     986             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     987             : #if defined(__clang__)
     988             : #pragma clang diagnostic push
     989             : #pragma clang diagnostic ignored "-Wmissing-braces"
     990             : #endif
     991             : static const JSPropertySpec sAttributes_specs[] = {
     992             :   { "charCode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &charCode_getterinfo, nullptr, nullptr },
     993             :   { "keyCode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &keyCode_getterinfo, nullptr, nullptr },
     994             :   { "altKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &altKey_getterinfo, nullptr, nullptr },
     995             :   { "ctrlKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ctrlKey_getterinfo, nullptr, nullptr },
     996             :   { "shiftKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shiftKey_getterinfo, nullptr, nullptr },
     997             :   { "metaKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &metaKey_getterinfo, nullptr, nullptr },
     998             :   { "location", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &location_getterinfo, nullptr, nullptr },
     999             :   { "repeat", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &repeat_getterinfo, nullptr, nullptr },
    1000             :   { "isComposing", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isComposing_getterinfo, nullptr, nullptr },
    1001             :   { "key", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &key_getterinfo, nullptr, nullptr },
    1002             :   { "code", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &code_getterinfo, nullptr, nullptr },
    1003             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1004             : };
    1005             : #if defined(__clang__)
    1006             : #pragma clang diagnostic pop
    1007             : #endif
    1008             : 
    1009             : 
    1010             : // Can't be const because the pref-enabled boolean needs to be writable
    1011             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1012             :   { nullptr, &sAttributes_specs[0] },
    1013             :   { nullptr, nullptr }
    1014             : };
    1015             : 
    1016             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1017             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1018             : static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1019             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1020             : 
    1021             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1022             : #if defined(__clang__)
    1023             : #pragma clang diagnostic push
    1024             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1025             : #endif
    1026             : static const JSPropertySpec sChromeAttributes_specs[] = {
    1027             :   { "initDict", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &initDict_getterinfo, nullptr, nullptr },
    1028             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1029             : };
    1030             : #if defined(__clang__)
    1031             : #pragma clang diagnostic pop
    1032             : #endif
    1033             : 
    1034             : 
    1035             : // Can't be const because the pref-enabled boolean needs to be writable
    1036             : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
    1037             :   { nullptr, &sChromeAttributes_specs[0] },
    1038             :   { nullptr, nullptr }
    1039             : };
    1040             : 
    1041             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1042             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1043             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1044             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1045             : 
    1046             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1047             : #if defined(__clang__)
    1048             : #pragma clang diagnostic push
    1049             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1050             : #endif
    1051             : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
    1052             :   { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
    1053             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1054             : };
    1055             : #if defined(__clang__)
    1056             : #pragma clang diagnostic pop
    1057             : #endif
    1058             : 
    1059             : 
    1060             : // Can't be const because the pref-enabled boolean needs to be writable
    1061             : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
    1062             :   { nullptr, &sUnforgeableAttributes_specs[0] },
    1063             :   { nullptr, nullptr }
    1064             : };
    1065             : 
    1066             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1067             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1068             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1069             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1070             : 
    1071             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1072             : #if defined(__clang__)
    1073             : #pragma clang diagnostic push
    1074             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1075             : #endif
    1076             : static const ConstantSpec sConstants_specs[] = {
    1077             :   { "DOM_KEY_LOCATION_STANDARD", JS::NumberValue(0U) },
    1078             :   { "DOM_KEY_LOCATION_LEFT", JS::NumberValue(1U) },
    1079             :   { "DOM_KEY_LOCATION_RIGHT", JS::NumberValue(2U) },
    1080             :   { "DOM_KEY_LOCATION_NUMPAD", JS::NumberValue(3U) },
    1081             :   { "DOM_VK_CANCEL", JS::NumberValue(3U) },
    1082             :   { "DOM_VK_HELP", JS::NumberValue(6U) },
    1083             :   { "DOM_VK_BACK_SPACE", JS::NumberValue(8U) },
    1084             :   { "DOM_VK_TAB", JS::NumberValue(9U) },
    1085             :   { "DOM_VK_CLEAR", JS::NumberValue(12U) },
    1086             :   { "DOM_VK_RETURN", JS::NumberValue(13U) },
    1087             :   { "DOM_VK_SHIFT", JS::NumberValue(16U) },
    1088             :   { "DOM_VK_CONTROL", JS::NumberValue(17U) },
    1089             :   { "DOM_VK_ALT", JS::NumberValue(18U) },
    1090             :   { "DOM_VK_PAUSE", JS::NumberValue(19U) },
    1091             :   { "DOM_VK_CAPS_LOCK", JS::NumberValue(20U) },
    1092             :   { "DOM_VK_KANA", JS::NumberValue(21U) },
    1093             :   { "DOM_VK_HANGUL", JS::NumberValue(21U) },
    1094             :   { "DOM_VK_EISU", JS::NumberValue(22U) },
    1095             :   { "DOM_VK_JUNJA", JS::NumberValue(23U) },
    1096             :   { "DOM_VK_FINAL", JS::NumberValue(24U) },
    1097             :   { "DOM_VK_HANJA", JS::NumberValue(25U) },
    1098             :   { "DOM_VK_KANJI", JS::NumberValue(25U) },
    1099             :   { "DOM_VK_ESCAPE", JS::NumberValue(27U) },
    1100             :   { "DOM_VK_CONVERT", JS::NumberValue(28U) },
    1101             :   { "DOM_VK_NONCONVERT", JS::NumberValue(29U) },
    1102             :   { "DOM_VK_ACCEPT", JS::NumberValue(30U) },
    1103             :   { "DOM_VK_MODECHANGE", JS::NumberValue(31U) },
    1104             :   { "DOM_VK_SPACE", JS::NumberValue(32U) },
    1105             :   { "DOM_VK_PAGE_UP", JS::NumberValue(33U) },
    1106             :   { "DOM_VK_PAGE_DOWN", JS::NumberValue(34U) },
    1107             :   { "DOM_VK_END", JS::NumberValue(35U) },
    1108             :   { "DOM_VK_HOME", JS::NumberValue(36U) },
    1109             :   { "DOM_VK_LEFT", JS::NumberValue(37U) },
    1110             :   { "DOM_VK_UP", JS::NumberValue(38U) },
    1111             :   { "DOM_VK_RIGHT", JS::NumberValue(39U) },
    1112             :   { "DOM_VK_DOWN", JS::NumberValue(40U) },
    1113             :   { "DOM_VK_SELECT", JS::NumberValue(41U) },
    1114             :   { "DOM_VK_PRINT", JS::NumberValue(42U) },
    1115             :   { "DOM_VK_EXECUTE", JS::NumberValue(43U) },
    1116             :   { "DOM_VK_PRINTSCREEN", JS::NumberValue(44U) },
    1117             :   { "DOM_VK_INSERT", JS::NumberValue(45U) },
    1118             :   { "DOM_VK_DELETE", JS::NumberValue(46U) },
    1119             :   { "DOM_VK_0", JS::NumberValue(48U) },
    1120             :   { "DOM_VK_1", JS::NumberValue(49U) },
    1121             :   { "DOM_VK_2", JS::NumberValue(50U) },
    1122             :   { "DOM_VK_3", JS::NumberValue(51U) },
    1123             :   { "DOM_VK_4", JS::NumberValue(52U) },
    1124             :   { "DOM_VK_5", JS::NumberValue(53U) },
    1125             :   { "DOM_VK_6", JS::NumberValue(54U) },
    1126             :   { "DOM_VK_7", JS::NumberValue(55U) },
    1127             :   { "DOM_VK_8", JS::NumberValue(56U) },
    1128             :   { "DOM_VK_9", JS::NumberValue(57U) },
    1129             :   { "DOM_VK_COLON", JS::NumberValue(58U) },
    1130             :   { "DOM_VK_SEMICOLON", JS::NumberValue(59U) },
    1131             :   { "DOM_VK_LESS_THAN", JS::NumberValue(60U) },
    1132             :   { "DOM_VK_EQUALS", JS::NumberValue(61U) },
    1133             :   { "DOM_VK_GREATER_THAN", JS::NumberValue(62U) },
    1134             :   { "DOM_VK_QUESTION_MARK", JS::NumberValue(63U) },
    1135             :   { "DOM_VK_AT", JS::NumberValue(64U) },
    1136             :   { "DOM_VK_A", JS::NumberValue(65U) },
    1137             :   { "DOM_VK_B", JS::NumberValue(66U) },
    1138             :   { "DOM_VK_C", JS::NumberValue(67U) },
    1139             :   { "DOM_VK_D", JS::NumberValue(68U) },
    1140             :   { "DOM_VK_E", JS::NumberValue(69U) },
    1141             :   { "DOM_VK_F", JS::NumberValue(70U) },
    1142             :   { "DOM_VK_G", JS::NumberValue(71U) },
    1143             :   { "DOM_VK_H", JS::NumberValue(72U) },
    1144             :   { "DOM_VK_I", JS::NumberValue(73U) },
    1145             :   { "DOM_VK_J", JS::NumberValue(74U) },
    1146             :   { "DOM_VK_K", JS::NumberValue(75U) },
    1147             :   { "DOM_VK_L", JS::NumberValue(76U) },
    1148             :   { "DOM_VK_M", JS::NumberValue(77U) },
    1149             :   { "DOM_VK_N", JS::NumberValue(78U) },
    1150             :   { "DOM_VK_O", JS::NumberValue(79U) },
    1151             :   { "DOM_VK_P", JS::NumberValue(80U) },
    1152             :   { "DOM_VK_Q", JS::NumberValue(81U) },
    1153             :   { "DOM_VK_R", JS::NumberValue(82U) },
    1154             :   { "DOM_VK_S", JS::NumberValue(83U) },
    1155             :   { "DOM_VK_T", JS::NumberValue(84U) },
    1156             :   { "DOM_VK_U", JS::NumberValue(85U) },
    1157             :   { "DOM_VK_V", JS::NumberValue(86U) },
    1158             :   { "DOM_VK_W", JS::NumberValue(87U) },
    1159             :   { "DOM_VK_X", JS::NumberValue(88U) },
    1160             :   { "DOM_VK_Y", JS::NumberValue(89U) },
    1161             :   { "DOM_VK_Z", JS::NumberValue(90U) },
    1162             :   { "DOM_VK_WIN", JS::NumberValue(91U) },
    1163             :   { "DOM_VK_CONTEXT_MENU", JS::NumberValue(93U) },
    1164             :   { "DOM_VK_SLEEP", JS::NumberValue(95U) },
    1165             :   { "DOM_VK_NUMPAD0", JS::NumberValue(96U) },
    1166             :   { "DOM_VK_NUMPAD1", JS::NumberValue(97U) },
    1167             :   { "DOM_VK_NUMPAD2", JS::NumberValue(98U) },
    1168             :   { "DOM_VK_NUMPAD3", JS::NumberValue(99U) },
    1169             :   { "DOM_VK_NUMPAD4", JS::NumberValue(100U) },
    1170             :   { "DOM_VK_NUMPAD5", JS::NumberValue(101U) },
    1171             :   { "DOM_VK_NUMPAD6", JS::NumberValue(102U) },
    1172             :   { "DOM_VK_NUMPAD7", JS::NumberValue(103U) },
    1173             :   { "DOM_VK_NUMPAD8", JS::NumberValue(104U) },
    1174             :   { "DOM_VK_NUMPAD9", JS::NumberValue(105U) },
    1175             :   { "DOM_VK_MULTIPLY", JS::NumberValue(106U) },
    1176             :   { "DOM_VK_ADD", JS::NumberValue(107U) },
    1177             :   { "DOM_VK_SEPARATOR", JS::NumberValue(108U) },
    1178             :   { "DOM_VK_SUBTRACT", JS::NumberValue(109U) },
    1179             :   { "DOM_VK_DECIMAL", JS::NumberValue(110U) },
    1180             :   { "DOM_VK_DIVIDE", JS::NumberValue(111U) },
    1181             :   { "DOM_VK_F1", JS::NumberValue(112U) },
    1182             :   { "DOM_VK_F2", JS::NumberValue(113U) },
    1183             :   { "DOM_VK_F3", JS::NumberValue(114U) },
    1184             :   { "DOM_VK_F4", JS::NumberValue(115U) },
    1185             :   { "DOM_VK_F5", JS::NumberValue(116U) },
    1186             :   { "DOM_VK_F6", JS::NumberValue(117U) },
    1187             :   { "DOM_VK_F7", JS::NumberValue(118U) },
    1188             :   { "DOM_VK_F8", JS::NumberValue(119U) },
    1189             :   { "DOM_VK_F9", JS::NumberValue(120U) },
    1190             :   { "DOM_VK_F10", JS::NumberValue(121U) },
    1191             :   { "DOM_VK_F11", JS::NumberValue(122U) },
    1192             :   { "DOM_VK_F12", JS::NumberValue(123U) },
    1193             :   { "DOM_VK_F13", JS::NumberValue(124U) },
    1194             :   { "DOM_VK_F14", JS::NumberValue(125U) },
    1195             :   { "DOM_VK_F15", JS::NumberValue(126U) },
    1196             :   { "DOM_VK_F16", JS::NumberValue(127U) },
    1197             :   { "DOM_VK_F17", JS::NumberValue(128U) },
    1198             :   { "DOM_VK_F18", JS::NumberValue(129U) },
    1199             :   { "DOM_VK_F19", JS::NumberValue(130U) },
    1200             :   { "DOM_VK_F20", JS::NumberValue(131U) },
    1201             :   { "DOM_VK_F21", JS::NumberValue(132U) },
    1202             :   { "DOM_VK_F22", JS::NumberValue(133U) },
    1203             :   { "DOM_VK_F23", JS::NumberValue(134U) },
    1204             :   { "DOM_VK_F24", JS::NumberValue(135U) },
    1205             :   { "DOM_VK_NUM_LOCK", JS::NumberValue(144U) },
    1206             :   { "DOM_VK_SCROLL_LOCK", JS::NumberValue(145U) },
    1207             :   { "DOM_VK_WIN_OEM_FJ_JISHO", JS::NumberValue(146U) },
    1208             :   { "DOM_VK_WIN_OEM_FJ_MASSHOU", JS::NumberValue(147U) },
    1209             :   { "DOM_VK_WIN_OEM_FJ_TOUROKU", JS::NumberValue(148U) },
    1210             :   { "DOM_VK_WIN_OEM_FJ_LOYA", JS::NumberValue(149U) },
    1211             :   { "DOM_VK_WIN_OEM_FJ_ROYA", JS::NumberValue(150U) },
    1212             :   { "DOM_VK_CIRCUMFLEX", JS::NumberValue(160U) },
    1213             :   { "DOM_VK_EXCLAMATION", JS::NumberValue(161U) },
    1214             :   { "DOM_VK_DOUBLE_QUOTE", JS::NumberValue(162U) },
    1215             :   { "DOM_VK_HASH", JS::NumberValue(163U) },
    1216             :   { "DOM_VK_DOLLAR", JS::NumberValue(164U) },
    1217             :   { "DOM_VK_PERCENT", JS::NumberValue(165U) },
    1218             :   { "DOM_VK_AMPERSAND", JS::NumberValue(166U) },
    1219             :   { "DOM_VK_UNDERSCORE", JS::NumberValue(167U) },
    1220             :   { "DOM_VK_OPEN_PAREN", JS::NumberValue(168U) },
    1221             :   { "DOM_VK_CLOSE_PAREN", JS::NumberValue(169U) },
    1222             :   { "DOM_VK_ASTERISK", JS::NumberValue(170U) },
    1223             :   { "DOM_VK_PLUS", JS::NumberValue(171U) },
    1224             :   { "DOM_VK_PIPE", JS::NumberValue(172U) },
    1225             :   { "DOM_VK_HYPHEN_MINUS", JS::NumberValue(173U) },
    1226             :   { "DOM_VK_OPEN_CURLY_BRACKET", JS::NumberValue(174U) },
    1227             :   { "DOM_VK_CLOSE_CURLY_BRACKET", JS::NumberValue(175U) },
    1228             :   { "DOM_VK_TILDE", JS::NumberValue(176U) },
    1229             :   { "DOM_VK_VOLUME_MUTE", JS::NumberValue(181U) },
    1230             :   { "DOM_VK_VOLUME_DOWN", JS::NumberValue(182U) },
    1231             :   { "DOM_VK_VOLUME_UP", JS::NumberValue(183U) },
    1232             :   { "DOM_VK_COMMA", JS::NumberValue(188U) },
    1233             :   { "DOM_VK_PERIOD", JS::NumberValue(190U) },
    1234             :   { "DOM_VK_SLASH", JS::NumberValue(191U) },
    1235             :   { "DOM_VK_BACK_QUOTE", JS::NumberValue(192U) },
    1236             :   { "DOM_VK_OPEN_BRACKET", JS::NumberValue(219U) },
    1237             :   { "DOM_VK_BACK_SLASH", JS::NumberValue(220U) },
    1238             :   { "DOM_VK_CLOSE_BRACKET", JS::NumberValue(221U) },
    1239             :   { "DOM_VK_QUOTE", JS::NumberValue(222U) },
    1240             :   { "DOM_VK_META", JS::NumberValue(224U) },
    1241             :   { "DOM_VK_ALTGR", JS::NumberValue(225U) },
    1242             :   { "DOM_VK_WIN_ICO_HELP", JS::NumberValue(227U) },
    1243             :   { "DOM_VK_WIN_ICO_00", JS::NumberValue(228U) },
    1244             :   { "DOM_VK_WIN_ICO_CLEAR", JS::NumberValue(230U) },
    1245             :   { "DOM_VK_WIN_OEM_RESET", JS::NumberValue(233U) },
    1246             :   { "DOM_VK_WIN_OEM_JUMP", JS::NumberValue(234U) },
    1247             :   { "DOM_VK_WIN_OEM_PA1", JS::NumberValue(235U) },
    1248             :   { "DOM_VK_WIN_OEM_PA2", JS::NumberValue(236U) },
    1249             :   { "DOM_VK_WIN_OEM_PA3", JS::NumberValue(237U) },
    1250             :   { "DOM_VK_WIN_OEM_WSCTRL", JS::NumberValue(238U) },
    1251             :   { "DOM_VK_WIN_OEM_CUSEL", JS::NumberValue(239U) },
    1252             :   { "DOM_VK_WIN_OEM_ATTN", JS::NumberValue(240U) },
    1253             :   { "DOM_VK_WIN_OEM_FINISH", JS::NumberValue(241U) },
    1254             :   { "DOM_VK_WIN_OEM_COPY", JS::NumberValue(242U) },
    1255             :   { "DOM_VK_WIN_OEM_AUTO", JS::NumberValue(243U) },
    1256             :   { "DOM_VK_WIN_OEM_ENLW", JS::NumberValue(244U) },
    1257             :   { "DOM_VK_WIN_OEM_BACKTAB", JS::NumberValue(245U) },
    1258             :   { "DOM_VK_ATTN", JS::NumberValue(246U) },
    1259             :   { "DOM_VK_CRSEL", JS::NumberValue(247U) },
    1260             :   { "DOM_VK_EXSEL", JS::NumberValue(248U) },
    1261             :   { "DOM_VK_EREOF", JS::NumberValue(249U) },
    1262             :   { "DOM_VK_PLAY", JS::NumberValue(250U) },
    1263             :   { "DOM_VK_ZOOM", JS::NumberValue(251U) },
    1264             :   { "DOM_VK_PA1", JS::NumberValue(253U) },
    1265             :   { "DOM_VK_WIN_OEM_CLEAR", JS::NumberValue(254U) },
    1266             :   { 0, JS::UndefinedValue() }
    1267             : };
    1268             : #if defined(__clang__)
    1269             : #pragma clang diagnostic pop
    1270             : #endif
    1271             : 
    1272             : 
    1273             : // Can't be const because the pref-enabled boolean needs to be writable
    1274             : static Prefable<const ConstantSpec> sConstants[] = {
    1275             :   { nullptr, &sConstants_specs[0] },
    1276             :   { nullptr, nullptr }
    1277             : };
    1278             : 
    1279             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1280             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1281             : static_assert(189 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1282             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1283             : 
    1284             : 
    1285             : static uint16_t sNativeProperties_sortedPropertyIndices[203];
    1286             : static PropertyInfo sNativeProperties_propertyInfos[203];
    1287             : 
    1288             : static const NativePropertiesN<4> sNativeProperties = {
    1289             :   false, 0,
    1290             :   false, 0,
    1291             :   true,  0 /* sMethods */,
    1292             :   true,  1 /* sAttributes */,
    1293             :   false, 0,
    1294             :   true,  2 /* sUnforgeableAttributes */,
    1295             :   true,  3 /* sConstants */,
    1296             :   -1,
    1297             :   203,
    1298             :   sNativeProperties_sortedPropertyIndices,
    1299             :   {
    1300             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    1301             :     { sAttributes, &sNativeProperties_propertyInfos[2] },
    1302             :     { sUnforgeableAttributes, &sNativeProperties_propertyInfos[13] },
    1303             :     { sConstants, &sNativeProperties_propertyInfos[14] }
    1304             :   }
    1305             : };
    1306             : static_assert(203 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1307             :     "We have a property info count that is oversized");
    1308             : 
    1309             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
    1310             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
    1311             : 
    1312             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    1313             :   false, 0,
    1314             :   false, 0,
    1315             :   false, 0,
    1316             :   true,  0 /* sChromeAttributes */,
    1317             :   false, 0,
    1318             :   false, 0,
    1319             :   false, 0,
    1320             :   -1,
    1321             :   1,
    1322             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    1323             :   {
    1324             :     { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
    1325             :   }
    1326             : };
    1327             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    1328             :     "We have a property info count that is oversized");
    1329             : 
    1330             : static bool
    1331           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    1332             : {
    1333           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1334           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    1335           0 :   if (!args.isConstructing()) {
    1336             :     // XXXbz wish I could get the name from the callee instead of
    1337             :     // Adding more relocations
    1338           0 :     return ThrowConstructorWithoutNew(cx, "KeyboardEvent");
    1339             :   }
    1340             : 
    1341           0 :   GlobalObject global(cx, obj);
    1342           0 :   if (global.Failed()) {
    1343           0 :     return false;
    1344             :   }
    1345             : 
    1346           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    1347           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    1348           0 :     return false;
    1349             :   }
    1350             : 
    1351           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1352           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "KeyboardEvent");
    1353             :   }
    1354           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1355           0 :   binding_detail::FakeString arg0;
    1356           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    1357           0 :     return false;
    1358             :   }
    1359           0 :   binding_detail::FastKeyboardEventInit arg1;
    1360           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of KeyboardEvent.constructor", false)) {
    1361           0 :     return false;
    1362             :   }
    1363           0 :   Maybe<JSAutoCompartment> ac;
    1364           0 :   if (objIsXray) {
    1365           0 :     obj = js::CheckedUnwrap(obj);
    1366           0 :     if (!obj) {
    1367           0 :       return false;
    1368             :     }
    1369           0 :     ac.emplace(cx, obj);
    1370           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    1371           0 :       return false;
    1372             :     }
    1373             :   }
    1374           0 :   binding_detail::FastErrorResult rv;
    1375           0 :   auto result(StrongOrRawPtr<mozilla::dom::KeyboardEvent>(mozilla::dom::KeyboardEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
    1376           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1377           0 :     return false;
    1378             :   }
    1379           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1380             :   static_assert(!IsPointer<decltype(result)>::value,
    1381             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    1382           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1383           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1384           0 :     return false;
    1385             :   }
    1386           0 :   return true;
    1387             : }
    1388             : 
    1389             : static const js::ClassOps sInterfaceObjectClassOps = {
    1390             :     nullptr,               /* addProperty */
    1391             :     nullptr,               /* delProperty */
    1392             :     nullptr,               /* getProperty */
    1393             :     nullptr,               /* setProperty */
    1394             :     nullptr,               /* enumerate */
    1395             :     nullptr,               /* newEnumerate */
    1396             :     nullptr,               /* resolve */
    1397             :     nullptr,               /* mayResolve */
    1398             :     nullptr,               /* finalize */
    1399             :     _constructor, /* call */
    1400             :     nullptr,               /* hasInstance */
    1401             :     _constructor, /* construct */
    1402             :     nullptr,               /* trace */
    1403             : };
    1404             : 
    1405             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1406             :   {
    1407             :     "Function",
    1408             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1409             :     &sInterfaceObjectClassOps,
    1410             :     JS_NULL_CLASS_SPEC,
    1411             :     JS_NULL_CLASS_EXT,
    1412             :     &sInterfaceObjectClassObjectOps
    1413             :   },
    1414             :   eInterface,
    1415             :   true,
    1416             :   prototypes::id::KeyboardEvent,
    1417             :   PrototypeTraits<prototypes::id::KeyboardEvent>::Depth,
    1418             :   sNativePropertyHooks,
    1419             :   "function KeyboardEvent() {\n    [native code]\n}",
    1420             :   UIEventBinding::GetConstructorObject
    1421             : };
    1422             : 
    1423             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1424             :   {
    1425             :     "KeyboardEventPrototype",
    1426             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
    1427             :     JS_NULL_CLASS_OPS,
    1428             :     JS_NULL_CLASS_SPEC,
    1429             :     JS_NULL_CLASS_EXT,
    1430             :     JS_NULL_OBJECT_OPS
    1431             :   },
    1432             :   eInterfacePrototype,
    1433             :   false,
    1434             :   prototypes::id::KeyboardEvent,
    1435             :   PrototypeTraits<prototypes::id::KeyboardEvent>::Depth,
    1436             :   sNativePropertyHooks,
    1437             :   "[object KeyboardEventPrototype]",
    1438             :   UIEventBinding::GetProtoObject
    1439             : };
    1440             : 
    1441             : JSObject*
    1442           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1443             : {
    1444           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1445             : }
    1446             : 
    1447             : static const js::ClassOps sClassOps = {
    1448             :   _addProperty, /* addProperty */
    1449             :   nullptr,               /* delProperty */
    1450             :   nullptr,               /* getProperty */
    1451             :   nullptr,               /* setProperty */
    1452             :   nullptr,               /* enumerate */
    1453             :   nullptr, /* newEnumerate */
    1454             :   nullptr, /* resolve */
    1455             :   nullptr, /* mayResolve */
    1456             :   _finalize, /* finalize */
    1457             :   nullptr, /* call */
    1458             :   nullptr,               /* hasInstance */
    1459             :   nullptr,               /* construct */
    1460             :   nullptr, /* trace */
    1461             : };
    1462             : 
    1463             : static const js::ClassExtension sClassExtension = {
    1464             :   nullptr, /* weakmapKeyDelegateOp */
    1465             :   _objectMoved /* objectMovedOp */
    1466             : };
    1467             : 
    1468             : static const DOMJSClass sClass = {
    1469             :   { "KeyboardEvent",
    1470             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2) | JSCLASS_SKIP_NURSERY_FINALIZE,
    1471             :     &sClassOps,
    1472             :     JS_NULL_CLASS_SPEC,
    1473             :     &sClassExtension,
    1474             :     JS_NULL_OBJECT_OPS
    1475             :   },
    1476             :   { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::KeyboardEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    1477             :   IsBaseOf<nsISupports, mozilla::dom::KeyboardEvent >::value,
    1478             :   sNativePropertyHooks,
    1479             :   FindAssociatedGlobalForNative<mozilla::dom::KeyboardEvent>::Get,
    1480             :   GetProtoObjectHandle,
    1481             :   GetCCParticipant<mozilla::dom::KeyboardEvent>::Get()
    1482             : };
    1483             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1484             :               "Must have the right minimal number of reserved slots.");
    1485             : static_assert(2 >= 2,
    1486             :               "Must have enough reserved slots.");
    1487             : 
    1488             : const JSClass*
    1489           0 : GetJSClass()
    1490             : {
    1491           0 :   return sClass.ToJSClass();
    1492             : }
    1493             : 
    1494             : bool
    1495           0 : Wrap(JSContext* aCx, mozilla::dom::KeyboardEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1496             : {
    1497             :   MOZ_ASSERT(static_cast<mozilla::dom::KeyboardEvent*>(aObject) ==
    1498             :              reinterpret_cast<mozilla::dom::KeyboardEvent*>(aObject),
    1499             :              "Multiple inheritance for mozilla::dom::KeyboardEvent is broken.");
    1500             :   MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
    1501             :              reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
    1502             :              "Multiple inheritance for mozilla::dom::UIEvent is broken.");
    1503             :   MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
    1504             :              reinterpret_cast<mozilla::dom::Event*>(aObject),
    1505             :              "Multiple inheritance for mozilla::dom::Event is broken.");
    1506           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1507           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1508           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1509             :              "You should probably not be using Wrap() directly; use "
    1510             :              "GetOrCreateDOMReflector instead");
    1511             : 
    1512           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1513             :              "nsISupports must be on our primary inheritance chain");
    1514             : 
    1515           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1516           0 :   if (!global) {
    1517           0 :     return false;
    1518             :   }
    1519           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1520           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1521             : 
    1522             :   // That might have ended up wrapping us already, due to the wonders
    1523             :   // of XBL.  Check for that, and bail out as needed.
    1524           0 :   aReflector.set(aCache->GetWrapper());
    1525           0 :   if (aReflector) {
    1526             : #ifdef DEBUG
    1527           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1528             : #endif // DEBUG
    1529           0 :     return true;
    1530             :   }
    1531             : 
    1532           0 :   JSAutoCompartment ac(aCx, global);
    1533           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1534           0 :   if (!canonicalProto) {
    1535           0 :     return false;
    1536             :   }
    1537           0 :   JS::Rooted<JSObject*> proto(aCx);
    1538           0 :   if (aGivenProto) {
    1539           0 :     proto = aGivenProto;
    1540             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1541             :     // coming in, we changed compartments to that of "parent" so may need
    1542             :     // to wrap the proto here.
    1543           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1544           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1545           0 :         return false;
    1546             :       }
    1547             :     }
    1548             :   } else {
    1549           0 :     proto = canonicalProto;
    1550             :   }
    1551             : 
    1552           0 :   BindingJSObjectCreator<mozilla::dom::KeyboardEvent> creator(aCx);
    1553           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1554           0 :   if (!aReflector) {
    1555           0 :     return false;
    1556             :   }
    1557             : 
    1558           0 :   aCache->SetWrapper(aReflector);
    1559             : 
    1560             :   // Important: do unforgeable property setup after we have handed
    1561             :   // over ownership of the C++ object to obj as needed, so that if
    1562             :   // we fail and it ends up GCed it won't have problems in the
    1563             :   // finalizer trying to drop its ownership of the C++ object.
    1564             :   JS::Rooted<JSObject*> unforgeableHolder(aCx,
    1565           0 :     &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
    1566           0 :   if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
    1567           0 :     aCache->ReleaseWrapper(aObject);
    1568           0 :     aCache->ClearWrapper();
    1569           0 :     return false;
    1570             :   }
    1571           0 :   creator.InitializationSucceeded();
    1572             : 
    1573           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1574             :              aCache->GetWrapperPreserveColor() == aReflector);
    1575             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1576             :   // otherwise we won't be able to properly recreate it later, since
    1577             :   // we won't know what proto to use.  Note that we don't check
    1578             :   // aGivenProto here, since it's entirely possible (and even
    1579             :   // somewhat common) to have a non-null aGivenProto which is the
    1580             :   // same as canonicalProto.
    1581           0 :   if (proto != canonicalProto) {
    1582           0 :     PreserveWrapper(aObject);
    1583             :   }
    1584             : 
    1585           0 :   return true;
    1586             : }
    1587             : 
    1588             : // This may allocate too many slots, because we only really need
    1589             : // slots for our non-interface-typed members that we cache.  But
    1590             : // allocating slots only for those would make the slot index
    1591             : // computations much more complicated, so let's do this the simple
    1592             : // way for now.
    1593             : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
    1594             : 
    1595             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1596             :   nullptr,
    1597             :   nullptr,
    1598             :   nullptr,
    1599             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    1600             :   prototypes::id::KeyboardEvent,
    1601             :   constructors::id::KeyboardEvent,
    1602             :   UIEventBinding::sNativePropertyHooks,
    1603             :   &sXrayExpandoObjectClass
    1604             : } };
    1605             : 
    1606             : void
    1607           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1608             : {
    1609           0 :   JS::Handle<JSObject*> parentProto(UIEventBinding::GetProtoObjectHandle(aCx));
    1610           0 :   if (!parentProto) {
    1611           0 :     return;
    1612             :   }
    1613             : 
    1614           0 :   JS::Handle<JSObject*> constructorProto(UIEventBinding::GetConstructorObjectHandle(aCx));
    1615           0 :   if (!constructorProto) {
    1616           0 :     return;
    1617             :   }
    1618             : 
    1619             :   static bool sIdsInited = false;
    1620           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1621           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1622           0 :       return;
    1623             :     }
    1624           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    1625           0 :       return;
    1626             :     }
    1627           0 :     sIdsInited = true;
    1628             :   }
    1629             : 
    1630           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::KeyboardEvent);
    1631           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::KeyboardEvent);
    1632           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1633             :                               &sPrototypeClass.mBase, protoCache,
    1634             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
    1635             :                               interfaceCache,
    1636             :                               sNativeProperties.Upcast(),
    1637           0 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    1638             :                               "KeyboardEvent", aDefineOnGlobal,
    1639             :                               nullptr,
    1640           0 :                               false);
    1641             : 
    1642           0 :   JS::Rooted<JSObject*> unforgeableHolder(aCx);
    1643             :   {
    1644           0 :     JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
    1645           0 :     unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
    1646           0 :     if (!unforgeableHolder) {
    1647           0 :       *protoCache = nullptr;
    1648           0 :       if (interfaceCache) {
    1649           0 :         *interfaceCache = nullptr;
    1650             :       }
    1651           0 :       return;
    1652             :     }
    1653             :   }
    1654             : 
    1655           0 :   if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
    1656           0 :     *protoCache = nullptr;
    1657           0 :     if (interfaceCache) {
    1658           0 :       *interfaceCache = nullptr;
    1659             :     }
    1660           0 :     return;
    1661             :   }
    1662             : 
    1663           0 :   if (*protoCache) {
    1664           0 :     js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
    1665           0 :                         JS::ObjectValue(*unforgeableHolder));
    1666             :   }
    1667             : }
    1668             : 
    1669             : JS::Handle<JSObject*>
    1670           0 : GetProtoObjectHandle(JSContext* aCx)
    1671             : {
    1672             :   /* Get the interface prototype object for this class.  This will create the
    1673             :      object as needed. */
    1674           0 :   bool aDefineOnGlobal = true;
    1675             : 
    1676             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1677           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1678           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1679           0 :     return nullptr;
    1680             :   }
    1681             : 
    1682             :   /* Check to see whether the interface objects are already installed */
    1683           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1684           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::KeyboardEvent)) {
    1685           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1686           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1687             :   }
    1688             : 
    1689             :   /*
    1690             :    * The object might _still_ be null, but that's OK.
    1691             :    *
    1692             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1693             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1694             :    * changed after they have been set.
    1695             :    *
    1696             :    * Calling address() avoids the read read barrier that does gray
    1697             :    * unmarking, but it's not possible for the object to be gray here.
    1698             :    */
    1699             : 
    1700           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::KeyboardEvent);
    1701           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1702           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1703             : }
    1704             : 
    1705             : JS::Handle<JSObject*>
    1706           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1707             : {
    1708             :   /* Get the interface object for this class.  This will create the object as
    1709             :      needed. */
    1710             : 
    1711             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1712           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1713           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1714           0 :     return nullptr;
    1715             :   }
    1716             : 
    1717             :   /* Check to see whether the interface objects are already installed */
    1718           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1719           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::KeyboardEvent)) {
    1720           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1721           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1722             :   }
    1723             : 
    1724             :   /*
    1725             :    * The object might _still_ be null, but that's OK.
    1726             :    *
    1727             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1728             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1729             :    * changed after they have been set.
    1730             :    *
    1731             :    * Calling address() avoids the read read barrier that does gray
    1732             :    * unmarking, but it's not possible for the object to be gray here.
    1733             :    */
    1734             : 
    1735           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::KeyboardEvent);
    1736           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1737           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1738             : }
    1739             : 
    1740             : JSObject*
    1741           0 : GetConstructorObject(JSContext* aCx)
    1742             : {
    1743           0 :   return GetConstructorObjectHandle(aCx);
    1744             : }
    1745             : 
    1746             : } // namespace KeyboardEventBinding
    1747             : 
    1748             : 
    1749             : 
    1750             : } // namespace dom
    1751             : } // namespace mozilla

Generated by: LCOV version 1.13