Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/UIEventBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM UIEvent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "EventBinding.h"
5
#include "UIEventBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/Nullable.h"
12
#include "mozilla/dom/PrimitiveConversions.h"
13
#include "mozilla/dom/ScriptSettings.h"
14
#include "mozilla/dom/SimpleGlobalObject.h"
15
#include "mozilla/dom/UIEvent.h"
16
#include "mozilla/dom/XrayExpandoClass.h"
17
#include "nsContentUtils.h"
18
#include "nsGlobalWindow.h"
19
#include "nsINode.h"
20
#include "nsPIDOMWindow.h"
21
22
namespace mozilla {
23
namespace dom {
24
25
namespace binding_detail {}; // Just to make sure it's known as a namespace
26
using namespace mozilla::dom::binding_detail;
27
28
29
30
UIEventInit::UIEventInit()
31
  : EventInit(FastDictionaryInitializer())
32
0
{
33
0
  // Safe to pass a null context if we pass a null value
34
0
  Init(nullptr, JS::NullHandleValue);
35
0
}
36
37
38
39
bool
40
UIEventInit::InitIds(JSContext* cx, UIEventInitAtoms* atomsCache)
41
0
{
42
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
43
0
44
0
  // Initialize these in reverse order so that any failure leaves the first one
45
0
  // uninitialized.
46
0
  if (!atomsCache->view_id.init(cx, "view") ||
47
0
      !atomsCache->detail_id.init(cx, "detail")) {
48
0
    return false;
49
0
  }
50
0
  return true;
51
0
}
52
53
bool
54
UIEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
55
0
{
56
0
  // Passing a null JSContext is OK only if we're initing from null,
57
0
  // Since in that case we will not have to do any property gets
58
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
59
0
  // checkers by static analysis tools
60
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
61
0
  UIEventInitAtoms* atomsCache = nullptr;
62
0
  if (cx) {
63
0
    atomsCache = GetAtomCache<UIEventInitAtoms>(cx);
64
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
65
0
      return false;
66
0
    }
67
0
  }
68
0
69
0
  // Per spec, we init the parent's members first
70
0
  if (!EventInit::Init(cx, val)) {
71
0
    return false;
72
0
  }
73
0
74
0
  bool isNull = val.isNullOrUndefined();
75
0
  // We only need these if !isNull, in which case we have |cx|.
76
0
  Maybe<JS::Rooted<JSObject *> > object;
77
0
  Maybe<JS::Rooted<JS::Value> > temp;
78
0
  if (!isNull) {
79
0
    MOZ_ASSERT(cx);
80
0
    object.emplace(cx, &val.toObject());
81
0
    temp.emplace(cx);
82
0
  }
83
0
  if (!isNull) {
84
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->detail_id, temp.ptr())) {
85
0
      return false;
86
0
    }
87
0
  }
88
0
  if (!isNull && !temp->isUndefined()) {
89
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mDetail)) {
90
0
      return false;
91
0
    }
92
0
  } else {
93
0
    mDetail = 0;
94
0
  }
95
0
  mIsAnyMemberPresent = true;
96
0
97
0
  if (!isNull) {
98
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->view_id, temp.ptr())) {
99
0
      return false;
100
0
    }
101
0
  }
102
0
  if (!isNull && !temp->isUndefined()) {
103
0
    if (temp.ref().isObject()) {
104
0
      static_assert(IsRefcounted<nsGlobalWindowInner>::value, "We can only store refcounted classes.");{
105
0
        nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(temp.ptr(), mView);
106
0
        if (NS_FAILED(rv)) {
107
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'view' member of UIEventInit", "Window");
108
0
          return false;
109
0
        }
110
0
      }
111
0
    } else if (temp.ref().isNullOrUndefined()) {
112
0
      mView = nullptr;
113
0
    } else {
114
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'view' member of UIEventInit");
115
0
      return false;
116
0
    }
117
0
  } else {
118
0
    mView = nullptr;
119
0
  }
120
0
  mIsAnyMemberPresent = true;
121
0
  return true;
122
0
}
123
124
bool
125
UIEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
126
0
{
127
0
  UIEventInitAtoms* atomsCache = GetAtomCache<UIEventInitAtoms>(cx);
128
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
129
0
    return false;
130
0
  }
131
0
132
0
  // Per spec, we define the parent's members first
133
0
  if (!EventInit::ToObjectInternal(cx, rval)) {
134
0
    return false;
135
0
  }
136
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
137
0
138
0
  do {
139
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
140
0
    JS::Rooted<JS::Value> temp(cx);
141
0
    int32_t const & currentValue = mDetail;
142
0
    temp.setInt32(int32_t(currentValue));
143
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->detail_id, temp, JSPROP_ENUMERATE)) {
144
0
      return false;
145
0
    }
146
0
    break;
147
0
  } while(false);
148
0
149
0
  do {
150
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
151
0
    JS::Rooted<JS::Value> temp(cx);
152
0
    RefPtr<nsGlobalWindowInner> const & currentValue = mView;
153
0
    if (!currentValue) {
154
0
      temp.setNull();
155
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->view_id, temp, JSPROP_ENUMERATE)) {
156
0
        return false;
157
0
      }
158
0
      break;
159
0
    }
160
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
161
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
162
0
      return false;
163
0
    }
164
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->view_id, temp, JSPROP_ENUMERATE)) {
165
0
      return false;
166
0
    }
167
0
    break;
168
0
  } while(false);
169
0
170
0
  return true;
171
0
}
172
173
void
174
UIEventInit::TraceDictionary(JSTracer* trc)
175
0
{
176
0
  EventInit::TraceDictionary(trc);
177
0
}
178
179
180
181
UIEventInit&
182
UIEventInit::operator=(const UIEventInit& aOther)
183
0
{
184
0
  EventInit::operator=(aOther);
185
0
  mDetail = aOther.mDetail;
186
0
  mView = aOther.mView;
187
0
  return *this;
188
0
}
189
190
namespace binding_detail {
191
} // namespace binding_detail
192
193
194
195
EventModifierInit::EventModifierInit()
196
  : UIEventInit(FastDictionaryInitializer())
197
0
{
198
0
  // Safe to pass a null context if we pass a null value
199
0
  Init(nullptr, JS::NullHandleValue);
200
0
}
201
202
203
204
bool
205
EventModifierInit::InitIds(JSContext* cx, EventModifierInitAtoms* atomsCache)
206
0
{
207
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
208
0
209
0
  // Initialize these in reverse order so that any failure leaves the first one
210
0
  // uninitialized.
211
0
  if (!atomsCache->shiftKey_id.init(cx, "shiftKey") ||
212
0
      !atomsCache->modifierSymbolLock_id.init(cx, "modifierSymbolLock") ||
213
0
      !atomsCache->modifierSymbol_id.init(cx, "modifierSymbol") ||
214
0
      !atomsCache->modifierScrollLock_id.init(cx, "modifierScrollLock") ||
215
0
      !atomsCache->modifierOS_id.init(cx, "modifierOS") ||
216
0
      !atomsCache->modifierNumLock_id.init(cx, "modifierNumLock") ||
217
0
      !atomsCache->modifierFnLock_id.init(cx, "modifierFnLock") ||
218
0
      !atomsCache->modifierFn_id.init(cx, "modifierFn") ||
219
0
      !atomsCache->modifierCapsLock_id.init(cx, "modifierCapsLock") ||
220
0
      !atomsCache->modifierAltGraph_id.init(cx, "modifierAltGraph") ||
221
0
      !atomsCache->metaKey_id.init(cx, "metaKey") ||
222
0
      !atomsCache->ctrlKey_id.init(cx, "ctrlKey") ||
223
0
      !atomsCache->altKey_id.init(cx, "altKey")) {
224
0
    return false;
225
0
  }
226
0
  return true;
227
0
}
228
229
bool
230
EventModifierInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
231
0
{
232
0
  // Passing a null JSContext is OK only if we're initing from null,
233
0
  // Since in that case we will not have to do any property gets
234
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
235
0
  // checkers by static analysis tools
236
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
237
0
  EventModifierInitAtoms* atomsCache = nullptr;
238
0
  if (cx) {
239
0
    atomsCache = GetAtomCache<EventModifierInitAtoms>(cx);
240
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
241
0
      return false;
242
0
    }
243
0
  }
244
0
245
0
  // Per spec, we init the parent's members first
246
0
  if (!UIEventInit::Init(cx, val)) {
247
0
    return false;
248
0
  }
249
0
250
0
  bool isNull = val.isNullOrUndefined();
251
0
  // We only need these if !isNull, in which case we have |cx|.
252
0
  Maybe<JS::Rooted<JSObject *> > object;
253
0
  Maybe<JS::Rooted<JS::Value> > temp;
254
0
  if (!isNull) {
255
0
    MOZ_ASSERT(cx);
256
0
    object.emplace(cx, &val.toObject());
257
0
    temp.emplace(cx);
258
0
  }
259
0
  if (!isNull) {
260
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->altKey_id, temp.ptr())) {
261
0
      return false;
262
0
    }
263
0
  }
264
0
  if (!isNull && !temp->isUndefined()) {
265
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAltKey)) {
266
0
      return false;
267
0
    }
268
0
  } else {
269
0
    mAltKey = false;
270
0
  }
271
0
  mIsAnyMemberPresent = true;
272
0
273
0
  if (!isNull) {
274
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->ctrlKey_id, temp.ptr())) {
275
0
      return false;
276
0
    }
277
0
  }
278
0
  if (!isNull && !temp->isUndefined()) {
279
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mCtrlKey)) {
280
0
      return false;
281
0
    }
282
0
  } else {
283
0
    mCtrlKey = false;
284
0
  }
285
0
  mIsAnyMemberPresent = true;
286
0
287
0
  if (!isNull) {
288
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->metaKey_id, temp.ptr())) {
289
0
      return false;
290
0
    }
291
0
  }
292
0
  if (!isNull && !temp->isUndefined()) {
293
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMetaKey)) {
294
0
      return false;
295
0
    }
296
0
  } else {
297
0
    mMetaKey = false;
298
0
  }
299
0
  mIsAnyMemberPresent = true;
300
0
301
0
  if (!isNull) {
302
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierAltGraph_id, temp.ptr())) {
303
0
      return false;
304
0
    }
305
0
  }
306
0
  if (!isNull && !temp->isUndefined()) {
307
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierAltGraph)) {
308
0
      return false;
309
0
    }
310
0
  } else {
311
0
    mModifierAltGraph = false;
312
0
  }
313
0
  mIsAnyMemberPresent = true;
314
0
315
0
  if (!isNull) {
316
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierCapsLock_id, temp.ptr())) {
317
0
      return false;
318
0
    }
319
0
  }
320
0
  if (!isNull && !temp->isUndefined()) {
321
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierCapsLock)) {
322
0
      return false;
323
0
    }
324
0
  } else {
325
0
    mModifierCapsLock = false;
326
0
  }
327
0
  mIsAnyMemberPresent = true;
328
0
329
0
  if (!isNull) {
330
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierFn_id, temp.ptr())) {
331
0
      return false;
332
0
    }
333
0
  }
334
0
  if (!isNull && !temp->isUndefined()) {
335
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierFn)) {
336
0
      return false;
337
0
    }
338
0
  } else {
339
0
    mModifierFn = false;
340
0
  }
341
0
  mIsAnyMemberPresent = true;
342
0
343
0
  if (!isNull) {
344
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierFnLock_id, temp.ptr())) {
345
0
      return false;
346
0
    }
347
0
  }
348
0
  if (!isNull && !temp->isUndefined()) {
349
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierFnLock)) {
350
0
      return false;
351
0
    }
352
0
  } else {
353
0
    mModifierFnLock = false;
354
0
  }
355
0
  mIsAnyMemberPresent = true;
356
0
357
0
  if (!isNull) {
358
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierNumLock_id, temp.ptr())) {
359
0
      return false;
360
0
    }
361
0
  }
362
0
  if (!isNull && !temp->isUndefined()) {
363
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierNumLock)) {
364
0
      return false;
365
0
    }
366
0
  } else {
367
0
    mModifierNumLock = false;
368
0
  }
369
0
  mIsAnyMemberPresent = true;
370
0
371
0
  if (!isNull) {
372
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierOS_id, temp.ptr())) {
373
0
      return false;
374
0
    }
375
0
  }
376
0
  if (!isNull && !temp->isUndefined()) {
377
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierOS)) {
378
0
      return false;
379
0
    }
380
0
  } else {
381
0
    mModifierOS = false;
382
0
  }
383
0
  mIsAnyMemberPresent = true;
384
0
385
0
  if (!isNull) {
386
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierScrollLock_id, temp.ptr())) {
387
0
      return false;
388
0
    }
389
0
  }
390
0
  if (!isNull && !temp->isUndefined()) {
391
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierScrollLock)) {
392
0
      return false;
393
0
    }
394
0
  } else {
395
0
    mModifierScrollLock = false;
396
0
  }
397
0
  mIsAnyMemberPresent = true;
398
0
399
0
  if (!isNull) {
400
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierSymbol_id, temp.ptr())) {
401
0
      return false;
402
0
    }
403
0
  }
404
0
  if (!isNull && !temp->isUndefined()) {
405
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierSymbol)) {
406
0
      return false;
407
0
    }
408
0
  } else {
409
0
    mModifierSymbol = false;
410
0
  }
411
0
  mIsAnyMemberPresent = true;
412
0
413
0
  if (!isNull) {
414
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->modifierSymbolLock_id, temp.ptr())) {
415
0
      return false;
416
0
    }
417
0
  }
418
0
  if (!isNull && !temp->isUndefined()) {
419
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierSymbolLock)) {
420
0
      return false;
421
0
    }
422
0
  } else {
423
0
    mModifierSymbolLock = false;
424
0
  }
425
0
  mIsAnyMemberPresent = true;
426
0
427
0
  if (!isNull) {
428
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->shiftKey_id, temp.ptr())) {
429
0
      return false;
430
0
    }
431
0
  }
432
0
  if (!isNull && !temp->isUndefined()) {
433
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mShiftKey)) {
434
0
      return false;
435
0
    }
436
0
  } else {
437
0
    mShiftKey = false;
438
0
  }
439
0
  mIsAnyMemberPresent = true;
440
0
  return true;
441
0
}
442
443
bool
444
EventModifierInit::Init(const nsAString& aJSON)
445
0
{
446
0
  AutoJSAPI jsapi;
447
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
448
0
  if (!cleanGlobal) {
449
0
    return false;
450
0
  }
451
0
  if (!jsapi.Init(cleanGlobal)) {
452
0
    return false;
453
0
  }
454
0
  JSContext* cx = jsapi.cx();
455
0
  JS::Rooted<JS::Value> json(cx);
456
0
  bool ok = ParseJSON(cx, aJSON, &json);
457
0
  NS_ENSURE_TRUE(ok, false);
458
0
  return Init(cx, json);
459
0
}
460
461
bool
462
EventModifierInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
463
0
{
464
0
  EventModifierInitAtoms* atomsCache = GetAtomCache<EventModifierInitAtoms>(cx);
465
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
466
0
    return false;
467
0
  }
468
0
469
0
  // Per spec, we define the parent's members first
470
0
  if (!UIEventInit::ToObjectInternal(cx, rval)) {
471
0
    return false;
472
0
  }
473
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
474
0
475
0
  do {
476
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
477
0
    JS::Rooted<JS::Value> temp(cx);
478
0
    bool const & currentValue = mAltKey;
479
0
    temp.setBoolean(currentValue);
480
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->altKey_id, temp, JSPROP_ENUMERATE)) {
481
0
      return false;
482
0
    }
483
0
    break;
484
0
  } while(false);
485
0
486
0
  do {
487
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
488
0
    JS::Rooted<JS::Value> temp(cx);
489
0
    bool const & currentValue = mCtrlKey;
490
0
    temp.setBoolean(currentValue);
491
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->ctrlKey_id, temp, JSPROP_ENUMERATE)) {
492
0
      return false;
493
0
    }
494
0
    break;
495
0
  } while(false);
496
0
497
0
  do {
498
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
499
0
    JS::Rooted<JS::Value> temp(cx);
500
0
    bool const & currentValue = mMetaKey;
501
0
    temp.setBoolean(currentValue);
502
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->metaKey_id, temp, JSPROP_ENUMERATE)) {
503
0
      return false;
504
0
    }
505
0
    break;
506
0
  } while(false);
507
0
508
0
  do {
509
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
510
0
    JS::Rooted<JS::Value> temp(cx);
511
0
    bool const & currentValue = mModifierAltGraph;
512
0
    temp.setBoolean(currentValue);
513
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierAltGraph_id, temp, JSPROP_ENUMERATE)) {
514
0
      return false;
515
0
    }
516
0
    break;
517
0
  } while(false);
518
0
519
0
  do {
520
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
521
0
    JS::Rooted<JS::Value> temp(cx);
522
0
    bool const & currentValue = mModifierCapsLock;
523
0
    temp.setBoolean(currentValue);
524
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierCapsLock_id, temp, JSPROP_ENUMERATE)) {
525
0
      return false;
526
0
    }
527
0
    break;
528
0
  } while(false);
529
0
530
0
  do {
531
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
532
0
    JS::Rooted<JS::Value> temp(cx);
533
0
    bool const & currentValue = mModifierFn;
534
0
    temp.setBoolean(currentValue);
535
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierFn_id, temp, JSPROP_ENUMERATE)) {
536
0
      return false;
537
0
    }
538
0
    break;
539
0
  } while(false);
540
0
541
0
  do {
542
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
543
0
    JS::Rooted<JS::Value> temp(cx);
544
0
    bool const & currentValue = mModifierFnLock;
545
0
    temp.setBoolean(currentValue);
546
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierFnLock_id, temp, JSPROP_ENUMERATE)) {
547
0
      return false;
548
0
    }
549
0
    break;
550
0
  } while(false);
551
0
552
0
  do {
553
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
554
0
    JS::Rooted<JS::Value> temp(cx);
555
0
    bool const & currentValue = mModifierNumLock;
556
0
    temp.setBoolean(currentValue);
557
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierNumLock_id, temp, JSPROP_ENUMERATE)) {
558
0
      return false;
559
0
    }
560
0
    break;
561
0
  } while(false);
562
0
563
0
  do {
564
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
565
0
    JS::Rooted<JS::Value> temp(cx);
566
0
    bool const & currentValue = mModifierOS;
567
0
    temp.setBoolean(currentValue);
568
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierOS_id, temp, JSPROP_ENUMERATE)) {
569
0
      return false;
570
0
    }
571
0
    break;
572
0
  } while(false);
573
0
574
0
  do {
575
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
576
0
    JS::Rooted<JS::Value> temp(cx);
577
0
    bool const & currentValue = mModifierScrollLock;
578
0
    temp.setBoolean(currentValue);
579
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierScrollLock_id, temp, JSPROP_ENUMERATE)) {
580
0
      return false;
581
0
    }
582
0
    break;
583
0
  } while(false);
584
0
585
0
  do {
586
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
587
0
    JS::Rooted<JS::Value> temp(cx);
588
0
    bool const & currentValue = mModifierSymbol;
589
0
    temp.setBoolean(currentValue);
590
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierSymbol_id, temp, JSPROP_ENUMERATE)) {
591
0
      return false;
592
0
    }
593
0
    break;
594
0
  } while(false);
595
0
596
0
  do {
597
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
598
0
    JS::Rooted<JS::Value> temp(cx);
599
0
    bool const & currentValue = mModifierSymbolLock;
600
0
    temp.setBoolean(currentValue);
601
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierSymbolLock_id, temp, JSPROP_ENUMERATE)) {
602
0
      return false;
603
0
    }
604
0
    break;
605
0
  } while(false);
606
0
607
0
  do {
608
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
609
0
    JS::Rooted<JS::Value> temp(cx);
610
0
    bool const & currentValue = mShiftKey;
611
0
    temp.setBoolean(currentValue);
612
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->shiftKey_id, temp, JSPROP_ENUMERATE)) {
613
0
      return false;
614
0
    }
615
0
    break;
616
0
  } while(false);
617
0
618
0
  return true;
619
0
}
620
621
bool
622
EventModifierInit::ToJSON(nsAString& aJSON) const
623
0
{
624
0
  AutoJSAPI jsapi;
625
0
  jsapi.Init();
626
0
  JSContext *cx = jsapi.cx();
627
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
628
0
  // because we'll only be creating objects, in ways that have no
629
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
630
0
  // which likewise guarantees no side-effects for the sorts of
631
0
  // things we will pass it.
632
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
633
0
  JS::Rooted<JS::Value> val(cx);
634
0
  if (!ToObjectInternal(cx, &val)) {
635
0
    return false;
636
0
  }
637
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
638
0
  return StringifyToJSON(cx, obj, aJSON);
639
0
}
640
641
void
642
EventModifierInit::TraceDictionary(JSTracer* trc)
643
0
{
644
0
  UIEventInit::TraceDictionary(trc);
645
0
}
646
647
648
649
EventModifierInit&
650
EventModifierInit::operator=(const EventModifierInit& aOther)
651
0
{
652
0
  UIEventInit::operator=(aOther);
653
0
  mAltKey = aOther.mAltKey;
654
0
  mCtrlKey = aOther.mCtrlKey;
655
0
  mMetaKey = aOther.mMetaKey;
656
0
  mModifierAltGraph = aOther.mModifierAltGraph;
657
0
  mModifierCapsLock = aOther.mModifierCapsLock;
658
0
  mModifierFn = aOther.mModifierFn;
659
0
  mModifierFnLock = aOther.mModifierFnLock;
660
0
  mModifierNumLock = aOther.mModifierNumLock;
661
0
  mModifierOS = aOther.mModifierOS;
662
0
  mModifierScrollLock = aOther.mModifierScrollLock;
663
0
  mModifierSymbol = aOther.mModifierSymbol;
664
0
  mModifierSymbolLock = aOther.mModifierSymbolLock;
665
0
  mShiftKey = aOther.mShiftKey;
666
0
  return *this;
667
0
}
668
669
namespace binding_detail {
670
} // namespace binding_detail
671
672
673
namespace UIEvent_Binding {
674
675
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value,
676
              "Can't inherit from an interface with a different ownership model.");
677
678
MOZ_CAN_RUN_SCRIPT static bool
679
get_view(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
680
0
{
681
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.view", DOM, cx);
682
0
683
0
  auto result(StrongOrRawPtr<nsPIDOMWindowOuter>(self->GetView()));
684
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
685
0
  if (!result) {
686
0
    args.rval().setNull();
687
0
    return true;
688
0
  }
689
0
  if (!WrapObject(cx, result, args.rval())) {
690
0
    return false;
691
0
  }
692
0
  return true;
693
0
}
694
695
static const JSJitInfo view_getterinfo = {
696
  { (JSJitGetterOp)get_view },
697
  { prototypes::id::UIEvent },
698
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
699
  JSJitInfo::Getter,
700
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
701
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
702
  false,  /* isInfallible. False in setters. */
703
  false,  /* isMovable.  Not relevant for setters. */
704
  false, /* isEliminatable.  Not relevant for setters. */
705
  false, /* isAlwaysInSlot.  Only relevant for getters. */
706
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
707
  false,  /* isTypedMethod.  Only relevant for methods. */
708
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
709
};
710
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
711
static_assert(0 < 1, "There is no slot for us");
712
713
MOZ_CAN_RUN_SCRIPT static bool
714
get_detail(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
715
0
{
716
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.detail", DOM, cx);
717
0
718
0
  int32_t result(self->Detail());
719
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
720
0
  args.rval().setInt32(int32_t(result));
721
0
  return true;
722
0
}
723
724
static const JSJitInfo detail_getterinfo = {
725
  { (JSJitGetterOp)get_detail },
726
  { prototypes::id::UIEvent },
727
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
728
  JSJitInfo::Getter,
729
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
730
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
731
  true,  /* isInfallible. False in setters. */
732
  false,  /* isMovable.  Not relevant for setters. */
733
  false, /* isEliminatable.  Not relevant for setters. */
734
  false, /* isAlwaysInSlot.  Only relevant for getters. */
735
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
736
  false,  /* isTypedMethod.  Only relevant for methods. */
737
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
738
};
739
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
740
static_assert(0 < 1, "There is no slot for us");
741
742
MOZ_CAN_RUN_SCRIPT static bool
743
initUIEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, const JSJitMethodCallArgs& args)
744
0
{
745
0
  AUTO_PROFILER_LABEL_FAST("UIEvent.initUIEvent", DOM, cx);
746
0
747
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
748
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "UIEvent.initUIEvent");
749
0
  }
750
0
  binding_detail::FakeString arg0;
751
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
752
0
    return false;
753
0
  }
754
0
  bool arg1;
755
0
  if (args.hasDefined(1)) {
756
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
757
0
      return false;
758
0
    }
759
0
  } else {
760
0
    arg1 = false;
761
0
  }
762
0
  bool arg2;
763
0
  if (args.hasDefined(2)) {
764
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
765
0
      return false;
766
0
    }
767
0
  } else {
768
0
    arg2 = false;
769
0
  }
770
0
  nsGlobalWindowInner* arg3;
771
0
  if (args.hasDefined(3)) {
772
0
    if (args[3].isObject()) {
773
0
      {
774
0
        nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(args[3], arg3);
775
0
        if (NS_FAILED(rv)) {
776
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of UIEvent.initUIEvent", "Window");
777
0
          return false;
778
0
        }
779
0
      }
780
0
    } else if (args[3].isNullOrUndefined()) {
781
0
      arg3 = nullptr;
782
0
    } else {
783
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of UIEvent.initUIEvent");
784
0
      return false;
785
0
    }
786
0
  } else {
787
0
    arg3 = nullptr;
788
0
  }
789
0
  int32_t arg4;
790
0
  if (args.hasDefined(4)) {
791
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
792
0
      return false;
793
0
    }
794
0
  } else {
795
0
    arg4 = 0;
796
0
  }
797
0
  self->InitUIEvent(NonNullHelper(Constify(arg0)), arg1, arg2, MOZ_KnownLive(Constify(arg3)), arg4);
798
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
799
0
  args.rval().setUndefined();
800
0
  return true;
801
0
}
802
803
static const JSJitInfo initUIEvent_methodinfo = {
804
  { (JSJitGetterOp)initUIEvent },
805
  { prototypes::id::UIEvent },
806
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
807
  JSJitInfo::Method,
808
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
809
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
810
  false,  /* isInfallible. False in setters. */
811
  false,  /* isMovable.  Not relevant for setters. */
812
  false, /* isEliminatable.  Not relevant for setters. */
813
  false, /* isAlwaysInSlot.  Only relevant for getters. */
814
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
815
  false,  /* isTypedMethod.  Only relevant for methods. */
816
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
817
};
818
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
819
static_assert(0 < 1, "There is no slot for us");
820
821
MOZ_CAN_RUN_SCRIPT static bool
822
get_layerX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
823
0
{
824
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.layerX", DOM, cx);
825
0
826
0
  int32_t result(self->LayerX());
827
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
828
0
  args.rval().setInt32(int32_t(result));
829
0
  return true;
830
0
}
831
832
static const JSJitInfo layerX_getterinfo = {
833
  { (JSJitGetterOp)get_layerX },
834
  { prototypes::id::UIEvent },
835
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
836
  JSJitInfo::Getter,
837
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
838
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
839
  true,  /* isInfallible. False in setters. */
840
  false,  /* isMovable.  Not relevant for setters. */
841
  false, /* isEliminatable.  Not relevant for setters. */
842
  false, /* isAlwaysInSlot.  Only relevant for getters. */
843
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
844
  false,  /* isTypedMethod.  Only relevant for methods. */
845
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
846
};
847
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
848
static_assert(0 < 1, "There is no slot for us");
849
850
MOZ_CAN_RUN_SCRIPT static bool
851
get_layerY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
852
0
{
853
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.layerY", DOM, cx);
854
0
855
0
  int32_t result(self->LayerY());
856
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
857
0
  args.rval().setInt32(int32_t(result));
858
0
  return true;
859
0
}
860
861
static const JSJitInfo layerY_getterinfo = {
862
  { (JSJitGetterOp)get_layerY },
863
  { prototypes::id::UIEvent },
864
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
865
  JSJitInfo::Getter,
866
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
867
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
868
  true,  /* isInfallible. False in setters. */
869
  false,  /* isMovable.  Not relevant for setters. */
870
  false, /* isEliminatable.  Not relevant for setters. */
871
  false, /* isAlwaysInSlot.  Only relevant for getters. */
872
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
873
  false,  /* isTypedMethod.  Only relevant for methods. */
874
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
875
};
876
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
877
static_assert(0 < 1, "There is no slot for us");
878
879
MOZ_CAN_RUN_SCRIPT static bool
880
get_pageX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
881
0
{
882
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.pageX", DOM, cx);
883
0
884
0
  int32_t result(self->PageX());
885
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
886
0
  args.rval().setInt32(int32_t(result));
887
0
  return true;
888
0
}
889
890
static const JSJitInfo pageX_getterinfo = {
891
  { (JSJitGetterOp)get_pageX },
892
  { prototypes::id::UIEvent },
893
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
894
  JSJitInfo::Getter,
895
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
896
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
897
  true,  /* isInfallible. False in setters. */
898
  false,  /* isMovable.  Not relevant for setters. */
899
  false, /* isEliminatable.  Not relevant for setters. */
900
  false, /* isAlwaysInSlot.  Only relevant for getters. */
901
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
902
  false,  /* isTypedMethod.  Only relevant for methods. */
903
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
904
};
905
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
906
static_assert(0 < 1, "There is no slot for us");
907
908
MOZ_CAN_RUN_SCRIPT static bool
909
get_pageY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
910
0
{
911
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.pageY", DOM, cx);
912
0
913
0
  int32_t result(self->PageY());
914
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
915
0
  args.rval().setInt32(int32_t(result));
916
0
  return true;
917
0
}
918
919
static const JSJitInfo pageY_getterinfo = {
920
  { (JSJitGetterOp)get_pageY },
921
  { prototypes::id::UIEvent },
922
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
923
  JSJitInfo::Getter,
924
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
925
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
926
  true,  /* isInfallible. False in setters. */
927
  false,  /* isMovable.  Not relevant for setters. */
928
  false, /* isEliminatable.  Not relevant for setters. */
929
  false, /* isAlwaysInSlot.  Only relevant for getters. */
930
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
931
  false,  /* isTypedMethod.  Only relevant for methods. */
932
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
933
};
934
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
935
static_assert(0 < 1, "There is no slot for us");
936
937
MOZ_CAN_RUN_SCRIPT static bool
938
get_which(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
939
0
{
940
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.which", DOM, cx);
941
0
942
0
  uint32_t result(self->Which(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
943
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
944
0
  args.rval().setNumber(result);
945
0
  return true;
946
0
}
947
948
static const JSJitInfo which_getterinfo = {
949
  { (JSJitGetterOp)get_which },
950
  { prototypes::id::UIEvent },
951
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
952
  JSJitInfo::Getter,
953
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
954
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
955
  true,  /* isInfallible. False in setters. */
956
  false,  /* isMovable.  Not relevant for setters. */
957
  false, /* isEliminatable.  Not relevant for setters. */
958
  false, /* isAlwaysInSlot.  Only relevant for getters. */
959
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
960
  false,  /* isTypedMethod.  Only relevant for methods. */
961
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
962
};
963
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
964
static_assert(0 < 1, "There is no slot for us");
965
966
MOZ_CAN_RUN_SCRIPT static bool
967
get_rangeParent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
968
0
{
969
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.rangeParent", DOM, cx);
970
0
971
0
  auto result(StrongOrRawPtr<nsINode>(self->GetRangeParent()));
972
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
973
0
  if (!result) {
974
0
    args.rval().setNull();
975
0
    return true;
976
0
  }
977
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
978
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
979
0
    return false;
980
0
  }
981
0
  return true;
982
0
}
983
984
static const JSJitInfo rangeParent_getterinfo = {
985
  { (JSJitGetterOp)get_rangeParent },
986
  { prototypes::id::UIEvent },
987
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
988
  JSJitInfo::Getter,
989
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
990
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
991
  false,  /* isInfallible. False in setters. */
992
  false,  /* isMovable.  Not relevant for setters. */
993
  false, /* isEliminatable.  Not relevant for setters. */
994
  false, /* isAlwaysInSlot.  Only relevant for getters. */
995
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
996
  false,  /* isTypedMethod.  Only relevant for methods. */
997
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
998
};
999
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1000
static_assert(0 < 1, "There is no slot for us");
1001
1002
MOZ_CAN_RUN_SCRIPT static bool
1003
get_rangeOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
1004
0
{
1005
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.rangeOffset", DOM, cx);
1006
0
1007
0
  int32_t result(self->RangeOffset());
1008
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1009
0
  args.rval().setInt32(int32_t(result));
1010
0
  return true;
1011
0
}
1012
1013
static const JSJitInfo rangeOffset_getterinfo = {
1014
  { (JSJitGetterOp)get_rangeOffset },
1015
  { prototypes::id::UIEvent },
1016
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
1017
  JSJitInfo::Getter,
1018
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1019
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
1020
  true,  /* isInfallible. False in setters. */
1021
  false,  /* isMovable.  Not relevant for setters. */
1022
  false, /* isEliminatable.  Not relevant for setters. */
1023
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1024
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1025
  false,  /* isTypedMethod.  Only relevant for methods. */
1026
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1027
};
1028
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1029
static_assert(0 < 1, "There is no slot for us");
1030
1031
MOZ_CAN_RUN_SCRIPT static bool
1032
get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
1033
0
{
1034
0
  AUTO_PROFILER_LABEL_FAST("get UIEvent.isTrusted", DOM, cx);
1035
0
1036
0
  bool result(self->IsTrusted());
1037
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1038
0
  args.rval().setBoolean(result);
1039
0
  return true;
1040
0
}
1041
1042
static const JSJitInfo isTrusted_getterinfo = {
1043
  { (JSJitGetterOp)get_isTrusted },
1044
  { prototypes::id::UIEvent },
1045
  { PrototypeTraits<prototypes::id::UIEvent>::Depth },
1046
  JSJitInfo::Getter,
1047
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1048
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1049
  true,  /* isInfallible. False in setters. */
1050
  true,  /* isMovable.  Not relevant for setters. */
1051
  true, /* isEliminatable.  Not relevant for setters. */
1052
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1053
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1054
  false,  /* isTypedMethod.  Only relevant for methods. */
1055
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1056
};
1057
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1058
static_assert(0 < 1, "There is no slot for us");
1059
1060
static bool
1061
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1062
0
{
1063
0
  mozilla::dom::UIEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::UIEvent>(obj);
1064
0
  // We don't want to preserve if we don't have a wrapper, and we
1065
0
  // obviously can't preserve if we're not initialized.
1066
0
  if (self && self->GetWrapperPreserveColor()) {
1067
0
    PreserveWrapper(self);
1068
0
  }
1069
0
  return true;
1070
0
}
1071
1072
static void
1073
_finalize(js::FreeOp* fop, JSObject* obj)
1074
0
{
1075
0
  mozilla::dom::UIEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::UIEvent>(obj);
1076
0
  if (self) {
1077
0
    ClearWrapper(self, self, obj);
1078
0
    AddForDeferredFinalization<mozilla::dom::UIEvent>(self);
1079
0
  }
1080
0
}
1081
1082
static size_t
1083
_objectMoved(JSObject* obj, JSObject* old)
1084
0
{
1085
0
  mozilla::dom::UIEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::UIEvent>(obj);
1086
0
  if (self) {
1087
0
    UpdateWrapper(self, self, obj, old);
1088
0
  }
1089
0
1090
0
  return 0;
1091
0
}
1092
1093
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1094
#if defined(__clang__)
1095
#pragma clang diagnostic push
1096
#pragma clang diagnostic ignored "-Wmissing-braces"
1097
#endif
1098
static const JSFunctionSpec sMethods_specs[] = {
1099
  JS_FNSPEC("initUIEvent", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&initUIEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1100
  JS_FS_END
1101
};
1102
#if defined(__clang__)
1103
#pragma clang diagnostic pop
1104
#endif
1105
1106
1107
static const Prefable<const JSFunctionSpec> sMethods[] = {
1108
  { nullptr, &sMethods_specs[0] },
1109
  { nullptr, nullptr }
1110
};
1111
1112
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1113
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1114
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1115
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1116
1117
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1118
#if defined(__clang__)
1119
#pragma clang diagnostic push
1120
#pragma clang diagnostic ignored "-Wmissing-braces"
1121
#endif
1122
static const JSPropertySpec sAttributes_specs[] = {
1123
  { "view", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &view_getterinfo, nullptr, nullptr },
1124
  { "detail", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &detail_getterinfo, nullptr, nullptr },
1125
  { "layerX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &layerX_getterinfo, nullptr, nullptr },
1126
  { "layerY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &layerY_getterinfo, nullptr, nullptr },
1127
  { "pageX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pageX_getterinfo, nullptr, nullptr },
1128
  { "pageY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pageY_getterinfo, nullptr, nullptr },
1129
  { "which", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &which_getterinfo, nullptr, nullptr },
1130
  { "rangeParent", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rangeParent_getterinfo, nullptr, nullptr },
1131
  { "rangeOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rangeOffset_getterinfo, nullptr, nullptr },
1132
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1133
};
1134
#if defined(__clang__)
1135
#pragma clang diagnostic pop
1136
#endif
1137
1138
1139
static const Prefable<const JSPropertySpec> sAttributes[] = {
1140
  { nullptr, &sAttributes_specs[0] },
1141
  { nullptr, nullptr }
1142
};
1143
1144
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1145
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1146
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1147
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1148
1149
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1150
#if defined(__clang__)
1151
#pragma clang diagnostic push
1152
#pragma clang diagnostic ignored "-Wmissing-braces"
1153
#endif
1154
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
1155
  { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr },
1156
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1157
};
1158
#if defined(__clang__)
1159
#pragma clang diagnostic pop
1160
#endif
1161
1162
1163
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
1164
  { nullptr, &sUnforgeableAttributes_specs[0] },
1165
  { nullptr, nullptr }
1166
};
1167
1168
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1169
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1170
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1171
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1172
1173
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1174
#if defined(__clang__)
1175
#pragma clang diagnostic push
1176
#pragma clang diagnostic ignored "-Wmissing-braces"
1177
#endif
1178
static const ConstantSpec sConstants_specs[] = {
1179
  { "SCROLL_PAGE_UP", JS::Int32Value(-32768) },
1180
  { "SCROLL_PAGE_DOWN", JS::Int32Value(32768) },
1181
  { 0, JS::UndefinedValue() }
1182
};
1183
#if defined(__clang__)
1184
#pragma clang diagnostic pop
1185
#endif
1186
1187
1188
static const Prefable<const ConstantSpec> sConstants[] = {
1189
  { nullptr, &sConstants_specs[0] },
1190
  { nullptr, nullptr }
1191
};
1192
1193
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1194
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1195
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1196
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1197
1198
1199
static uint16_t sNativeProperties_sortedPropertyIndices[13];
1200
static PropertyInfo sNativeProperties_propertyInfos[13];
1201
1202
static const NativePropertiesN<4> sNativeProperties = {
1203
  false, 0,
1204
  false, 0,
1205
  true,  0 /* sMethods */,
1206
  true,  1 /* sAttributes */,
1207
  false, 0,
1208
  true,  2 /* sUnforgeableAttributes */,
1209
  true,  3 /* sConstants */,
1210
  -1,
1211
  13,
1212
  sNativeProperties_sortedPropertyIndices,
1213
  {
1214
    { sMethods, &sNativeProperties_propertyInfos[0] },
1215
    { sAttributes, &sNativeProperties_propertyInfos[1] },
1216
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[10] },
1217
    { sConstants, &sNativeProperties_propertyInfos[11] }
1218
  }
1219
};
1220
static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1221
    "We have a property info count that is oversized");
1222
1223
static bool
1224
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1225
0
{
1226
0
  AUTO_PROFILER_LABEL_FAST("UIEvent constructor", DOM, cx);
1227
0
1228
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1229
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1230
0
  if (!args.isConstructing()) {
1231
0
    // XXXbz wish I could get the name from the callee instead of
1232
0
    // Adding more relocations
1233
0
    return ThrowConstructorWithoutNew(cx, "UIEvent");
1234
0
  }
1235
0
1236
0
  JS::Rooted<JSObject*> desiredProto(cx);
1237
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1238
0
    return false;
1239
0
  }
1240
0
1241
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1242
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "UIEvent");
1243
0
  }
1244
0
  GlobalObject global(cx, obj);
1245
0
  if (global.Failed()) {
1246
0
    return false;
1247
0
  }
1248
0
1249
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1250
0
  binding_detail::FakeString arg0;
1251
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1252
0
    return false;
1253
0
  }
1254
0
  binding_detail::FastUIEventInit arg1;
1255
0
  if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of UIEvent.constructor", false)) {
1256
0
    return false;
1257
0
  }
1258
0
  Maybe<JSAutoRealm> ar;
1259
0
  if (objIsXray) {
1260
0
    obj = js::CheckedUnwrap(obj);
1261
0
    if (!obj) {
1262
0
      return false;
1263
0
    }
1264
0
    ar.emplace(cx, obj);
1265
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1266
0
      return false;
1267
0
    }
1268
0
  }
1269
0
  FastErrorResult rv;
1270
0
  auto result(StrongOrRawPtr<mozilla::dom::UIEvent>(mozilla::dom::UIEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
1271
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1272
0
    return false;
1273
0
  }
1274
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1275
0
  static_assert(!IsPointer<decltype(result)>::value,
1276
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1277
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1278
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1279
0
    return false;
1280
0
  }
1281
0
  return true;
1282
0
}
1283
1284
static const js::ClassOps sInterfaceObjectClassOps = {
1285
    nullptr,               /* addProperty */
1286
    nullptr,               /* delProperty */
1287
    nullptr,               /* enumerate */
1288
    nullptr,               /* newEnumerate */
1289
    nullptr,               /* resolve */
1290
    nullptr,               /* mayResolve */
1291
    nullptr,               /* finalize */
1292
    _constructor, /* call */
1293
    nullptr,               /* hasInstance */
1294
    _constructor, /* construct */
1295
    nullptr,               /* trace */
1296
};
1297
1298
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1299
  {
1300
    "Function",
1301
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1302
    &sInterfaceObjectClassOps,
1303
    JS_NULL_CLASS_SPEC,
1304
    JS_NULL_CLASS_EXT,
1305
    &sInterfaceObjectClassObjectOps
1306
  },
1307
  eInterface,
1308
  true,
1309
  prototypes::id::UIEvent,
1310
  PrototypeTraits<prototypes::id::UIEvent>::Depth,
1311
  sNativePropertyHooks,
1312
  "function UIEvent() {\n    [native code]\n}",
1313
  Event_Binding::GetConstructorObject
1314
};
1315
1316
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1317
  {
1318
    "UIEventPrototype",
1319
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
1320
    JS_NULL_CLASS_OPS,
1321
    JS_NULL_CLASS_SPEC,
1322
    JS_NULL_CLASS_EXT,
1323
    JS_NULL_OBJECT_OPS
1324
  },
1325
  eInterfacePrototype,
1326
  false,
1327
  prototypes::id::UIEvent,
1328
  PrototypeTraits<prototypes::id::UIEvent>::Depth,
1329
  sNativePropertyHooks,
1330
  "[object UIEventPrototype]",
1331
  Event_Binding::GetProtoObject
1332
};
1333
1334
static const js::ClassOps sClassOps = {
1335
  _addProperty, /* addProperty */
1336
  nullptr,               /* delProperty */
1337
  nullptr,               /* enumerate */
1338
  nullptr, /* newEnumerate */
1339
  nullptr, /* resolve */
1340
  nullptr, /* mayResolve */
1341
  _finalize, /* finalize */
1342
  nullptr, /* call */
1343
  nullptr,               /* hasInstance */
1344
  nullptr,               /* construct */
1345
  nullptr, /* trace */
1346
};
1347
1348
static const js::ClassExtension sClassExtension = {
1349
  nullptr, /* weakmapKeyDelegateOp */
1350
  _objectMoved /* objectMovedOp */
1351
};
1352
1353
static const DOMJSClass sClass = {
1354
  { "UIEvent",
1355
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
1356
    &sClassOps,
1357
    JS_NULL_CLASS_SPEC,
1358
    &sClassExtension,
1359
    JS_NULL_OBJECT_OPS
1360
  },
1361
  { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1362
  IsBaseOf<nsISupports, mozilla::dom::UIEvent >::value,
1363
  sNativePropertyHooks,
1364
  FindAssociatedGlobalForNative<mozilla::dom::UIEvent>::Get,
1365
  GetProtoObjectHandle,
1366
  GetCCParticipant<mozilla::dom::UIEvent>::Get()
1367
};
1368
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1369
              "Must have the right minimal number of reserved slots.");
1370
static_assert(1 >= 1,
1371
              "Must have enough reserved slots.");
1372
1373
const JSClass*
1374
GetJSClass()
1375
0
{
1376
0
  return sClass.ToJSClass();
1377
0
}
1378
1379
bool
1380
Wrap(JSContext* aCx, mozilla::dom::UIEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1381
0
{
1382
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::UIEvent>::value,
1383
0
                "Shouldn't have wrappercached things that are not refcounted.");
1384
0
  MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
1385
0
             reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
1386
0
             "Multiple inheritance for mozilla::dom::UIEvent is broken.");
1387
0
  MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
1388
0
             reinterpret_cast<mozilla::dom::Event*>(aObject),
1389
0
             "Multiple inheritance for mozilla::dom::Event is broken.");
1390
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1391
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1392
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1393
0
             "You should probably not be using Wrap() directly; use "
1394
0
             "GetOrCreateDOMReflector instead");
1395
0
1396
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1397
0
             "nsISupports must be on our primary inheritance chain");
1398
0
1399
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1400
0
  if (!global) {
1401
0
    return false;
1402
0
  }
1403
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1404
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1405
0
1406
0
  // That might have ended up wrapping us already, due to the wonders
1407
0
  // of XBL.  Check for that, and bail out as needed.
1408
0
  aReflector.set(aCache->GetWrapper());
1409
0
  if (aReflector) {
1410
#ifdef DEBUG
1411
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1412
#endif // DEBUG
1413
    return true;
1414
0
  }
1415
0
1416
0
  JSAutoRealm ar(aCx, global);
1417
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1418
0
  if (!canonicalProto) {
1419
0
    return false;
1420
0
  }
1421
0
  JS::Rooted<JSObject*> proto(aCx);
1422
0
  if (aGivenProto) {
1423
0
    proto = aGivenProto;
1424
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1425
0
    // coming in, we changed compartments to that of "parent" so may need
1426
0
    // to wrap the proto here.
1427
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1428
0
      if (!JS_WrapObject(aCx, &proto)) {
1429
0
        return false;
1430
0
      }
1431
0
    }
1432
0
  } else {
1433
0
    proto = canonicalProto;
1434
0
  }
1435
0
1436
0
  BindingJSObjectCreator<mozilla::dom::UIEvent> creator(aCx);
1437
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1438
0
  if (!aReflector) {
1439
0
    return false;
1440
0
  }
1441
0
1442
0
  aCache->SetWrapper(aReflector);
1443
0
1444
0
  // Important: do unforgeable property setup after we have handed
1445
0
  // over ownership of the C++ object to obj as needed, so that if
1446
0
  // we fail and it ends up GCed it won't have problems in the
1447
0
  // finalizer trying to drop its ownership of the C++ object.
1448
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
1449
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
1450
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
1451
0
    aCache->ReleaseWrapper(aObject);
1452
0
    aCache->ClearWrapper();
1453
0
    return false;
1454
0
  }
1455
0
  creator.InitializationSucceeded();
1456
0
1457
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1458
0
             aCache->GetWrapperPreserveColor() == aReflector);
1459
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1460
0
  // otherwise we won't be able to properly recreate it later, since
1461
0
  // we won't know what proto to use.  Note that we don't check
1462
0
  // aGivenProto here, since it's entirely possible (and even
1463
0
  // somewhat common) to have a non-null aGivenProto which is the
1464
0
  // same as canonicalProto.
1465
0
  if (proto != canonicalProto) {
1466
0
    PreserveWrapper(aObject);
1467
0
  }
1468
0
1469
0
  return true;
1470
0
}
1471
1472
const NativePropertyHooks sNativePropertyHooks[] = { {
1473
  nullptr,
1474
  nullptr,
1475
  nullptr,
1476
  { sNativeProperties.Upcast(), nullptr },
1477
  prototypes::id::UIEvent,
1478
  constructors::id::UIEvent,
1479
  Event_Binding::sNativePropertyHooks,
1480
  &DefaultXrayExpandoObjectClass
1481
} };
1482
1483
void
1484
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1485
0
{
1486
0
  JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx));
1487
0
  if (!parentProto) {
1488
0
    return;
1489
0
  }
1490
0
1491
0
  JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx));
1492
0
  if (!constructorProto) {
1493
0
    return;
1494
0
  }
1495
0
1496
0
  static bool sIdsInited = false;
1497
0
  if (!sIdsInited && NS_IsMainThread()) {
1498
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1499
0
      return;
1500
0
    }
1501
0
    sIdsInited = true;
1502
0
  }
1503
0
1504
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::UIEvent);
1505
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::UIEvent);
1506
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1507
0
                              &sPrototypeClass.mBase, protoCache,
1508
0
                              nullptr,
1509
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1510
0
                              interfaceCache,
1511
0
                              sNativeProperties.Upcast(),
1512
0
                              nullptr,
1513
0
                              "UIEvent", aDefineOnGlobal,
1514
0
                              nullptr,
1515
0
                              false);
1516
0
1517
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
1518
0
  {
1519
0
    JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1520
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1521
0
    if (!unforgeableHolder) {
1522
0
      *protoCache = nullptr;
1523
0
      if (interfaceCache) {
1524
0
        *interfaceCache = nullptr;
1525
0
      }
1526
0
      return;
1527
0
    }
1528
0
  }
1529
0
1530
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1531
0
    *protoCache = nullptr;
1532
0
    if (interfaceCache) {
1533
0
      *interfaceCache = nullptr;
1534
0
    }
1535
0
    return;
1536
0
  }
1537
0
1538
0
  if (*protoCache) {
1539
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1540
0
                        JS::ObjectValue(*unforgeableHolder));
1541
0
  }
1542
0
}
1543
1544
JSObject*
1545
GetProtoObject(JSContext* aCx)
1546
0
{
1547
0
  return GetProtoObjectHandle(aCx);
1548
0
}
1549
1550
JSObject*
1551
GetConstructorObject(JSContext* aCx)
1552
0
{
1553
0
  return GetConstructorObjectHandle(aCx);
1554
0
}
1555
1556
} // namespace UIEvent_Binding
1557
1558
1559
1560
} // namespace dom
1561
} // namespace mozilla