Coverage Report

Created: 2018-09-25 14:53

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