Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/DocumentFragmentBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM DocumentFragment.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "DocumentFragmentBinding.h"
4
#include "NodeBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/CustomElementRegistry.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/DocGroup.h"
11
#include "mozilla/dom/DocumentFragment.h"
12
#include "mozilla/dom/Element.h"
13
#include "mozilla/dom/NonRefcountedDOMObject.h"
14
#include "mozilla/dom/Nullable.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/UnionConversions.h"
17
#include "mozilla/dom/UnionTypes.h"
18
#include "mozilla/dom/XrayExpandoClass.h"
19
#include "nsContentList.h"
20
#include "nsContentUtils.h"
21
#include "nsINodeList.h"
22
#include "nsISupports.h"
23
#include "xpcjsid.h"
24
25
namespace mozilla {
26
namespace dom {
27
28
namespace binding_detail {}; // Just to make sure it's known as a namespace
29
using namespace mozilla::dom::binding_detail;
30
31
32
namespace DocumentFragment_Binding {
33
34
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Node_Binding::NativeType>::value,
35
              "Can't inherit from an interface with a different ownership model.");
36
37
MOZ_CAN_RUN_SCRIPT static bool
38
getElementById(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
39
0
{
40
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.getElementById", DOM, cx);
41
0
42
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
43
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DocumentFragment.getElementById");
44
0
  }
45
0
  binding_detail::FakeString arg0;
46
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
47
0
    return false;
48
0
  }
49
0
  auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetElementById(NonNullHelper(Constify(arg0)))));
50
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
51
0
  if (!result) {
52
0
    args.rval().setNull();
53
0
    return true;
54
0
  }
55
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
56
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
57
0
    return false;
58
0
  }
59
0
  return true;
60
0
}
61
62
static const JSJitInfo getElementById_methodinfo = {
63
  { (JSJitGetterOp)getElementById },
64
  { prototypes::id::DocumentFragment },
65
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
66
  JSJitInfo::Method,
67
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
68
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
69
  false,  /* isInfallible. False in setters. */
70
  false,  /* isMovable.  Not relevant for setters. */
71
  false, /* isEliminatable.  Not relevant for setters. */
72
  false, /* isAlwaysInSlot.  Only relevant for getters. */
73
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
74
  false,  /* isTypedMethod.  Only relevant for methods. */
75
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
76
};
77
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
78
static_assert(0 < 1, "There is no slot for us");
79
80
MOZ_CAN_RUN_SCRIPT static bool
81
querySelector(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
82
0
{
83
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.querySelector", DOM, cx);
84
0
85
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
86
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DocumentFragment.querySelector");
87
0
  }
88
0
  binding_detail::FakeString arg0;
89
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
90
0
    return false;
91
0
  }
92
0
  FastErrorResult rv;
93
0
  auto result(StrongOrRawPtr<mozilla::dom::Element>(self->QuerySelector(NonNullHelper(Constify(arg0)), rv)));
94
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
95
0
    return false;
96
0
  }
97
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
98
0
  if (!result) {
99
0
    args.rval().setNull();
100
0
    return true;
101
0
  }
102
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
103
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
104
0
    return false;
105
0
  }
106
0
  return true;
107
0
}
108
109
static const JSJitInfo querySelector_methodinfo = {
110
  { (JSJitGetterOp)querySelector },
111
  { prototypes::id::DocumentFragment },
112
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
113
  JSJitInfo::Method,
114
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
115
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
116
  false,  /* isInfallible. False in setters. */
117
  false,  /* isMovable.  Not relevant for setters. */
118
  false, /* isEliminatable.  Not relevant for setters. */
119
  false, /* isAlwaysInSlot.  Only relevant for getters. */
120
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
121
  false,  /* isTypedMethod.  Only relevant for methods. */
122
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
123
};
124
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
125
static_assert(0 < 1, "There is no slot for us");
126
127
MOZ_CAN_RUN_SCRIPT static bool
128
querySelectorAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
129
0
{
130
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.querySelectorAll", DOM, cx);
131
0
132
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
133
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DocumentFragment.querySelectorAll");
134
0
  }
135
0
  binding_detail::FakeString arg0;
136
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
137
0
    return false;
138
0
  }
139
0
  FastErrorResult rv;
140
0
  auto result(StrongOrRawPtr<nsINodeList>(self->QuerySelectorAll(NonNullHelper(Constify(arg0)), rv)));
141
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
142
0
    return false;
143
0
  }
144
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
145
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
146
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
147
0
    return false;
148
0
  }
149
0
  return true;
150
0
}
151
152
static const JSJitInfo querySelectorAll_methodinfo = {
153
  { (JSJitGetterOp)querySelectorAll },
154
  { prototypes::id::DocumentFragment },
155
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
156
  JSJitInfo::Method,
157
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
158
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
159
  false,  /* isInfallible. False in setters. */
160
  false,  /* isMovable.  Not relevant for setters. */
161
  false, /* isEliminatable.  Not relevant for setters. */
162
  false, /* isAlwaysInSlot.  Only relevant for getters. */
163
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
164
  false,  /* isTypedMethod.  Only relevant for methods. */
165
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
166
};
167
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
168
static_assert(0 < 1, "There is no slot for us");
169
170
MOZ_CAN_RUN_SCRIPT static bool
171
get_children(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, JSJitGetterCallArgs args)
172
0
{
173
0
  AUTO_PROFILER_LABEL_FAST("get DocumentFragment.children", DOM, cx);
174
0
175
0
  auto result(StrongOrRawPtr<nsIHTMLCollection>(self->Children()));
176
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
177
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
178
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
179
0
    return false;
180
0
  }
181
0
  return true;
182
0
}
183
184
static const JSJitInfo children_getterinfo = {
185
  { (JSJitGetterOp)get_children },
186
  { prototypes::id::DocumentFragment },
187
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
188
  JSJitInfo::Getter,
189
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
190
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
191
  false,  /* isInfallible. False in setters. */
192
  true,  /* isMovable.  Not relevant for setters. */
193
  true, /* isEliminatable.  Not relevant for setters. */
194
  false, /* isAlwaysInSlot.  Only relevant for getters. */
195
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
196
  false,  /* isTypedMethod.  Only relevant for methods. */
197
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
198
};
199
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
200
static_assert(0 < 1, "There is no slot for us");
201
202
MOZ_CAN_RUN_SCRIPT static bool
203
get_firstElementChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, JSJitGetterCallArgs args)
204
0
{
205
0
  AUTO_PROFILER_LABEL_FAST("get DocumentFragment.firstElementChild", DOM, cx);
206
0
207
0
  auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetFirstElementChild()));
208
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
209
0
  if (!result) {
210
0
    args.rval().setNull();
211
0
    return true;
212
0
  }
213
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
214
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
215
0
    return false;
216
0
  }
217
0
  return true;
218
0
}
219
220
static const JSJitInfo firstElementChild_getterinfo = {
221
  { (JSJitGetterOp)get_firstElementChild },
222
  { prototypes::id::DocumentFragment },
223
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
224
  JSJitInfo::Getter,
225
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
226
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
227
  false,  /* isInfallible. False in setters. */
228
  true,  /* isMovable.  Not relevant for setters. */
229
  true, /* isEliminatable.  Not relevant for setters. */
230
  false, /* isAlwaysInSlot.  Only relevant for getters. */
231
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
232
  false,  /* isTypedMethod.  Only relevant for methods. */
233
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
234
};
235
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
236
static_assert(0 < 1, "There is no slot for us");
237
238
MOZ_CAN_RUN_SCRIPT static bool
239
get_lastElementChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, JSJitGetterCallArgs args)
240
0
{
241
0
  AUTO_PROFILER_LABEL_FAST("get DocumentFragment.lastElementChild", DOM, cx);
242
0
243
0
  auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetLastElementChild()));
244
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
245
0
  if (!result) {
246
0
    args.rval().setNull();
247
0
    return true;
248
0
  }
249
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
250
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
251
0
    return false;
252
0
  }
253
0
  return true;
254
0
}
255
256
static const JSJitInfo lastElementChild_getterinfo = {
257
  { (JSJitGetterOp)get_lastElementChild },
258
  { prototypes::id::DocumentFragment },
259
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
260
  JSJitInfo::Getter,
261
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
262
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
263
  false,  /* isInfallible. False in setters. */
264
  true,  /* isMovable.  Not relevant for setters. */
265
  true, /* isEliminatable.  Not relevant for setters. */
266
  false, /* isAlwaysInSlot.  Only relevant for getters. */
267
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
268
  false,  /* isTypedMethod.  Only relevant for methods. */
269
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
270
};
271
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
272
static_assert(0 < 1, "There is no slot for us");
273
274
MOZ_CAN_RUN_SCRIPT static bool
275
get_childElementCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, JSJitGetterCallArgs args)
276
0
{
277
0
  AUTO_PROFILER_LABEL_FAST("get DocumentFragment.childElementCount", DOM, cx);
278
0
279
0
  uint32_t result(self->ChildElementCount());
280
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
281
0
  args.rval().setNumber(result);
282
0
  return true;
283
0
}
284
285
static const JSJitInfo childElementCount_getterinfo = {
286
  { (JSJitGetterOp)get_childElementCount },
287
  { prototypes::id::DocumentFragment },
288
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
289
  JSJitInfo::Getter,
290
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
291
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
292
  true,  /* isInfallible. False in setters. */
293
  true,  /* isMovable.  Not relevant for setters. */
294
  true, /* isEliminatable.  Not relevant for setters. */
295
  false, /* isAlwaysInSlot.  Only relevant for getters. */
296
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
297
  false,  /* isTypedMethod.  Only relevant for methods. */
298
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
299
};
300
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
301
static_assert(0 < 1, "There is no slot for us");
302
303
MOZ_CAN_RUN_SCRIPT static bool
304
getElementsByAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
305
0
{
306
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.getElementsByAttribute", DOM, cx);
307
0
308
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
309
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DocumentFragment.getElementsByAttribute");
310
0
  }
311
0
  binding_detail::FakeString arg0;
312
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
313
0
    return false;
314
0
  }
315
0
  binding_detail::FakeString arg1;
316
0
  if (!ConvertJSValueToString(cx, args[1], eEmpty, eStringify, arg1)) {
317
0
    return false;
318
0
  }
319
0
  auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByAttribute(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)))));
320
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
321
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
322
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
323
0
    return false;
324
0
  }
325
0
  return true;
326
0
}
327
328
static const JSJitInfo getElementsByAttribute_methodinfo = {
329
  { (JSJitGetterOp)getElementsByAttribute },
330
  { prototypes::id::DocumentFragment },
331
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
332
  JSJitInfo::Method,
333
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
334
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
335
  false,  /* isInfallible. False in setters. */
336
  false,  /* isMovable.  Not relevant for setters. */
337
  false, /* isEliminatable.  Not relevant for setters. */
338
  false, /* isAlwaysInSlot.  Only relevant for getters. */
339
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
340
  false,  /* isTypedMethod.  Only relevant for methods. */
341
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
342
};
343
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
344
static_assert(0 < 1, "There is no slot for us");
345
346
MOZ_CAN_RUN_SCRIPT static bool
347
getElementsByAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
348
0
{
349
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.getElementsByAttributeNS", DOM, cx);
350
0
351
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
352
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DocumentFragment.getElementsByAttributeNS");
353
0
  }
354
0
  binding_detail::FakeString arg0;
355
0
  if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) {
356
0
    return false;
357
0
  }
358
0
  binding_detail::FakeString arg1;
359
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
360
0
    return false;
361
0
  }
362
0
  binding_detail::FakeString arg2;
363
0
  if (!ConvertJSValueToString(cx, args[2], eEmpty, eStringify, arg2)) {
364
0
    return false;
365
0
  }
366
0
  FastErrorResult rv;
367
0
  auto result(StrongOrRawPtr<nsIHTMLCollection>(self->GetElementsByAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv)));
368
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
369
0
    return false;
370
0
  }
371
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
372
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
373
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
374
0
    return false;
375
0
  }
376
0
  return true;
377
0
}
378
379
static const JSJitInfo getElementsByAttributeNS_methodinfo = {
380
  { (JSJitGetterOp)getElementsByAttributeNS },
381
  { prototypes::id::DocumentFragment },
382
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
383
  JSJitInfo::Method,
384
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
385
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
386
  false,  /* isInfallible. False in setters. */
387
  false,  /* isMovable.  Not relevant for setters. */
388
  false, /* isEliminatable.  Not relevant for setters. */
389
  false, /* isAlwaysInSlot.  Only relevant for getters. */
390
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
391
  false,  /* isTypedMethod.  Only relevant for methods. */
392
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
393
};
394
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
395
static_assert(0 < 1, "There is no slot for us");
396
397
MOZ_CAN_RUN_SCRIPT static bool
398
prepend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
399
0
{
400
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.prepend", DOM, cx);
401
0
402
0
  AutoSequence<OwningNodeOrString> arg0;
403
0
  if (args.length() > 0) {
404
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
405
0
      JS_ReportOutOfMemory(cx);
406
0
      return false;
407
0
    }
408
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
409
0
      OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible);
410
0
      {
411
0
        bool done = false, failed = false, tryNext;
412
0
        if (args[variadicArg].isObject()) {
413
0
          done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext;
414
0
415
0
        }
416
0
        if (!done) {
417
0
          do {
418
0
            done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext;
419
0
            break;
420
0
          } while (false);
421
0
        }
422
0
        if (failed) {
423
0
          return false;
424
0
        }
425
0
        if (!done) {
426
0
          ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of DocumentFragment.prepend", "Node");
427
0
          return false;
428
0
        }
429
0
      }
430
0
    }
431
0
  }
432
0
  Maybe<AutoCEReaction> ceReaction;
433
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
434
0
    DocGroup* docGroup = self->GetDocGroup();
435
0
    if (docGroup) {
436
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
437
0
    }
438
0
  }
439
0
  FastErrorResult rv;
440
0
  self->Prepend(Constify(arg0), rv);
441
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
442
0
    return false;
443
0
  }
444
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
445
0
  args.rval().setUndefined();
446
0
  return true;
447
0
}
448
449
static const JSJitInfo prepend_methodinfo = {
450
  { (JSJitGetterOp)prepend },
451
  { prototypes::id::DocumentFragment },
452
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
453
  JSJitInfo::Method,
454
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
455
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
456
  false,  /* isInfallible. False in setters. */
457
  false,  /* isMovable.  Not relevant for setters. */
458
  false, /* isEliminatable.  Not relevant for setters. */
459
  false, /* isAlwaysInSlot.  Only relevant for getters. */
460
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
461
  false,  /* isTypedMethod.  Only relevant for methods. */
462
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
463
};
464
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
465
static_assert(0 < 1, "There is no slot for us");
466
467
MOZ_CAN_RUN_SCRIPT static bool
468
append(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DocumentFragment* self, const JSJitMethodCallArgs& args)
469
0
{
470
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment.append", DOM, cx);
471
0
472
0
  AutoSequence<OwningNodeOrString> arg0;
473
0
  if (args.length() > 0) {
474
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
475
0
      JS_ReportOutOfMemory(cx);
476
0
      return false;
477
0
    }
478
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
479
0
      OwningNodeOrString& slot = *arg0.AppendElement(mozilla::fallible);
480
0
      {
481
0
        bool done = false, failed = false, tryNext;
482
0
        if (args[variadicArg].isObject()) {
483
0
          done = (failed = !slot.TrySetToNode(cx, args[variadicArg], tryNext, false)) || !tryNext;
484
0
485
0
        }
486
0
        if (!done) {
487
0
          do {
488
0
            done = (failed = !slot.TrySetToString(cx, args[variadicArg], tryNext)) || !tryNext;
489
0
            break;
490
0
          } while (false);
491
0
        }
492
0
        if (failed) {
493
0
          return false;
494
0
        }
495
0
        if (!done) {
496
0
          ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of DocumentFragment.append", "Node");
497
0
          return false;
498
0
        }
499
0
      }
500
0
    }
501
0
  }
502
0
  Maybe<AutoCEReaction> ceReaction;
503
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
504
0
    DocGroup* docGroup = self->GetDocGroup();
505
0
    if (docGroup) {
506
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
507
0
    }
508
0
  }
509
0
  FastErrorResult rv;
510
0
  self->Append(Constify(arg0), rv);
511
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
512
0
    return false;
513
0
  }
514
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
515
0
  args.rval().setUndefined();
516
0
  return true;
517
0
}
518
519
static const JSJitInfo append_methodinfo = {
520
  { (JSJitGetterOp)append },
521
  { prototypes::id::DocumentFragment },
522
  { PrototypeTraits<prototypes::id::DocumentFragment>::Depth },
523
  JSJitInfo::Method,
524
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
525
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
526
  false,  /* isInfallible. False in setters. */
527
  false,  /* isMovable.  Not relevant for setters. */
528
  false, /* isEliminatable.  Not relevant for setters. */
529
  false, /* isAlwaysInSlot.  Only relevant for getters. */
530
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
531
  false,  /* isTypedMethod.  Only relevant for methods. */
532
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
533
};
534
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
535
static_assert(0 < 1, "There is no slot for us");
536
537
static bool
538
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
539
0
{
540
0
  mozilla::dom::DocumentFragment* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DocumentFragment>(obj);
541
0
  // We don't want to preserve if we don't have a wrapper, and we
542
0
  // obviously can't preserve if we're not initialized.
543
0
  if (self && self->GetWrapperPreserveColor()) {
544
0
    PreserveWrapper(self);
545
0
  }
546
0
  return true;
547
0
}
548
549
static void
550
_finalize(js::FreeOp* fop, JSObject* obj)
551
0
{
552
0
  mozilla::dom::DocumentFragment* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DocumentFragment>(obj);
553
0
  if (self) {
554
0
    ClearWrapper(self, self, obj);
555
0
    AddForDeferredFinalization<mozilla::dom::DocumentFragment>(self);
556
0
  }
557
0
}
558
559
static size_t
560
_objectMoved(JSObject* obj, JSObject* old)
561
0
{
562
0
  mozilla::dom::DocumentFragment* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DocumentFragment>(obj);
563
0
  if (self) {
564
0
    UpdateWrapper(self, self, obj, old);
565
0
  }
566
0
567
0
  return 0;
568
0
}
569
570
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
571
#if defined(__clang__)
572
#pragma clang diagnostic push
573
#pragma clang diagnostic ignored "-Wmissing-braces"
574
#endif
575
static const JSFunctionSpec sMethods_specs[] = {
576
  JS_FNSPEC("getElementById", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementById_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
577
  JS_FNSPEC("querySelector", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&querySelector_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
578
  JS_FNSPEC("querySelectorAll", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&querySelectorAll_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
579
  JS_FS_END,
580
  JS_FNSPEC("getElementsByAttribute", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByAttribute_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
581
  JS_FNSPEC("getElementsByAttributeNS", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getElementsByAttributeNS_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
582
  JS_FS_END,
583
  JS_FNSPEC("prepend", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&prepend_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
584
  JS_FNSPEC("append", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&append_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
585
  JS_FS_END
586
};
587
#if defined(__clang__)
588
#pragma clang diagnostic pop
589
#endif
590
591
// Can't be const because the pref-enabled boolean needs to be writable
592
static PrefableDisablers sMethods_disablers4 = {
593
  true, false, 0, &IsChromeOrXBL
594
};
595
596
static const Prefable<const JSFunctionSpec> sMethods[] = {
597
  { nullptr, &sMethods_specs[0] },
598
  { &sMethods_disablers4, &sMethods_specs[4] },
599
  { nullptr, &sMethods_specs[7] },
600
  { nullptr, nullptr }
601
};
602
603
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
604
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
605
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
606
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
607
608
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
609
#if defined(__clang__)
610
#pragma clang diagnostic push
611
#pragma clang diagnostic ignored "-Wmissing-braces"
612
#endif
613
static const JSFunctionSpec sChromeMethods_specs[] = {
614
  JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
615
  JS_FS_END
616
};
617
#if defined(__clang__)
618
#pragma clang diagnostic pop
619
#endif
620
621
622
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
623
  { nullptr, &sChromeMethods_specs[0] },
624
  { nullptr, nullptr }
625
};
626
627
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
628
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
629
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
630
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
631
632
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
633
#if defined(__clang__)
634
#pragma clang diagnostic push
635
#pragma clang diagnostic ignored "-Wmissing-braces"
636
#endif
637
static const JSPropertySpec sAttributes_specs[] = {
638
  { "children", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &children_getterinfo, nullptr, nullptr },
639
  { "firstElementChild", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &firstElementChild_getterinfo, nullptr, nullptr },
640
  { "lastElementChild", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lastElementChild_getterinfo, nullptr, nullptr },
641
  { "childElementCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &childElementCount_getterinfo, nullptr, nullptr },
642
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
643
};
644
#if defined(__clang__)
645
#pragma clang diagnostic pop
646
#endif
647
648
649
static const Prefable<const JSPropertySpec> sAttributes[] = {
650
  { nullptr, &sAttributes_specs[0] },
651
  { nullptr, nullptr }
652
};
653
654
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
655
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
656
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
657
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
658
659
660
static uint16_t sNativeProperties_sortedPropertyIndices[11];
661
static PropertyInfo sNativeProperties_propertyInfos[11];
662
663
static const NativePropertiesN<2> sNativeProperties = {
664
  false, 0,
665
  false, 0,
666
  true,  0 /* sMethods */,
667
  true,  1 /* sAttributes */,
668
  false, 0,
669
  false, 0,
670
  false, 0,
671
  -1,
672
  11,
673
  sNativeProperties_sortedPropertyIndices,
674
  {
675
    { sMethods, &sNativeProperties_propertyInfos[0] },
676
    { sAttributes, &sNativeProperties_propertyInfos[7] }
677
  }
678
};
679
static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
680
    "We have a property info count that is oversized");
681
682
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
683
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
684
685
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
686
  false, 0,
687
  false, 0,
688
  true,  0 /* sChromeMethods */,
689
  false, 0,
690
  false, 0,
691
  false, 0,
692
  false, 0,
693
  -1,
694
  1,
695
  sChromeOnlyNativeProperties_sortedPropertyIndices,
696
  {
697
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
698
  }
699
};
700
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
701
    "We have a property info count that is oversized");
702
703
static bool
704
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
705
0
{
706
0
  AUTO_PROFILER_LABEL_FAST("DocumentFragment constructor", DOM, cx);
707
0
708
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
709
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
710
0
  if (!args.isConstructing()) {
711
0
    // XXXbz wish I could get the name from the callee instead of
712
0
    // Adding more relocations
713
0
    return ThrowConstructorWithoutNew(cx, "DocumentFragment");
714
0
  }
715
0
716
0
  JS::Rooted<JSObject*> desiredProto(cx);
717
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
718
0
    return false;
719
0
  }
720
0
721
0
  GlobalObject global(cx, obj);
722
0
  if (global.Failed()) {
723
0
    return false;
724
0
  }
725
0
726
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
727
0
  Maybe<JSAutoRealm> ar;
728
0
  if (objIsXray) {
729
0
    obj = js::CheckedUnwrap(obj);
730
0
    if (!obj) {
731
0
      return false;
732
0
    }
733
0
    ar.emplace(cx, obj);
734
0
    if (!JS_WrapObject(cx, &desiredProto)) {
735
0
      return false;
736
0
    }
737
0
  }
738
0
  FastErrorResult rv;
739
0
  auto result(StrongOrRawPtr<mozilla::dom::DocumentFragment>(mozilla::dom::DocumentFragment::Constructor(global, rv)));
740
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
741
0
    return false;
742
0
  }
743
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
744
0
  static_assert(!IsPointer<decltype(result)>::value,
745
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
746
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
747
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
748
0
    return false;
749
0
  }
750
0
  return true;
751
0
}
752
753
static const js::ClassOps sInterfaceObjectClassOps = {
754
    nullptr,               /* addProperty */
755
    nullptr,               /* delProperty */
756
    nullptr,               /* enumerate */
757
    nullptr,               /* newEnumerate */
758
    nullptr,               /* resolve */
759
    nullptr,               /* mayResolve */
760
    nullptr,               /* finalize */
761
    _constructor, /* call */
762
    nullptr,               /* hasInstance */
763
    _constructor, /* construct */
764
    nullptr,               /* trace */
765
};
766
767
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
768
  {
769
    "Function",
770
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
771
    &sInterfaceObjectClassOps,
772
    JS_NULL_CLASS_SPEC,
773
    JS_NULL_CLASS_EXT,
774
    &sInterfaceObjectClassObjectOps
775
  },
776
  eInterface,
777
  true,
778
  prototypes::id::DocumentFragment,
779
  PrototypeTraits<prototypes::id::DocumentFragment>::Depth,
780
  sNativePropertyHooks,
781
  "function DocumentFragment() {\n    [native code]\n}",
782
  Node_Binding::GetConstructorObject
783
};
784
785
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
786
  {
787
    "DocumentFragmentPrototype",
788
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
789
    JS_NULL_CLASS_OPS,
790
    JS_NULL_CLASS_SPEC,
791
    JS_NULL_CLASS_EXT,
792
    JS_NULL_OBJECT_OPS
793
  },
794
  eInterfacePrototype,
795
  false,
796
  prototypes::id::DocumentFragment,
797
  PrototypeTraits<prototypes::id::DocumentFragment>::Depth,
798
  sNativePropertyHooks,
799
  "[object DocumentFragmentPrototype]",
800
  Node_Binding::GetProtoObject
801
};
802
803
static const js::ClassOps sClassOps = {
804
  _addProperty, /* addProperty */
805
  nullptr,               /* delProperty */
806
  nullptr,               /* enumerate */
807
  nullptr, /* newEnumerate */
808
  nullptr, /* resolve */
809
  nullptr, /* mayResolve */
810
  _finalize, /* finalize */
811
  nullptr, /* call */
812
  nullptr,               /* hasInstance */
813
  nullptr,               /* construct */
814
  nullptr, /* trace */
815
};
816
817
static const js::ClassExtension sClassExtension = {
818
  nullptr, /* weakmapKeyDelegateOp */
819
  _objectMoved /* objectMovedOp */
820
};
821
822
static const DOMJSClass sClass = {
823
  { "DocumentFragment",
824
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
825
    &sClassOps,
826
    JS_NULL_CLASS_SPEC,
827
    &sClassExtension,
828
    JS_NULL_OBJECT_OPS
829
  },
830
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::DocumentFragment, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
831
  IsBaseOf<nsISupports, mozilla::dom::DocumentFragment >::value,
832
  sNativePropertyHooks,
833
  FindAssociatedGlobalForNative<mozilla::dom::DocumentFragment>::Get,
834
  GetProtoObjectHandle,
835
  GetCCParticipant<mozilla::dom::DocumentFragment>::Get()
836
};
837
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
838
              "Must have the right minimal number of reserved slots.");
839
static_assert(1 >= 1,
840
              "Must have enough reserved slots.");
841
842
const JSClass*
843
GetJSClass()
844
0
{
845
0
  return sClass.ToJSClass();
846
0
}
847
848
bool
849
Wrap(JSContext* aCx, mozilla::dom::DocumentFragment* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
850
0
{
851
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::DocumentFragment>::value,
852
0
                "Shouldn't have wrappercached things that are not refcounted.");
853
0
  MOZ_ASSERT(static_cast<mozilla::dom::DocumentFragment*>(aObject) ==
854
0
             reinterpret_cast<mozilla::dom::DocumentFragment*>(aObject),
855
0
             "Multiple inheritance for mozilla::dom::DocumentFragment is broken.");
856
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
857
0
             reinterpret_cast<nsINode*>(aObject),
858
0
             "Multiple inheritance for nsINode is broken.");
859
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
860
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
861
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
862
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
863
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
864
0
  MOZ_ASSERT(!aCache->GetWrapper(),
865
0
             "You should probably not be using Wrap() directly; use "
866
0
             "GetOrCreateDOMReflector instead");
867
0
868
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
869
0
             "nsISupports must be on our primary inheritance chain");
870
0
871
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
872
0
  if (!global) {
873
0
    return false;
874
0
  }
875
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
876
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
877
0
878
0
  // That might have ended up wrapping us already, due to the wonders
879
0
  // of XBL.  Check for that, and bail out as needed.
880
0
  aReflector.set(aCache->GetWrapper());
881
0
  if (aReflector) {
882
#ifdef DEBUG
883
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
884
#endif // DEBUG
885
    return true;
886
0
  }
887
0
888
0
  JSAutoRealm ar(aCx, global);
889
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
890
0
  if (!canonicalProto) {
891
0
    return false;
892
0
  }
893
0
  JS::Rooted<JSObject*> proto(aCx);
894
0
  if (aGivenProto) {
895
0
    proto = aGivenProto;
896
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
897
0
    // coming in, we changed compartments to that of "parent" so may need
898
0
    // to wrap the proto here.
899
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
900
0
      if (!JS_WrapObject(aCx, &proto)) {
901
0
        return false;
902
0
      }
903
0
    }
904
0
  } else {
905
0
    proto = canonicalProto;
906
0
  }
907
0
908
0
  BindingJSObjectCreator<mozilla::dom::DocumentFragment> creator(aCx);
909
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
910
0
  if (!aReflector) {
911
0
    return false;
912
0
  }
913
0
914
0
  aCache->SetWrapper(aReflector);
915
0
  creator.InitializationSucceeded();
916
0
917
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
918
0
             aCache->GetWrapperPreserveColor() == aReflector);
919
0
  // If proto != canonicalProto, we have to preserve our wrapper;
920
0
  // otherwise we won't be able to properly recreate it later, since
921
0
  // we won't know what proto to use.  Note that we don't check
922
0
  // aGivenProto here, since it's entirely possible (and even
923
0
  // somewhat common) to have a non-null aGivenProto which is the
924
0
  // same as canonicalProto.
925
0
  if (proto != canonicalProto) {
926
0
    PreserveWrapper(aObject);
927
0
  }
928
0
929
0
  return true;
930
0
}
931
932
const NativePropertyHooks sNativePropertyHooks[] = { {
933
  nullptr,
934
  nullptr,
935
  nullptr,
936
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
937
  prototypes::id::DocumentFragment,
938
  constructors::id::DocumentFragment,
939
  Node_Binding::sNativePropertyHooks,
940
  &DefaultXrayExpandoObjectClass
941
} };
942
943
static const char* const unscopableNames[] = {
944
  "prepend",
945
  "append",
946
  nullptr
947
};
948
949
void
950
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
951
0
{
952
0
  JS::Handle<JSObject*> parentProto(Node_Binding::GetProtoObjectHandle(aCx));
953
0
  if (!parentProto) {
954
0
    return;
955
0
  }
956
0
957
0
  JS::Handle<JSObject*> constructorProto(Node_Binding::GetConstructorObjectHandle(aCx));
958
0
  if (!constructorProto) {
959
0
    return;
960
0
  }
961
0
962
0
  static bool sIdsInited = false;
963
0
  if (!sIdsInited && NS_IsMainThread()) {
964
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
965
0
      return;
966
0
    }
967
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
968
0
      return;
969
0
    }
970
0
    sIdsInited = true;
971
0
  }
972
0
973
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DocumentFragment);
974
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DocumentFragment);
975
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
976
0
                              &sPrototypeClass.mBase, protoCache,
977
0
                              nullptr,
978
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
979
0
                              interfaceCache,
980
0
                              sNativeProperties.Upcast(),
981
0
                              sChromeOnlyNativeProperties.Upcast(),
982
0
                              "DocumentFragment", aDefineOnGlobal,
983
0
                              unscopableNames,
984
0
                              false);
985
0
}
986
987
JSObject*
988
GetProtoObject(JSContext* aCx)
989
0
{
990
0
  return GetProtoObjectHandle(aCx);
991
0
}
992
993
JSObject*
994
GetConstructorObject(JSContext* aCx)
995
0
{
996
0
  return GetConstructorObjectHandle(aCx);
997
0
}
998
999
} // namespace DocumentFragment_Binding
1000
1001
1002
1003
} // namespace dom
1004
} // namespace mozilla