Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/MouseEventBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM MouseEvent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "MouseEventBinding.h"
5
#include "UIEventBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/EventTarget.h"
12
#include "mozilla/dom/MouseEvent.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/ScriptSettings.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
MouseEventInit::MouseEventInit()
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
MouseEventInit::InitIds(JSContext* cx, MouseEventInitAtoms* 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->screenY_id.init(cx, "screenY") ||
46
0
      !atomsCache->screenX_id.init(cx, "screenX") ||
47
0
      !atomsCache->relatedTarget_id.init(cx, "relatedTarget") ||
48
0
      !atomsCache->movementY_id.init(cx, "movementY") ||
49
0
      !atomsCache->movementX_id.init(cx, "movementX") ||
50
0
      !atomsCache->clientY_id.init(cx, "clientY") ||
51
0
      !atomsCache->clientX_id.init(cx, "clientX") ||
52
0
      !atomsCache->buttons_id.init(cx, "buttons") ||
53
0
      !atomsCache->button_id.init(cx, "button")) {
54
0
    return false;
55
0
  }
56
0
  return true;
57
0
}
58
59
bool
60
MouseEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
61
0
{
62
0
  // Passing a null JSContext is OK only if we're initing from null,
63
0
  // Since in that case we will not have to do any property gets
64
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
65
0
  // checkers by static analysis tools
66
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
67
0
  MouseEventInitAtoms* atomsCache = nullptr;
68
0
  if (cx) {
69
0
    atomsCache = GetAtomCache<MouseEventInitAtoms>(cx);
70
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
71
0
      return false;
72
0
    }
73
0
  }
74
0
75
0
  // Per spec, we init the parent's members first
76
0
  if (!EventModifierInit::Init(cx, val)) {
77
0
    return false;
78
0
  }
79
0
80
0
  bool isNull = val.isNullOrUndefined();
81
0
  // We only need these if !isNull, in which case we have |cx|.
82
0
  Maybe<JS::Rooted<JSObject *> > object;
83
0
  Maybe<JS::Rooted<JS::Value> > temp;
84
0
  if (!isNull) {
85
0
    MOZ_ASSERT(cx);
86
0
    object.emplace(cx, &val.toObject());
87
0
    temp.emplace(cx);
88
0
  }
89
0
  if (!isNull) {
90
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->button_id, temp.ptr())) {
91
0
      return false;
92
0
    }
93
0
  }
94
0
  if (!isNull && !temp->isUndefined()) {
95
0
    if (!ValueToPrimitive<int16_t, eDefault>(cx, temp.ref(), &mButton)) {
96
0
      return false;
97
0
    }
98
0
  } else {
99
0
    mButton = 0;
100
0
  }
101
0
  mIsAnyMemberPresent = true;
102
0
103
0
  if (!isNull) {
104
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->buttons_id, temp.ptr())) {
105
0
      return false;
106
0
    }
107
0
  }
108
0
  if (!isNull && !temp->isUndefined()) {
109
0
    if (!ValueToPrimitive<uint16_t, eDefault>(cx, temp.ref(), &mButtons)) {
110
0
      return false;
111
0
    }
112
0
  } else {
113
0
    mButtons = 0;
114
0
  }
115
0
  mIsAnyMemberPresent = true;
116
0
117
0
  if (!isNull) {
118
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->clientX_id, temp.ptr())) {
119
0
      return false;
120
0
    }
121
0
  }
122
0
  if (!isNull && !temp->isUndefined()) {
123
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mClientX)) {
124
0
      return false;
125
0
    }
126
0
  } else {
127
0
    mClientX = 0;
128
0
  }
129
0
  mIsAnyMemberPresent = true;
130
0
131
0
  if (!isNull) {
132
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->clientY_id, temp.ptr())) {
133
0
      return false;
134
0
    }
135
0
  }
136
0
  if (!isNull && !temp->isUndefined()) {
137
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mClientY)) {
138
0
      return false;
139
0
    }
140
0
  } else {
141
0
    mClientY = 0;
142
0
  }
143
0
  mIsAnyMemberPresent = true;
144
0
145
0
  if (!isNull) {
146
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->movementX_id, temp.ptr())) {
147
0
      return false;
148
0
    }
149
0
  }
150
0
  if (!isNull && !temp->isUndefined()) {
151
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mMovementX)) {
152
0
      return false;
153
0
    }
154
0
  } else {
155
0
    mMovementX = 0;
156
0
  }
157
0
  mIsAnyMemberPresent = true;
158
0
159
0
  if (!isNull) {
160
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->movementY_id, temp.ptr())) {
161
0
      return false;
162
0
    }
163
0
  }
164
0
  if (!isNull && !temp->isUndefined()) {
165
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mMovementY)) {
166
0
      return false;
167
0
    }
168
0
  } else {
169
0
    mMovementY = 0;
170
0
  }
171
0
  mIsAnyMemberPresent = true;
172
0
173
0
  if (!isNull) {
174
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->relatedTarget_id, temp.ptr())) {
175
0
      return false;
176
0
    }
177
0
  }
178
0
  if (!isNull && !temp->isUndefined()) {
179
0
    if (temp.ref().isObject()) {
180
0
      static_assert(IsRefcounted<mozilla::dom::EventTarget>::value, "We can only store refcounted classes.");{
181
0
        nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(temp.ptr(), mRelatedTarget);
182
0
        if (NS_FAILED(rv)) {
183
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'relatedTarget' member of MouseEventInit", "EventTarget");
184
0
          return false;
185
0
        }
186
0
      }
187
0
    } else if (temp.ref().isNullOrUndefined()) {
188
0
      mRelatedTarget = nullptr;
189
0
    } else {
190
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'relatedTarget' member of MouseEventInit");
191
0
      return false;
192
0
    }
193
0
  } else {
194
0
    mRelatedTarget = nullptr;
195
0
  }
196
0
  mIsAnyMemberPresent = true;
197
0
198
0
  if (!isNull) {
199
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->screenX_id, temp.ptr())) {
200
0
      return false;
201
0
    }
202
0
  }
203
0
  if (!isNull && !temp->isUndefined()) {
204
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mScreenX)) {
205
0
      return false;
206
0
    }
207
0
  } else {
208
0
    mScreenX = 0;
209
0
  }
210
0
  mIsAnyMemberPresent = true;
211
0
212
0
  if (!isNull) {
213
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->screenY_id, temp.ptr())) {
214
0
      return false;
215
0
    }
216
0
  }
217
0
  if (!isNull && !temp->isUndefined()) {
218
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mScreenY)) {
219
0
      return false;
220
0
    }
221
0
  } else {
222
0
    mScreenY = 0;
223
0
  }
224
0
  mIsAnyMemberPresent = true;
225
0
  return true;
226
0
}
227
228
bool
229
MouseEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
230
0
{
231
0
  MouseEventInitAtoms* atomsCache = GetAtomCache<MouseEventInitAtoms>(cx);
232
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
233
0
    return false;
234
0
  }
235
0
236
0
  // Per spec, we define the parent's members first
237
0
  if (!EventModifierInit::ToObjectInternal(cx, rval)) {
238
0
    return false;
239
0
  }
240
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
241
0
242
0
  do {
243
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
244
0
    JS::Rooted<JS::Value> temp(cx);
245
0
    int16_t const & currentValue = mButton;
246
0
    temp.setInt32(int32_t(currentValue));
247
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->button_id, temp, JSPROP_ENUMERATE)) {
248
0
      return false;
249
0
    }
250
0
    break;
251
0
  } while(false);
252
0
253
0
  do {
254
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
255
0
    JS::Rooted<JS::Value> temp(cx);
256
0
    uint16_t const & currentValue = mButtons;
257
0
    temp.setInt32(int32_t(currentValue));
258
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->buttons_id, temp, JSPROP_ENUMERATE)) {
259
0
      return false;
260
0
    }
261
0
    break;
262
0
  } while(false);
263
0
264
0
  do {
265
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
266
0
    JS::Rooted<JS::Value> temp(cx);
267
0
    int32_t const & currentValue = mClientX;
268
0
    temp.setInt32(int32_t(currentValue));
269
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->clientX_id, temp, JSPROP_ENUMERATE)) {
270
0
      return false;
271
0
    }
272
0
    break;
273
0
  } while(false);
274
0
275
0
  do {
276
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
277
0
    JS::Rooted<JS::Value> temp(cx);
278
0
    int32_t const & currentValue = mClientY;
279
0
    temp.setInt32(int32_t(currentValue));
280
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->clientY_id, temp, JSPROP_ENUMERATE)) {
281
0
      return false;
282
0
    }
283
0
    break;
284
0
  } while(false);
285
0
286
0
  do {
287
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
288
0
    JS::Rooted<JS::Value> temp(cx);
289
0
    int32_t const & currentValue = mMovementX;
290
0
    temp.setInt32(int32_t(currentValue));
291
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->movementX_id, temp, JSPROP_ENUMERATE)) {
292
0
      return false;
293
0
    }
294
0
    break;
295
0
  } while(false);
296
0
297
0
  do {
298
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
299
0
    JS::Rooted<JS::Value> temp(cx);
300
0
    int32_t const & currentValue = mMovementY;
301
0
    temp.setInt32(int32_t(currentValue));
302
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->movementY_id, temp, JSPROP_ENUMERATE)) {
303
0
      return false;
304
0
    }
305
0
    break;
306
0
  } while(false);
307
0
308
0
  do {
309
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
310
0
    JS::Rooted<JS::Value> temp(cx);
311
0
    RefPtr<mozilla::dom::EventTarget> const & currentValue = mRelatedTarget;
312
0
    if (!currentValue) {
313
0
      temp.setNull();
314
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->relatedTarget_id, temp, JSPROP_ENUMERATE)) {
315
0
        return false;
316
0
      }
317
0
      break;
318
0
    }
319
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
320
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
321
0
      return false;
322
0
    }
323
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->relatedTarget_id, temp, JSPROP_ENUMERATE)) {
324
0
      return false;
325
0
    }
326
0
    break;
327
0
  } while(false);
328
0
329
0
  do {
330
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
331
0
    JS::Rooted<JS::Value> temp(cx);
332
0
    int32_t const & currentValue = mScreenX;
333
0
    temp.setInt32(int32_t(currentValue));
334
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->screenX_id, temp, JSPROP_ENUMERATE)) {
335
0
      return false;
336
0
    }
337
0
    break;
338
0
  } while(false);
339
0
340
0
  do {
341
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
342
0
    JS::Rooted<JS::Value> temp(cx);
343
0
    int32_t const & currentValue = mScreenY;
344
0
    temp.setInt32(int32_t(currentValue));
345
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->screenY_id, temp, JSPROP_ENUMERATE)) {
346
0
      return false;
347
0
    }
348
0
    break;
349
0
  } while(false);
350
0
351
0
  return true;
352
0
}
353
354
void
355
MouseEventInit::TraceDictionary(JSTracer* trc)
356
0
{
357
0
  EventModifierInit::TraceDictionary(trc);
358
0
}
359
360
361
362
MouseEventInit&
363
MouseEventInit::operator=(const MouseEventInit& aOther)
364
0
{
365
0
  EventModifierInit::operator=(aOther);
366
0
  mButton = aOther.mButton;
367
0
  mButtons = aOther.mButtons;
368
0
  mClientX = aOther.mClientX;
369
0
  mClientY = aOther.mClientY;
370
0
  mMovementX = aOther.mMovementX;
371
0
  mMovementY = aOther.mMovementY;
372
0
  mRelatedTarget = aOther.mRelatedTarget;
373
0
  mScreenX = aOther.mScreenX;
374
0
  mScreenY = aOther.mScreenY;
375
0
  return *this;
376
0
}
377
378
namespace binding_detail {
379
} // namespace binding_detail
380
381
382
namespace MouseEvent_Binding {
383
384
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<UIEvent_Binding::NativeType>::value,
385
              "Can't inherit from an interface with a different ownership model.");
386
387
MOZ_CAN_RUN_SCRIPT static bool
388
get_screenX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
389
0
{
390
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.screenX", DOM, cx);
391
0
392
0
  int32_t result(self->ScreenX(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
393
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
394
0
  args.rval().setInt32(int32_t(result));
395
0
  return true;
396
0
}
397
398
static const JSJitInfo screenX_getterinfo = {
399
  { (JSJitGetterOp)get_screenX },
400
  { prototypes::id::MouseEvent },
401
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
402
  JSJitInfo::Getter,
403
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
404
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
405
  true,  /* isInfallible. False in setters. */
406
  false,  /* isMovable.  Not relevant for setters. */
407
  false, /* isEliminatable.  Not relevant for setters. */
408
  false, /* isAlwaysInSlot.  Only relevant for getters. */
409
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
410
  false,  /* isTypedMethod.  Only relevant for methods. */
411
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
412
};
413
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
414
static_assert(0 < 1, "There is no slot for us");
415
416
MOZ_CAN_RUN_SCRIPT static bool
417
get_screenY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
418
0
{
419
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.screenY", DOM, cx);
420
0
421
0
  int32_t result(self->ScreenY(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
422
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
423
0
  args.rval().setInt32(int32_t(result));
424
0
  return true;
425
0
}
426
427
static const JSJitInfo screenY_getterinfo = {
428
  { (JSJitGetterOp)get_screenY },
429
  { prototypes::id::MouseEvent },
430
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
431
  JSJitInfo::Getter,
432
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
433
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
434
  true,  /* isInfallible. False in setters. */
435
  false,  /* isMovable.  Not relevant for setters. */
436
  false, /* isEliminatable.  Not relevant for setters. */
437
  false, /* isAlwaysInSlot.  Only relevant for getters. */
438
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
439
  false,  /* isTypedMethod.  Only relevant for methods. */
440
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
441
};
442
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
443
static_assert(0 < 1, "There is no slot for us");
444
445
MOZ_CAN_RUN_SCRIPT static bool
446
get_clientX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
447
0
{
448
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.clientX", DOM, cx);
449
0
450
0
  int32_t result(self->ClientX());
451
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
452
0
  args.rval().setInt32(int32_t(result));
453
0
  return true;
454
0
}
455
456
static const JSJitInfo clientX_getterinfo = {
457
  { (JSJitGetterOp)get_clientX },
458
  { prototypes::id::MouseEvent },
459
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
460
  JSJitInfo::Getter,
461
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
462
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
463
  true,  /* isInfallible. False in setters. */
464
  false,  /* isMovable.  Not relevant for setters. */
465
  false, /* isEliminatable.  Not relevant for setters. */
466
  false, /* isAlwaysInSlot.  Only relevant for getters. */
467
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
468
  false,  /* isTypedMethod.  Only relevant for methods. */
469
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
470
};
471
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
472
static_assert(0 < 1, "There is no slot for us");
473
474
MOZ_CAN_RUN_SCRIPT static bool
475
get_clientY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
476
0
{
477
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.clientY", DOM, cx);
478
0
479
0
  int32_t result(self->ClientY());
480
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
481
0
  args.rval().setInt32(int32_t(result));
482
0
  return true;
483
0
}
484
485
static const JSJitInfo clientY_getterinfo = {
486
  { (JSJitGetterOp)get_clientY },
487
  { prototypes::id::MouseEvent },
488
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
489
  JSJitInfo::Getter,
490
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
491
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
492
  true,  /* isInfallible. False in setters. */
493
  false,  /* isMovable.  Not relevant for setters. */
494
  false, /* isEliminatable.  Not relevant for setters. */
495
  false, /* isAlwaysInSlot.  Only relevant for getters. */
496
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
497
  false,  /* isTypedMethod.  Only relevant for methods. */
498
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
499
};
500
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
501
static_assert(0 < 1, "There is no slot for us");
502
503
MOZ_CAN_RUN_SCRIPT static bool
504
get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
505
0
{
506
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.x", DOM, cx);
507
0
508
0
  int32_t result(self->ClientX());
509
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
510
0
  args.rval().setInt32(int32_t(result));
511
0
  return true;
512
0
}
513
514
static const JSJitInfo x_getterinfo = {
515
  { (JSJitGetterOp)get_x },
516
  { prototypes::id::MouseEvent },
517
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
518
  JSJitInfo::Getter,
519
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
520
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
521
  true,  /* isInfallible. False in setters. */
522
  false,  /* isMovable.  Not relevant for setters. */
523
  false, /* isEliminatable.  Not relevant for setters. */
524
  false, /* isAlwaysInSlot.  Only relevant for getters. */
525
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
526
  false,  /* isTypedMethod.  Only relevant for methods. */
527
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
528
};
529
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
530
static_assert(0 < 1, "There is no slot for us");
531
532
MOZ_CAN_RUN_SCRIPT static bool
533
get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
534
0
{
535
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.y", DOM, cx);
536
0
537
0
  int32_t result(self->ClientY());
538
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
539
0
  args.rval().setInt32(int32_t(result));
540
0
  return true;
541
0
}
542
543
static const JSJitInfo y_getterinfo = {
544
  { (JSJitGetterOp)get_y },
545
  { prototypes::id::MouseEvent },
546
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
547
  JSJitInfo::Getter,
548
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
549
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
550
  true,  /* isInfallible. False in setters. */
551
  false,  /* isMovable.  Not relevant for setters. */
552
  false, /* isEliminatable.  Not relevant for setters. */
553
  false, /* isAlwaysInSlot.  Only relevant for getters. */
554
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
555
  false,  /* isTypedMethod.  Only relevant for methods. */
556
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
557
};
558
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
559
static_assert(0 < 1, "There is no slot for us");
560
561
MOZ_CAN_RUN_SCRIPT static bool
562
get_offsetX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
563
0
{
564
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.offsetX", DOM, cx);
565
0
566
0
  int32_t result(self->OffsetX());
567
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
568
0
  args.rval().setInt32(int32_t(result));
569
0
  return true;
570
0
}
571
572
static const JSJitInfo offsetX_getterinfo = {
573
  { (JSJitGetterOp)get_offsetX },
574
  { prototypes::id::MouseEvent },
575
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
576
  JSJitInfo::Getter,
577
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
578
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
579
  true,  /* isInfallible. False in setters. */
580
  false,  /* isMovable.  Not relevant for setters. */
581
  false, /* isEliminatable.  Not relevant for setters. */
582
  false, /* isAlwaysInSlot.  Only relevant for getters. */
583
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
584
  false,  /* isTypedMethod.  Only relevant for methods. */
585
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
586
};
587
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
588
static_assert(0 < 1, "There is no slot for us");
589
590
MOZ_CAN_RUN_SCRIPT static bool
591
get_offsetY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
592
0
{
593
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.offsetY", DOM, cx);
594
0
595
0
  int32_t result(self->OffsetY());
596
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
597
0
  args.rval().setInt32(int32_t(result));
598
0
  return true;
599
0
}
600
601
static const JSJitInfo offsetY_getterinfo = {
602
  { (JSJitGetterOp)get_offsetY },
603
  { prototypes::id::MouseEvent },
604
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
605
  JSJitInfo::Getter,
606
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
607
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
608
  true,  /* isInfallible. False in setters. */
609
  false,  /* isMovable.  Not relevant for setters. */
610
  false, /* isEliminatable.  Not relevant for setters. */
611
  false, /* isAlwaysInSlot.  Only relevant for getters. */
612
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
613
  false,  /* isTypedMethod.  Only relevant for methods. */
614
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
615
};
616
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
617
static_assert(0 < 1, "There is no slot for us");
618
619
MOZ_CAN_RUN_SCRIPT static bool
620
get_ctrlKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
621
0
{
622
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.ctrlKey", DOM, cx);
623
0
624
0
  bool result(self->CtrlKey());
625
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
626
0
  args.rval().setBoolean(result);
627
0
  return true;
628
0
}
629
630
static const JSJitInfo ctrlKey_getterinfo = {
631
  { (JSJitGetterOp)get_ctrlKey },
632
  { prototypes::id::MouseEvent },
633
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
634
  JSJitInfo::Getter,
635
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
636
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
637
  true,  /* isInfallible. False in setters. */
638
  false,  /* isMovable.  Not relevant for setters. */
639
  false, /* isEliminatable.  Not relevant for setters. */
640
  false, /* isAlwaysInSlot.  Only relevant for getters. */
641
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
642
  false,  /* isTypedMethod.  Only relevant for methods. */
643
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
644
};
645
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
646
static_assert(0 < 1, "There is no slot for us");
647
648
MOZ_CAN_RUN_SCRIPT static bool
649
get_shiftKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
650
0
{
651
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.shiftKey", DOM, cx);
652
0
653
0
  bool result(self->ShiftKey());
654
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
655
0
  args.rval().setBoolean(result);
656
0
  return true;
657
0
}
658
659
static const JSJitInfo shiftKey_getterinfo = {
660
  { (JSJitGetterOp)get_shiftKey },
661
  { prototypes::id::MouseEvent },
662
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
663
  JSJitInfo::Getter,
664
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
665
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
666
  true,  /* isInfallible. False in setters. */
667
  false,  /* isMovable.  Not relevant for setters. */
668
  false, /* isEliminatable.  Not relevant for setters. */
669
  false, /* isAlwaysInSlot.  Only relevant for getters. */
670
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
671
  false,  /* isTypedMethod.  Only relevant for methods. */
672
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
673
};
674
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
675
static_assert(0 < 1, "There is no slot for us");
676
677
MOZ_CAN_RUN_SCRIPT static bool
678
get_altKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
679
0
{
680
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.altKey", DOM, cx);
681
0
682
0
  bool result(self->AltKey());
683
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
684
0
  args.rval().setBoolean(result);
685
0
  return true;
686
0
}
687
688
static const JSJitInfo altKey_getterinfo = {
689
  { (JSJitGetterOp)get_altKey },
690
  { prototypes::id::MouseEvent },
691
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
692
  JSJitInfo::Getter,
693
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
694
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
695
  true,  /* isInfallible. False in setters. */
696
  false,  /* isMovable.  Not relevant for setters. */
697
  false, /* isEliminatable.  Not relevant for setters. */
698
  false, /* isAlwaysInSlot.  Only relevant for getters. */
699
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
700
  false,  /* isTypedMethod.  Only relevant for methods. */
701
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
702
};
703
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
704
static_assert(0 < 1, "There is no slot for us");
705
706
MOZ_CAN_RUN_SCRIPT static bool
707
get_metaKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
708
0
{
709
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.metaKey", DOM, cx);
710
0
711
0
  bool result(self->MetaKey());
712
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
713
0
  args.rval().setBoolean(result);
714
0
  return true;
715
0
}
716
717
static const JSJitInfo metaKey_getterinfo = {
718
  { (JSJitGetterOp)get_metaKey },
719
  { prototypes::id::MouseEvent },
720
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
721
  JSJitInfo::Getter,
722
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
723
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
724
  true,  /* isInfallible. False in setters. */
725
  false,  /* isMovable.  Not relevant for setters. */
726
  false, /* isEliminatable.  Not relevant for setters. */
727
  false, /* isAlwaysInSlot.  Only relevant for getters. */
728
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
729
  false,  /* isTypedMethod.  Only relevant for methods. */
730
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
731
};
732
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
733
static_assert(0 < 1, "There is no slot for us");
734
735
MOZ_CAN_RUN_SCRIPT static bool
736
get_button(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
737
0
{
738
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.button", DOM, cx);
739
0
740
0
  int16_t result(self->Button());
741
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
742
0
  args.rval().setInt32(int32_t(result));
743
0
  return true;
744
0
}
745
746
static const JSJitInfo button_getterinfo = {
747
  { (JSJitGetterOp)get_button },
748
  { prototypes::id::MouseEvent },
749
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
750
  JSJitInfo::Getter,
751
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
752
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
753
  true,  /* isInfallible. False in setters. */
754
  false,  /* isMovable.  Not relevant for setters. */
755
  false, /* isEliminatable.  Not relevant for setters. */
756
  false, /* isAlwaysInSlot.  Only relevant for getters. */
757
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
758
  false,  /* isTypedMethod.  Only relevant for methods. */
759
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
760
};
761
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
762
static_assert(0 < 1, "There is no slot for us");
763
764
MOZ_CAN_RUN_SCRIPT static bool
765
get_buttons(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
766
0
{
767
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.buttons", DOM, cx);
768
0
769
0
  uint16_t result(self->Buttons());
770
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
771
0
  args.rval().setInt32(int32_t(result));
772
0
  return true;
773
0
}
774
775
static const JSJitInfo buttons_getterinfo = {
776
  { (JSJitGetterOp)get_buttons },
777
  { prototypes::id::MouseEvent },
778
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
779
  JSJitInfo::Getter,
780
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
781
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
782
  true,  /* isInfallible. False in setters. */
783
  false,  /* isMovable.  Not relevant for setters. */
784
  false, /* isEliminatable.  Not relevant for setters. */
785
  false, /* isAlwaysInSlot.  Only relevant for getters. */
786
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
787
  false,  /* isTypedMethod.  Only relevant for methods. */
788
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
789
};
790
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
791
static_assert(0 < 1, "There is no slot for us");
792
793
MOZ_CAN_RUN_SCRIPT static bool
794
get_relatedTarget(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
795
0
{
796
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.relatedTarget", DOM, cx);
797
0
798
0
  auto result(StrongOrRawPtr<mozilla::dom::EventTarget>(self->GetRelatedTarget()));
799
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
800
0
  if (!result) {
801
0
    args.rval().setNull();
802
0
    return true;
803
0
  }
804
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
805
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
806
0
    return false;
807
0
  }
808
0
  return true;
809
0
}
810
811
static const JSJitInfo relatedTarget_getterinfo = {
812
  { (JSJitGetterOp)get_relatedTarget },
813
  { prototypes::id::MouseEvent },
814
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
815
  JSJitInfo::Getter,
816
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
817
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
818
  false,  /* isInfallible. False in setters. */
819
  false,  /* isMovable.  Not relevant for setters. */
820
  false, /* isEliminatable.  Not relevant for setters. */
821
  false, /* isAlwaysInSlot.  Only relevant for getters. */
822
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
823
  false,  /* isTypedMethod.  Only relevant for methods. */
824
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
825
};
826
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
827
static_assert(0 < 1, "There is no slot for us");
828
829
MOZ_CAN_RUN_SCRIPT static bool
830
get_region(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
831
0
{
832
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.region", DOM, cx);
833
0
834
0
  DOMString result;
835
0
  self->GetRegion(result);
836
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
837
0
  if (!xpc::StringToJsval(cx, result, args.rval())) {
838
0
    return false;
839
0
  }
840
0
  return true;
841
0
}
842
843
static const JSJitInfo region_getterinfo = {
844
  { (JSJitGetterOp)get_region },
845
  { prototypes::id::MouseEvent },
846
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
847
  JSJitInfo::Getter,
848
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
849
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
850
  false,  /* isInfallible. False in setters. */
851
  false,  /* isMovable.  Not relevant for setters. */
852
  false, /* isEliminatable.  Not relevant for setters. */
853
  false, /* isAlwaysInSlot.  Only relevant for getters. */
854
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
855
  false,  /* isTypedMethod.  Only relevant for methods. */
856
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
857
};
858
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
859
static_assert(0 < 1, "There is no slot for us");
860
861
MOZ_CAN_RUN_SCRIPT static bool
862
get_movementX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
863
0
{
864
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.movementX", DOM, cx);
865
0
866
0
  int32_t result(self->MovementX());
867
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
868
0
  args.rval().setInt32(int32_t(result));
869
0
  return true;
870
0
}
871
872
static const JSJitInfo movementX_getterinfo = {
873
  { (JSJitGetterOp)get_movementX },
874
  { prototypes::id::MouseEvent },
875
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
876
  JSJitInfo::Getter,
877
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
878
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
879
  true,  /* isInfallible. False in setters. */
880
  false,  /* isMovable.  Not relevant for setters. */
881
  false, /* isEliminatable.  Not relevant for setters. */
882
  false, /* isAlwaysInSlot.  Only relevant for getters. */
883
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
884
  false,  /* isTypedMethod.  Only relevant for methods. */
885
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
886
};
887
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
888
static_assert(0 < 1, "There is no slot for us");
889
890
MOZ_CAN_RUN_SCRIPT static bool
891
get_movementY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
892
0
{
893
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.movementY", DOM, cx);
894
0
895
0
  int32_t result(self->MovementY());
896
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
897
0
  args.rval().setInt32(int32_t(result));
898
0
  return true;
899
0
}
900
901
static const JSJitInfo movementY_getterinfo = {
902
  { (JSJitGetterOp)get_movementY },
903
  { prototypes::id::MouseEvent },
904
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
905
  JSJitInfo::Getter,
906
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
907
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
908
  true,  /* isInfallible. False in setters. */
909
  false,  /* isMovable.  Not relevant for setters. */
910
  false, /* isEliminatable.  Not relevant for setters. */
911
  false, /* isAlwaysInSlot.  Only relevant for getters. */
912
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
913
  false,  /* isTypedMethod.  Only relevant for methods. */
914
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
915
};
916
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
917
static_assert(0 < 1, "There is no slot for us");
918
919
MOZ_CAN_RUN_SCRIPT static bool
920
initMouseEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, const JSJitMethodCallArgs& args)
921
0
{
922
0
  AUTO_PROFILER_LABEL_FAST("MouseEvent.initMouseEvent", DOM, cx);
923
0
924
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
925
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent.initMouseEvent");
926
0
  }
927
0
  binding_detail::FakeString arg0;
928
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
929
0
    return false;
930
0
  }
931
0
  bool arg1;
932
0
  if (args.hasDefined(1)) {
933
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
934
0
      return false;
935
0
    }
936
0
  } else {
937
0
    arg1 = false;
938
0
  }
939
0
  bool arg2;
940
0
  if (args.hasDefined(2)) {
941
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
942
0
      return false;
943
0
    }
944
0
  } else {
945
0
    arg2 = false;
946
0
  }
947
0
  nsGlobalWindowInner* arg3;
948
0
  if (args.hasDefined(3)) {
949
0
    if (args[3].isObject()) {
950
0
      {
951
0
        nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(args[3], arg3);
952
0
        if (NS_FAILED(rv)) {
953
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of MouseEvent.initMouseEvent", "Window");
954
0
          return false;
955
0
        }
956
0
      }
957
0
    } else if (args[3].isNullOrUndefined()) {
958
0
      arg3 = nullptr;
959
0
    } else {
960
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of MouseEvent.initMouseEvent");
961
0
      return false;
962
0
    }
963
0
  } else {
964
0
    arg3 = nullptr;
965
0
  }
966
0
  int32_t arg4;
967
0
  if (args.hasDefined(4)) {
968
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
969
0
      return false;
970
0
    }
971
0
  } else {
972
0
    arg4 = 0;
973
0
  }
974
0
  int32_t arg5;
975
0
  if (args.hasDefined(5)) {
976
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) {
977
0
      return false;
978
0
    }
979
0
  } else {
980
0
    arg5 = 0;
981
0
  }
982
0
  int32_t arg6;
983
0
  if (args.hasDefined(6)) {
984
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) {
985
0
      return false;
986
0
    }
987
0
  } else {
988
0
    arg6 = 0;
989
0
  }
990
0
  int32_t arg7;
991
0
  if (args.hasDefined(7)) {
992
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) {
993
0
      return false;
994
0
    }
995
0
  } else {
996
0
    arg7 = 0;
997
0
  }
998
0
  int32_t arg8;
999
0
  if (args.hasDefined(8)) {
1000
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[8], &arg8)) {
1001
0
      return false;
1002
0
    }
1003
0
  } else {
1004
0
    arg8 = 0;
1005
0
  }
1006
0
  bool arg9;
1007
0
  if (args.hasDefined(9)) {
1008
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[9], &arg9)) {
1009
0
      return false;
1010
0
    }
1011
0
  } else {
1012
0
    arg9 = false;
1013
0
  }
1014
0
  bool arg10;
1015
0
  if (args.hasDefined(10)) {
1016
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[10], &arg10)) {
1017
0
      return false;
1018
0
    }
1019
0
  } else {
1020
0
    arg10 = false;
1021
0
  }
1022
0
  bool arg11;
1023
0
  if (args.hasDefined(11)) {
1024
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[11], &arg11)) {
1025
0
      return false;
1026
0
    }
1027
0
  } else {
1028
0
    arg11 = false;
1029
0
  }
1030
0
  bool arg12;
1031
0
  if (args.hasDefined(12)) {
1032
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[12], &arg12)) {
1033
0
      return false;
1034
0
    }
1035
0
  } else {
1036
0
    arg12 = false;
1037
0
  }
1038
0
  int16_t arg13;
1039
0
  if (args.hasDefined(13)) {
1040
0
    if (!ValueToPrimitive<int16_t, eDefault>(cx, args[13], &arg13)) {
1041
0
      return false;
1042
0
    }
1043
0
  } else {
1044
0
    arg13 = 0;
1045
0
  }
1046
0
  mozilla::dom::EventTarget* arg14;
1047
0
  if (args.hasDefined(14)) {
1048
0
    if (args[14].isObject()) {
1049
0
      {
1050
0
        nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(args[14], arg14);
1051
0
        if (NS_FAILED(rv)) {
1052
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 15 of MouseEvent.initMouseEvent", "EventTarget");
1053
0
          return false;
1054
0
        }
1055
0
      }
1056
0
    } else if (args[14].isNullOrUndefined()) {
1057
0
      arg14 = nullptr;
1058
0
    } else {
1059
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 15 of MouseEvent.initMouseEvent");
1060
0
      return false;
1061
0
    }
1062
0
  } else {
1063
0
    arg14 = nullptr;
1064
0
  }
1065
0
  self->InitMouseEvent(NonNullHelper(Constify(arg0)), arg1, arg2, MOZ_KnownLive(Constify(arg3)), arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, MOZ_KnownLive(Constify(arg14)));
1066
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1067
0
  args.rval().setUndefined();
1068
0
  return true;
1069
0
}
1070
1071
static const JSJitInfo initMouseEvent_methodinfo = {
1072
  { (JSJitGetterOp)initMouseEvent },
1073
  { prototypes::id::MouseEvent },
1074
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1075
  JSJitInfo::Method,
1076
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1077
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1078
  false,  /* isInfallible. False in setters. */
1079
  false,  /* isMovable.  Not relevant for setters. */
1080
  false, /* isEliminatable.  Not relevant for setters. */
1081
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1082
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1083
  false,  /* isTypedMethod.  Only relevant for methods. */
1084
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1085
};
1086
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1087
static_assert(0 < 1, "There is no slot for us");
1088
1089
MOZ_CAN_RUN_SCRIPT static bool
1090
getModifierState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, const JSJitMethodCallArgs& args)
1091
0
{
1092
0
  AUTO_PROFILER_LABEL_FAST("MouseEvent.getModifierState", DOM, cx);
1093
0
1094
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1095
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent.getModifierState");
1096
0
  }
1097
0
  binding_detail::FakeString arg0;
1098
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1099
0
    return false;
1100
0
  }
1101
0
  bool result(self->GetModifierState(NonNullHelper(Constify(arg0))));
1102
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1103
0
  args.rval().setBoolean(result);
1104
0
  return true;
1105
0
}
1106
1107
static const JSJitInfo getModifierState_methodinfo = {
1108
  { (JSJitGetterOp)getModifierState },
1109
  { prototypes::id::MouseEvent },
1110
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1111
  JSJitInfo::Method,
1112
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1113
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1114
  false,  /* isInfallible. False in setters. */
1115
  false,  /* isMovable.  Not relevant for setters. */
1116
  false, /* isEliminatable.  Not relevant for setters. */
1117
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1118
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1119
  false,  /* isTypedMethod.  Only relevant for methods. */
1120
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1121
};
1122
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1123
static_assert(0 < 1, "There is no slot for us");
1124
1125
MOZ_CAN_RUN_SCRIPT static bool
1126
get_mozPressure(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1127
0
{
1128
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.mozPressure", DOM, cx);
1129
0
1130
0
  float result(self->MozPressure());
1131
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1132
0
  args.rval().set(JS_NumberValue(double(result)));
1133
0
  return true;
1134
0
}
1135
1136
static const JSJitInfo mozPressure_getterinfo = {
1137
  { (JSJitGetterOp)get_mozPressure },
1138
  { prototypes::id::MouseEvent },
1139
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1140
  JSJitInfo::Getter,
1141
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1142
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1143
  true,  /* isInfallible. False in setters. */
1144
  false,  /* isMovable.  Not relevant for setters. */
1145
  false, /* isEliminatable.  Not relevant for setters. */
1146
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1147
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1148
  false,  /* isTypedMethod.  Only relevant for methods. */
1149
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1150
};
1151
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1152
static_assert(0 < 1, "There is no slot for us");
1153
1154
MOZ_CAN_RUN_SCRIPT static bool
1155
get_mozInputSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1156
0
{
1157
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.mozInputSource", DOM, cx);
1158
0
1159
0
  uint16_t result(self->MozInputSource());
1160
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1161
0
  args.rval().setInt32(int32_t(result));
1162
0
  return true;
1163
0
}
1164
1165
static const JSJitInfo mozInputSource_getterinfo = {
1166
  { (JSJitGetterOp)get_mozInputSource },
1167
  { prototypes::id::MouseEvent },
1168
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1169
  JSJitInfo::Getter,
1170
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1171
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
1172
  true,  /* isInfallible. False in setters. */
1173
  false,  /* isMovable.  Not relevant for setters. */
1174
  false, /* isEliminatable.  Not relevant for setters. */
1175
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1176
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1177
  false,  /* isTypedMethod.  Only relevant for methods. */
1178
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1179
};
1180
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1181
static_assert(0 < 1, "There is no slot for us");
1182
1183
MOZ_CAN_RUN_SCRIPT static bool
1184
initNSMouseEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, const JSJitMethodCallArgs& args)
1185
0
{
1186
0
  AUTO_PROFILER_LABEL_FAST("MouseEvent.initNSMouseEvent", DOM, cx);
1187
0
1188
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1189
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent.initNSMouseEvent");
1190
0
  }
1191
0
  binding_detail::FakeString arg0;
1192
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1193
0
    return false;
1194
0
  }
1195
0
  bool arg1;
1196
0
  if (args.hasDefined(1)) {
1197
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
1198
0
      return false;
1199
0
    }
1200
0
  } else {
1201
0
    arg1 = false;
1202
0
  }
1203
0
  bool arg2;
1204
0
  if (args.hasDefined(2)) {
1205
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
1206
0
      return false;
1207
0
    }
1208
0
  } else {
1209
0
    arg2 = false;
1210
0
  }
1211
0
  nsGlobalWindowInner* arg3;
1212
0
  if (args.hasDefined(3)) {
1213
0
    if (args[3].isObject()) {
1214
0
      {
1215
0
        nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(args[3], arg3);
1216
0
        if (NS_FAILED(rv)) {
1217
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of MouseEvent.initNSMouseEvent", "Window");
1218
0
          return false;
1219
0
        }
1220
0
      }
1221
0
    } else if (args[3].isNullOrUndefined()) {
1222
0
      arg3 = nullptr;
1223
0
    } else {
1224
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of MouseEvent.initNSMouseEvent");
1225
0
      return false;
1226
0
    }
1227
0
  } else {
1228
0
    arg3 = nullptr;
1229
0
  }
1230
0
  int32_t arg4;
1231
0
  if (args.hasDefined(4)) {
1232
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
1233
0
      return false;
1234
0
    }
1235
0
  } else {
1236
0
    arg4 = 0;
1237
0
  }
1238
0
  int32_t arg5;
1239
0
  if (args.hasDefined(5)) {
1240
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) {
1241
0
      return false;
1242
0
    }
1243
0
  } else {
1244
0
    arg5 = 0;
1245
0
  }
1246
0
  int32_t arg6;
1247
0
  if (args.hasDefined(6)) {
1248
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) {
1249
0
      return false;
1250
0
    }
1251
0
  } else {
1252
0
    arg6 = 0;
1253
0
  }
1254
0
  int32_t arg7;
1255
0
  if (args.hasDefined(7)) {
1256
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) {
1257
0
      return false;
1258
0
    }
1259
0
  } else {
1260
0
    arg7 = 0;
1261
0
  }
1262
0
  int32_t arg8;
1263
0
  if (args.hasDefined(8)) {
1264
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[8], &arg8)) {
1265
0
      return false;
1266
0
    }
1267
0
  } else {
1268
0
    arg8 = 0;
1269
0
  }
1270
0
  bool arg9;
1271
0
  if (args.hasDefined(9)) {
1272
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[9], &arg9)) {
1273
0
      return false;
1274
0
    }
1275
0
  } else {
1276
0
    arg9 = false;
1277
0
  }
1278
0
  bool arg10;
1279
0
  if (args.hasDefined(10)) {
1280
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[10], &arg10)) {
1281
0
      return false;
1282
0
    }
1283
0
  } else {
1284
0
    arg10 = false;
1285
0
  }
1286
0
  bool arg11;
1287
0
  if (args.hasDefined(11)) {
1288
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[11], &arg11)) {
1289
0
      return false;
1290
0
    }
1291
0
  } else {
1292
0
    arg11 = false;
1293
0
  }
1294
0
  bool arg12;
1295
0
  if (args.hasDefined(12)) {
1296
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[12], &arg12)) {
1297
0
      return false;
1298
0
    }
1299
0
  } else {
1300
0
    arg12 = false;
1301
0
  }
1302
0
  int16_t arg13;
1303
0
  if (args.hasDefined(13)) {
1304
0
    if (!ValueToPrimitive<int16_t, eDefault>(cx, args[13], &arg13)) {
1305
0
      return false;
1306
0
    }
1307
0
  } else {
1308
0
    arg13 = 0;
1309
0
  }
1310
0
  mozilla::dom::EventTarget* arg14;
1311
0
  if (args.hasDefined(14)) {
1312
0
    if (args[14].isObject()) {
1313
0
      {
1314
0
        nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(args[14], arg14);
1315
0
        if (NS_FAILED(rv)) {
1316
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 15 of MouseEvent.initNSMouseEvent", "EventTarget");
1317
0
          return false;
1318
0
        }
1319
0
      }
1320
0
    } else if (args[14].isNullOrUndefined()) {
1321
0
      arg14 = nullptr;
1322
0
    } else {
1323
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 15 of MouseEvent.initNSMouseEvent");
1324
0
      return false;
1325
0
    }
1326
0
  } else {
1327
0
    arg14 = nullptr;
1328
0
  }
1329
0
  float arg15;
1330
0
  if (args.hasDefined(15)) {
1331
0
    if (!ValueToPrimitive<float, eDefault>(cx, args[15], &arg15)) {
1332
0
      return false;
1333
0
    } else if (!mozilla::IsFinite(arg15)) {
1334
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 16 of MouseEvent.initNSMouseEvent");
1335
0
      return false;
1336
0
    }
1337
0
  } else {
1338
0
    arg15 = 0.0F;
1339
0
  }
1340
0
  uint16_t arg16;
1341
0
  if (args.hasDefined(16)) {
1342
0
    if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[16], &arg16)) {
1343
0
      return false;
1344
0
    }
1345
0
  } else {
1346
0
    arg16 = 0;
1347
0
  }
1348
0
  self->InitNSMouseEvent(NonNullHelper(Constify(arg0)), arg1, arg2, MOZ_KnownLive(Constify(arg3)), arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, MOZ_KnownLive(Constify(arg14)), arg15, arg16);
1349
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1350
0
  args.rval().setUndefined();
1351
0
  return true;
1352
0
}
1353
1354
static const JSJitInfo initNSMouseEvent_methodinfo = {
1355
  { (JSJitGetterOp)initNSMouseEvent },
1356
  { prototypes::id::MouseEvent },
1357
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1358
  JSJitInfo::Method,
1359
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1360
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1361
  false,  /* isInfallible. False in setters. */
1362
  false,  /* isMovable.  Not relevant for setters. */
1363
  false, /* isEliminatable.  Not relevant for setters. */
1364
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1365
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1366
  false,  /* isTypedMethod.  Only relevant for methods. */
1367
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1368
};
1369
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1370
static_assert(0 < 1, "There is no slot for us");
1371
1372
MOZ_CAN_RUN_SCRIPT static bool
1373
get_hitCluster(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1374
0
{
1375
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.hitCluster", DOM, cx);
1376
0
1377
0
  bool result(self->HitCluster());
1378
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1379
0
  args.rval().setBoolean(result);
1380
0
  return true;
1381
0
}
1382
1383
static const JSJitInfo hitCluster_getterinfo = {
1384
  { (JSJitGetterOp)get_hitCluster },
1385
  { prototypes::id::MouseEvent },
1386
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1387
  JSJitInfo::Getter,
1388
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1389
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1390
  true,  /* isInfallible. False in setters. */
1391
  false,  /* isMovable.  Not relevant for setters. */
1392
  false, /* isEliminatable.  Not relevant for setters. */
1393
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1394
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1395
  false,  /* isTypedMethod.  Only relevant for methods. */
1396
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1397
};
1398
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1399
static_assert(0 < 1, "There is no slot for us");
1400
1401
MOZ_CAN_RUN_SCRIPT static bool
1402
get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1403
0
{
1404
0
  AUTO_PROFILER_LABEL_FAST("get MouseEvent.isTrusted", DOM, cx);
1405
0
1406
0
  bool result(self->IsTrusted());
1407
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1408
0
  args.rval().setBoolean(result);
1409
0
  return true;
1410
0
}
1411
1412
static const JSJitInfo isTrusted_getterinfo = {
1413
  { (JSJitGetterOp)get_isTrusted },
1414
  { prototypes::id::MouseEvent },
1415
  { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1416
  JSJitInfo::Getter,
1417
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1418
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1419
  true,  /* isInfallible. False in setters. */
1420
  true,  /* isMovable.  Not relevant for setters. */
1421
  true, /* isEliminatable.  Not relevant for setters. */
1422
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1423
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1424
  false,  /* isTypedMethod.  Only relevant for methods. */
1425
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1426
};
1427
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1428
static_assert(0 < 1, "There is no slot for us");
1429
1430
static bool
1431
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1432
0
{
1433
0
  mozilla::dom::MouseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MouseEvent>(obj);
1434
0
  // We don't want to preserve if we don't have a wrapper, and we
1435
0
  // obviously can't preserve if we're not initialized.
1436
0
  if (self && self->GetWrapperPreserveColor()) {
1437
0
    PreserveWrapper(self);
1438
0
  }
1439
0
  return true;
1440
0
}
1441
1442
static void
1443
_finalize(js::FreeOp* fop, JSObject* obj)
1444
0
{
1445
0
  mozilla::dom::MouseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MouseEvent>(obj);
1446
0
  if (self) {
1447
0
    ClearWrapper(self, self, obj);
1448
0
    AddForDeferredFinalization<mozilla::dom::MouseEvent>(self);
1449
0
  }
1450
0
}
1451
1452
static size_t
1453
_objectMoved(JSObject* obj, JSObject* old)
1454
0
{
1455
0
  mozilla::dom::MouseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MouseEvent>(obj);
1456
0
  if (self) {
1457
0
    UpdateWrapper(self, self, obj, old);
1458
0
  }
1459
0
1460
0
  return 0;
1461
0
}
1462
1463
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1464
#if defined(__clang__)
1465
#pragma clang diagnostic push
1466
#pragma clang diagnostic ignored "-Wmissing-braces"
1467
#endif
1468
static const JSFunctionSpec sMethods_specs[] = {
1469
  JS_FNSPEC("initMouseEvent", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&initMouseEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1470
  JS_FNSPEC("getModifierState", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getModifierState_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1471
  JS_FNSPEC("initNSMouseEvent", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&initNSMouseEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1472
  JS_FS_END
1473
};
1474
#if defined(__clang__)
1475
#pragma clang diagnostic pop
1476
#endif
1477
1478
1479
static const Prefable<const JSFunctionSpec> sMethods[] = {
1480
  { nullptr, &sMethods_specs[0] },
1481
  { nullptr, nullptr }
1482
};
1483
1484
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1485
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1486
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1487
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1488
1489
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1490
#if defined(__clang__)
1491
#pragma clang diagnostic push
1492
#pragma clang diagnostic ignored "-Wmissing-braces"
1493
#endif
1494
static const JSPropertySpec sAttributes_specs[] = {
1495
  { "screenX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &screenX_getterinfo, nullptr, nullptr },
1496
  { "screenY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &screenY_getterinfo, nullptr, nullptr },
1497
  { "clientX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clientX_getterinfo, nullptr, nullptr },
1498
  { "clientY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clientY_getterinfo, nullptr, nullptr },
1499
  { "x", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &x_getterinfo, nullptr, nullptr },
1500
  { "y", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &y_getterinfo, nullptr, nullptr },
1501
  { "offsetX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &offsetX_getterinfo, nullptr, nullptr },
1502
  { "offsetY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &offsetY_getterinfo, nullptr, nullptr },
1503
  { "ctrlKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &ctrlKey_getterinfo, nullptr, nullptr },
1504
  { "shiftKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shiftKey_getterinfo, nullptr, nullptr },
1505
  { "altKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &altKey_getterinfo, nullptr, nullptr },
1506
  { "metaKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &metaKey_getterinfo, nullptr, nullptr },
1507
  { "button", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &button_getterinfo, nullptr, nullptr },
1508
  { "buttons", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &buttons_getterinfo, nullptr, nullptr },
1509
  { "relatedTarget", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &relatedTarget_getterinfo, nullptr, nullptr },
1510
  { "region", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &region_getterinfo, nullptr, nullptr },
1511
  { "movementX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &movementX_getterinfo, nullptr, nullptr },
1512
  { "movementY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &movementY_getterinfo, nullptr, nullptr },
1513
  { "mozPressure", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozPressure_getterinfo, nullptr, nullptr },
1514
  { "mozInputSource", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozInputSource_getterinfo, nullptr, nullptr },
1515
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1516
};
1517
#if defined(__clang__)
1518
#pragma clang diagnostic pop
1519
#endif
1520
1521
1522
static const Prefable<const JSPropertySpec> sAttributes[] = {
1523
  { nullptr, &sAttributes_specs[0] },
1524
  { nullptr, nullptr }
1525
};
1526
1527
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1528
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1529
static_assert(20 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1530
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1531
1532
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1533
#if defined(__clang__)
1534
#pragma clang diagnostic push
1535
#pragma clang diagnostic ignored "-Wmissing-braces"
1536
#endif
1537
static const JSPropertySpec sChromeAttributes_specs[] = {
1538
  { "hitCluster", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hitCluster_getterinfo, nullptr, nullptr },
1539
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1540
};
1541
#if defined(__clang__)
1542
#pragma clang diagnostic pop
1543
#endif
1544
1545
1546
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
1547
  { nullptr, &sChromeAttributes_specs[0] },
1548
  { nullptr, nullptr }
1549
};
1550
1551
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1552
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1553
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1554
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1555
1556
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1557
#if defined(__clang__)
1558
#pragma clang diagnostic push
1559
#pragma clang diagnostic ignored "-Wmissing-braces"
1560
#endif
1561
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
1562
  { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr },
1563
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1564
};
1565
#if defined(__clang__)
1566
#pragma clang diagnostic pop
1567
#endif
1568
1569
1570
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
1571
  { nullptr, &sUnforgeableAttributes_specs[0] },
1572
  { nullptr, nullptr }
1573
};
1574
1575
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1576
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1577
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1578
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1579
1580
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1581
#if defined(__clang__)
1582
#pragma clang diagnostic push
1583
#pragma clang diagnostic ignored "-Wmissing-braces"
1584
#endif
1585
static const ConstantSpec sConstants_specs[] = {
1586
  { "MOZ_SOURCE_UNKNOWN", JS::Int32Value(0) },
1587
  { "MOZ_SOURCE_MOUSE", JS::Int32Value(1) },
1588
  { "MOZ_SOURCE_PEN", JS::Int32Value(2) },
1589
  { "MOZ_SOURCE_ERASER", JS::Int32Value(3) },
1590
  { "MOZ_SOURCE_CURSOR", JS::Int32Value(4) },
1591
  { "MOZ_SOURCE_TOUCH", JS::Int32Value(5) },
1592
  { "MOZ_SOURCE_KEYBOARD", JS::Int32Value(6) },
1593
  { 0, JS::UndefinedValue() }
1594
};
1595
#if defined(__clang__)
1596
#pragma clang diagnostic pop
1597
#endif
1598
1599
1600
static const Prefable<const ConstantSpec> sConstants[] = {
1601
  { nullptr, &sConstants_specs[0] },
1602
  { nullptr, nullptr }
1603
};
1604
1605
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1606
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1607
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1608
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1609
1610
1611
static uint16_t sNativeProperties_sortedPropertyIndices[31];
1612
static PropertyInfo sNativeProperties_propertyInfos[31];
1613
1614
static const NativePropertiesN<4> sNativeProperties = {
1615
  false, 0,
1616
  false, 0,
1617
  true,  0 /* sMethods */,
1618
  true,  1 /* sAttributes */,
1619
  false, 0,
1620
  true,  2 /* sUnforgeableAttributes */,
1621
  true,  3 /* sConstants */,
1622
  -1,
1623
  31,
1624
  sNativeProperties_sortedPropertyIndices,
1625
  {
1626
    { sMethods, &sNativeProperties_propertyInfos[0] },
1627
    { sAttributes, &sNativeProperties_propertyInfos[3] },
1628
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[23] },
1629
    { sConstants, &sNativeProperties_propertyInfos[24] }
1630
  }
1631
};
1632
static_assert(31 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1633
    "We have a property info count that is oversized");
1634
1635
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
1636
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
1637
1638
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1639
  false, 0,
1640
  false, 0,
1641
  false, 0,
1642
  true,  0 /* sChromeAttributes */,
1643
  false, 0,
1644
  false, 0,
1645
  false, 0,
1646
  -1,
1647
  1,
1648
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1649
  {
1650
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
1651
  }
1652
};
1653
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1654
    "We have a property info count that is oversized");
1655
1656
static bool
1657
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1658
0
{
1659
0
  AUTO_PROFILER_LABEL_FAST("MouseEvent constructor", DOM, cx);
1660
0
1661
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1662
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1663
0
  if (!args.isConstructing()) {
1664
0
    // XXXbz wish I could get the name from the callee instead of
1665
0
    // Adding more relocations
1666
0
    return ThrowConstructorWithoutNew(cx, "MouseEvent");
1667
0
  }
1668
0
1669
0
  JS::Rooted<JSObject*> desiredProto(cx);
1670
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1671
0
    return false;
1672
0
  }
1673
0
1674
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1675
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent");
1676
0
  }
1677
0
  GlobalObject global(cx, obj);
1678
0
  if (global.Failed()) {
1679
0
    return false;
1680
0
  }
1681
0
1682
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1683
0
  binding_detail::FakeString arg0;
1684
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1685
0
    return false;
1686
0
  }
1687
0
  binding_detail::FastMouseEventInit arg1;
1688
0
  if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of MouseEvent.constructor", false)) {
1689
0
    return false;
1690
0
  }
1691
0
  Maybe<JSAutoRealm> ar;
1692
0
  if (objIsXray) {
1693
0
    obj = js::CheckedUnwrap(obj);
1694
0
    if (!obj) {
1695
0
      return false;
1696
0
    }
1697
0
    ar.emplace(cx, obj);
1698
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1699
0
      return false;
1700
0
    }
1701
0
  }
1702
0
  FastErrorResult rv;
1703
0
  auto result(StrongOrRawPtr<mozilla::dom::MouseEvent>(mozilla::dom::MouseEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
1704
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1705
0
    return false;
1706
0
  }
1707
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1708
0
  static_assert(!IsPointer<decltype(result)>::value,
1709
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1710
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1711
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1712
0
    return false;
1713
0
  }
1714
0
  return true;
1715
0
}
1716
1717
static const js::ClassOps sInterfaceObjectClassOps = {
1718
    nullptr,               /* addProperty */
1719
    nullptr,               /* delProperty */
1720
    nullptr,               /* enumerate */
1721
    nullptr,               /* newEnumerate */
1722
    nullptr,               /* resolve */
1723
    nullptr,               /* mayResolve */
1724
    nullptr,               /* finalize */
1725
    _constructor, /* call */
1726
    nullptr,               /* hasInstance */
1727
    _constructor, /* construct */
1728
    nullptr,               /* trace */
1729
};
1730
1731
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1732
  {
1733
    "Function",
1734
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1735
    &sInterfaceObjectClassOps,
1736
    JS_NULL_CLASS_SPEC,
1737
    JS_NULL_CLASS_EXT,
1738
    &sInterfaceObjectClassObjectOps
1739
  },
1740
  eInterface,
1741
  true,
1742
  prototypes::id::MouseEvent,
1743
  PrototypeTraits<prototypes::id::MouseEvent>::Depth,
1744
  sNativePropertyHooks,
1745
  "function MouseEvent() {\n    [native code]\n}",
1746
  UIEvent_Binding::GetConstructorObject
1747
};
1748
1749
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1750
  {
1751
    "MouseEventPrototype",
1752
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
1753
    JS_NULL_CLASS_OPS,
1754
    JS_NULL_CLASS_SPEC,
1755
    JS_NULL_CLASS_EXT,
1756
    JS_NULL_OBJECT_OPS
1757
  },
1758
  eInterfacePrototype,
1759
  false,
1760
  prototypes::id::MouseEvent,
1761
  PrototypeTraits<prototypes::id::MouseEvent>::Depth,
1762
  sNativePropertyHooks,
1763
  "[object MouseEventPrototype]",
1764
  UIEvent_Binding::GetProtoObject
1765
};
1766
1767
static const js::ClassOps sClassOps = {
1768
  _addProperty, /* addProperty */
1769
  nullptr,               /* delProperty */
1770
  nullptr,               /* enumerate */
1771
  nullptr, /* newEnumerate */
1772
  nullptr, /* resolve */
1773
  nullptr, /* mayResolve */
1774
  _finalize, /* finalize */
1775
  nullptr, /* call */
1776
  nullptr,               /* hasInstance */
1777
  nullptr,               /* construct */
1778
  nullptr, /* trace */
1779
};
1780
1781
static const js::ClassExtension sClassExtension = {
1782
  nullptr, /* weakmapKeyDelegateOp */
1783
  _objectMoved /* objectMovedOp */
1784
};
1785
1786
static const DOMJSClass sClass = {
1787
  { "MouseEvent",
1788
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
1789
    &sClassOps,
1790
    JS_NULL_CLASS_SPEC,
1791
    &sClassExtension,
1792
    JS_NULL_OBJECT_OPS
1793
  },
1794
  { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::MouseEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1795
  IsBaseOf<nsISupports, mozilla::dom::MouseEvent >::value,
1796
  sNativePropertyHooks,
1797
  FindAssociatedGlobalForNative<mozilla::dom::MouseEvent>::Get,
1798
  GetProtoObjectHandle,
1799
  GetCCParticipant<mozilla::dom::MouseEvent>::Get()
1800
};
1801
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1802
              "Must have the right minimal number of reserved slots.");
1803
static_assert(1 >= 1,
1804
              "Must have enough reserved slots.");
1805
1806
const JSClass*
1807
GetJSClass()
1808
0
{
1809
0
  return sClass.ToJSClass();
1810
0
}
1811
1812
bool
1813
Wrap(JSContext* aCx, mozilla::dom::MouseEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1814
0
{
1815
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::MouseEvent>::value,
1816
0
                "Shouldn't have wrappercached things that are not refcounted.");
1817
0
  MOZ_ASSERT(static_cast<mozilla::dom::MouseEvent*>(aObject) ==
1818
0
             reinterpret_cast<mozilla::dom::MouseEvent*>(aObject),
1819
0
             "Multiple inheritance for mozilla::dom::MouseEvent is broken.");
1820
0
  MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
1821
0
             reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
1822
0
             "Multiple inheritance for mozilla::dom::UIEvent is broken.");
1823
0
  MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
1824
0
             reinterpret_cast<mozilla::dom::Event*>(aObject),
1825
0
             "Multiple inheritance for mozilla::dom::Event is broken.");
1826
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1827
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1828
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1829
0
             "You should probably not be using Wrap() directly; use "
1830
0
             "GetOrCreateDOMReflector instead");
1831
0
1832
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1833
0
             "nsISupports must be on our primary inheritance chain");
1834
0
1835
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1836
0
  if (!global) {
1837
0
    return false;
1838
0
  }
1839
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1840
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1841
0
1842
0
  // That might have ended up wrapping us already, due to the wonders
1843
0
  // of XBL.  Check for that, and bail out as needed.
1844
0
  aReflector.set(aCache->GetWrapper());
1845
0
  if (aReflector) {
1846
#ifdef DEBUG
1847
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1848
#endif // DEBUG
1849
    return true;
1850
0
  }
1851
0
1852
0
  JSAutoRealm ar(aCx, global);
1853
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1854
0
  if (!canonicalProto) {
1855
0
    return false;
1856
0
  }
1857
0
  JS::Rooted<JSObject*> proto(aCx);
1858
0
  if (aGivenProto) {
1859
0
    proto = aGivenProto;
1860
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1861
0
    // coming in, we changed compartments to that of "parent" so may need
1862
0
    // to wrap the proto here.
1863
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1864
0
      if (!JS_WrapObject(aCx, &proto)) {
1865
0
        return false;
1866
0
      }
1867
0
    }
1868
0
  } else {
1869
0
    proto = canonicalProto;
1870
0
  }
1871
0
1872
0
  BindingJSObjectCreator<mozilla::dom::MouseEvent> creator(aCx);
1873
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1874
0
  if (!aReflector) {
1875
0
    return false;
1876
0
  }
1877
0
1878
0
  aCache->SetWrapper(aReflector);
1879
0
1880
0
  // Important: do unforgeable property setup after we have handed
1881
0
  // over ownership of the C++ object to obj as needed, so that if
1882
0
  // we fail and it ends up GCed it won't have problems in the
1883
0
  // finalizer trying to drop its ownership of the C++ object.
1884
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
1885
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
1886
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
1887
0
    aCache->ReleaseWrapper(aObject);
1888
0
    aCache->ClearWrapper();
1889
0
    return false;
1890
0
  }
1891
0
  creator.InitializationSucceeded();
1892
0
1893
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1894
0
             aCache->GetWrapperPreserveColor() == aReflector);
1895
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1896
0
  // otherwise we won't be able to properly recreate it later, since
1897
0
  // we won't know what proto to use.  Note that we don't check
1898
0
  // aGivenProto here, since it's entirely possible (and even
1899
0
  // somewhat common) to have a non-null aGivenProto which is the
1900
0
  // same as canonicalProto.
1901
0
  if (proto != canonicalProto) {
1902
0
    PreserveWrapper(aObject);
1903
0
  }
1904
0
1905
0
  return true;
1906
0
}
1907
1908
const NativePropertyHooks sNativePropertyHooks[] = { {
1909
  nullptr,
1910
  nullptr,
1911
  nullptr,
1912
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1913
  prototypes::id::MouseEvent,
1914
  constructors::id::MouseEvent,
1915
  UIEvent_Binding::sNativePropertyHooks,
1916
  &DefaultXrayExpandoObjectClass
1917
} };
1918
1919
void
1920
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1921
0
{
1922
0
  JS::Handle<JSObject*> parentProto(UIEvent_Binding::GetProtoObjectHandle(aCx));
1923
0
  if (!parentProto) {
1924
0
    return;
1925
0
  }
1926
0
1927
0
  JS::Handle<JSObject*> constructorProto(UIEvent_Binding::GetConstructorObjectHandle(aCx));
1928
0
  if (!constructorProto) {
1929
0
    return;
1930
0
  }
1931
0
1932
0
  static bool sIdsInited = false;
1933
0
  if (!sIdsInited && NS_IsMainThread()) {
1934
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1935
0
      return;
1936
0
    }
1937
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1938
0
      return;
1939
0
    }
1940
0
    sIdsInited = true;
1941
0
  }
1942
0
1943
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MouseEvent);
1944
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MouseEvent);
1945
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1946
0
                              &sPrototypeClass.mBase, protoCache,
1947
0
                              nullptr,
1948
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1949
0
                              interfaceCache,
1950
0
                              sNativeProperties.Upcast(),
1951
0
                              sChromeOnlyNativeProperties.Upcast(),
1952
0
                              "MouseEvent", aDefineOnGlobal,
1953
0
                              nullptr,
1954
0
                              false);
1955
0
1956
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
1957
0
  {
1958
0
    JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1959
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1960
0
    if (!unforgeableHolder) {
1961
0
      *protoCache = nullptr;
1962
0
      if (interfaceCache) {
1963
0
        *interfaceCache = nullptr;
1964
0
      }
1965
0
      return;
1966
0
    }
1967
0
  }
1968
0
1969
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1970
0
    *protoCache = nullptr;
1971
0
    if (interfaceCache) {
1972
0
      *interfaceCache = nullptr;
1973
0
    }
1974
0
    return;
1975
0
  }
1976
0
1977
0
  if (*protoCache) {
1978
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1979
0
                        JS::ObjectValue(*unforgeableHolder));
1980
0
  }
1981
0
}
1982
1983
JSObject*
1984
GetProtoObject(JSContext* aCx)
1985
0
{
1986
0
  return GetProtoObjectHandle(aCx);
1987
0
}
1988
1989
JSObject*
1990
GetConstructorObject(JSContext* aCx)
1991
0
{
1992
0
  return GetConstructorObjectHandle(aCx);
1993
0
}
1994
1995
} // namespace MouseEvent_Binding
1996
1997
1998
1999
} // namespace dom
2000
} // namespace mozilla