Coverage Report

Created: 2018-09-25 14:53

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