Coverage Report

Created: 2018-09-25 14:53

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