Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLDocumentBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLDocument.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "DocumentBinding.h"
4
#include "HTMLDocumentBinding.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/DOMJSProxyHandler.h"
11
#include "mozilla/dom/DocGroup.h"
12
#include "mozilla/dom/HTMLAllCollection.h"
13
#include "mozilla/dom/Location.h"
14
#include "mozilla/dom/NonRefcountedDOMObject.h"
15
#include "mozilla/dom/Nullable.h"
16
#include "mozilla/dom/PrimitiveConversions.h"
17
#include "mozilla/dom/XrayExpandoClass.h"
18
#include "nsContentUtils.h"
19
#include "nsHTMLDocument.h"
20
#include "nsIDocument.h"
21
#include "nsINodeList.h"
22
#include "nsPIDOMWindow.h"
23
24
namespace mozilla {
25
namespace dom {
26
27
namespace binding_detail {}; // Just to make sure it's known as a namespace
28
using namespace mozilla::dom::binding_detail;
29
30
31
namespace HTMLDocument_Binding {
32
33
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Document_Binding::NativeType>::value,
34
              "Can't inherit from an interface with a different ownership model.");
35
36
MOZ_CAN_RUN_SCRIPT static bool
37
get_domain(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
38
0
{
39
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.domain", DOM, cx);
40
0
41
0
  DOMString result;
42
0
  self->GetDomain(result);
43
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
44
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
45
0
    return false;
46
0
  }
47
0
  return true;
48
0
}
49
50
MOZ_CAN_RUN_SCRIPT static bool
51
set_domain(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
52
0
{
53
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.domain", DOM, cx);
54
0
55
0
  binding_detail::FakeString arg0;
56
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
57
0
    return false;
58
0
  }
59
0
  FastErrorResult rv;
60
0
  self->SetDomain(NonNullHelper(Constify(arg0)), rv);
61
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
62
0
    return false;
63
0
  }
64
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
65
0
66
0
  return true;
67
0
}
68
69
static const JSJitInfo domain_getterinfo = {
70
  { (JSJitGetterOp)get_domain },
71
  { prototypes::id::HTMLDocument },
72
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
73
  JSJitInfo::Getter,
74
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
75
  JSVAL_TYPE_STRING,  /* 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
static const JSJitInfo domain_setterinfo = {
87
  { (JSJitGetterOp)set_domain },
88
  { prototypes::id::HTMLDocument },
89
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
90
  JSJitInfo::Setter,
91
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
92
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
93
  false,  /* isInfallible. False in setters. */
94
  false,  /* isMovable.  Not relevant for setters. */
95
  false, /* isEliminatable.  Not relevant for setters. */
96
  false, /* isAlwaysInSlot.  Only relevant for getters. */
97
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
98
  false,  /* isTypedMethod.  Only relevant for methods. */
99
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
100
};
101
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
102
static_assert(0 < 1, "There is no slot for us");
103
104
MOZ_CAN_RUN_SCRIPT static bool
105
get_cookie(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
106
0
{
107
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.cookie", DOM, cx);
108
0
109
0
  FastErrorResult rv;
110
0
  DOMString result;
111
0
  self->GetCookie(result, rv);
112
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
113
0
    return false;
114
0
  }
115
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
116
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
117
0
    return false;
118
0
  }
119
0
  return true;
120
0
}
121
122
MOZ_CAN_RUN_SCRIPT static bool
123
set_cookie(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
124
0
{
125
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.cookie", DOM, cx);
126
0
127
0
  binding_detail::FakeString arg0;
128
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
129
0
    return false;
130
0
  }
131
0
  FastErrorResult rv;
132
0
  self->SetCookie(NonNullHelper(Constify(arg0)), rv);
133
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
134
0
    return false;
135
0
  }
136
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
137
0
138
0
  return true;
139
0
}
140
141
static const JSJitInfo cookie_getterinfo = {
142
  { (JSJitGetterOp)get_cookie },
143
  { prototypes::id::HTMLDocument },
144
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
145
  JSJitInfo::Getter,
146
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
147
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
148
  false,  /* isInfallible. False in setters. */
149
  false,  /* isMovable.  Not relevant for setters. */
150
  false, /* isEliminatable.  Not relevant for setters. */
151
  false, /* isAlwaysInSlot.  Only relevant for getters. */
152
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
153
  false,  /* isTypedMethod.  Only relevant for methods. */
154
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
155
};
156
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
157
static_assert(0 < 1, "There is no slot for us");
158
static const JSJitInfo cookie_setterinfo = {
159
  { (JSJitGetterOp)set_cookie },
160
  { prototypes::id::HTMLDocument },
161
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
162
  JSJitInfo::Setter,
163
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
164
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
165
  false,  /* isInfallible. False in setters. */
166
  false,  /* isMovable.  Not relevant for setters. */
167
  false, /* isEliminatable.  Not relevant for setters. */
168
  false, /* isAlwaysInSlot.  Only relevant for getters. */
169
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
170
  false,  /* isTypedMethod.  Only relevant for methods. */
171
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
172
};
173
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
174
static_assert(0 < 1, "There is no slot for us");
175
176
MOZ_CAN_RUN_SCRIPT static bool
177
open(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
178
0
{
179
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.open", DOM, cx);
180
0
181
0
  unsigned argcount = std::min(args.length(), 4u);
182
0
  switch (argcount) {
183
0
    case 0: {
184
0
      MOZ_FALLTHROUGH;
185
0
    }
186
0
    case 1: {
187
0
      MOZ_FALLTHROUGH;
188
0
    }
189
0
    case 2: {
190
0
      Optional<nsAString> arg0;
191
0
      binding_detail::FakeString arg0_holder;
192
0
      if (args.hasDefined(0)) {
193
0
        if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0_holder)) {
194
0
          return false;
195
0
        }
196
0
        arg0 = &arg0_holder;
197
0
      }
198
0
      binding_detail::FakeString arg1;
199
0
      if (args.hasDefined(1)) {
200
0
        if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
201
0
          return false;
202
0
        }
203
0
      } else {
204
0
        static const char16_t data[] = { 0 };
205
0
        arg1.Rebind(data, ArrayLength(data) - 1);
206
0
      }
207
0
      Maybe<AutoCEReaction> ceReaction;
208
0
      if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
209
0
        DocGroup* docGroup = self->GetDocGroup();
210
0
        if (docGroup) {
211
0
          ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
212
0
        }
213
0
      }
214
0
      FastErrorResult rv;
215
0
      auto result(StrongOrRawPtr<nsIDocument>(self->Open(cx, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
216
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
217
0
        return false;
218
0
      }
219
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
220
0
      if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
221
0
        MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing");
222
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
223
0
        return false;
224
0
      }
225
0
      return true;
226
0
      break;
227
0
    }
228
0
    case 3: {
229
0
      MOZ_FALLTHROUGH;
230
0
    }
231
0
    case 4: {
232
0
      binding_detail::FakeString arg0;
233
0
      if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
234
0
        return false;
235
0
      }
236
0
      binding_detail::FakeString arg1;
237
0
      if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
238
0
        return false;
239
0
      }
240
0
      binding_detail::FakeString arg2;
241
0
      if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
242
0
        return false;
243
0
      }
244
0
      bool arg3;
245
0
      if (args.hasDefined(3)) {
246
0
        if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3)) {
247
0
          return false;
248
0
        }
249
0
      } else {
250
0
        arg3 = false;
251
0
      }
252
0
      Maybe<AutoCEReaction> ceReaction;
253
0
      if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
254
0
        DocGroup* docGroup = self->GetDocGroup();
255
0
        if (docGroup) {
256
0
          ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
257
0
        }
258
0
      }
259
0
      FastErrorResult rv;
260
0
      auto result(StrongOrRawPtr<nsPIDOMWindowOuter>(self->Open(cx, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), arg3, rv)));
261
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
262
0
        return false;
263
0
      }
264
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
265
0
      if (!result) {
266
0
        args.rval().setNull();
267
0
        return true;
268
0
      }
269
0
      if (!WrapObject(cx, result, args.rval())) {
270
0
        return false;
271
0
      }
272
0
      return true;
273
0
      break;
274
0
    }
275
0
    default: {
276
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.open");
277
0
      break;
278
0
    }
279
0
  }
280
0
  MOZ_CRASH("We have an always-returning default case");
281
0
  return false;
282
0
}
283
284
static const JSJitInfo open_methodinfo = {
285
  { (JSJitGetterOp)open },
286
  { prototypes::id::HTMLDocument },
287
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
288
  JSJitInfo::Method,
289
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
290
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
291
  false,  /* isInfallible. False in setters. */
292
  false,  /* isMovable.  Not relevant for setters. */
293
  false, /* isEliminatable.  Not relevant for setters. */
294
  false, /* isAlwaysInSlot.  Only relevant for getters. */
295
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
296
  false,  /* isTypedMethod.  Only relevant for methods. */
297
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
298
};
299
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
300
static_assert(0 < 1, "There is no slot for us");
301
302
MOZ_CAN_RUN_SCRIPT static bool
303
close(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
304
0
{
305
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.close", DOM, cx);
306
0
307
0
  Maybe<AutoCEReaction> ceReaction;
308
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
309
0
    DocGroup* docGroup = self->GetDocGroup();
310
0
    if (docGroup) {
311
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
312
0
    }
313
0
  }
314
0
  FastErrorResult rv;
315
0
  self->Close(rv);
316
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
317
0
    return false;
318
0
  }
319
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
320
0
  args.rval().setUndefined();
321
0
  return true;
322
0
}
323
324
static const JSJitInfo close_methodinfo = {
325
  { (JSJitGetterOp)close },
326
  { prototypes::id::HTMLDocument },
327
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
328
  JSJitInfo::Method,
329
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
330
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
331
  false,  /* isInfallible. False in setters. */
332
  false,  /* isMovable.  Not relevant for setters. */
333
  false, /* isEliminatable.  Not relevant for setters. */
334
  false, /* isAlwaysInSlot.  Only relevant for getters. */
335
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
336
  false,  /* isTypedMethod.  Only relevant for methods. */
337
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
338
};
339
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
340
static_assert(0 < 1, "There is no slot for us");
341
342
MOZ_CAN_RUN_SCRIPT static bool
343
write(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
344
0
{
345
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.write", DOM, cx);
346
0
347
0
  AutoSequence<nsString> arg0;
348
0
  if (args.length() > 0) {
349
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
350
0
      JS_ReportOutOfMemory(cx);
351
0
      return false;
352
0
    }
353
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
354
0
      nsString& slot = *arg0.AppendElement(mozilla::fallible);
355
0
      if (!ConvertJSValueToString(cx, args[variadicArg], eStringify, eStringify, slot)) {
356
0
        return false;
357
0
      }
358
0
    }
359
0
  }
360
0
  Maybe<AutoCEReaction> ceReaction;
361
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
362
0
    DocGroup* docGroup = self->GetDocGroup();
363
0
    if (docGroup) {
364
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
365
0
    }
366
0
  }
367
0
  FastErrorResult rv;
368
0
  self->Write(cx, NonNullHelper(Constify(arg0)), rv);
369
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
370
0
    return false;
371
0
  }
372
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
373
0
  args.rval().setUndefined();
374
0
  return true;
375
0
}
376
377
static const JSJitInfo write_methodinfo = {
378
  { (JSJitGetterOp)write },
379
  { prototypes::id::HTMLDocument },
380
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
381
  JSJitInfo::Method,
382
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
383
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
384
  false,  /* isInfallible. False in setters. */
385
  false,  /* isMovable.  Not relevant for setters. */
386
  false, /* isEliminatable.  Not relevant for setters. */
387
  false, /* isAlwaysInSlot.  Only relevant for getters. */
388
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
389
  false,  /* isTypedMethod.  Only relevant for methods. */
390
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
391
};
392
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
393
static_assert(0 < 1, "There is no slot for us");
394
395
MOZ_CAN_RUN_SCRIPT static bool
396
writeln(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
397
0
{
398
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.writeln", DOM, cx);
399
0
400
0
  AutoSequence<nsString> arg0;
401
0
  if (args.length() > 0) {
402
0
    if (!arg0.SetCapacity(args.length() - 0, mozilla::fallible)) {
403
0
      JS_ReportOutOfMemory(cx);
404
0
      return false;
405
0
    }
406
0
    for (uint32_t variadicArg = 0; variadicArg < args.length(); ++variadicArg) {
407
0
      nsString& slot = *arg0.AppendElement(mozilla::fallible);
408
0
      if (!ConvertJSValueToString(cx, args[variadicArg], eStringify, eStringify, slot)) {
409
0
        return false;
410
0
      }
411
0
    }
412
0
  }
413
0
  Maybe<AutoCEReaction> ceReaction;
414
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
415
0
    DocGroup* docGroup = self->GetDocGroup();
416
0
    if (docGroup) {
417
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
418
0
    }
419
0
  }
420
0
  FastErrorResult rv;
421
0
  self->Writeln(cx, NonNullHelper(Constify(arg0)), rv);
422
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
423
0
    return false;
424
0
  }
425
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
426
0
  args.rval().setUndefined();
427
0
  return true;
428
0
}
429
430
static const JSJitInfo writeln_methodinfo = {
431
  { (JSJitGetterOp)writeln },
432
  { prototypes::id::HTMLDocument },
433
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
434
  JSJitInfo::Method,
435
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
436
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
437
  false,  /* isInfallible. False in setters. */
438
  false,  /* isMovable.  Not relevant for setters. */
439
  false, /* isEliminatable.  Not relevant for setters. */
440
  false, /* isAlwaysInSlot.  Only relevant for getters. */
441
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
442
  false,  /* isTypedMethod.  Only relevant for methods. */
443
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
444
};
445
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
446
static_assert(0 < 1, "There is no slot for us");
447
448
MOZ_CAN_RUN_SCRIPT static bool
449
get_designMode(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
450
0
{
451
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.designMode", DOM, cx);
452
0
453
0
  DOMString result;
454
0
  self->GetDesignMode(result);
455
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
456
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
457
0
    return false;
458
0
  }
459
0
  return true;
460
0
}
461
462
MOZ_CAN_RUN_SCRIPT static bool
463
set_designMode(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
464
0
{
465
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.designMode", DOM, cx);
466
0
467
0
  binding_detail::FakeString arg0;
468
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
469
0
    return false;
470
0
  }
471
0
  Maybe<AutoCEReaction> ceReaction;
472
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
473
0
    DocGroup* docGroup = self->GetDocGroup();
474
0
    if (docGroup) {
475
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
476
0
    }
477
0
  }
478
0
  FastErrorResult rv;
479
0
  NonNull<nsIPrincipal> subjectPrincipal;
480
0
  {
481
0
    JS::Realm* realm = js::GetContextRealm(cx);
482
0
    MOZ_ASSERT(realm);
483
0
    JSPrincipals* principals = JS::GetRealmPrincipals(realm);
484
0
    nsIPrincipal* principal = nsJSPrincipals::get(principals);
485
0
486
0
    subjectPrincipal = principal;
487
0
  }
488
0
  self->SetDesignMode(NonNullHelper(Constify(arg0)), subjectPrincipal, rv);
489
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
490
0
    return false;
491
0
  }
492
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
493
0
494
0
  return true;
495
0
}
496
497
static const JSJitInfo designMode_getterinfo = {
498
  { (JSJitGetterOp)get_designMode },
499
  { prototypes::id::HTMLDocument },
500
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
501
  JSJitInfo::Getter,
502
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
503
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
504
  false,  /* isInfallible. False in setters. */
505
  false,  /* isMovable.  Not relevant for setters. */
506
  false, /* isEliminatable.  Not relevant for setters. */
507
  false, /* isAlwaysInSlot.  Only relevant for getters. */
508
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
509
  false,  /* isTypedMethod.  Only relevant for methods. */
510
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
511
};
512
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
513
static_assert(0 < 1, "There is no slot for us");
514
static const JSJitInfo designMode_setterinfo = {
515
  { (JSJitGetterOp)set_designMode },
516
  { prototypes::id::HTMLDocument },
517
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
518
  JSJitInfo::Setter,
519
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
520
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
521
  false,  /* isInfallible. False in setters. */
522
  false,  /* isMovable.  Not relevant for setters. */
523
  false, /* isEliminatable.  Not relevant for setters. */
524
  false, /* isAlwaysInSlot.  Only relevant for getters. */
525
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
526
  false,  /* isTypedMethod.  Only relevant for methods. */
527
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
528
};
529
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
530
static_assert(0 < 1, "There is no slot for us");
531
532
MOZ_CAN_RUN_SCRIPT static bool
533
execCommand(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
534
0
{
535
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.execCommand", DOM, cx);
536
0
537
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
538
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.execCommand");
539
0
  }
540
0
  binding_detail::FakeString arg0;
541
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
542
0
    return false;
543
0
  }
544
0
  bool arg1;
545
0
  if (args.hasDefined(1)) {
546
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
547
0
      return false;
548
0
    }
549
0
  } else {
550
0
    arg1 = false;
551
0
  }
552
0
  binding_detail::FakeString arg2;
553
0
  if (args.hasDefined(2)) {
554
0
    if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
555
0
      return false;
556
0
    }
557
0
  } else {
558
0
    static const char16_t data[] = { 0 };
559
0
    arg2.Rebind(data, ArrayLength(data) - 1);
560
0
  }
561
0
  Maybe<AutoCEReaction> ceReaction;
562
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
563
0
    DocGroup* docGroup = self->GetDocGroup();
564
0
    if (docGroup) {
565
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
566
0
    }
567
0
  }
568
0
  FastErrorResult rv;
569
0
  NonNull<nsIPrincipal> subjectPrincipal;
570
0
  {
571
0
    JS::Realm* realm = js::GetContextRealm(cx);
572
0
    MOZ_ASSERT(realm);
573
0
    JSPrincipals* principals = JS::GetRealmPrincipals(realm);
574
0
    nsIPrincipal* principal = nsJSPrincipals::get(principals);
575
0
576
0
    subjectPrincipal = principal;
577
0
  }
578
0
  bool result(self->ExecCommand(NonNullHelper(Constify(arg0)), arg1, NonNullHelper(Constify(arg2)), subjectPrincipal, rv));
579
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
580
0
    return false;
581
0
  }
582
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
583
0
  args.rval().setBoolean(result);
584
0
  return true;
585
0
}
586
587
static const JSJitInfo execCommand_methodinfo = {
588
  { (JSJitGetterOp)execCommand },
589
  { prototypes::id::HTMLDocument },
590
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
591
  JSJitInfo::Method,
592
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
593
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
594
  false,  /* isInfallible. False in setters. */
595
  false,  /* isMovable.  Not relevant for setters. */
596
  false, /* isEliminatable.  Not relevant for setters. */
597
  false, /* isAlwaysInSlot.  Only relevant for getters. */
598
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
599
  false,  /* isTypedMethod.  Only relevant for methods. */
600
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
601
};
602
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
603
static_assert(0 < 1, "There is no slot for us");
604
605
MOZ_CAN_RUN_SCRIPT static bool
606
queryCommandEnabled(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
607
0
{
608
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.queryCommandEnabled", DOM, cx);
609
0
610
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
611
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.queryCommandEnabled");
612
0
  }
613
0
  binding_detail::FakeString arg0;
614
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
615
0
    return false;
616
0
  }
617
0
  FastErrorResult rv;
618
0
  NonNull<nsIPrincipal> subjectPrincipal;
619
0
  {
620
0
    JS::Realm* realm = js::GetContextRealm(cx);
621
0
    MOZ_ASSERT(realm);
622
0
    JSPrincipals* principals = JS::GetRealmPrincipals(realm);
623
0
    nsIPrincipal* principal = nsJSPrincipals::get(principals);
624
0
625
0
    subjectPrincipal = principal;
626
0
  }
627
0
  bool result(self->QueryCommandEnabled(NonNullHelper(Constify(arg0)), subjectPrincipal, rv));
628
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
629
0
    return false;
630
0
  }
631
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
632
0
  args.rval().setBoolean(result);
633
0
  return true;
634
0
}
635
636
static const JSJitInfo queryCommandEnabled_methodinfo = {
637
  { (JSJitGetterOp)queryCommandEnabled },
638
  { prototypes::id::HTMLDocument },
639
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
640
  JSJitInfo::Method,
641
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
642
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
643
  false,  /* isInfallible. False in setters. */
644
  false,  /* isMovable.  Not relevant for setters. */
645
  false, /* isEliminatable.  Not relevant for setters. */
646
  false, /* isAlwaysInSlot.  Only relevant for getters. */
647
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
648
  false,  /* isTypedMethod.  Only relevant for methods. */
649
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
650
};
651
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
652
static_assert(0 < 1, "There is no slot for us");
653
654
MOZ_CAN_RUN_SCRIPT static bool
655
queryCommandIndeterm(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
656
0
{
657
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.queryCommandIndeterm", DOM, cx);
658
0
659
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
660
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.queryCommandIndeterm");
661
0
  }
662
0
  binding_detail::FakeString arg0;
663
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
664
0
    return false;
665
0
  }
666
0
  FastErrorResult rv;
667
0
  bool result(self->QueryCommandIndeterm(NonNullHelper(Constify(arg0)), rv));
668
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
669
0
    return false;
670
0
  }
671
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
672
0
  args.rval().setBoolean(result);
673
0
  return true;
674
0
}
675
676
static const JSJitInfo queryCommandIndeterm_methodinfo = {
677
  { (JSJitGetterOp)queryCommandIndeterm },
678
  { prototypes::id::HTMLDocument },
679
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
680
  JSJitInfo::Method,
681
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
682
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
683
  false,  /* isInfallible. False in setters. */
684
  false,  /* isMovable.  Not relevant for setters. */
685
  false, /* isEliminatable.  Not relevant for setters. */
686
  false, /* isAlwaysInSlot.  Only relevant for getters. */
687
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
688
  false,  /* isTypedMethod.  Only relevant for methods. */
689
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
690
};
691
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
692
static_assert(0 < 1, "There is no slot for us");
693
694
MOZ_CAN_RUN_SCRIPT static bool
695
queryCommandState(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
696
0
{
697
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.queryCommandState", DOM, cx);
698
0
699
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
700
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.queryCommandState");
701
0
  }
702
0
  binding_detail::FakeString arg0;
703
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
704
0
    return false;
705
0
  }
706
0
  FastErrorResult rv;
707
0
  bool result(self->QueryCommandState(NonNullHelper(Constify(arg0)), rv));
708
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
709
0
    return false;
710
0
  }
711
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
712
0
  args.rval().setBoolean(result);
713
0
  return true;
714
0
}
715
716
static const JSJitInfo queryCommandState_methodinfo = {
717
  { (JSJitGetterOp)queryCommandState },
718
  { prototypes::id::HTMLDocument },
719
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
720
  JSJitInfo::Method,
721
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
722
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
723
  false,  /* isInfallible. False in setters. */
724
  false,  /* isMovable.  Not relevant for setters. */
725
  false, /* isEliminatable.  Not relevant for setters. */
726
  false, /* isAlwaysInSlot.  Only relevant for getters. */
727
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
728
  false,  /* isTypedMethod.  Only relevant for methods. */
729
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
730
};
731
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
732
static_assert(0 < 1, "There is no slot for us");
733
734
MOZ_CAN_RUN_SCRIPT static bool
735
queryCommandSupported(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
736
0
{
737
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.queryCommandSupported", DOM, cx);
738
0
739
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
740
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.queryCommandSupported");
741
0
  }
742
0
  binding_detail::FakeString arg0;
743
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
744
0
    return false;
745
0
  }
746
0
  bool result(self->QueryCommandSupported(NonNullHelper(Constify(arg0)), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
747
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
748
0
  args.rval().setBoolean(result);
749
0
  return true;
750
0
}
751
752
static const JSJitInfo queryCommandSupported_methodinfo = {
753
  { (JSJitGetterOp)queryCommandSupported },
754
  { prototypes::id::HTMLDocument },
755
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
756
  JSJitInfo::Method,
757
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
758
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
759
  false,  /* isInfallible. False in setters. */
760
  false,  /* isMovable.  Not relevant for setters. */
761
  false, /* isEliminatable.  Not relevant for setters. */
762
  false, /* isAlwaysInSlot.  Only relevant for getters. */
763
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
764
  false,  /* isTypedMethod.  Only relevant for methods. */
765
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
766
};
767
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
768
static_assert(0 < 1, "There is no slot for us");
769
770
MOZ_CAN_RUN_SCRIPT static bool
771
queryCommandValue(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
772
0
{
773
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.queryCommandValue", DOM, cx);
774
0
775
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
776
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLDocument.queryCommandValue");
777
0
  }
778
0
  binding_detail::FakeString arg0;
779
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
780
0
    return false;
781
0
  }
782
0
  FastErrorResult rv;
783
0
  DOMString result;
784
0
  self->QueryCommandValue(NonNullHelper(Constify(arg0)), result, rv);
785
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
786
0
    return false;
787
0
  }
788
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
789
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
790
0
    return false;
791
0
  }
792
0
  return true;
793
0
}
794
795
static const JSJitInfo queryCommandValue_methodinfo = {
796
  { (JSJitGetterOp)queryCommandValue },
797
  { prototypes::id::HTMLDocument },
798
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
799
  JSJitInfo::Method,
800
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
801
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
802
  false,  /* isInfallible. False in setters. */
803
  false,  /* isMovable.  Not relevant for setters. */
804
  false, /* isEliminatable.  Not relevant for setters. */
805
  false, /* isAlwaysInSlot.  Only relevant for getters. */
806
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
807
  false,  /* isTypedMethod.  Only relevant for methods. */
808
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
809
};
810
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
811
static_assert(0 < 1, "There is no slot for us");
812
813
MOZ_CAN_RUN_SCRIPT static bool
814
get_fgColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
815
0
{
816
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.fgColor", DOM, cx);
817
0
818
0
  DOMString result;
819
0
  self->GetFgColor(result);
820
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
821
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
822
0
    return false;
823
0
  }
824
0
  return true;
825
0
}
826
827
MOZ_CAN_RUN_SCRIPT static bool
828
set_fgColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
829
0
{
830
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.fgColor", DOM, cx);
831
0
832
0
  binding_detail::FakeString arg0;
833
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
834
0
    return false;
835
0
  }
836
0
  Maybe<AutoCEReaction> ceReaction;
837
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
838
0
    DocGroup* docGroup = self->GetDocGroup();
839
0
    if (docGroup) {
840
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
841
0
    }
842
0
  }
843
0
  self->SetFgColor(NonNullHelper(Constify(arg0)));
844
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
845
0
846
0
  return true;
847
0
}
848
849
static const JSJitInfo fgColor_getterinfo = {
850
  { (JSJitGetterOp)get_fgColor },
851
  { prototypes::id::HTMLDocument },
852
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
853
  JSJitInfo::Getter,
854
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
855
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
856
  false,  /* isInfallible. False in setters. */
857
  false,  /* isMovable.  Not relevant for setters. */
858
  false, /* isEliminatable.  Not relevant for setters. */
859
  false, /* isAlwaysInSlot.  Only relevant for getters. */
860
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
861
  false,  /* isTypedMethod.  Only relevant for methods. */
862
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
863
};
864
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
865
static_assert(0 < 1, "There is no slot for us");
866
static const JSJitInfo fgColor_setterinfo = {
867
  { (JSJitGetterOp)set_fgColor },
868
  { prototypes::id::HTMLDocument },
869
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
870
  JSJitInfo::Setter,
871
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
872
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
873
  false,  /* isInfallible. False in setters. */
874
  false,  /* isMovable.  Not relevant for setters. */
875
  false, /* isEliminatable.  Not relevant for setters. */
876
  false, /* isAlwaysInSlot.  Only relevant for getters. */
877
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
878
  false,  /* isTypedMethod.  Only relevant for methods. */
879
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
880
};
881
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
882
static_assert(0 < 1, "There is no slot for us");
883
884
MOZ_CAN_RUN_SCRIPT static bool
885
get_linkColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
886
0
{
887
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.linkColor", DOM, cx);
888
0
889
0
  DOMString result;
890
0
  self->GetLinkColor(result);
891
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
892
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
893
0
    return false;
894
0
  }
895
0
  return true;
896
0
}
897
898
MOZ_CAN_RUN_SCRIPT static bool
899
set_linkColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
900
0
{
901
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.linkColor", DOM, cx);
902
0
903
0
  binding_detail::FakeString arg0;
904
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
905
0
    return false;
906
0
  }
907
0
  Maybe<AutoCEReaction> ceReaction;
908
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
909
0
    DocGroup* docGroup = self->GetDocGroup();
910
0
    if (docGroup) {
911
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
912
0
    }
913
0
  }
914
0
  self->SetLinkColor(NonNullHelper(Constify(arg0)));
915
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
916
0
917
0
  return true;
918
0
}
919
920
static const JSJitInfo linkColor_getterinfo = {
921
  { (JSJitGetterOp)get_linkColor },
922
  { prototypes::id::HTMLDocument },
923
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
924
  JSJitInfo::Getter,
925
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
926
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
927
  false,  /* isInfallible. False in setters. */
928
  false,  /* isMovable.  Not relevant for setters. */
929
  false, /* isEliminatable.  Not relevant for setters. */
930
  false, /* isAlwaysInSlot.  Only relevant for getters. */
931
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
932
  false,  /* isTypedMethod.  Only relevant for methods. */
933
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
934
};
935
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
936
static_assert(0 < 1, "There is no slot for us");
937
static const JSJitInfo linkColor_setterinfo = {
938
  { (JSJitGetterOp)set_linkColor },
939
  { prototypes::id::HTMLDocument },
940
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
941
  JSJitInfo::Setter,
942
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
943
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
944
  false,  /* isInfallible. False in setters. */
945
  false,  /* isMovable.  Not relevant for setters. */
946
  false, /* isEliminatable.  Not relevant for setters. */
947
  false, /* isAlwaysInSlot.  Only relevant for getters. */
948
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
949
  false,  /* isTypedMethod.  Only relevant for methods. */
950
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
951
};
952
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
953
static_assert(0 < 1, "There is no slot for us");
954
955
MOZ_CAN_RUN_SCRIPT static bool
956
get_vlinkColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
957
0
{
958
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.vlinkColor", DOM, cx);
959
0
960
0
  DOMString result;
961
0
  self->GetVlinkColor(result);
962
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
963
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
964
0
    return false;
965
0
  }
966
0
  return true;
967
0
}
968
969
MOZ_CAN_RUN_SCRIPT static bool
970
set_vlinkColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
971
0
{
972
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.vlinkColor", DOM, cx);
973
0
974
0
  binding_detail::FakeString arg0;
975
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
976
0
    return false;
977
0
  }
978
0
  Maybe<AutoCEReaction> ceReaction;
979
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
980
0
    DocGroup* docGroup = self->GetDocGroup();
981
0
    if (docGroup) {
982
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
983
0
    }
984
0
  }
985
0
  self->SetVlinkColor(NonNullHelper(Constify(arg0)));
986
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
987
0
988
0
  return true;
989
0
}
990
991
static const JSJitInfo vlinkColor_getterinfo = {
992
  { (JSJitGetterOp)get_vlinkColor },
993
  { prototypes::id::HTMLDocument },
994
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
995
  JSJitInfo::Getter,
996
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
997
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
998
  false,  /* isInfallible. False in setters. */
999
  false,  /* isMovable.  Not relevant for setters. */
1000
  false, /* isEliminatable.  Not relevant for setters. */
1001
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1002
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1003
  false,  /* isTypedMethod.  Only relevant for methods. */
1004
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1005
};
1006
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1007
static_assert(0 < 1, "There is no slot for us");
1008
static const JSJitInfo vlinkColor_setterinfo = {
1009
  { (JSJitGetterOp)set_vlinkColor },
1010
  { prototypes::id::HTMLDocument },
1011
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1012
  JSJitInfo::Setter,
1013
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1014
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1015
  false,  /* isInfallible. False in setters. */
1016
  false,  /* isMovable.  Not relevant for setters. */
1017
  false, /* isEliminatable.  Not relevant for setters. */
1018
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1019
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1020
  false,  /* isTypedMethod.  Only relevant for methods. */
1021
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1022
};
1023
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1024
static_assert(0 < 1, "There is no slot for us");
1025
1026
MOZ_CAN_RUN_SCRIPT static bool
1027
get_alinkColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
1028
0
{
1029
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.alinkColor", DOM, cx);
1030
0
1031
0
  DOMString result;
1032
0
  self->GetAlinkColor(result);
1033
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1034
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1035
0
    return false;
1036
0
  }
1037
0
  return true;
1038
0
}
1039
1040
MOZ_CAN_RUN_SCRIPT static bool
1041
set_alinkColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
1042
0
{
1043
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.alinkColor", DOM, cx);
1044
0
1045
0
  binding_detail::FakeString arg0;
1046
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
1047
0
    return false;
1048
0
  }
1049
0
  Maybe<AutoCEReaction> ceReaction;
1050
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
1051
0
    DocGroup* docGroup = self->GetDocGroup();
1052
0
    if (docGroup) {
1053
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
1054
0
    }
1055
0
  }
1056
0
  self->SetAlinkColor(NonNullHelper(Constify(arg0)));
1057
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1058
0
1059
0
  return true;
1060
0
}
1061
1062
static const JSJitInfo alinkColor_getterinfo = {
1063
  { (JSJitGetterOp)get_alinkColor },
1064
  { prototypes::id::HTMLDocument },
1065
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1066
  JSJitInfo::Getter,
1067
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1068
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1069
  false,  /* isInfallible. False in setters. */
1070
  false,  /* isMovable.  Not relevant for setters. */
1071
  false, /* isEliminatable.  Not relevant for setters. */
1072
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1073
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1074
  false,  /* isTypedMethod.  Only relevant for methods. */
1075
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1076
};
1077
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1078
static_assert(0 < 1, "There is no slot for us");
1079
static const JSJitInfo alinkColor_setterinfo = {
1080
  { (JSJitGetterOp)set_alinkColor },
1081
  { prototypes::id::HTMLDocument },
1082
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1083
  JSJitInfo::Setter,
1084
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1085
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1086
  false,  /* isInfallible. False in setters. */
1087
  false,  /* isMovable.  Not relevant for setters. */
1088
  false, /* isEliminatable.  Not relevant for setters. */
1089
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1090
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1091
  false,  /* isTypedMethod.  Only relevant for methods. */
1092
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1093
};
1094
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1095
static_assert(0 < 1, "There is no slot for us");
1096
1097
MOZ_CAN_RUN_SCRIPT static bool
1098
get_bgColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
1099
0
{
1100
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.bgColor", DOM, cx);
1101
0
1102
0
  DOMString result;
1103
0
  self->GetBgColor(result);
1104
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1105
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1106
0
    return false;
1107
0
  }
1108
0
  return true;
1109
0
}
1110
1111
MOZ_CAN_RUN_SCRIPT static bool
1112
set_bgColor(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
1113
0
{
1114
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.bgColor", DOM, cx);
1115
0
1116
0
  binding_detail::FakeString arg0;
1117
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
1118
0
    return false;
1119
0
  }
1120
0
  Maybe<AutoCEReaction> ceReaction;
1121
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
1122
0
    DocGroup* docGroup = self->GetDocGroup();
1123
0
    if (docGroup) {
1124
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
1125
0
    }
1126
0
  }
1127
0
  self->SetBgColor(NonNullHelper(Constify(arg0)));
1128
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1129
0
1130
0
  return true;
1131
0
}
1132
1133
static const JSJitInfo bgColor_getterinfo = {
1134
  { (JSJitGetterOp)get_bgColor },
1135
  { prototypes::id::HTMLDocument },
1136
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1137
  JSJitInfo::Getter,
1138
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1139
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1140
  false,  /* isInfallible. False in setters. */
1141
  false,  /* isMovable.  Not relevant for setters. */
1142
  false, /* isEliminatable.  Not relevant for setters. */
1143
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1144
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1145
  false,  /* isTypedMethod.  Only relevant for methods. */
1146
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1147
};
1148
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1149
static_assert(0 < 1, "There is no slot for us");
1150
static const JSJitInfo bgColor_setterinfo = {
1151
  { (JSJitGetterOp)set_bgColor },
1152
  { prototypes::id::HTMLDocument },
1153
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1154
  JSJitInfo::Setter,
1155
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1156
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1157
  false,  /* isInfallible. False in setters. */
1158
  false,  /* isMovable.  Not relevant for setters. */
1159
  false, /* isEliminatable.  Not relevant for setters. */
1160
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1161
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1162
  false,  /* isTypedMethod.  Only relevant for methods. */
1163
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1164
};
1165
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1166
static_assert(0 < 1, "There is no slot for us");
1167
1168
MOZ_CAN_RUN_SCRIPT static bool
1169
clear(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
1170
0
{
1171
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.clear", DOM, cx);
1172
0
1173
0
  self->Clear();
1174
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1175
0
  args.rval().setUndefined();
1176
0
  return true;
1177
0
}
1178
1179
static const JSJitInfo clear_methodinfo = {
1180
  { (JSJitGetterOp)clear },
1181
  { prototypes::id::HTMLDocument },
1182
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1183
  JSJitInfo::Method,
1184
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1185
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1186
  true,  /* isInfallible. False in setters. */
1187
  false,  /* isMovable.  Not relevant for setters. */
1188
  false, /* isEliminatable.  Not relevant for setters. */
1189
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1190
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1191
  false,  /* isTypedMethod.  Only relevant for methods. */
1192
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1193
};
1194
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1195
static_assert(0 < 1, "There is no slot for us");
1196
1197
MOZ_CAN_RUN_SCRIPT static bool
1198
get_all(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
1199
0
{
1200
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.all", DOM, cx);
1201
0
1202
0
  auto result(StrongOrRawPtr<mozilla::dom::HTMLAllCollection>(self->All()));
1203
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1204
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1205
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1206
0
    return false;
1207
0
  }
1208
0
  return true;
1209
0
}
1210
1211
static const JSJitInfo all_getterinfo = {
1212
  { (JSJitGetterOp)get_all },
1213
  { prototypes::id::HTMLDocument },
1214
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1215
  JSJitInfo::Getter,
1216
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1217
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1218
  false,  /* isInfallible. False in setters. */
1219
  false,  /* isMovable.  Not relevant for setters. */
1220
  false, /* isEliminatable.  Not relevant for setters. */
1221
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1222
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1223
  false,  /* isTypedMethod.  Only relevant for methods. */
1224
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1225
};
1226
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1227
static_assert(0 < 1, "There is no slot for us");
1228
1229
MOZ_CAN_RUN_SCRIPT static bool
1230
captureEvents(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
1231
0
{
1232
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.captureEvents", DOM, cx);
1233
0
1234
0
  self->CaptureEvents();
1235
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1236
0
  args.rval().setUndefined();
1237
0
  return true;
1238
0
}
1239
1240
static const JSJitInfo captureEvents_methodinfo = {
1241
  { (JSJitGetterOp)captureEvents },
1242
  { prototypes::id::HTMLDocument },
1243
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1244
  JSJitInfo::Method,
1245
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1246
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1247
  true,  /* isInfallible. False in setters. */
1248
  false,  /* isMovable.  Not relevant for setters. */
1249
  false, /* isEliminatable.  Not relevant for setters. */
1250
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1251
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1252
  false,  /* isTypedMethod.  Only relevant for methods. */
1253
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1254
};
1255
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1256
static_assert(0 < 1, "There is no slot for us");
1257
1258
MOZ_CAN_RUN_SCRIPT static bool
1259
releaseEvents(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
1260
0
{
1261
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.releaseEvents", DOM, cx);
1262
0
1263
0
  self->ReleaseEvents();
1264
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1265
0
  args.rval().setUndefined();
1266
0
  return true;
1267
0
}
1268
1269
static const JSJitInfo releaseEvents_methodinfo = {
1270
  { (JSJitGetterOp)releaseEvents },
1271
  { prototypes::id::HTMLDocument },
1272
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1273
  JSJitInfo::Method,
1274
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1275
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1276
  true,  /* isInfallible. False in setters. */
1277
  false,  /* isMovable.  Not relevant for setters. */
1278
  false, /* isEliminatable.  Not relevant for setters. */
1279
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1280
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1281
  false,  /* isTypedMethod.  Only relevant for methods. */
1282
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1283
};
1284
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1285
static_assert(0 < 1, "There is no slot for us");
1286
1287
MOZ_CAN_RUN_SCRIPT static bool
1288
get_blockedTrackingNodeCount(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
1289
0
{
1290
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.blockedTrackingNodeCount", DOM, cx);
1291
0
1292
0
  int32_t result(self->BlockedTrackingNodeCount());
1293
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1294
0
  args.rval().setInt32(int32_t(result));
1295
0
  return true;
1296
0
}
1297
1298
static const JSJitInfo blockedTrackingNodeCount_getterinfo = {
1299
  { (JSJitGetterOp)get_blockedTrackingNodeCount },
1300
  { prototypes::id::HTMLDocument },
1301
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1302
  JSJitInfo::Getter,
1303
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1304
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
1305
  true,  /* isInfallible. False in setters. */
1306
  true,  /* isMovable.  Not relevant for setters. */
1307
  true, /* isEliminatable.  Not relevant for setters. */
1308
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1309
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1310
  false,  /* isTypedMethod.  Only relevant for methods. */
1311
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1312
};
1313
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1314
static_assert(0 < 1, "There is no slot for us");
1315
1316
MOZ_CAN_RUN_SCRIPT static bool
1317
get_blockedTrackingNodes(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
1318
0
{
1319
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.blockedTrackingNodes", DOM, cx);
1320
0
1321
0
  auto result(StrongOrRawPtr<nsINodeList>(self->BlockedTrackingNodes()));
1322
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1323
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1324
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1325
0
    return false;
1326
0
  }
1327
0
  return true;
1328
0
}
1329
1330
static const JSJitInfo blockedTrackingNodes_getterinfo = {
1331
  { (JSJitGetterOp)get_blockedTrackingNodes },
1332
  { prototypes::id::HTMLDocument },
1333
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1334
  JSJitInfo::Getter,
1335
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
1336
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1337
  false,  /* isInfallible. False in setters. */
1338
  true,  /* isMovable.  Not relevant for setters. */
1339
  true, /* isEliminatable.  Not relevant for setters. */
1340
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1341
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1342
  false,  /* isTypedMethod.  Only relevant for methods. */
1343
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1344
};
1345
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1346
static_assert(0 < 1, "There is no slot for us");
1347
1348
MOZ_CAN_RUN_SCRIPT static bool
1349
userInteractionForTesting(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, const JSJitMethodCallArgs& args)
1350
0
{
1351
0
  AUTO_PROFILER_LABEL_FAST("HTMLDocument.userInteractionForTesting", DOM, cx);
1352
0
1353
0
  self->UserInteractionForTesting();
1354
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1355
0
  args.rval().setUndefined();
1356
0
  return true;
1357
0
}
1358
1359
static const JSJitInfo userInteractionForTesting_methodinfo = {
1360
  { (JSJitGetterOp)userInteractionForTesting },
1361
  { prototypes::id::HTMLDocument },
1362
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1363
  JSJitInfo::Method,
1364
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1365
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1366
  true,  /* isInfallible. False in setters. */
1367
  false,  /* isMovable.  Not relevant for setters. */
1368
  false, /* isEliminatable.  Not relevant for setters. */
1369
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1370
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1371
  false,  /* isTypedMethod.  Only relevant for methods. */
1372
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1373
};
1374
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1375
static_assert(0 < 1, "There is no slot for us");
1376
1377
MOZ_CAN_RUN_SCRIPT static bool
1378
get_location(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitGetterCallArgs args)
1379
0
{
1380
0
  AUTO_PROFILER_LABEL_FAST("get HTMLDocument.location", DOM, cx);
1381
0
1382
0
  auto result(StrongOrRawPtr<mozilla::dom::Location>(self->GetLocation()));
1383
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1384
0
  if (!result) {
1385
0
    args.rval().setNull();
1386
0
    return true;
1387
0
  }
1388
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1389
0
    MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing");
1390
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1391
0
    return false;
1392
0
  }
1393
0
  return true;
1394
0
}
1395
1396
MOZ_CAN_RUN_SCRIPT static bool
1397
set_location(JSContext* cx, JS::Handle<JSObject*> obj, nsHTMLDocument* self, JSJitSetterCallArgs args)
1398
0
{
1399
0
  AUTO_PROFILER_LABEL_FAST("set HTMLDocument.location", DOM, cx);
1400
0
1401
0
  JS::Rooted<JS::Value> v(cx);
1402
0
  if (!JS_GetProperty(cx, obj, "location", &v)) {
1403
0
    return false;
1404
0
  }
1405
0
1406
0
  if (!v.isObject()) {
1407
0
    return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "HTMLDocument.location");
1408
0
  }
1409
0
1410
0
  JS::Rooted<JSObject*> targetObj(cx, &v.toObject());
1411
0
  return JS_SetProperty(cx, targetObj, "href", args[0]);
1412
0
}
1413
1414
static const JSJitInfo location_getterinfo = {
1415
  { (JSJitGetterOp)get_location },
1416
  { prototypes::id::HTMLDocument },
1417
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1418
  JSJitInfo::Getter,
1419
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1420
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1421
  false,  /* isInfallible. False in setters. */
1422
  false,  /* isMovable.  Not relevant for setters. */
1423
  false, /* isEliminatable.  Not relevant for setters. */
1424
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1425
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1426
  false,  /* isTypedMethod.  Only relevant for methods. */
1427
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1428
};
1429
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1430
static_assert(0 < 1, "There is no slot for us");
1431
static const JSJitInfo location_setterinfo = {
1432
  { (JSJitGetterOp)set_location },
1433
  { prototypes::id::HTMLDocument },
1434
  { PrototypeTraits<prototypes::id::HTMLDocument>::Depth },
1435
  JSJitInfo::Setter,
1436
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1437
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1438
  false,  /* isInfallible. False in setters. */
1439
  false,  /* isMovable.  Not relevant for setters. */
1440
  false, /* isEliminatable.  Not relevant for setters. */
1441
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1442
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1443
  false,  /* isTypedMethod.  Only relevant for methods. */
1444
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1445
};
1446
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1447
static_assert(0 < 1, "There is no slot for us");
1448
1449
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1450
#if defined(__clang__)
1451
#pragma clang diagnostic push
1452
#pragma clang diagnostic ignored "-Wmissing-braces"
1453
#endif
1454
static const JSFunctionSpec sMethods_specs[] = {
1455
  JS_FNSPEC("open", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&open_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1456
  JS_FNSPEC("close", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&close_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1457
  JS_FNSPEC("write", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&write_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1458
  JS_FNSPEC("writeln", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&writeln_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1459
  JS_FNSPEC("execCommand", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&execCommand_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1460
  JS_FNSPEC("queryCommandEnabled", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&queryCommandEnabled_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1461
  JS_FNSPEC("queryCommandIndeterm", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&queryCommandIndeterm_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1462
  JS_FNSPEC("queryCommandState", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&queryCommandState_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1463
  JS_FNSPEC("queryCommandSupported", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&queryCommandSupported_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1464
  JS_FNSPEC("queryCommandValue", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&queryCommandValue_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1465
  JS_FNSPEC("clear", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clear_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1466
  JS_FNSPEC("captureEvents", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&captureEvents_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1467
  JS_FNSPEC("releaseEvents", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&releaseEvents_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1468
  JS_FS_END
1469
};
1470
#if defined(__clang__)
1471
#pragma clang diagnostic pop
1472
#endif
1473
1474
1475
static const Prefable<const JSFunctionSpec> sMethods[] = {
1476
  { nullptr, &sMethods_specs[0] },
1477
  { nullptr, nullptr }
1478
};
1479
1480
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1481
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1482
static_assert(13 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1483
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1484
1485
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1486
#if defined(__clang__)
1487
#pragma clang diagnostic push
1488
#pragma clang diagnostic ignored "-Wmissing-braces"
1489
#endif
1490
static const JSFunctionSpec sChromeMethods_specs[] = {
1491
  JS_FNSPEC("userInteractionForTesting", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&userInteractionForTesting_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1492
  JS_FS_END
1493
};
1494
#if defined(__clang__)
1495
#pragma clang diagnostic pop
1496
#endif
1497
1498
1499
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
1500
  { nullptr, &sChromeMethods_specs[0] },
1501
  { nullptr, nullptr }
1502
};
1503
1504
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1505
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1506
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1507
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1508
1509
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1510
#if defined(__clang__)
1511
#pragma clang diagnostic push
1512
#pragma clang diagnostic ignored "-Wmissing-braces"
1513
#endif
1514
static const JSPropertySpec sAttributes_specs[] = {
1515
  { "domain", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &domain_getterinfo, GenericSetter<NormalThisPolicy>, &domain_setterinfo },
1516
  { "cookie", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cookie_getterinfo, GenericSetter<NormalThisPolicy>, &cookie_setterinfo },
1517
  { "designMode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &designMode_getterinfo, GenericSetter<NormalThisPolicy>, &designMode_setterinfo },
1518
  { "fgColor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fgColor_getterinfo, GenericSetter<NormalThisPolicy>, &fgColor_setterinfo },
1519
  { "linkColor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &linkColor_getterinfo, GenericSetter<NormalThisPolicy>, &linkColor_setterinfo },
1520
  { "vlinkColor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &vlinkColor_getterinfo, GenericSetter<NormalThisPolicy>, &vlinkColor_setterinfo },
1521
  { "alinkColor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &alinkColor_getterinfo, GenericSetter<NormalThisPolicy>, &alinkColor_setterinfo },
1522
  { "bgColor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &bgColor_getterinfo, GenericSetter<NormalThisPolicy>, &bgColor_setterinfo },
1523
  { "all", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &all_getterinfo, nullptr, nullptr },
1524
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1525
};
1526
#if defined(__clang__)
1527
#pragma clang diagnostic pop
1528
#endif
1529
1530
1531
static const Prefable<const JSPropertySpec> sAttributes[] = {
1532
  { nullptr, &sAttributes_specs[0] },
1533
  { nullptr, nullptr }
1534
};
1535
1536
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1537
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1538
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1539
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1540
1541
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1542
#if defined(__clang__)
1543
#pragma clang diagnostic push
1544
#pragma clang diagnostic ignored "-Wmissing-braces"
1545
#endif
1546
static const JSPropertySpec sChromeAttributes_specs[] = {
1547
  { "blockedTrackingNodeCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &blockedTrackingNodeCount_getterinfo, nullptr, nullptr },
1548
  { "blockedTrackingNodes", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &blockedTrackingNodes_getterinfo, nullptr, nullptr },
1549
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1550
};
1551
#if defined(__clang__)
1552
#pragma clang diagnostic pop
1553
#endif
1554
1555
1556
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
1557
  { nullptr, &sChromeAttributes_specs[0] },
1558
  { nullptr, nullptr }
1559
};
1560
1561
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1562
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1563
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1564
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1565
1566
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1567
#if defined(__clang__)
1568
#pragma clang diagnostic push
1569
#pragma clang diagnostic ignored "-Wmissing-braces"
1570
#endif
1571
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
1572
  { "location", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &location_getterinfo, GenericSetter<NormalThisPolicy>, &location_setterinfo },
1573
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1574
};
1575
#if defined(__clang__)
1576
#pragma clang diagnostic pop
1577
#endif
1578
1579
1580
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
1581
  { nullptr, &sUnforgeableAttributes_specs[0] },
1582
  { nullptr, nullptr }
1583
};
1584
1585
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1586
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1587
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1588
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1589
1590
1591
static uint16_t sNativeProperties_sortedPropertyIndices[23];
1592
static PropertyInfo sNativeProperties_propertyInfos[23];
1593
1594
static const NativePropertiesN<3> sNativeProperties = {
1595
  false, 0,
1596
  false, 0,
1597
  true,  0 /* sMethods */,
1598
  true,  1 /* sAttributes */,
1599
  false, 0,
1600
  true,  2 /* sUnforgeableAttributes */,
1601
  false, 0,
1602
  -1,
1603
  23,
1604
  sNativeProperties_sortedPropertyIndices,
1605
  {
1606
    { sMethods, &sNativeProperties_propertyInfos[0] },
1607
    { sAttributes, &sNativeProperties_propertyInfos[13] },
1608
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[22] }
1609
  }
1610
};
1611
static_assert(23 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1612
    "We have a property info count that is oversized");
1613
1614
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[3];
1615
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[3];
1616
1617
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
1618
  false, 0,
1619
  false, 0,
1620
  true,  0 /* sChromeMethods */,
1621
  true,  1 /* sChromeAttributes */,
1622
  false, 0,
1623
  false, 0,
1624
  false, 0,
1625
  -1,
1626
  3,
1627
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1628
  {
1629
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
1630
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[1] }
1631
  }
1632
};
1633
static_assert(3 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1634
    "We have a property info count that is oversized");
1635
1636
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1637
  {
1638
    "Function",
1639
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1640
    &sBoringInterfaceObjectClassClassOps,
1641
    JS_NULL_CLASS_SPEC,
1642
    JS_NULL_CLASS_EXT,
1643
    &sInterfaceObjectClassObjectOps
1644
  },
1645
  eInterface,
1646
  true,
1647
  prototypes::id::HTMLDocument,
1648
  PrototypeTraits<prototypes::id::HTMLDocument>::Depth,
1649
  sNativePropertyHooks,
1650
  "function HTMLDocument() {\n    [native code]\n}",
1651
  Document_Binding::GetConstructorObject
1652
};
1653
1654
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1655
  {
1656
    "HTMLDocumentPrototype",
1657
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
1658
    JS_NULL_CLASS_OPS,
1659
    JS_NULL_CLASS_SPEC,
1660
    JS_NULL_CLASS_EXT,
1661
    JS_NULL_OBJECT_OPS
1662
  },
1663
  eInterfacePrototype,
1664
  false,
1665
  prototypes::id::HTMLDocument,
1666
  PrototypeTraits<prototypes::id::HTMLDocument>::Depth,
1667
  sNativePropertyHooks,
1668
  "[object HTMLDocumentPrototype]",
1669
  Document_Binding::GetProtoObject
1670
};
1671
1672
static_assert(IsBaseOf<nsISupports, nsHTMLDocument >::value,
1673
                  "We don't support non-nsISupports native classes for "
1674
                  "proxy-based bindings yet");
1675
1676
1677
class DOMProxyHandler : public ShadowingDOMProxyHandler
1678
{
1679
public:
1680
  explicit constexpr DOMProxyHandler()
1681
0
  {
1682
0
  }
1683
1684
  virtual bool
1685
  getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
1686
1687
  virtual bool
1688
  defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
1689
1690
  using mozilla::dom::DOMProxyHandler::defineProperty;
1691
1692
  virtual bool
1693
  ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
1694
1695
  virtual bool
1696
  hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
1697
1698
  virtual bool
1699
  get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
1700
1701
  virtual const char*
1702
  className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
1703
1704
  virtual bool
1705
  finalizeInBackground(const JS::Value& priv) const override;
1706
1707
  virtual void
1708
  finalize(JSFreeOp* fop, JSObject* proxy) const override;
1709
1710
  static const DOMProxyHandler*
1711
  getInstance();
1712
1713
  virtual bool
1714
  delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
1715
1716
  virtual size_t
1717
  objectMoved(JSObject* obj, JSObject* old) const override;
1718
};
1719
1720
MOZ_ALWAYS_INLINE bool
1721
IsProxy(JSObject* obj)
1722
0
{
1723
0
  return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
1724
0
}
1725
1726
MOZ_ALWAYS_INLINE nsHTMLDocument*
1727
UnwrapProxy(JSObject* obj)
1728
0
{
1729
0
  MOZ_ASSERT(js::IsProxy(obj));
1730
0
  if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
1731
0
    MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
1732
0
    obj = js::UncheckedUnwrap(obj);
1733
0
  }
1734
0
  MOZ_ASSERT(IsProxy(obj));
1735
0
  return static_cast<nsHTMLDocument*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
1736
0
}
1737
1738
bool
1739
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
1740
0
{
1741
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
1742
0
  JS::Rooted<JSObject*> expando(cx);
1743
0
  if (!isXray && (expando = GetExpandoObject(proxy))) {
1744
0
    if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
1745
0
      return false;
1746
0
    }
1747
0
    if (desc.object()) {
1748
0
      // Pretend the property lives on the wrapper.
1749
0
      desc.object().set(proxy);
1750
0
      return true;
1751
0
    }
1752
0
  }
1753
0
1754
0
  bool callNamedGetter = false;
1755
0
  if (!ignoreNamedProps) {
1756
0
    if (!isXray) {
1757
0
      callNamedGetter = true;
1758
0
    } else {
1759
0
      bool hasOnProto;
1760
0
      if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
1761
0
        return false;
1762
0
      }
1763
0
      callNamedGetter = !hasOnProto;
1764
0
    }
1765
0
  }
1766
0
  if (callNamedGetter) {
1767
0
    FakeString name;
1768
0
    bool isSymbol;
1769
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
1770
0
      return false;
1771
0
    }
1772
0
    if (!isSymbol) {
1773
0
      nsHTMLDocument* self = UnwrapProxy(proxy);
1774
0
      bool found = false;
1775
0
      FastErrorResult rv;
1776
0
      JS::Rooted<JSObject*> result(cx);
1777
0
      self->NamedGetter(cx, NonNullHelper(Constify(name)), found, &result, rv);
1778
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1779
0
        return false;
1780
0
      }
1781
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
1782
0
1783
0
      if (found) {
1784
0
        JS::ExposeObjectToActiveJS(result);
1785
0
        desc.value().setObject(*result);
1786
0
        if (!MaybeWrapObjectValue(cx, desc.value())) {
1787
0
          return false;
1788
0
        }
1789
0
        FillPropertyDescriptor(desc, proxy, true, true);
1790
0
        return true;
1791
0
      }
1792
0
    }
1793
0
  }
1794
0
1795
0
  desc.object().set(nullptr);
1796
0
  return true;
1797
0
}
1798
1799
bool
1800
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
1801
0
{
1802
0
  bool found = false;
1803
0
  FakeString name;
1804
0
  bool isSymbol;
1805
0
  if (!ConvertIdToString(cx, id, name, isSymbol)) {
1806
0
    return false;
1807
0
  }
1808
0
  if (!isSymbol) {
1809
0
    nsHTMLDocument* self = UnwrapProxy(proxy);
1810
0
    FastErrorResult rv;
1811
0
    JS::Rooted<JSObject*> result(cx);
1812
0
    self->NamedGetter(cx, NonNullHelper(Constify(name)), found, &result, rv);
1813
0
    if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1814
0
      return false;
1815
0
    }
1816
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1817
0
    (void)result;
1818
0
  }
1819
0
1820
0
  if (found) {
1821
0
    *defined = true;
1822
0
    return opresult.failNoNamedSetter();
1823
0
  }
1824
0
  return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
1825
0
}
1826
1827
1828
bool
1829
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
1830
0
{
1831
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
1832
0
1833
0
  nsTArray<nsString> names;
1834
0
  UnwrapProxy(proxy)->GetSupportedNames(names);
1835
0
  if (!AppendNamedPropertyIds(cx, proxy, names, !isXray, props)) {
1836
0
    return false;
1837
0
  }
1838
0
1839
0
  JS::Rooted<JSObject*> expando(cx);
1840
0
  if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
1841
0
      !js::GetPropertyKeys(cx, expando, flags, &props)) {
1842
0
    return false;
1843
0
  }
1844
0
1845
0
  return true;
1846
0
}
1847
1848
bool
1849
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
1850
0
{
1851
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1852
0
            "Should not have a XrayWrapper here");
1853
0
1854
0
1855
0
  JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
1856
0
  if (expando) {
1857
0
    bool b = true;
1858
0
    bool ok = JS_HasPropertyById(cx, expando, id, &b);
1859
0
    *bp = !!b;
1860
0
    if (!ok || *bp) {
1861
0
      return ok;
1862
0
    }
1863
0
  }
1864
0
1865
0
  bool found = false;
1866
0
  FakeString name;
1867
0
  bool isSymbol;
1868
0
  if (!ConvertIdToString(cx, id, name, isSymbol)) {
1869
0
    return false;
1870
0
  }
1871
0
  if (!isSymbol) {
1872
0
    nsHTMLDocument* self = UnwrapProxy(proxy);
1873
0
    FastErrorResult rv;
1874
0
    JS::Rooted<JSObject*> result(cx);
1875
0
    self->NamedGetter(cx, NonNullHelper(Constify(name)), found, &result, rv);
1876
0
    if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1877
0
      return false;
1878
0
    }
1879
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1880
0
    (void)result;
1881
0
  }
1882
0
1883
0
  *bp = found;
1884
0
1885
0
  return true;
1886
0
}
1887
1888
bool
1889
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
1890
0
{
1891
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1892
0
              "Should not have a XrayWrapper here");
1893
0
1894
0
  { // Scope for expando
1895
0
    JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
1896
0
    if (expando) {
1897
0
      bool hasProp;
1898
0
      if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
1899
0
        return false;
1900
0
      }
1901
0
1902
0
      if (hasProp) {
1903
0
        // Forward the get to the expando object, but our receiver is whatever our
1904
0
        // receiver is.
1905
0
        return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
1906
0
      }
1907
0
    }
1908
0
  }
1909
0
1910
0
  FakeString name;
1911
0
  bool isSymbol;
1912
0
  if (!ConvertIdToString(cx, id, name, isSymbol)) {
1913
0
    return false;
1914
0
  }
1915
0
  if (!isSymbol) {
1916
0
    nsHTMLDocument* self = UnwrapProxy(proxy);
1917
0
    bool found = false;
1918
0
    FastErrorResult rv;
1919
0
    JS::Rooted<JSObject*> result(cx);
1920
0
    self->NamedGetter(cx, NonNullHelper(Constify(name)), found, &result, rv);
1921
0
    if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1922
0
      return false;
1923
0
    }
1924
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1925
0
1926
0
    if (found) {
1927
0
      JS::ExposeObjectToActiveJS(result);
1928
0
      vp.setObject(*result);
1929
0
      if (!MaybeWrapObjectValue(cx, vp)) {
1930
0
        return false;
1931
0
      }
1932
0
      return true;
1933
0
    }
1934
0
  }
1935
0
1936
0
  bool foundOnPrototype;
1937
0
  if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
1938
0
    return false;
1939
0
  }
1940
0
1941
0
  if (foundOnPrototype) {
1942
0
    return true;
1943
0
  }
1944
0
1945
0
  vp.setUndefined();
1946
0
  return true;
1947
0
}
1948
1949
const char*
1950
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
1951
0
{
1952
0
  return "HTMLDocument";
1953
0
}
1954
1955
bool
1956
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
1957
0
{
1958
0
  return false;
1959
0
}
1960
1961
void
1962
DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
1963
0
{
1964
0
  nsHTMLDocument* self = UnwrapPossiblyNotInitializedDOMObject<nsHTMLDocument>(proxy);
1965
0
  if (self) {
1966
0
    // Either our proxy created an expando object or not.  If it did,
1967
0
    // then we would have preserved ourselves, and hence if we're going
1968
0
    // away so is our C++ object and we should reset its expando value.
1969
0
    // It's possible that in this situation the C++ object's reflector
1970
0
    // pointer has been nulled out, but if not it's pointing to us.  If
1971
0
    // our proxy did _not_ create an expando object then it's possible
1972
0
    // that we're no longer the reflector for our C++ object (and
1973
0
    // incremental finalization is finally getting to us), and that in
1974
0
    // the meantime the new reflector has created an expando object.
1975
0
    // In that case we do NOT want to clear the expando pointer in the
1976
0
    // C++ object.
1977
0
    //
1978
0
    // It's important to do this before we ClearWrapper, of course.
1979
0
    JSObject* reflector = self->GetWrapperMaybeDead();
1980
0
    if (!reflector || reflector == proxy) {
1981
0
      self->mExpandoAndGeneration.expando = JS::UndefinedValue();
1982
0
    }
1983
0
    ClearWrapper(self, self, proxy);
1984
0
    AddForDeferredFinalization<nsHTMLDocument>(self);
1985
0
  }
1986
0
}
1987
1988
const DOMProxyHandler*
1989
DOMProxyHandler::getInstance()
1990
0
{
1991
0
  static const DOMProxyHandler instance;
1992
0
  return &instance;
1993
0
}
1994
1995
bool
1996
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
1997
0
{
1998
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1999
0
            "Should not have a XrayWrapper here");
2000
0
2001
0
  // Try named delete only if the named property visibility
2002
0
  // algorithm says the property is visible.
2003
0
  bool tryNamedDelete = true;
2004
0
  { // Scope for expando
2005
0
    JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
2006
0
    if (expando) {
2007
0
      bool hasProp;
2008
0
      if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
2009
0
        return false;
2010
0
      }
2011
0
      tryNamedDelete = !hasProp;
2012
0
    }
2013
0
  }
2014
0
  if (tryNamedDelete) {
2015
0
    bool found = false;
2016
0
    bool deleteSucceeded;
2017
0
    FakeString name;
2018
0
    bool isSymbol;
2019
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
2020
0
      return false;
2021
0
    }
2022
0
    if (!isSymbol) {
2023
0
      nsHTMLDocument* self = UnwrapProxy(proxy);
2024
0
      FastErrorResult rv;
2025
0
      JS::Rooted<JSObject*> result(cx);
2026
0
      self->NamedGetter(cx, NonNullHelper(Constify(name)), found, &result, rv);
2027
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2028
0
        return false;
2029
0
      }
2030
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2031
0
      (void)result;
2032
0
    }
2033
0
    deleteSucceeded = !found;
2034
0
    if (found) {
2035
0
      return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
2036
0
    }
2037
0
  }
2038
0
2039
0
  return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
2040
0
}
2041
2042
size_t
2043
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
2044
0
{
2045
0
  nsHTMLDocument* self = UnwrapPossiblyNotInitializedDOMObject<nsHTMLDocument>(obj);
2046
0
  if (self) {
2047
0
    UpdateWrapper(self, self, obj, old);
2048
0
  }
2049
0
2050
0
  return 0;
2051
0
}
2052
2053
static const DOMJSClass sClass = {
2054
  PROXY_CLASS_DEF("HTMLDocument",
2055
                  JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
2056
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Document, prototypes::id::HTMLDocument, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
2057
  IsBaseOf<nsISupports, nsHTMLDocument >::value,
2058
  sNativePropertyHooks,
2059
  FindAssociatedGlobalForNative<nsHTMLDocument>::Get,
2060
  GetProtoObjectHandle,
2061
  GetCCParticipant<nsHTMLDocument>::Get()
2062
};
2063
2064
bool
2065
Wrap(JSContext* aCx, nsHTMLDocument* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2066
0
{
2067
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, nsHTMLDocument>::value,
2068
0
                "Shouldn't have wrappercached things that are not refcounted.");
2069
0
  MOZ_ASSERT(static_cast<nsHTMLDocument*>(aObject) ==
2070
0
             reinterpret_cast<nsHTMLDocument*>(aObject),
2071
0
             "Multiple inheritance for nsHTMLDocument is broken.");
2072
0
  MOZ_ASSERT(static_cast<nsIDocument*>(aObject) ==
2073
0
             reinterpret_cast<nsIDocument*>(aObject),
2074
0
             "Multiple inheritance for nsIDocument is broken.");
2075
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
2076
0
             reinterpret_cast<nsINode*>(aObject),
2077
0
             "Multiple inheritance for nsINode is broken.");
2078
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
2079
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
2080
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
2081
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2082
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2083
0
  MOZ_ASSERT(!aCache->GetWrapper(),
2084
0
             "You should probably not be using Wrap() directly; use "
2085
0
             "GetOrCreateDOMReflector instead");
2086
0
2087
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2088
0
             "nsISupports must be on our primary inheritance chain");
2089
0
2090
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2091
0
  if (!global) {
2092
0
    return false;
2093
0
  }
2094
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
2095
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
2096
0
2097
0
  // That might have ended up wrapping us already, due to the wonders
2098
0
  // of XBL.  Check for that, and bail out as needed.
2099
0
  aReflector.set(aCache->GetWrapper());
2100
0
  if (aReflector) {
2101
#ifdef DEBUG
2102
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2103
#endif // DEBUG
2104
    return true;
2105
0
  }
2106
0
2107
0
  JSAutoRealm ar(aCx, global);
2108
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2109
0
  if (!canonicalProto) {
2110
0
    return false;
2111
0
  }
2112
0
  JS::Rooted<JSObject*> proto(aCx);
2113
0
  if (aGivenProto) {
2114
0
    proto = aGivenProto;
2115
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2116
0
    // coming in, we changed compartments to that of "parent" so may need
2117
0
    // to wrap the proto here.
2118
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2119
0
      if (!JS_WrapObject(aCx, &proto)) {
2120
0
        return false;
2121
0
      }
2122
0
    }
2123
0
  } else {
2124
0
    proto = canonicalProto;
2125
0
  }
2126
0
2127
0
  BindingJSObjectCreator<nsHTMLDocument> creator(aCx);
2128
0
  aObject->mExpandoAndGeneration.expando.setUndefined();
2129
0
  JS::Rooted<JS::Value> expandoValue(aCx, JS::PrivateValue(&aObject->mExpandoAndGeneration));
2130
0
  creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
2131
0
                            proto, aObject, expandoValue, aReflector);
2132
0
  if (!aReflector) {
2133
0
    return false;
2134
0
  }
2135
0
2136
0
  aCache->SetWrapper(aReflector);
2137
0
2138
0
  // Important: do unforgeable property setup after we have handed
2139
0
  // over ownership of the C++ object to obj as needed, so that if
2140
0
  // we fail and it ends up GCed it won't have problems in the
2141
0
  // finalizer trying to drop its ownership of the C++ object.
2142
0
  JS::Rooted<JSObject*> expando(aCx,
2143
0
    DOMProxyHandler::EnsureExpandoObject(aCx, aReflector));
2144
0
  if (!expando) {
2145
0
    aCache->ReleaseWrapper(aObject);
2146
0
    aCache->ClearWrapper();
2147
0
    return false;
2148
0
  }
2149
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
2150
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
2151
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, expando, unforgeableHolder)) {
2152
0
    aCache->ReleaseWrapper(aObject);
2153
0
    aCache->ClearWrapper();
2154
0
    return false;
2155
0
  }
2156
0
  creator.InitializationSucceeded();
2157
0
2158
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2159
0
             aCache->GetWrapperPreserveColor() == aReflector);
2160
0
  // If proto != canonicalProto, we have to preserve our wrapper;
2161
0
  // otherwise we won't be able to properly recreate it later, since
2162
0
  // we won't know what proto to use.  Note that we don't check
2163
0
  // aGivenProto here, since it's entirely possible (and even
2164
0
  // somewhat common) to have a non-null aGivenProto which is the
2165
0
  // same as canonicalProto.
2166
0
  if (proto != canonicalProto) {
2167
0
    PreserveWrapper(aObject);
2168
0
  }
2169
0
2170
0
  return true;
2171
0
}
2172
2173
static bool
2174
ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
2175
0
{
2176
0
  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
2177
0
}
2178
2179
static bool
2180
EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
2181
0
{
2182
0
  return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
2183
0
}
2184
2185
const NativePropertyHooks sNativePropertyHooks[] = { {
2186
  ResolveOwnProperty,
2187
  EnumerateOwnProperties,
2188
  nullptr,
2189
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
2190
  prototypes::id::HTMLDocument,
2191
  constructors::id::HTMLDocument,
2192
  Document_Binding::sNativePropertyHooks,
2193
  &DefaultXrayExpandoObjectClass
2194
} };
2195
2196
void
2197
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2198
0
{
2199
0
  JS::Handle<JSObject*> parentProto(Document_Binding::GetProtoObjectHandle(aCx));
2200
0
  if (!parentProto) {
2201
0
    return;
2202
0
  }
2203
0
2204
0
  JS::Handle<JSObject*> constructorProto(Document_Binding::GetConstructorObjectHandle(aCx));
2205
0
  if (!constructorProto) {
2206
0
    return;
2207
0
  }
2208
0
2209
0
  static bool sIdsInited = false;
2210
0
  if (!sIdsInited && NS_IsMainThread()) {
2211
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
2212
0
      return;
2213
0
    }
2214
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
2215
0
      return;
2216
0
    }
2217
0
    sIdsInited = true;
2218
0
  }
2219
0
2220
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLDocument);
2221
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLDocument);
2222
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2223
0
                              &sPrototypeClass.mBase, protoCache,
2224
0
                              nullptr,
2225
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2226
0
                              interfaceCache,
2227
0
                              sNativeProperties.Upcast(),
2228
0
                              sChromeOnlyNativeProperties.Upcast(),
2229
0
                              "HTMLDocument", aDefineOnGlobal,
2230
0
                              nullptr,
2231
0
                              false);
2232
0
2233
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
2234
0
  {
2235
0
    JS::Rooted<JSObject*> holderProto(aCx, nullptr);
2236
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, nullptr, holderProto);
2237
0
    if (!unforgeableHolder) {
2238
0
      *protoCache = nullptr;
2239
0
      if (interfaceCache) {
2240
0
        *interfaceCache = nullptr;
2241
0
      }
2242
0
      return;
2243
0
    }
2244
0
  }
2245
0
2246
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
2247
0
    *protoCache = nullptr;
2248
0
    if (interfaceCache) {
2249
0
      *interfaceCache = nullptr;
2250
0
    }
2251
0
    return;
2252
0
  }
2253
0
2254
0
  if (*protoCache) {
2255
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
2256
0
                        JS::ObjectValue(*unforgeableHolder));
2257
0
  }
2258
0
}
2259
2260
JSObject*
2261
GetProtoObject(JSContext* aCx)
2262
0
{
2263
0
  return GetProtoObjectHandle(aCx);
2264
0
}
2265
2266
JSObject*
2267
GetConstructorObject(JSContext* aCx)
2268
0
{
2269
0
  return GetConstructorObjectHandle(aCx);
2270
0
}
2271
2272
} // namespace HTMLDocument_Binding
2273
2274
2275
2276
} // namespace dom
2277
} // namespace mozilla