Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/XPathResultBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM XPathResult.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "WrapperFactory.h"
4
#include "XPathResultBinding.h"
5
#include "mozilla/FloatingPoint.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/Nullable.h"
11
#include "mozilla/dom/PrimitiveConversions.h"
12
#include "mozilla/dom/XPathResult.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 XPathResult_Binding {
24
25
MOZ_CAN_RUN_SCRIPT static bool
26
get_resultType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
27
0
{
28
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.resultType", DOM, cx);
29
0
30
0
  uint16_t result(self->ResultType());
31
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
32
0
  args.rval().setInt32(int32_t(result));
33
0
  return true;
34
0
}
35
36
static const JSJitInfo resultType_getterinfo = {
37
  { (JSJitGetterOp)get_resultType },
38
  { prototypes::id::XPathResult },
39
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
40
  JSJitInfo::Getter,
41
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
42
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
43
  true,  /* isInfallible. False in setters. */
44
  false,  /* isMovable.  Not relevant for setters. */
45
  false, /* isEliminatable.  Not relevant for setters. */
46
  false, /* isAlwaysInSlot.  Only relevant for getters. */
47
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
48
  false,  /* isTypedMethod.  Only relevant for methods. */
49
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
50
};
51
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
52
static_assert(0 < 1, "There is no slot for us");
53
54
MOZ_CAN_RUN_SCRIPT static bool
55
get_numberValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
56
0
{
57
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.numberValue", DOM, cx);
58
0
59
0
  FastErrorResult rv;
60
0
  double result(self->GetNumberValue(rv));
61
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
62
0
    return false;
63
0
  }
64
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
65
0
  args.rval().set(JS_NumberValue(double(result)));
66
0
  return true;
67
0
}
68
69
static const JSJitInfo numberValue_getterinfo = {
70
  { (JSJitGetterOp)get_numberValue },
71
  { prototypes::id::XPathResult },
72
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
73
  JSJitInfo::Getter,
74
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
75
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
76
  false,  /* isInfallible. False in setters. */
77
  false,  /* isMovable.  Not relevant for setters. */
78
  false, /* isEliminatable.  Not relevant for setters. */
79
  false, /* isAlwaysInSlot.  Only relevant for getters. */
80
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
81
  false,  /* isTypedMethod.  Only relevant for methods. */
82
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
83
};
84
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
85
static_assert(0 < 1, "There is no slot for us");
86
87
MOZ_CAN_RUN_SCRIPT static bool
88
get_stringValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
89
0
{
90
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.stringValue", DOM, cx);
91
0
92
0
  FastErrorResult rv;
93
0
  DOMString result;
94
0
  self->GetStringValue(result, rv);
95
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
96
0
    return false;
97
0
  }
98
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
99
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
100
0
    return false;
101
0
  }
102
0
  return true;
103
0
}
104
105
static const JSJitInfo stringValue_getterinfo = {
106
  { (JSJitGetterOp)get_stringValue },
107
  { prototypes::id::XPathResult },
108
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
109
  JSJitInfo::Getter,
110
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
111
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
112
  false,  /* isInfallible. False in setters. */
113
  false,  /* isMovable.  Not relevant for setters. */
114
  false, /* isEliminatable.  Not relevant for setters. */
115
  false, /* isAlwaysInSlot.  Only relevant for getters. */
116
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
117
  false,  /* isTypedMethod.  Only relevant for methods. */
118
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
119
};
120
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
121
static_assert(0 < 1, "There is no slot for us");
122
123
MOZ_CAN_RUN_SCRIPT static bool
124
get_booleanValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
125
0
{
126
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.booleanValue", DOM, cx);
127
0
128
0
  FastErrorResult rv;
129
0
  bool result(self->GetBooleanValue(rv));
130
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
131
0
    return false;
132
0
  }
133
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
134
0
  args.rval().setBoolean(result);
135
0
  return true;
136
0
}
137
138
static const JSJitInfo booleanValue_getterinfo = {
139
  { (JSJitGetterOp)get_booleanValue },
140
  { prototypes::id::XPathResult },
141
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
142
  JSJitInfo::Getter,
143
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
144
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
145
  false,  /* isInfallible. False in setters. */
146
  false,  /* isMovable.  Not relevant for setters. */
147
  false, /* isEliminatable.  Not relevant for setters. */
148
  false, /* isAlwaysInSlot.  Only relevant for getters. */
149
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
150
  false,  /* isTypedMethod.  Only relevant for methods. */
151
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
152
};
153
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
154
static_assert(0 < 1, "There is no slot for us");
155
156
MOZ_CAN_RUN_SCRIPT static bool
157
get_singleNodeValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
158
0
{
159
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.singleNodeValue", DOM, cx);
160
0
161
0
  FastErrorResult rv;
162
0
  auto result(StrongOrRawPtr<nsINode>(self->GetSingleNodeValue(rv)));
163
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
164
0
    return false;
165
0
  }
166
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
167
0
  if (!result) {
168
0
    args.rval().setNull();
169
0
    return true;
170
0
  }
171
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
172
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
173
0
    return false;
174
0
  }
175
0
  return true;
176
0
}
177
178
static const JSJitInfo singleNodeValue_getterinfo = {
179
  { (JSJitGetterOp)get_singleNodeValue },
180
  { prototypes::id::XPathResult },
181
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
182
  JSJitInfo::Getter,
183
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
184
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
185
  false,  /* isInfallible. False in setters. */
186
  false,  /* isMovable.  Not relevant for setters. */
187
  false, /* isEliminatable.  Not relevant for setters. */
188
  false, /* isAlwaysInSlot.  Only relevant for getters. */
189
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
190
  false,  /* isTypedMethod.  Only relevant for methods. */
191
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
192
};
193
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
194
static_assert(0 < 1, "There is no slot for us");
195
196
MOZ_CAN_RUN_SCRIPT static bool
197
get_invalidIteratorState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
198
0
{
199
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.invalidIteratorState", DOM, cx);
200
0
201
0
  bool result(self->InvalidIteratorState());
202
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
203
0
  args.rval().setBoolean(result);
204
0
  return true;
205
0
}
206
207
static const JSJitInfo invalidIteratorState_getterinfo = {
208
  { (JSJitGetterOp)get_invalidIteratorState },
209
  { prototypes::id::XPathResult },
210
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
211
  JSJitInfo::Getter,
212
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
213
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
214
  true,  /* isInfallible. False in setters. */
215
  false,  /* isMovable.  Not relevant for setters. */
216
  false, /* isEliminatable.  Not relevant for setters. */
217
  false, /* isAlwaysInSlot.  Only relevant for getters. */
218
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
219
  false,  /* isTypedMethod.  Only relevant for methods. */
220
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
221
};
222
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
223
static_assert(0 < 1, "There is no slot for us");
224
225
MOZ_CAN_RUN_SCRIPT static bool
226
get_snapshotLength(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, JSJitGetterCallArgs args)
227
0
{
228
0
  AUTO_PROFILER_LABEL_FAST("get XPathResult.snapshotLength", DOM, cx);
229
0
230
0
  FastErrorResult rv;
231
0
  uint32_t result(self->GetSnapshotLength(rv));
232
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
233
0
    return false;
234
0
  }
235
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
236
0
  args.rval().setNumber(result);
237
0
  return true;
238
0
}
239
240
static const JSJitInfo snapshotLength_getterinfo = {
241
  { (JSJitGetterOp)get_snapshotLength },
242
  { prototypes::id::XPathResult },
243
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
244
  JSJitInfo::Getter,
245
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
246
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
247
  false,  /* isInfallible. False in setters. */
248
  false,  /* isMovable.  Not relevant for setters. */
249
  false, /* isEliminatable.  Not relevant for setters. */
250
  false, /* isAlwaysInSlot.  Only relevant for getters. */
251
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
252
  false,  /* isTypedMethod.  Only relevant for methods. */
253
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
254
};
255
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
256
static_assert(0 < 1, "There is no slot for us");
257
258
MOZ_CAN_RUN_SCRIPT static bool
259
iterateNext(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, const JSJitMethodCallArgs& args)
260
0
{
261
0
  AUTO_PROFILER_LABEL_FAST("XPathResult.iterateNext", DOM, cx);
262
0
263
0
  FastErrorResult rv;
264
0
  auto result(StrongOrRawPtr<nsINode>(self->IterateNext(rv)));
265
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
266
0
    return false;
267
0
  }
268
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
269
0
  if (!result) {
270
0
    args.rval().setNull();
271
0
    return true;
272
0
  }
273
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
274
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
275
0
    return false;
276
0
  }
277
0
  return true;
278
0
}
279
280
static const JSJitInfo iterateNext_methodinfo = {
281
  { (JSJitGetterOp)iterateNext },
282
  { prototypes::id::XPathResult },
283
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
284
  JSJitInfo::Method,
285
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
286
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
287
  false,  /* isInfallible. False in setters. */
288
  false,  /* isMovable.  Not relevant for setters. */
289
  false, /* isEliminatable.  Not relevant for setters. */
290
  false, /* isAlwaysInSlot.  Only relevant for getters. */
291
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
292
  false,  /* isTypedMethod.  Only relevant for methods. */
293
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
294
};
295
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
296
static_assert(0 < 1, "There is no slot for us");
297
298
MOZ_CAN_RUN_SCRIPT static bool
299
snapshotItem(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XPathResult* self, const JSJitMethodCallArgs& args)
300
0
{
301
0
  AUTO_PROFILER_LABEL_FAST("XPathResult.snapshotItem", DOM, cx);
302
0
303
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
304
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XPathResult.snapshotItem");
305
0
  }
306
0
  uint32_t arg0;
307
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
308
0
    return false;
309
0
  }
310
0
  FastErrorResult rv;
311
0
  auto result(StrongOrRawPtr<nsINode>(self->SnapshotItem(arg0, rv)));
312
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
313
0
    return false;
314
0
  }
315
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
316
0
  if (!result) {
317
0
    args.rval().setNull();
318
0
    return true;
319
0
  }
320
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
321
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
322
0
    return false;
323
0
  }
324
0
  return true;
325
0
}
326
327
static const JSJitInfo snapshotItem_methodinfo = {
328
  { (JSJitGetterOp)snapshotItem },
329
  { prototypes::id::XPathResult },
330
  { PrototypeTraits<prototypes::id::XPathResult>::Depth },
331
  JSJitInfo::Method,
332
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
333
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
334
  false,  /* isInfallible. False in setters. */
335
  false,  /* isMovable.  Not relevant for setters. */
336
  false, /* isEliminatable.  Not relevant for setters. */
337
  false, /* isAlwaysInSlot.  Only relevant for getters. */
338
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
339
  false,  /* isTypedMethod.  Only relevant for methods. */
340
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
341
};
342
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
343
static_assert(0 < 1, "There is no slot for us");
344
345
static bool
346
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
347
0
{
348
0
  mozilla::dom::XPathResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XPathResult>(obj);
349
0
  // We don't want to preserve if we don't have a wrapper, and we
350
0
  // obviously can't preserve if we're not initialized.
351
0
  if (self && self->GetWrapperPreserveColor()) {
352
0
    PreserveWrapper(self);
353
0
  }
354
0
  return true;
355
0
}
356
357
static void
358
_finalize(js::FreeOp* fop, JSObject* obj)
359
0
{
360
0
  mozilla::dom::XPathResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XPathResult>(obj);
361
0
  if (self) {
362
0
    ClearWrapper(self, self, obj);
363
0
    AddForDeferredFinalization<mozilla::dom::XPathResult>(self);
364
0
  }
365
0
}
366
367
static size_t
368
_objectMoved(JSObject* obj, JSObject* old)
369
0
{
370
0
  mozilla::dom::XPathResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XPathResult>(obj);
371
0
  if (self) {
372
0
    UpdateWrapper(self, self, obj, old);
373
0
  }
374
0
375
0
  return 0;
376
0
}
377
378
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
379
#if defined(__clang__)
380
#pragma clang diagnostic push
381
#pragma clang diagnostic ignored "-Wmissing-braces"
382
#endif
383
static const JSFunctionSpec sMethods_specs[] = {
384
  JS_FNSPEC("iterateNext", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&iterateNext_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
385
  JS_FNSPEC("snapshotItem", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&snapshotItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
386
  JS_FS_END
387
};
388
#if defined(__clang__)
389
#pragma clang diagnostic pop
390
#endif
391
392
393
static const Prefable<const JSFunctionSpec> sMethods[] = {
394
  { nullptr, &sMethods_specs[0] },
395
  { nullptr, nullptr }
396
};
397
398
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
399
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
400
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
401
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
402
403
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
404
#if defined(__clang__)
405
#pragma clang diagnostic push
406
#pragma clang diagnostic ignored "-Wmissing-braces"
407
#endif
408
static const JSPropertySpec sAttributes_specs[] = {
409
  { "resultType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &resultType_getterinfo, nullptr, nullptr },
410
  { "numberValue", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &numberValue_getterinfo, nullptr, nullptr },
411
  { "stringValue", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &stringValue_getterinfo, nullptr, nullptr },
412
  { "booleanValue", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &booleanValue_getterinfo, nullptr, nullptr },
413
  { "singleNodeValue", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &singleNodeValue_getterinfo, nullptr, nullptr },
414
  { "invalidIteratorState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &invalidIteratorState_getterinfo, nullptr, nullptr },
415
  { "snapshotLength", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &snapshotLength_getterinfo, nullptr, nullptr },
416
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
417
};
418
#if defined(__clang__)
419
#pragma clang diagnostic pop
420
#endif
421
422
423
static const Prefable<const JSPropertySpec> sAttributes[] = {
424
  { nullptr, &sAttributes_specs[0] },
425
  { nullptr, nullptr }
426
};
427
428
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
429
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
430
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
431
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
432
433
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
434
#if defined(__clang__)
435
#pragma clang diagnostic push
436
#pragma clang diagnostic ignored "-Wmissing-braces"
437
#endif
438
static const ConstantSpec sConstants_specs[] = {
439
  { "ANY_TYPE", JS::Int32Value(0) },
440
  { "NUMBER_TYPE", JS::Int32Value(1) },
441
  { "STRING_TYPE", JS::Int32Value(2) },
442
  { "BOOLEAN_TYPE", JS::Int32Value(3) },
443
  { "UNORDERED_NODE_ITERATOR_TYPE", JS::Int32Value(4) },
444
  { "ORDERED_NODE_ITERATOR_TYPE", JS::Int32Value(5) },
445
  { "UNORDERED_NODE_SNAPSHOT_TYPE", JS::Int32Value(6) },
446
  { "ORDERED_NODE_SNAPSHOT_TYPE", JS::Int32Value(7) },
447
  { "ANY_UNORDERED_NODE_TYPE", JS::Int32Value(8) },
448
  { "FIRST_ORDERED_NODE_TYPE", JS::Int32Value(9) },
449
  { 0, JS::UndefinedValue() }
450
};
451
#if defined(__clang__)
452
#pragma clang diagnostic pop
453
#endif
454
455
456
static const Prefable<const ConstantSpec> sConstants[] = {
457
  { nullptr, &sConstants_specs[0] },
458
  { nullptr, nullptr }
459
};
460
461
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
462
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
463
static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
464
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
465
466
467
static uint16_t sNativeProperties_sortedPropertyIndices[19];
468
static PropertyInfo sNativeProperties_propertyInfos[19];
469
470
static const NativePropertiesN<3> sNativeProperties = {
471
  false, 0,
472
  false, 0,
473
  true,  0 /* sMethods */,
474
  true,  1 /* sAttributes */,
475
  false, 0,
476
  false, 0,
477
  true,  2 /* sConstants */,
478
  -1,
479
  19,
480
  sNativeProperties_sortedPropertyIndices,
481
  {
482
    { sMethods, &sNativeProperties_propertyInfos[0] },
483
    { sAttributes, &sNativeProperties_propertyInfos[2] },
484
    { sConstants, &sNativeProperties_propertyInfos[9] }
485
  }
486
};
487
static_assert(19 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
488
    "We have a property info count that is oversized");
489
490
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
491
  {
492
    "Function",
493
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
494
    &sBoringInterfaceObjectClassClassOps,
495
    JS_NULL_CLASS_SPEC,
496
    JS_NULL_CLASS_EXT,
497
    &sInterfaceObjectClassObjectOps
498
  },
499
  eInterface,
500
  true,
501
  prototypes::id::XPathResult,
502
  PrototypeTraits<prototypes::id::XPathResult>::Depth,
503
  sNativePropertyHooks,
504
  "function XPathResult() {\n    [native code]\n}",
505
  JS::GetRealmFunctionPrototype
506
};
507
508
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
509
  {
510
    "XPathResultPrototype",
511
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
512
    JS_NULL_CLASS_OPS,
513
    JS_NULL_CLASS_SPEC,
514
    JS_NULL_CLASS_EXT,
515
    JS_NULL_OBJECT_OPS
516
  },
517
  eInterfacePrototype,
518
  false,
519
  prototypes::id::XPathResult,
520
  PrototypeTraits<prototypes::id::XPathResult>::Depth,
521
  sNativePropertyHooks,
522
  "[object XPathResultPrototype]",
523
  JS::GetRealmObjectPrototype
524
};
525
526
static const js::ClassOps sClassOps = {
527
  _addProperty, /* addProperty */
528
  nullptr,               /* delProperty */
529
  nullptr,               /* enumerate */
530
  nullptr, /* newEnumerate */
531
  nullptr, /* resolve */
532
  nullptr, /* mayResolve */
533
  _finalize, /* finalize */
534
  nullptr, /* call */
535
  nullptr,               /* hasInstance */
536
  nullptr,               /* construct */
537
  nullptr, /* trace */
538
};
539
540
static const js::ClassExtension sClassExtension = {
541
  nullptr, /* weakmapKeyDelegateOp */
542
  _objectMoved /* objectMovedOp */
543
};
544
545
static const DOMJSClass sClass = {
546
  { "XPathResult",
547
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
548
    &sClassOps,
549
    JS_NULL_CLASS_SPEC,
550
    &sClassExtension,
551
    JS_NULL_OBJECT_OPS
552
  },
553
  { prototypes::id::XPathResult, 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 },
554
  IsBaseOf<nsISupports, mozilla::dom::XPathResult >::value,
555
  sNativePropertyHooks,
556
  FindAssociatedGlobalForNative<mozilla::dom::XPathResult>::Get,
557
  GetProtoObjectHandle,
558
  GetCCParticipant<mozilla::dom::XPathResult>::Get()
559
};
560
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
561
              "Must have the right minimal number of reserved slots.");
562
static_assert(1 >= 1,
563
              "Must have enough reserved slots.");
564
565
const JSClass*
566
GetJSClass()
567
0
{
568
0
  return sClass.ToJSClass();
569
0
}
570
571
bool
572
Wrap(JSContext* aCx, mozilla::dom::XPathResult* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
573
0
{
574
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::XPathResult>::value,
575
0
                "Shouldn't have wrappercached things that are not refcounted.");
576
0
  MOZ_ASSERT(static_cast<mozilla::dom::XPathResult*>(aObject) ==
577
0
             reinterpret_cast<mozilla::dom::XPathResult*>(aObject),
578
0
             "Multiple inheritance for mozilla::dom::XPathResult is broken.");
579
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
580
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
581
0
  MOZ_ASSERT(!aCache->GetWrapper(),
582
0
             "You should probably not be using Wrap() directly; use "
583
0
             "GetOrCreateDOMReflector instead");
584
0
585
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
586
0
             "nsISupports must be on our primary inheritance chain");
587
0
588
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
589
0
  if (!global) {
590
0
    return false;
591
0
  }
592
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
593
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
594
0
595
0
  // That might have ended up wrapping us already, due to the wonders
596
0
  // of XBL.  Check for that, and bail out as needed.
597
0
  aReflector.set(aCache->GetWrapper());
598
0
  if (aReflector) {
599
#ifdef DEBUG
600
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
601
#endif // DEBUG
602
    return true;
603
0
  }
604
0
605
0
  JSAutoRealm ar(aCx, global);
606
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
607
0
  if (!canonicalProto) {
608
0
    return false;
609
0
  }
610
0
  JS::Rooted<JSObject*> proto(aCx);
611
0
  if (aGivenProto) {
612
0
    proto = aGivenProto;
613
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
614
0
    // coming in, we changed compartments to that of "parent" so may need
615
0
    // to wrap the proto here.
616
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
617
0
      if (!JS_WrapObject(aCx, &proto)) {
618
0
        return false;
619
0
      }
620
0
    }
621
0
  } else {
622
0
    proto = canonicalProto;
623
0
  }
624
0
625
0
  BindingJSObjectCreator<mozilla::dom::XPathResult> creator(aCx);
626
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
627
0
  if (!aReflector) {
628
0
    return false;
629
0
  }
630
0
631
0
  aCache->SetWrapper(aReflector);
632
0
  creator.InitializationSucceeded();
633
0
634
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
635
0
             aCache->GetWrapperPreserveColor() == aReflector);
636
0
  // If proto != canonicalProto, we have to preserve our wrapper;
637
0
  // otherwise we won't be able to properly recreate it later, since
638
0
  // we won't know what proto to use.  Note that we don't check
639
0
  // aGivenProto here, since it's entirely possible (and even
640
0
  // somewhat common) to have a non-null aGivenProto which is the
641
0
  // same as canonicalProto.
642
0
  if (proto != canonicalProto) {
643
0
    PreserveWrapper(aObject);
644
0
  }
645
0
646
0
  return true;
647
0
}
648
649
const NativePropertyHooks sNativePropertyHooks[] = { {
650
  nullptr,
651
  nullptr,
652
  nullptr,
653
  { sNativeProperties.Upcast(), nullptr },
654
  prototypes::id::XPathResult,
655
  constructors::id::XPathResult,
656
  nullptr,
657
  &DefaultXrayExpandoObjectClass
658
} };
659
660
void
661
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
662
0
{
663
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
664
0
  if (!parentProto) {
665
0
    return;
666
0
  }
667
0
668
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
669
0
  if (!constructorProto) {
670
0
    return;
671
0
  }
672
0
673
0
  static bool sIdsInited = false;
674
0
  if (!sIdsInited && NS_IsMainThread()) {
675
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
676
0
      return;
677
0
    }
678
0
    sIdsInited = true;
679
0
  }
680
0
681
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XPathResult);
682
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XPathResult);
683
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
684
0
                              &sPrototypeClass.mBase, protoCache,
685
0
                              nullptr,
686
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
687
0
                              interfaceCache,
688
0
                              sNativeProperties.Upcast(),
689
0
                              nullptr,
690
0
                              "XPathResult", aDefineOnGlobal,
691
0
                              nullptr,
692
0
                              false);
693
0
}
694
695
JSObject*
696
GetConstructorObject(JSContext* aCx)
697
0
{
698
0
  return GetConstructorObjectHandle(aCx);
699
0
}
700
701
} // namespace XPathResult_Binding
702
703
704
705
} // namespace dom
706
} // namespace mozilla