Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SimpleGestureEventBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SimpleGestureEvent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "MouseEventBinding.h"
4
#include "SimpleGestureEventBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/FloatingPoint.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/dom/BindingUtils.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/EventTarget.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/PrimitiveConversions.h"
14
#include "mozilla/dom/SimpleGestureEvent.h"
15
#include "mozilla/dom/XrayExpandoClass.h"
16
#include "nsGlobalWindow.h"
17
18
namespace mozilla {
19
namespace dom {
20
21
namespace binding_detail {}; // Just to make sure it's known as a namespace
22
using namespace mozilla::dom::binding_detail;
23
24
25
namespace SimpleGestureEvent_Binding {
26
27
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<MouseEvent_Binding::NativeType>::value,
28
              "Can't inherit from an interface with a different ownership model.");
29
30
MOZ_CAN_RUN_SCRIPT static bool
31
get_allowedDirections(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
32
0
{
33
0
  AUTO_PROFILER_LABEL_FAST("get SimpleGestureEvent.allowedDirections", DOM, cx);
34
0
35
0
  uint32_t result(self->AllowedDirections());
36
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
37
0
  args.rval().setNumber(result);
38
0
  return true;
39
0
}
40
41
MOZ_CAN_RUN_SCRIPT static bool
42
set_allowedDirections(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitSetterCallArgs args)
43
0
{
44
0
  AUTO_PROFILER_LABEL_FAST("set SimpleGestureEvent.allowedDirections", DOM, cx);
45
0
46
0
  uint32_t arg0;
47
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
48
0
    return false;
49
0
  }
50
0
  self->SetAllowedDirections(arg0);
51
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
52
0
53
0
  return true;
54
0
}
55
56
static const JSJitInfo allowedDirections_getterinfo = {
57
  { (JSJitGetterOp)get_allowedDirections },
58
  { prototypes::id::SimpleGestureEvent },
59
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
60
  JSJitInfo::Getter,
61
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
62
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
63
  true,  /* isInfallible. False in setters. */
64
  false,  /* isMovable.  Not relevant for setters. */
65
  false, /* isEliminatable.  Not relevant for setters. */
66
  false, /* isAlwaysInSlot.  Only relevant for getters. */
67
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
68
  false,  /* isTypedMethod.  Only relevant for methods. */
69
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
70
};
71
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
72
static_assert(0 < 1, "There is no slot for us");
73
static const JSJitInfo allowedDirections_setterinfo = {
74
  { (JSJitGetterOp)set_allowedDirections },
75
  { prototypes::id::SimpleGestureEvent },
76
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
77
  JSJitInfo::Setter,
78
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
79
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
80
  false,  /* isInfallible. False in setters. */
81
  false,  /* isMovable.  Not relevant for setters. */
82
  false, /* isEliminatable.  Not relevant for setters. */
83
  false, /* isAlwaysInSlot.  Only relevant for getters. */
84
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
85
  false,  /* isTypedMethod.  Only relevant for methods. */
86
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
87
};
88
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
89
static_assert(0 < 1, "There is no slot for us");
90
91
MOZ_CAN_RUN_SCRIPT static bool
92
get_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
93
0
{
94
0
  AUTO_PROFILER_LABEL_FAST("get SimpleGestureEvent.direction", DOM, cx);
95
0
96
0
  uint32_t result(self->Direction());
97
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
98
0
  args.rval().setNumber(result);
99
0
  return true;
100
0
}
101
102
static const JSJitInfo direction_getterinfo = {
103
  { (JSJitGetterOp)get_direction },
104
  { prototypes::id::SimpleGestureEvent },
105
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
106
  JSJitInfo::Getter,
107
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
108
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
109
  true,  /* isInfallible. False in setters. */
110
  false,  /* isMovable.  Not relevant for setters. */
111
  false, /* isEliminatable.  Not relevant for setters. */
112
  false, /* isAlwaysInSlot.  Only relevant for getters. */
113
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
114
  false,  /* isTypedMethod.  Only relevant for methods. */
115
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
116
};
117
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
118
static_assert(0 < 1, "There is no slot for us");
119
120
MOZ_CAN_RUN_SCRIPT static bool
121
get_delta(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
122
0
{
123
0
  AUTO_PROFILER_LABEL_FAST("get SimpleGestureEvent.delta", DOM, cx);
124
0
125
0
  double result(self->Delta());
126
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
127
0
  args.rval().set(JS_NumberValue(double(result)));
128
0
  return true;
129
0
}
130
131
static const JSJitInfo delta_getterinfo = {
132
  { (JSJitGetterOp)get_delta },
133
  { prototypes::id::SimpleGestureEvent },
134
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
135
  JSJitInfo::Getter,
136
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
137
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
138
  true,  /* isInfallible. False in setters. */
139
  false,  /* isMovable.  Not relevant for setters. */
140
  false, /* isEliminatable.  Not relevant for setters. */
141
  false, /* isAlwaysInSlot.  Only relevant for getters. */
142
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
143
  false,  /* isTypedMethod.  Only relevant for methods. */
144
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
145
};
146
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
147
static_assert(0 < 1, "There is no slot for us");
148
149
MOZ_CAN_RUN_SCRIPT static bool
150
get_clickCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
151
0
{
152
0
  AUTO_PROFILER_LABEL_FAST("get SimpleGestureEvent.clickCount", DOM, cx);
153
0
154
0
  uint32_t result(self->ClickCount());
155
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
156
0
  args.rval().setNumber(result);
157
0
  return true;
158
0
}
159
160
static const JSJitInfo clickCount_getterinfo = {
161
  { (JSJitGetterOp)get_clickCount },
162
  { prototypes::id::SimpleGestureEvent },
163
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
164
  JSJitInfo::Getter,
165
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
166
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
167
  true,  /* isInfallible. False in setters. */
168
  false,  /* isMovable.  Not relevant for setters. */
169
  false, /* isEliminatable.  Not relevant for setters. */
170
  false, /* isAlwaysInSlot.  Only relevant for getters. */
171
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
172
  false,  /* isTypedMethod.  Only relevant for methods. */
173
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
174
};
175
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
176
static_assert(0 < 1, "There is no slot for us");
177
178
MOZ_CAN_RUN_SCRIPT static bool
179
initSimpleGestureEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, const JSJitMethodCallArgs& args)
180
0
{
181
0
  AUTO_PROFILER_LABEL_FAST("SimpleGestureEvent.initSimpleGestureEvent", DOM, cx);
182
0
183
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
184
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SimpleGestureEvent.initSimpleGestureEvent");
185
0
  }
186
0
  binding_detail::FakeString arg0;
187
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
188
0
    return false;
189
0
  }
190
0
  bool arg1;
191
0
  if (args.hasDefined(1)) {
192
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
193
0
      return false;
194
0
    }
195
0
  } else {
196
0
    arg1 = false;
197
0
  }
198
0
  bool arg2;
199
0
  if (args.hasDefined(2)) {
200
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
201
0
      return false;
202
0
    }
203
0
  } else {
204
0
    arg2 = false;
205
0
  }
206
0
  nsGlobalWindowInner* arg3;
207
0
  if (args.hasDefined(3)) {
208
0
    if (args[3].isObject()) {
209
0
      {
210
0
        nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(args[3], arg3);
211
0
        if (NS_FAILED(rv)) {
212
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of SimpleGestureEvent.initSimpleGestureEvent", "Window");
213
0
          return false;
214
0
        }
215
0
      }
216
0
    } else if (args[3].isNullOrUndefined()) {
217
0
      arg3 = nullptr;
218
0
    } else {
219
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of SimpleGestureEvent.initSimpleGestureEvent");
220
0
      return false;
221
0
    }
222
0
  } else {
223
0
    arg3 = nullptr;
224
0
  }
225
0
  int32_t arg4;
226
0
  if (args.hasDefined(4)) {
227
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
228
0
      return false;
229
0
    }
230
0
  } else {
231
0
    arg4 = 0;
232
0
  }
233
0
  int32_t arg5;
234
0
  if (args.hasDefined(5)) {
235
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) {
236
0
      return false;
237
0
    }
238
0
  } else {
239
0
    arg5 = 0;
240
0
  }
241
0
  int32_t arg6;
242
0
  if (args.hasDefined(6)) {
243
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) {
244
0
      return false;
245
0
    }
246
0
  } else {
247
0
    arg6 = 0;
248
0
  }
249
0
  int32_t arg7;
250
0
  if (args.hasDefined(7)) {
251
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) {
252
0
      return false;
253
0
    }
254
0
  } else {
255
0
    arg7 = 0;
256
0
  }
257
0
  int32_t arg8;
258
0
  if (args.hasDefined(8)) {
259
0
    if (!ValueToPrimitive<int32_t, eDefault>(cx, args[8], &arg8)) {
260
0
      return false;
261
0
    }
262
0
  } else {
263
0
    arg8 = 0;
264
0
  }
265
0
  bool arg9;
266
0
  if (args.hasDefined(9)) {
267
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[9], &arg9)) {
268
0
      return false;
269
0
    }
270
0
  } else {
271
0
    arg9 = false;
272
0
  }
273
0
  bool arg10;
274
0
  if (args.hasDefined(10)) {
275
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[10], &arg10)) {
276
0
      return false;
277
0
    }
278
0
  } else {
279
0
    arg10 = false;
280
0
  }
281
0
  bool arg11;
282
0
  if (args.hasDefined(11)) {
283
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[11], &arg11)) {
284
0
      return false;
285
0
    }
286
0
  } else {
287
0
    arg11 = false;
288
0
  }
289
0
  bool arg12;
290
0
  if (args.hasDefined(12)) {
291
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[12], &arg12)) {
292
0
      return false;
293
0
    }
294
0
  } else {
295
0
    arg12 = false;
296
0
  }
297
0
  int16_t arg13;
298
0
  if (args.hasDefined(13)) {
299
0
    if (!ValueToPrimitive<int16_t, eDefault>(cx, args[13], &arg13)) {
300
0
      return false;
301
0
    }
302
0
  } else {
303
0
    arg13 = 0;
304
0
  }
305
0
  mozilla::dom::EventTarget* arg14;
306
0
  if (args.hasDefined(14)) {
307
0
    if (args[14].isObject()) {
308
0
      {
309
0
        nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(args[14], arg14);
310
0
        if (NS_FAILED(rv)) {
311
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 15 of SimpleGestureEvent.initSimpleGestureEvent", "EventTarget");
312
0
          return false;
313
0
        }
314
0
      }
315
0
    } else if (args[14].isNullOrUndefined()) {
316
0
      arg14 = nullptr;
317
0
    } else {
318
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 15 of SimpleGestureEvent.initSimpleGestureEvent");
319
0
      return false;
320
0
    }
321
0
  } else {
322
0
    arg14 = nullptr;
323
0
  }
324
0
  uint32_t arg15;
325
0
  if (args.hasDefined(15)) {
326
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[15], &arg15)) {
327
0
      return false;
328
0
    }
329
0
  } else {
330
0
    arg15 = 0U;
331
0
  }
332
0
  uint32_t arg16;
333
0
  if (args.hasDefined(16)) {
334
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[16], &arg16)) {
335
0
      return false;
336
0
    }
337
0
  } else {
338
0
    arg16 = 0U;
339
0
  }
340
0
  double arg17;
341
0
  if (args.hasDefined(17)) {
342
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[17], &arg17)) {
343
0
      return false;
344
0
    } else if (!mozilla::IsFinite(arg17)) {
345
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 18 of SimpleGestureEvent.initSimpleGestureEvent");
346
0
      return false;
347
0
    }
348
0
  } else {
349
0
    arg17 = 0.0;
350
0
  }
351
0
  uint32_t arg18;
352
0
  if (args.hasDefined(18)) {
353
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[18], &arg18)) {
354
0
      return false;
355
0
    }
356
0
  } else {
357
0
    arg18 = 0U;
358
0
  }
359
0
  self->InitSimpleGestureEvent(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, arg17, arg18);
360
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
361
0
  args.rval().setUndefined();
362
0
  return true;
363
0
}
364
365
static const JSJitInfo initSimpleGestureEvent_methodinfo = {
366
  { (JSJitGetterOp)initSimpleGestureEvent },
367
  { prototypes::id::SimpleGestureEvent },
368
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
369
  JSJitInfo::Method,
370
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
371
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
372
  false,  /* isInfallible. False in setters. */
373
  false,  /* isMovable.  Not relevant for setters. */
374
  false, /* isEliminatable.  Not relevant for setters. */
375
  false, /* isAlwaysInSlot.  Only relevant for getters. */
376
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
377
  false,  /* isTypedMethod.  Only relevant for methods. */
378
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
379
};
380
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
381
static_assert(0 < 1, "There is no slot for us");
382
383
MOZ_CAN_RUN_SCRIPT static bool
384
get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
385
0
{
386
0
  AUTO_PROFILER_LABEL_FAST("get SimpleGestureEvent.isTrusted", DOM, cx);
387
0
388
0
  bool result(self->IsTrusted());
389
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
390
0
  args.rval().setBoolean(result);
391
0
  return true;
392
0
}
393
394
static const JSJitInfo isTrusted_getterinfo = {
395
  { (JSJitGetterOp)get_isTrusted },
396
  { prototypes::id::SimpleGestureEvent },
397
  { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
398
  JSJitInfo::Getter,
399
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
400
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
401
  true,  /* isInfallible. False in setters. */
402
  true,  /* isMovable.  Not relevant for setters. */
403
  true, /* isEliminatable.  Not relevant for setters. */
404
  false, /* isAlwaysInSlot.  Only relevant for getters. */
405
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
406
  false,  /* isTypedMethod.  Only relevant for methods. */
407
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
408
};
409
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
410
static_assert(0 < 1, "There is no slot for us");
411
412
static bool
413
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
414
0
{
415
0
  mozilla::dom::SimpleGestureEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SimpleGestureEvent>(obj);
416
0
  // We don't want to preserve if we don't have a wrapper, and we
417
0
  // obviously can't preserve if we're not initialized.
418
0
  if (self && self->GetWrapperPreserveColor()) {
419
0
    PreserveWrapper(self);
420
0
  }
421
0
  return true;
422
0
}
423
424
static void
425
_finalize(js::FreeOp* fop, JSObject* obj)
426
0
{
427
0
  mozilla::dom::SimpleGestureEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SimpleGestureEvent>(obj);
428
0
  if (self) {
429
0
    ClearWrapper(self, self, obj);
430
0
    AddForDeferredFinalization<mozilla::dom::SimpleGestureEvent>(self);
431
0
  }
432
0
}
433
434
static size_t
435
_objectMoved(JSObject* obj, JSObject* old)
436
0
{
437
0
  mozilla::dom::SimpleGestureEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SimpleGestureEvent>(obj);
438
0
  if (self) {
439
0
    UpdateWrapper(self, self, obj, old);
440
0
  }
441
0
442
0
  return 0;
443
0
}
444
445
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
446
#if defined(__clang__)
447
#pragma clang diagnostic push
448
#pragma clang diagnostic ignored "-Wmissing-braces"
449
#endif
450
static const JSFunctionSpec sMethods_specs[] = {
451
  JS_FNSPEC("initSimpleGestureEvent", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&initSimpleGestureEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
452
  JS_FS_END
453
};
454
#if defined(__clang__)
455
#pragma clang diagnostic pop
456
#endif
457
458
459
static const Prefable<const JSFunctionSpec> sMethods[] = {
460
  { nullptr, &sMethods_specs[0] },
461
  { nullptr, nullptr }
462
};
463
464
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
465
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
466
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
467
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
468
469
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
470
#if defined(__clang__)
471
#pragma clang diagnostic push
472
#pragma clang diagnostic ignored "-Wmissing-braces"
473
#endif
474
static const JSPropertySpec sAttributes_specs[] = {
475
  { "allowedDirections", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &allowedDirections_getterinfo, GenericSetter<NormalThisPolicy>, &allowedDirections_setterinfo },
476
  { "direction", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &direction_getterinfo, nullptr, nullptr },
477
  { "delta", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &delta_getterinfo, nullptr, nullptr },
478
  { "clickCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &clickCount_getterinfo, nullptr, nullptr },
479
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
480
};
481
#if defined(__clang__)
482
#pragma clang diagnostic pop
483
#endif
484
485
486
static const Prefable<const JSPropertySpec> sAttributes[] = {
487
  { nullptr, &sAttributes_specs[0] },
488
  { nullptr, nullptr }
489
};
490
491
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
492
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
493
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
494
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
495
496
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
497
#if defined(__clang__)
498
#pragma clang diagnostic push
499
#pragma clang diagnostic ignored "-Wmissing-braces"
500
#endif
501
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
502
  { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr },
503
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
504
};
505
#if defined(__clang__)
506
#pragma clang diagnostic pop
507
#endif
508
509
510
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
511
  { nullptr, &sUnforgeableAttributes_specs[0] },
512
  { nullptr, nullptr }
513
};
514
515
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
516
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
517
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
518
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
519
520
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
521
#if defined(__clang__)
522
#pragma clang diagnostic push
523
#pragma clang diagnostic ignored "-Wmissing-braces"
524
#endif
525
static const ConstantSpec sConstants_specs[] = {
526
  { "DIRECTION_UP", JS::NumberValue(1U) },
527
  { "DIRECTION_DOWN", JS::NumberValue(2U) },
528
  { "DIRECTION_LEFT", JS::NumberValue(4U) },
529
  { "DIRECTION_RIGHT", JS::NumberValue(8U) },
530
  { "ROTATION_COUNTERCLOCKWISE", JS::NumberValue(1U) },
531
  { "ROTATION_CLOCKWISE", JS::NumberValue(2U) },
532
  { 0, JS::UndefinedValue() }
533
};
534
#if defined(__clang__)
535
#pragma clang diagnostic pop
536
#endif
537
538
539
static const Prefable<const ConstantSpec> sConstants[] = {
540
  { nullptr, &sConstants_specs[0] },
541
  { nullptr, nullptr }
542
};
543
544
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
545
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
546
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
547
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
548
549
550
static uint16_t sNativeProperties_sortedPropertyIndices[12];
551
static PropertyInfo sNativeProperties_propertyInfos[12];
552
553
static const NativePropertiesN<4> sNativeProperties = {
554
  false, 0,
555
  false, 0,
556
  true,  0 /* sMethods */,
557
  true,  1 /* sAttributes */,
558
  false, 0,
559
  true,  2 /* sUnforgeableAttributes */,
560
  true,  3 /* sConstants */,
561
  -1,
562
  12,
563
  sNativeProperties_sortedPropertyIndices,
564
  {
565
    { sMethods, &sNativeProperties_propertyInfos[0] },
566
    { sAttributes, &sNativeProperties_propertyInfos[1] },
567
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[5] },
568
    { sConstants, &sNativeProperties_propertyInfos[6] }
569
  }
570
};
571
static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
572
    "We have a property info count that is oversized");
573
574
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
575
  {
576
    "Function",
577
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
578
    &sBoringInterfaceObjectClassClassOps,
579
    JS_NULL_CLASS_SPEC,
580
    JS_NULL_CLASS_EXT,
581
    &sInterfaceObjectClassObjectOps
582
  },
583
  eInterface,
584
  true,
585
  prototypes::id::SimpleGestureEvent,
586
  PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth,
587
  sNativePropertyHooks,
588
  "function SimpleGestureEvent() {\n    [native code]\n}",
589
  MouseEvent_Binding::GetConstructorObject
590
};
591
592
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
593
  {
594
    "SimpleGestureEventPrototype",
595
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
596
    JS_NULL_CLASS_OPS,
597
    JS_NULL_CLASS_SPEC,
598
    JS_NULL_CLASS_EXT,
599
    JS_NULL_OBJECT_OPS
600
  },
601
  eInterfacePrototype,
602
  false,
603
  prototypes::id::SimpleGestureEvent,
604
  PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth,
605
  sNativePropertyHooks,
606
  "[object SimpleGestureEventPrototype]",
607
  MouseEvent_Binding::GetProtoObject
608
};
609
610
bool
611
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
612
0
{
613
0
  return IsChromeOrXBL(aCx, aObj);
614
0
}
615
616
static const js::ClassOps sClassOps = {
617
  _addProperty, /* addProperty */
618
  nullptr,               /* delProperty */
619
  nullptr,               /* enumerate */
620
  nullptr, /* newEnumerate */
621
  nullptr, /* resolve */
622
  nullptr, /* mayResolve */
623
  _finalize, /* finalize */
624
  nullptr, /* call */
625
  nullptr,               /* hasInstance */
626
  nullptr,               /* construct */
627
  nullptr, /* trace */
628
};
629
630
static const js::ClassExtension sClassExtension = {
631
  nullptr, /* weakmapKeyDelegateOp */
632
  _objectMoved /* objectMovedOp */
633
};
634
635
static const DOMJSClass sClass = {
636
  { "SimpleGestureEvent",
637
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
638
    &sClassOps,
639
    JS_NULL_CLASS_SPEC,
640
    &sClassExtension,
641
    JS_NULL_OBJECT_OPS
642
  },
643
  { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::MouseEvent, prototypes::id::SimpleGestureEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
644
  IsBaseOf<nsISupports, mozilla::dom::SimpleGestureEvent >::value,
645
  sNativePropertyHooks,
646
  FindAssociatedGlobalForNative<mozilla::dom::SimpleGestureEvent>::Get,
647
  GetProtoObjectHandle,
648
  GetCCParticipant<mozilla::dom::SimpleGestureEvent>::Get()
649
};
650
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
651
              "Must have the right minimal number of reserved slots.");
652
static_assert(1 >= 1,
653
              "Must have enough reserved slots.");
654
655
const JSClass*
656
GetJSClass()
657
0
{
658
0
  return sClass.ToJSClass();
659
0
}
660
661
bool
662
Wrap(JSContext* aCx, mozilla::dom::SimpleGestureEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
663
0
{
664
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SimpleGestureEvent>::value,
665
0
                "Shouldn't have wrappercached things that are not refcounted.");
666
0
  MOZ_ASSERT(static_cast<mozilla::dom::SimpleGestureEvent*>(aObject) ==
667
0
             reinterpret_cast<mozilla::dom::SimpleGestureEvent*>(aObject),
668
0
             "Multiple inheritance for mozilla::dom::SimpleGestureEvent is broken.");
669
0
  MOZ_ASSERT(static_cast<mozilla::dom::MouseEvent*>(aObject) ==
670
0
             reinterpret_cast<mozilla::dom::MouseEvent*>(aObject),
671
0
             "Multiple inheritance for mozilla::dom::MouseEvent is broken.");
672
0
  MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
673
0
             reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
674
0
             "Multiple inheritance for mozilla::dom::UIEvent is broken.");
675
0
  MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
676
0
             reinterpret_cast<mozilla::dom::Event*>(aObject),
677
0
             "Multiple inheritance for mozilla::dom::Event is broken.");
678
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
679
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
680
0
  MOZ_ASSERT(!aCache->GetWrapper(),
681
0
             "You should probably not be using Wrap() directly; use "
682
0
             "GetOrCreateDOMReflector instead");
683
0
684
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
685
0
             "nsISupports must be on our primary inheritance chain");
686
0
687
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
688
0
  if (!global) {
689
0
    return false;
690
0
  }
691
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
692
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
693
0
694
0
  // That might have ended up wrapping us already, due to the wonders
695
0
  // of XBL.  Check for that, and bail out as needed.
696
0
  aReflector.set(aCache->GetWrapper());
697
0
  if (aReflector) {
698
#ifdef DEBUG
699
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
700
#endif // DEBUG
701
    return true;
702
0
  }
703
0
704
0
  JSAutoRealm ar(aCx, global);
705
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
706
0
  if (!canonicalProto) {
707
0
    return false;
708
0
  }
709
0
  JS::Rooted<JSObject*> proto(aCx);
710
0
  if (aGivenProto) {
711
0
    proto = aGivenProto;
712
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
713
0
    // coming in, we changed compartments to that of "parent" so may need
714
0
    // to wrap the proto here.
715
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
716
0
      if (!JS_WrapObject(aCx, &proto)) {
717
0
        return false;
718
0
      }
719
0
    }
720
0
  } else {
721
0
    proto = canonicalProto;
722
0
  }
723
0
724
0
  BindingJSObjectCreator<mozilla::dom::SimpleGestureEvent> creator(aCx);
725
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
726
0
  if (!aReflector) {
727
0
    return false;
728
0
  }
729
0
730
0
  aCache->SetWrapper(aReflector);
731
0
732
0
  // Important: do unforgeable property setup after we have handed
733
0
  // over ownership of the C++ object to obj as needed, so that if
734
0
  // we fail and it ends up GCed it won't have problems in the
735
0
  // finalizer trying to drop its ownership of the C++ object.
736
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
737
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
738
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
739
0
    aCache->ReleaseWrapper(aObject);
740
0
    aCache->ClearWrapper();
741
0
    return false;
742
0
  }
743
0
  creator.InitializationSucceeded();
744
0
745
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
746
0
             aCache->GetWrapperPreserveColor() == aReflector);
747
0
  // If proto != canonicalProto, we have to preserve our wrapper;
748
0
  // otherwise we won't be able to properly recreate it later, since
749
0
  // we won't know what proto to use.  Note that we don't check
750
0
  // aGivenProto here, since it's entirely possible (and even
751
0
  // somewhat common) to have a non-null aGivenProto which is the
752
0
  // same as canonicalProto.
753
0
  if (proto != canonicalProto) {
754
0
    PreserveWrapper(aObject);
755
0
  }
756
0
757
0
  return true;
758
0
}
759
760
const NativePropertyHooks sNativePropertyHooks[] = { {
761
  nullptr,
762
  nullptr,
763
  nullptr,
764
  { sNativeProperties.Upcast(), nullptr },
765
  prototypes::id::SimpleGestureEvent,
766
  constructors::id::SimpleGestureEvent,
767
  MouseEvent_Binding::sNativePropertyHooks,
768
  &DefaultXrayExpandoObjectClass
769
} };
770
771
void
772
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
773
0
{
774
0
  JS::Handle<JSObject*> parentProto(MouseEvent_Binding::GetProtoObjectHandle(aCx));
775
0
  if (!parentProto) {
776
0
    return;
777
0
  }
778
0
779
0
  JS::Handle<JSObject*> constructorProto(MouseEvent_Binding::GetConstructorObjectHandle(aCx));
780
0
  if (!constructorProto) {
781
0
    return;
782
0
  }
783
0
784
0
  static bool sIdsInited = false;
785
0
  if (!sIdsInited && NS_IsMainThread()) {
786
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
787
0
      return;
788
0
    }
789
0
    sIdsInited = true;
790
0
  }
791
0
792
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SimpleGestureEvent);
793
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SimpleGestureEvent);
794
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
795
0
                              &sPrototypeClass.mBase, protoCache,
796
0
                              nullptr,
797
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
798
0
                              interfaceCache,
799
0
                              sNativeProperties.Upcast(),
800
0
                              nullptr,
801
0
                              "SimpleGestureEvent", aDefineOnGlobal,
802
0
                              nullptr,
803
0
                              false);
804
0
805
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
806
0
  {
807
0
    JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
808
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
809
0
    if (!unforgeableHolder) {
810
0
      *protoCache = nullptr;
811
0
      if (interfaceCache) {
812
0
        *interfaceCache = nullptr;
813
0
      }
814
0
      return;
815
0
    }
816
0
  }
817
0
818
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
819
0
    *protoCache = nullptr;
820
0
    if (interfaceCache) {
821
0
      *interfaceCache = nullptr;
822
0
    }
823
0
    return;
824
0
  }
825
0
826
0
  if (*protoCache) {
827
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
828
0
                        JS::ObjectValue(*unforgeableHolder));
829
0
  }
830
0
}
831
832
JSObject*
833
GetConstructorObject(JSContext* aCx)
834
0
{
835
0
  return GetConstructorObjectHandle(aCx);
836
0
}
837
838
} // namespace SimpleGestureEvent_Binding
839
840
841
842
} // namespace dom
843
} // namespace mozilla