Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLMapElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLMapElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLMapElementBinding.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/HTMLMapElement.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/XrayExpandoClass.h"
14
#include "nsContentList.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 HTMLMapElement_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_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMapElement* self, JSJitGetterCallArgs args)
30
0
{
31
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMapElement.name", DOM, cx);
32
0
33
0
  DOMString result;
34
0
  self->GetName(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_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMapElement* self, JSJitSetterCallArgs args)
44
0
{
45
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMapElement.name", 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
  self->SetName(NonNullHelper(Constify(arg0)), rv);
60
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
61
0
    return false;
62
0
  }
63
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
64
0
65
0
  return true;
66
0
}
67
68
static const JSJitInfo name_getterinfo = {
69
  { (JSJitGetterOp)get_name },
70
  { prototypes::id::HTMLMapElement },
71
  { PrototypeTraits<prototypes::id::HTMLMapElement>::Depth },
72
  JSJitInfo::Getter,
73
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
74
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
75
  false,  /* isInfallible. False in setters. */
76
  true,  /* isMovable.  Not relevant for setters. */
77
  true, /* isEliminatable.  Not relevant for setters. */
78
  false, /* isAlwaysInSlot.  Only relevant for getters. */
79
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
80
  false,  /* isTypedMethod.  Only relevant for methods. */
81
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
82
};
83
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
84
static_assert(0 < 1, "There is no slot for us");
85
static const JSJitInfo name_setterinfo = {
86
  { (JSJitGetterOp)set_name },
87
  { prototypes::id::HTMLMapElement },
88
  { PrototypeTraits<prototypes::id::HTMLMapElement>::Depth },
89
  JSJitInfo::Setter,
90
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
91
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
92
  false,  /* isInfallible. False in setters. */
93
  false,  /* isMovable.  Not relevant for setters. */
94
  false, /* isEliminatable.  Not relevant for setters. */
95
  false, /* isAlwaysInSlot.  Only relevant for getters. */
96
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
97
  false,  /* isTypedMethod.  Only relevant for methods. */
98
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
99
};
100
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
101
static_assert(0 < 1, "There is no slot for us");
102
103
MOZ_CAN_RUN_SCRIPT static bool
104
get_areas(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMapElement* self, JSJitGetterCallArgs args)
105
0
{
106
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMapElement.areas", DOM, cx);
107
0
108
0
  auto result(StrongOrRawPtr<nsIHTMLCollection>(self->Areas()));
109
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
110
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
111
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
112
0
    return false;
113
0
  }
114
0
  return true;
115
0
}
116
117
static const JSJitInfo areas_getterinfo = {
118
  { (JSJitGetterOp)get_areas },
119
  { prototypes::id::HTMLMapElement },
120
  { PrototypeTraits<prototypes::id::HTMLMapElement>::Depth },
121
  JSJitInfo::Getter,
122
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
123
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
124
  false,  /* isInfallible. False in setters. */
125
  true,  /* isMovable.  Not relevant for setters. */
126
  true, /* isEliminatable.  Not relevant for setters. */
127
  false, /* isAlwaysInSlot.  Only relevant for getters. */
128
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
129
  false,  /* isTypedMethod.  Only relevant for methods. */
130
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
131
};
132
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
133
static_assert(0 < 1, "There is no slot for us");
134
135
static bool
136
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
137
0
{
138
0
  mozilla::dom::HTMLMapElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLMapElement>(obj);
139
0
  // We don't want to preserve if we don't have a wrapper, and we
140
0
  // obviously can't preserve if we're not initialized.
141
0
  if (self && self->GetWrapperPreserveColor()) {
142
0
    PreserveWrapper(self);
143
0
  }
144
0
  return true;
145
0
}
146
147
static void
148
_finalize(js::FreeOp* fop, JSObject* obj)
149
0
{
150
0
  mozilla::dom::HTMLMapElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLMapElement>(obj);
151
0
  if (self) {
152
0
    ClearWrapper(self, self, obj);
153
0
    AddForDeferredFinalization<mozilla::dom::HTMLMapElement>(self);
154
0
  }
155
0
}
156
157
static size_t
158
_objectMoved(JSObject* obj, JSObject* old)
159
0
{
160
0
  mozilla::dom::HTMLMapElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLMapElement>(obj);
161
0
  if (self) {
162
0
    UpdateWrapper(self, self, obj, old);
163
0
  }
164
0
165
0
  return 0;
166
0
}
167
168
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
169
#if defined(__clang__)
170
#pragma clang diagnostic push
171
#pragma clang diagnostic ignored "-Wmissing-braces"
172
#endif
173
static const JSPropertySpec sAttributes_specs[] = {
174
  { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, GenericSetter<NormalThisPolicy>, &name_setterinfo },
175
  { "areas", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &areas_getterinfo, nullptr, nullptr },
176
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
177
};
178
#if defined(__clang__)
179
#pragma clang diagnostic pop
180
#endif
181
182
183
static const Prefable<const JSPropertySpec> sAttributes[] = {
184
  { nullptr, &sAttributes_specs[0] },
185
  { nullptr, nullptr }
186
};
187
188
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
189
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
190
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
191
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
192
193
194
static uint16_t sNativeProperties_sortedPropertyIndices[2];
195
static PropertyInfo sNativeProperties_propertyInfos[2];
196
197
static const NativePropertiesN<1> sNativeProperties = {
198
  false, 0,
199
  false, 0,
200
  false, 0,
201
  true,  0 /* sAttributes */,
202
  false, 0,
203
  false, 0,
204
  false, 0,
205
  -1,
206
  2,
207
  sNativeProperties_sortedPropertyIndices,
208
  {
209
    { sAttributes, &sNativeProperties_propertyInfos[0] }
210
  }
211
};
212
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
213
    "We have a property info count that is oversized");
214
215
static bool
216
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
217
0
{
218
0
  AUTO_PROFILER_LABEL_FAST("HTMLMapElement constructor", DOM, cx);
219
0
220
0
  return HTMLConstructor(cx, argc, vp,
221
0
                         constructors::id::HTMLMapElement,
222
0
                         prototypes::id::HTMLMapElement,
223
0
                         CreateInterfaceObjects);
224
0
}
225
226
static const js::ClassOps sInterfaceObjectClassOps = {
227
    nullptr,               /* addProperty */
228
    nullptr,               /* delProperty */
229
    nullptr,               /* enumerate */
230
    nullptr,               /* newEnumerate */
231
    nullptr,               /* resolve */
232
    nullptr,               /* mayResolve */
233
    nullptr,               /* finalize */
234
    _constructor, /* call */
235
    nullptr,               /* hasInstance */
236
    _constructor, /* construct */
237
    nullptr,               /* trace */
238
};
239
240
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
241
  {
242
    "Function",
243
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
244
    &sInterfaceObjectClassOps,
245
    JS_NULL_CLASS_SPEC,
246
    JS_NULL_CLASS_EXT,
247
    &sInterfaceObjectClassObjectOps
248
  },
249
  eInterface,
250
  true,
251
  prototypes::id::HTMLMapElement,
252
  PrototypeTraits<prototypes::id::HTMLMapElement>::Depth,
253
  sNativePropertyHooks,
254
  "function HTMLMapElement() {\n    [native code]\n}",
255
  HTMLElement_Binding::GetConstructorObject
256
};
257
258
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
259
  {
260
    "HTMLMapElementPrototype",
261
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
262
    JS_NULL_CLASS_OPS,
263
    JS_NULL_CLASS_SPEC,
264
    JS_NULL_CLASS_EXT,
265
    JS_NULL_OBJECT_OPS
266
  },
267
  eInterfacePrototype,
268
  false,
269
  prototypes::id::HTMLMapElement,
270
  PrototypeTraits<prototypes::id::HTMLMapElement>::Depth,
271
  sNativePropertyHooks,
272
  "[object HTMLMapElementPrototype]",
273
  HTMLElement_Binding::GetProtoObject
274
};
275
276
static const js::ClassOps sClassOps = {
277
  _addProperty, /* addProperty */
278
  nullptr,               /* delProperty */
279
  nullptr,               /* enumerate */
280
  nullptr, /* newEnumerate */
281
  nullptr, /* resolve */
282
  nullptr, /* mayResolve */
283
  _finalize, /* finalize */
284
  nullptr, /* call */
285
  nullptr,               /* hasInstance */
286
  nullptr,               /* construct */
287
  nullptr, /* trace */
288
};
289
290
static const js::ClassExtension sClassExtension = {
291
  nullptr, /* weakmapKeyDelegateOp */
292
  _objectMoved /* objectMovedOp */
293
};
294
295
static const DOMJSClass sClass = {
296
  { "HTMLMapElement",
297
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
298
    &sClassOps,
299
    JS_NULL_CLASS_SPEC,
300
    &sClassExtension,
301
    JS_NULL_OBJECT_OPS
302
  },
303
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLMapElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
304
  IsBaseOf<nsISupports, mozilla::dom::HTMLMapElement >::value,
305
  sNativePropertyHooks,
306
  FindAssociatedGlobalForNative<mozilla::dom::HTMLMapElement>::Get,
307
  GetProtoObjectHandle,
308
  GetCCParticipant<mozilla::dom::HTMLMapElement>::Get()
309
};
310
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
311
              "Must have the right minimal number of reserved slots.");
312
static_assert(1 >= 1,
313
              "Must have enough reserved slots.");
314
315
const JSClass*
316
GetJSClass()
317
0
{
318
0
  return sClass.ToJSClass();
319
0
}
320
321
bool
322
Wrap(JSContext* aCx, mozilla::dom::HTMLMapElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
323
0
{
324
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLMapElement>::value,
325
0
                "Shouldn't have wrappercached things that are not refcounted.");
326
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLMapElement*>(aObject) ==
327
0
             reinterpret_cast<mozilla::dom::HTMLMapElement*>(aObject),
328
0
             "Multiple inheritance for mozilla::dom::HTMLMapElement is broken.");
329
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
330
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
331
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
332
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
333
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
334
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
335
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
336
0
             reinterpret_cast<nsINode*>(aObject),
337
0
             "Multiple inheritance for nsINode is broken.");
338
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
339
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
340
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
341
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
342
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
343
0
  MOZ_ASSERT(!aCache->GetWrapper(),
344
0
             "You should probably not be using Wrap() directly; use "
345
0
             "GetOrCreateDOMReflector instead");
346
0
347
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
348
0
             "nsISupports must be on our primary inheritance chain");
349
0
350
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
351
0
  if (!global) {
352
0
    return false;
353
0
  }
354
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
355
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
356
0
357
0
  // That might have ended up wrapping us already, due to the wonders
358
0
  // of XBL.  Check for that, and bail out as needed.
359
0
  aReflector.set(aCache->GetWrapper());
360
0
  if (aReflector) {
361
#ifdef DEBUG
362
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
363
#endif // DEBUG
364
    return true;
365
0
  }
366
0
367
0
  JSAutoRealm ar(aCx, global);
368
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
369
0
  if (!canonicalProto) {
370
0
    return false;
371
0
  }
372
0
  JS::Rooted<JSObject*> proto(aCx);
373
0
  if (aGivenProto) {
374
0
    proto = aGivenProto;
375
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
376
0
    // coming in, we changed compartments to that of "parent" so may need
377
0
    // to wrap the proto here.
378
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
379
0
      if (!JS_WrapObject(aCx, &proto)) {
380
0
        return false;
381
0
      }
382
0
    }
383
0
  } else {
384
0
    proto = canonicalProto;
385
0
  }
386
0
387
0
  BindingJSObjectCreator<mozilla::dom::HTMLMapElement> creator(aCx);
388
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
389
0
  if (!aReflector) {
390
0
    return false;
391
0
  }
392
0
393
0
  aCache->SetWrapper(aReflector);
394
0
  creator.InitializationSucceeded();
395
0
396
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
397
0
             aCache->GetWrapperPreserveColor() == aReflector);
398
0
  // If proto != canonicalProto, we have to preserve our wrapper;
399
0
  // otherwise we won't be able to properly recreate it later, since
400
0
  // we won't know what proto to use.  Note that we don't check
401
0
  // aGivenProto here, since it's entirely possible (and even
402
0
  // somewhat common) to have a non-null aGivenProto which is the
403
0
  // same as canonicalProto.
404
0
  if (proto != canonicalProto) {
405
0
    PreserveWrapper(aObject);
406
0
  }
407
0
408
0
  return true;
409
0
}
410
411
const NativePropertyHooks sNativePropertyHooks[] = { {
412
  nullptr,
413
  nullptr,
414
  nullptr,
415
  { sNativeProperties.Upcast(), nullptr },
416
  prototypes::id::HTMLMapElement,
417
  constructors::id::HTMLMapElement,
418
  HTMLElement_Binding::sNativePropertyHooks,
419
  &DefaultXrayExpandoObjectClass
420
} };
421
422
void
423
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
424
0
{
425
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
426
0
  if (!parentProto) {
427
0
    return;
428
0
  }
429
0
430
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
431
0
  if (!constructorProto) {
432
0
    return;
433
0
  }
434
0
435
0
  static bool sIdsInited = false;
436
0
  if (!sIdsInited && NS_IsMainThread()) {
437
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
438
0
      return;
439
0
    }
440
0
    sIdsInited = true;
441
0
  }
442
0
443
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLMapElement);
444
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLMapElement);
445
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
446
0
                              &sPrototypeClass.mBase, protoCache,
447
0
                              nullptr,
448
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
449
0
                              interfaceCache,
450
0
                              sNativeProperties.Upcast(),
451
0
                              nullptr,
452
0
                              "HTMLMapElement", aDefineOnGlobal,
453
0
                              nullptr,
454
0
                              false);
455
0
}
456
457
JSObject*
458
GetConstructorObject(JSContext* aCx)
459
0
{
460
0
  return GetConstructorObjectHandle(aCx);
461
0
}
462
463
} // namespace HTMLMapElement_Binding
464
465
466
467
} // namespace dom
468
} // namespace mozilla