Coverage Report

Created: 2018-09-25 14:53

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