Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/NodeIteratorBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM NodeIterator.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "NodeFilterBinding.h"
4
#include "NodeIteratorBinding.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/NodeIterator.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 "nsINode.h"
15
16
namespace mozilla {
17
namespace dom {
18
19
namespace binding_detail {}; // Just to make sure it's known as a namespace
20
using namespace mozilla::dom::binding_detail;
21
22
23
namespace NodeIterator_Binding {
24
25
MOZ_CAN_RUN_SCRIPT static bool
26
get_root(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, JSJitGetterCallArgs args)
27
0
{
28
0
  AUTO_PROFILER_LABEL_FAST("get NodeIterator.root", DOM, cx);
29
0
30
0
  auto result(StrongOrRawPtr<nsINode>(self->Root()));
31
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
32
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
33
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
34
0
    return false;
35
0
  }
36
0
  return true;
37
0
}
38
39
static const JSJitInfo root_getterinfo = {
40
  { (JSJitGetterOp)get_root },
41
  { prototypes::id::NodeIterator },
42
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
43
  JSJitInfo::Getter,
44
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
45
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
46
  false,  /* isInfallible. False in setters. */
47
  true,  /* isMovable.  Not relevant for setters. */
48
  true, /* isEliminatable.  Not relevant for setters. */
49
  false, /* isAlwaysInSlot.  Only relevant for getters. */
50
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
51
  false,  /* isTypedMethod.  Only relevant for methods. */
52
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
53
};
54
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
55
static_assert(0 < 1, "There is no slot for us");
56
57
MOZ_CAN_RUN_SCRIPT static bool
58
get_referenceNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, JSJitGetterCallArgs args)
59
0
{
60
0
  AUTO_PROFILER_LABEL_FAST("get NodeIterator.referenceNode", DOM, cx);
61
0
62
0
  auto result(StrongOrRawPtr<nsINode>(self->GetReferenceNode()));
63
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
64
0
  if (!result) {
65
0
    args.rval().setNull();
66
0
    return true;
67
0
  }
68
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
69
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
70
0
    return false;
71
0
  }
72
0
  return true;
73
0
}
74
75
static const JSJitInfo referenceNode_getterinfo = {
76
  { (JSJitGetterOp)get_referenceNode },
77
  { prototypes::id::NodeIterator },
78
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
79
  JSJitInfo::Getter,
80
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
81
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
82
  false,  /* isInfallible. False in setters. */
83
  true,  /* isMovable.  Not relevant for setters. */
84
  true, /* isEliminatable.  Not relevant for setters. */
85
  false, /* isAlwaysInSlot.  Only relevant for getters. */
86
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
87
  false,  /* isTypedMethod.  Only relevant for methods. */
88
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
89
};
90
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
91
static_assert(0 < 1, "There is no slot for us");
92
93
MOZ_CAN_RUN_SCRIPT static bool
94
get_pointerBeforeReferenceNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, JSJitGetterCallArgs args)
95
0
{
96
0
  AUTO_PROFILER_LABEL_FAST("get NodeIterator.pointerBeforeReferenceNode", DOM, cx);
97
0
98
0
  bool result(self->PointerBeforeReferenceNode());
99
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
100
0
  args.rval().setBoolean(result);
101
0
  return true;
102
0
}
103
104
static const JSJitInfo pointerBeforeReferenceNode_getterinfo = {
105
  { (JSJitGetterOp)get_pointerBeforeReferenceNode },
106
  { prototypes::id::NodeIterator },
107
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
108
  JSJitInfo::Getter,
109
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
110
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
111
  true,  /* isInfallible. False in setters. */
112
  true,  /* isMovable.  Not relevant for setters. */
113
  true, /* isEliminatable.  Not relevant for setters. */
114
  false, /* isAlwaysInSlot.  Only relevant for getters. */
115
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
116
  false,  /* isTypedMethod.  Only relevant for methods. */
117
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
118
};
119
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
120
static_assert(0 < 1, "There is no slot for us");
121
122
MOZ_CAN_RUN_SCRIPT static bool
123
get_whatToShow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, JSJitGetterCallArgs args)
124
0
{
125
0
  AUTO_PROFILER_LABEL_FAST("get NodeIterator.whatToShow", DOM, cx);
126
0
127
0
  uint32_t result(self->WhatToShow());
128
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
129
0
  args.rval().setNumber(result);
130
0
  return true;
131
0
}
132
133
static const JSJitInfo whatToShow_getterinfo = {
134
  { (JSJitGetterOp)get_whatToShow },
135
  { prototypes::id::NodeIterator },
136
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
137
  JSJitInfo::Getter,
138
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
139
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
140
  true,  /* isInfallible. False in setters. */
141
  true,  /* isMovable.  Not relevant for setters. */
142
  true, /* isEliminatable.  Not relevant for setters. */
143
  false, /* isAlwaysInSlot.  Only relevant for getters. */
144
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
145
  false,  /* isTypedMethod.  Only relevant for methods. */
146
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
147
};
148
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
149
static_assert(0 < 1, "There is no slot for us");
150
151
MOZ_CAN_RUN_SCRIPT static bool
152
get_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, JSJitGetterCallArgs args)
153
0
{
154
0
  AUTO_PROFILER_LABEL_FAST("get NodeIterator.filter", DOM, cx);
155
0
156
0
  auto result(StrongOrRawPtr<mozilla::dom::NodeFilter>(self->GetFilter()));
157
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
158
0
  if (result) {
159
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
160
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
161
0
      return false;
162
0
    }
163
0
    return true;
164
0
  } else {
165
0
    args.rval().setNull();
166
0
    return true;
167
0
  }
168
0
}
169
170
static const JSJitInfo filter_getterinfo = {
171
  { (JSJitGetterOp)get_filter },
172
  { prototypes::id::NodeIterator },
173
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
174
  JSJitInfo::Getter,
175
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
176
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
177
  false,  /* isInfallible. False in setters. */
178
  true,  /* isMovable.  Not relevant for setters. */
179
  true, /* isEliminatable.  Not relevant for setters. */
180
  false, /* isAlwaysInSlot.  Only relevant for getters. */
181
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
182
  false,  /* isTypedMethod.  Only relevant for methods. */
183
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
184
};
185
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
186
static_assert(0 < 1, "There is no slot for us");
187
188
MOZ_CAN_RUN_SCRIPT static bool
189
nextNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, const JSJitMethodCallArgs& args)
190
0
{
191
0
  AUTO_PROFILER_LABEL_FAST("NodeIterator.nextNode", DOM, cx);
192
0
193
0
  FastErrorResult rv;
194
0
  auto result(StrongOrRawPtr<nsINode>(self->NextNode(rv)));
195
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
196
0
    return false;
197
0
  }
198
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
199
0
  if (!result) {
200
0
    args.rval().setNull();
201
0
    return true;
202
0
  }
203
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
204
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
205
0
    return false;
206
0
  }
207
0
  return true;
208
0
}
209
210
static const JSJitInfo nextNode_methodinfo = {
211
  { (JSJitGetterOp)nextNode },
212
  { prototypes::id::NodeIterator },
213
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
214
  JSJitInfo::Method,
215
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
216
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
217
  false,  /* isInfallible. False in setters. */
218
  false,  /* isMovable.  Not relevant for setters. */
219
  false, /* isEliminatable.  Not relevant for setters. */
220
  false, /* isAlwaysInSlot.  Only relevant for getters. */
221
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
222
  false,  /* isTypedMethod.  Only relevant for methods. */
223
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
224
};
225
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
226
static_assert(0 < 1, "There is no slot for us");
227
228
MOZ_CAN_RUN_SCRIPT static bool
229
previousNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, const JSJitMethodCallArgs& args)
230
0
{
231
0
  AUTO_PROFILER_LABEL_FAST("NodeIterator.previousNode", DOM, cx);
232
0
233
0
  FastErrorResult rv;
234
0
  auto result(StrongOrRawPtr<nsINode>(self->PreviousNode(rv)));
235
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
236
0
    return false;
237
0
  }
238
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
239
0
  if (!result) {
240
0
    args.rval().setNull();
241
0
    return true;
242
0
  }
243
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
244
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
245
0
    return false;
246
0
  }
247
0
  return true;
248
0
}
249
250
static const JSJitInfo previousNode_methodinfo = {
251
  { (JSJitGetterOp)previousNode },
252
  { prototypes::id::NodeIterator },
253
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
254
  JSJitInfo::Method,
255
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
256
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
257
  false,  /* isInfallible. False in setters. */
258
  false,  /* isMovable.  Not relevant for setters. */
259
  false, /* isEliminatable.  Not relevant for setters. */
260
  false, /* isAlwaysInSlot.  Only relevant for getters. */
261
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
262
  false,  /* isTypedMethod.  Only relevant for methods. */
263
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
264
};
265
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
266
static_assert(0 < 1, "There is no slot for us");
267
268
MOZ_CAN_RUN_SCRIPT static bool
269
detach(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::NodeIterator* self, const JSJitMethodCallArgs& args)
270
0
{
271
0
  AUTO_PROFILER_LABEL_FAST("NodeIterator.detach", DOM, cx);
272
0
273
0
  self->Detach();
274
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
275
0
  args.rval().setUndefined();
276
0
  return true;
277
0
}
278
279
static const JSJitInfo detach_methodinfo = {
280
  { (JSJitGetterOp)detach },
281
  { prototypes::id::NodeIterator },
282
  { PrototypeTraits<prototypes::id::NodeIterator>::Depth },
283
  JSJitInfo::Method,
284
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
285
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
286
  true,  /* isInfallible. False in setters. */
287
  false,  /* isMovable.  Not relevant for setters. */
288
  false, /* isEliminatable.  Not relevant for setters. */
289
  false, /* isAlwaysInSlot.  Only relevant for getters. */
290
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
291
  false,  /* isTypedMethod.  Only relevant for methods. */
292
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
293
};
294
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
295
static_assert(0 < 1, "There is no slot for us");
296
297
static void
298
_finalize(js::FreeOp* fop, JSObject* obj)
299
0
{
300
0
  mozilla::dom::NodeIterator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::NodeIterator>(obj);
301
0
  if (self) {
302
0
    AddForDeferredFinalization<mozilla::dom::NodeIterator>(self);
303
0
  }
304
0
}
305
306
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
307
#if defined(__clang__)
308
#pragma clang diagnostic push
309
#pragma clang diagnostic ignored "-Wmissing-braces"
310
#endif
311
static const JSFunctionSpec sMethods_specs[] = {
312
  JS_FNSPEC("nextNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&nextNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
313
  JS_FNSPEC("previousNode", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&previousNode_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
314
  JS_FNSPEC("detach", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&detach_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
315
  JS_FS_END
316
};
317
#if defined(__clang__)
318
#pragma clang diagnostic pop
319
#endif
320
321
322
static const Prefable<const JSFunctionSpec> sMethods[] = {
323
  { nullptr, &sMethods_specs[0] },
324
  { nullptr, nullptr }
325
};
326
327
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
328
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
329
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
330
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
331
332
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
333
#if defined(__clang__)
334
#pragma clang diagnostic push
335
#pragma clang diagnostic ignored "-Wmissing-braces"
336
#endif
337
static const JSPropertySpec sAttributes_specs[] = {
338
  { "root", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &root_getterinfo, nullptr, nullptr },
339
  { "referenceNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &referenceNode_getterinfo, nullptr, nullptr },
340
  { "pointerBeforeReferenceNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pointerBeforeReferenceNode_getterinfo, nullptr, nullptr },
341
  { "whatToShow", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &whatToShow_getterinfo, nullptr, nullptr },
342
  { "filter", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &filter_getterinfo, nullptr, nullptr },
343
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
344
};
345
#if defined(__clang__)
346
#pragma clang diagnostic pop
347
#endif
348
349
350
static const Prefable<const JSPropertySpec> sAttributes[] = {
351
  { nullptr, &sAttributes_specs[0] },
352
  { nullptr, nullptr }
353
};
354
355
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
356
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
357
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
358
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
359
360
361
static uint16_t sNativeProperties_sortedPropertyIndices[8];
362
static PropertyInfo sNativeProperties_propertyInfos[8];
363
364
static const NativePropertiesN<2> sNativeProperties = {
365
  false, 0,
366
  false, 0,
367
  true,  0 /* sMethods */,
368
  true,  1 /* sAttributes */,
369
  false, 0,
370
  false, 0,
371
  false, 0,
372
  -1,
373
  8,
374
  sNativeProperties_sortedPropertyIndices,
375
  {
376
    { sMethods, &sNativeProperties_propertyInfos[0] },
377
    { sAttributes, &sNativeProperties_propertyInfos[3] }
378
  }
379
};
380
static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
381
    "We have a property info count that is oversized");
382
383
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
384
  {
385
    "Function",
386
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
387
    &sBoringInterfaceObjectClassClassOps,
388
    JS_NULL_CLASS_SPEC,
389
    JS_NULL_CLASS_EXT,
390
    &sInterfaceObjectClassObjectOps
391
  },
392
  eInterface,
393
  true,
394
  prototypes::id::NodeIterator,
395
  PrototypeTraits<prototypes::id::NodeIterator>::Depth,
396
  sNativePropertyHooks,
397
  "function NodeIterator() {\n    [native code]\n}",
398
  JS::GetRealmFunctionPrototype
399
};
400
401
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
402
  {
403
    "NodeIteratorPrototype",
404
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
405
    JS_NULL_CLASS_OPS,
406
    JS_NULL_CLASS_SPEC,
407
    JS_NULL_CLASS_EXT,
408
    JS_NULL_OBJECT_OPS
409
  },
410
  eInterfacePrototype,
411
  false,
412
  prototypes::id::NodeIterator,
413
  PrototypeTraits<prototypes::id::NodeIterator>::Depth,
414
  sNativePropertyHooks,
415
  "[object NodeIteratorPrototype]",
416
  JS::GetRealmObjectPrototype
417
};
418
419
static const js::ClassOps sClassOps = {
420
  nullptr, /* addProperty */
421
  nullptr,               /* delProperty */
422
  nullptr,               /* enumerate */
423
  nullptr, /* newEnumerate */
424
  nullptr, /* resolve */
425
  nullptr, /* mayResolve */
426
  _finalize, /* finalize */
427
  nullptr, /* call */
428
  nullptr,               /* hasInstance */
429
  nullptr,               /* construct */
430
  nullptr, /* trace */
431
};
432
433
static const js::ClassExtension sClassExtension = {
434
  nullptr, /* weakmapKeyDelegateOp */
435
  nullptr /* objectMovedOp */
436
};
437
438
static const DOMJSClass sClass = {
439
  { "NodeIterator",
440
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
441
    &sClassOps,
442
    JS_NULL_CLASS_SPEC,
443
    &sClassExtension,
444
    JS_NULL_OBJECT_OPS
445
  },
446
  { prototypes::id::NodeIterator, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
447
  IsBaseOf<nsISupports, mozilla::dom::NodeIterator >::value,
448
  sNativePropertyHooks,
449
  FindAssociatedGlobalForNative<mozilla::dom::NodeIterator>::Get,
450
  GetProtoObjectHandle,
451
  GetCCParticipant<mozilla::dom::NodeIterator>::Get()
452
};
453
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
454
              "Must have the right minimal number of reserved slots.");
455
static_assert(1 >= 1,
456
              "Must have enough reserved slots.");
457
458
const JSClass*
459
GetJSClass()
460
0
{
461
0
  return sClass.ToJSClass();
462
0
}
463
464
bool
465
Wrap(JSContext* aCx, mozilla::dom::NodeIterator* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
466
0
{
467
0
  MOZ_ASSERT(static_cast<mozilla::dom::NodeIterator*>(aObject) ==
468
0
             reinterpret_cast<mozilla::dom::NodeIterator*>(aObject),
469
0
             "Multiple inheritance for mozilla::dom::NodeIterator is broken.");
470
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
471
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
472
0
473
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
474
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
475
0
  if (!canonicalProto) {
476
0
    return false;
477
0
  }
478
0
  JS::Rooted<JSObject*> proto(aCx);
479
0
  if (aGivenProto) {
480
0
    proto = aGivenProto;
481
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
482
0
    // coming in, we changed compartments to that of "parent" so may need
483
0
    // to wrap the proto here.
484
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
485
0
      if (!JS_WrapObject(aCx, &proto)) {
486
0
        return false;
487
0
      }
488
0
    }
489
0
  } else {
490
0
    proto = canonicalProto;
491
0
  }
492
0
493
0
  BindingJSObjectCreator<mozilla::dom::NodeIterator> creator(aCx);
494
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
495
0
  if (!aReflector) {
496
0
    return false;
497
0
  }
498
0
499
0
500
0
501
0
  creator.InitializationSucceeded();
502
0
  return true;
503
0
}
504
505
const NativePropertyHooks sNativePropertyHooks[] = { {
506
  nullptr,
507
  nullptr,
508
  nullptr,
509
  { sNativeProperties.Upcast(), nullptr },
510
  prototypes::id::NodeIterator,
511
  constructors::id::NodeIterator,
512
  nullptr,
513
  &DefaultXrayExpandoObjectClass
514
} };
515
516
void
517
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
518
0
{
519
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
520
0
  if (!parentProto) {
521
0
    return;
522
0
  }
523
0
524
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
525
0
  if (!constructorProto) {
526
0
    return;
527
0
  }
528
0
529
0
  static bool sIdsInited = false;
530
0
  if (!sIdsInited && NS_IsMainThread()) {
531
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
532
0
      return;
533
0
    }
534
0
    sIdsInited = true;
535
0
  }
536
0
537
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::NodeIterator);
538
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::NodeIterator);
539
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
540
0
                              &sPrototypeClass.mBase, protoCache,
541
0
                              nullptr,
542
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
543
0
                              interfaceCache,
544
0
                              sNativeProperties.Upcast(),
545
0
                              nullptr,
546
0
                              "NodeIterator", aDefineOnGlobal,
547
0
                              nullptr,
548
0
                              false);
549
0
}
550
551
JSObject*
552
GetConstructorObject(JSContext* aCx)
553
0
{
554
0
  return GetConstructorObjectHandle(aCx);
555
0
}
556
557
} // namespace NodeIterator_Binding
558
559
560
561
} // namespace dom
562
} // namespace mozilla