Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLMenuItemElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLMenuItemElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLMenuItemElementBinding.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/HTMLMenuItemElement.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/PrimitiveConversions.h"
14
#include "mozilla/dom/XrayExpandoClass.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 HTMLMenuItemElement_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_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
30
0
{
31
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.type", DOM, cx);
32
0
33
0
  DOMString result;
34
0
  self->GetType(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_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
44
0
{
45
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.type", 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->SetType(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 type_getterinfo = {
69
  { (JSJitGetterOp)get_type },
70
  { prototypes::id::HTMLMenuItemElement },
71
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
72
  JSJitInfo::Getter,
73
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
74
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
75
  false,  /* isInfallible. False in setters. */
76
  false,  /* isMovable.  Not relevant for setters. */
77
  false, /* 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 type_setterinfo = {
86
  { (JSJitGetterOp)set_type },
87
  { prototypes::id::HTMLMenuItemElement },
88
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::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_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
105
0
{
106
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.label", DOM, cx);
107
0
108
0
  DOMString result;
109
0
  self->GetLabel(result);
110
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
111
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
112
0
    return false;
113
0
  }
114
0
  return true;
115
0
}
116
117
MOZ_CAN_RUN_SCRIPT static bool
118
set_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
119
0
{
120
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.label", DOM, cx);
121
0
122
0
  binding_detail::FakeString arg0;
123
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
124
0
    return false;
125
0
  }
126
0
  Maybe<AutoCEReaction> ceReaction;
127
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
128
0
    DocGroup* docGroup = self->GetDocGroup();
129
0
    if (docGroup) {
130
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
131
0
    }
132
0
  }
133
0
  FastErrorResult rv;
134
0
  self->SetLabel(NonNullHelper(Constify(arg0)), rv);
135
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
136
0
    return false;
137
0
  }
138
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
139
0
140
0
  return true;
141
0
}
142
143
static const JSJitInfo label_getterinfo = {
144
  { (JSJitGetterOp)get_label },
145
  { prototypes::id::HTMLMenuItemElement },
146
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
147
  JSJitInfo::Getter,
148
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
149
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
150
  false,  /* isInfallible. False in setters. */
151
  false,  /* isMovable.  Not relevant for setters. */
152
  false, /* isEliminatable.  Not relevant for setters. */
153
  false, /* isAlwaysInSlot.  Only relevant for getters. */
154
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
155
  false,  /* isTypedMethod.  Only relevant for methods. */
156
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
157
};
158
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
159
static_assert(0 < 1, "There is no slot for us");
160
static const JSJitInfo label_setterinfo = {
161
  { (JSJitGetterOp)set_label },
162
  { prototypes::id::HTMLMenuItemElement },
163
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
164
  JSJitInfo::Setter,
165
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
166
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
167
  false,  /* isInfallible. False in setters. */
168
  false,  /* isMovable.  Not relevant for setters. */
169
  false, /* isEliminatable.  Not relevant for setters. */
170
  false, /* isAlwaysInSlot.  Only relevant for getters. */
171
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
172
  false,  /* isTypedMethod.  Only relevant for methods. */
173
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
174
};
175
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
176
static_assert(0 < 1, "There is no slot for us");
177
178
MOZ_CAN_RUN_SCRIPT static bool
179
get_icon(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
180
0
{
181
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.icon", DOM, cx);
182
0
183
0
  DOMString result;
184
0
  self->GetIcon(result);
185
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
186
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
187
0
    return false;
188
0
  }
189
0
  return true;
190
0
}
191
192
MOZ_CAN_RUN_SCRIPT static bool
193
set_icon(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
194
0
{
195
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.icon", DOM, cx);
196
0
197
0
  binding_detail::FakeString arg0;
198
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
199
0
    return false;
200
0
  }
201
0
  Maybe<AutoCEReaction> ceReaction;
202
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
203
0
    DocGroup* docGroup = self->GetDocGroup();
204
0
    if (docGroup) {
205
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
206
0
    }
207
0
  }
208
0
  FastErrorResult rv;
209
0
  self->SetIcon(NonNullHelper(Constify(arg0)), rv);
210
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
211
0
    return false;
212
0
  }
213
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
214
0
215
0
  return true;
216
0
}
217
218
static const JSJitInfo icon_getterinfo = {
219
  { (JSJitGetterOp)get_icon },
220
  { prototypes::id::HTMLMenuItemElement },
221
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
222
  JSJitInfo::Getter,
223
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
224
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
225
  false,  /* isInfallible. False in setters. */
226
  false,  /* isMovable.  Not relevant for setters. */
227
  false, /* isEliminatable.  Not relevant for setters. */
228
  false, /* isAlwaysInSlot.  Only relevant for getters. */
229
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
230
  false,  /* isTypedMethod.  Only relevant for methods. */
231
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
232
};
233
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
234
static_assert(0 < 1, "There is no slot for us");
235
static const JSJitInfo icon_setterinfo = {
236
  { (JSJitGetterOp)set_icon },
237
  { prototypes::id::HTMLMenuItemElement },
238
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
239
  JSJitInfo::Setter,
240
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
241
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
242
  false,  /* isInfallible. False in setters. */
243
  false,  /* isMovable.  Not relevant for setters. */
244
  false, /* isEliminatable.  Not relevant for setters. */
245
  false, /* isAlwaysInSlot.  Only relevant for getters. */
246
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
247
  false,  /* isTypedMethod.  Only relevant for methods. */
248
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
249
};
250
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
251
static_assert(0 < 1, "There is no slot for us");
252
253
MOZ_CAN_RUN_SCRIPT static bool
254
get_disabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
255
0
{
256
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.disabled", DOM, cx);
257
0
258
0
  bool result(self->Disabled());
259
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
260
0
  args.rval().setBoolean(result);
261
0
  return true;
262
0
}
263
264
MOZ_CAN_RUN_SCRIPT static bool
265
set_disabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
266
0
{
267
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.disabled", DOM, cx);
268
0
269
0
  bool arg0;
270
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
271
0
    return false;
272
0
  }
273
0
  Maybe<AutoCEReaction> ceReaction;
274
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
275
0
    DocGroup* docGroup = self->GetDocGroup();
276
0
    if (docGroup) {
277
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
278
0
    }
279
0
  }
280
0
  FastErrorResult rv;
281
0
  self->SetDisabled(arg0, rv);
282
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
283
0
    return false;
284
0
  }
285
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
286
0
287
0
  return true;
288
0
}
289
290
static const JSJitInfo disabled_getterinfo = {
291
  { (JSJitGetterOp)get_disabled },
292
  { prototypes::id::HTMLMenuItemElement },
293
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
294
  JSJitInfo::Getter,
295
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
296
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
297
  true,  /* isInfallible. False in setters. */
298
  false,  /* isMovable.  Not relevant for setters. */
299
  false, /* isEliminatable.  Not relevant for setters. */
300
  false, /* isAlwaysInSlot.  Only relevant for getters. */
301
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
302
  false,  /* isTypedMethod.  Only relevant for methods. */
303
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
304
};
305
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
306
static_assert(0 < 1, "There is no slot for us");
307
static const JSJitInfo disabled_setterinfo = {
308
  { (JSJitGetterOp)set_disabled },
309
  { prototypes::id::HTMLMenuItemElement },
310
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
311
  JSJitInfo::Setter,
312
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
313
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
314
  false,  /* isInfallible. False in setters. */
315
  false,  /* isMovable.  Not relevant for setters. */
316
  false, /* isEliminatable.  Not relevant for setters. */
317
  false, /* isAlwaysInSlot.  Only relevant for getters. */
318
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
319
  false,  /* isTypedMethod.  Only relevant for methods. */
320
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
321
};
322
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
323
static_assert(0 < 1, "There is no slot for us");
324
325
MOZ_CAN_RUN_SCRIPT static bool
326
get_checked(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
327
0
{
328
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.checked", DOM, cx);
329
0
330
0
  bool result(self->Checked());
331
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
332
0
  args.rval().setBoolean(result);
333
0
  return true;
334
0
}
335
336
MOZ_CAN_RUN_SCRIPT static bool
337
set_checked(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
338
0
{
339
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.checked", DOM, cx);
340
0
341
0
  bool arg0;
342
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
343
0
    return false;
344
0
  }
345
0
  Maybe<AutoCEReaction> ceReaction;
346
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
347
0
    DocGroup* docGroup = self->GetDocGroup();
348
0
    if (docGroup) {
349
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
350
0
    }
351
0
  }
352
0
  self->SetChecked(arg0);
353
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
354
0
355
0
  return true;
356
0
}
357
358
static const JSJitInfo checked_getterinfo = {
359
  { (JSJitGetterOp)get_checked },
360
  { prototypes::id::HTMLMenuItemElement },
361
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
362
  JSJitInfo::Getter,
363
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
364
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
365
  true,  /* isInfallible. False in setters. */
366
  false,  /* isMovable.  Not relevant for setters. */
367
  false, /* isEliminatable.  Not relevant for setters. */
368
  false, /* isAlwaysInSlot.  Only relevant for getters. */
369
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
370
  false,  /* isTypedMethod.  Only relevant for methods. */
371
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
372
};
373
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
374
static_assert(0 < 1, "There is no slot for us");
375
static const JSJitInfo checked_setterinfo = {
376
  { (JSJitGetterOp)set_checked },
377
  { prototypes::id::HTMLMenuItemElement },
378
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
379
  JSJitInfo::Setter,
380
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
381
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
382
  false,  /* isInfallible. False in setters. */
383
  false,  /* isMovable.  Not relevant for setters. */
384
  false, /* isEliminatable.  Not relevant for setters. */
385
  false, /* isAlwaysInSlot.  Only relevant for getters. */
386
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
387
  false,  /* isTypedMethod.  Only relevant for methods. */
388
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
389
};
390
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
391
static_assert(0 < 1, "There is no slot for us");
392
393
MOZ_CAN_RUN_SCRIPT static bool
394
get_radiogroup(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
395
0
{
396
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.radiogroup", DOM, cx);
397
0
398
0
  DOMString result;
399
0
  self->GetRadiogroup(result);
400
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
401
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
402
0
    return false;
403
0
  }
404
0
  return true;
405
0
}
406
407
MOZ_CAN_RUN_SCRIPT static bool
408
set_radiogroup(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
409
0
{
410
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.radiogroup", DOM, cx);
411
0
412
0
  binding_detail::FakeString arg0;
413
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
414
0
    return false;
415
0
  }
416
0
  Maybe<AutoCEReaction> ceReaction;
417
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
418
0
    DocGroup* docGroup = self->GetDocGroup();
419
0
    if (docGroup) {
420
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
421
0
    }
422
0
  }
423
0
  FastErrorResult rv;
424
0
  self->SetRadiogroup(NonNullHelper(Constify(arg0)), rv);
425
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
426
0
    return false;
427
0
  }
428
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
429
0
430
0
  return true;
431
0
}
432
433
static const JSJitInfo radiogroup_getterinfo = {
434
  { (JSJitGetterOp)get_radiogroup },
435
  { prototypes::id::HTMLMenuItemElement },
436
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
437
  JSJitInfo::Getter,
438
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
439
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
440
  false,  /* isInfallible. False in setters. */
441
  false,  /* isMovable.  Not relevant for setters. */
442
  false, /* isEliminatable.  Not relevant for setters. */
443
  false, /* isAlwaysInSlot.  Only relevant for getters. */
444
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
445
  false,  /* isTypedMethod.  Only relevant for methods. */
446
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
447
};
448
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
449
static_assert(0 < 1, "There is no slot for us");
450
static const JSJitInfo radiogroup_setterinfo = {
451
  { (JSJitGetterOp)set_radiogroup },
452
  { prototypes::id::HTMLMenuItemElement },
453
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
454
  JSJitInfo::Setter,
455
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
456
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
457
  false,  /* isInfallible. False in setters. */
458
  false,  /* isMovable.  Not relevant for setters. */
459
  false, /* isEliminatable.  Not relevant for setters. */
460
  false, /* isAlwaysInSlot.  Only relevant for getters. */
461
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
462
  false,  /* isTypedMethod.  Only relevant for methods. */
463
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
464
};
465
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
466
static_assert(0 < 1, "There is no slot for us");
467
468
MOZ_CAN_RUN_SCRIPT static bool
469
get_defaultChecked(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitGetterCallArgs args)
470
0
{
471
0
  AUTO_PROFILER_LABEL_FAST("get HTMLMenuItemElement.defaultChecked", DOM, cx);
472
0
473
0
  bool result(self->DefaultChecked());
474
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
475
0
  args.rval().setBoolean(result);
476
0
  return true;
477
0
}
478
479
MOZ_CAN_RUN_SCRIPT static bool
480
set_defaultChecked(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLMenuItemElement* self, JSJitSetterCallArgs args)
481
0
{
482
0
  AUTO_PROFILER_LABEL_FAST("set HTMLMenuItemElement.defaultChecked", DOM, cx);
483
0
484
0
  bool arg0;
485
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
486
0
    return false;
487
0
  }
488
0
  Maybe<AutoCEReaction> ceReaction;
489
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
490
0
    DocGroup* docGroup = self->GetDocGroup();
491
0
    if (docGroup) {
492
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
493
0
    }
494
0
  }
495
0
  FastErrorResult rv;
496
0
  self->SetDefaultChecked(arg0, rv);
497
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
498
0
    return false;
499
0
  }
500
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
501
0
502
0
  return true;
503
0
}
504
505
static const JSJitInfo defaultChecked_getterinfo = {
506
  { (JSJitGetterOp)get_defaultChecked },
507
  { prototypes::id::HTMLMenuItemElement },
508
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
509
  JSJitInfo::Getter,
510
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
511
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
512
  true,  /* isInfallible. False in setters. */
513
  false,  /* isMovable.  Not relevant for setters. */
514
  false, /* isEliminatable.  Not relevant for setters. */
515
  false, /* isAlwaysInSlot.  Only relevant for getters. */
516
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
517
  false,  /* isTypedMethod.  Only relevant for methods. */
518
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
519
};
520
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
521
static_assert(0 < 1, "There is no slot for us");
522
static const JSJitInfo defaultChecked_setterinfo = {
523
  { (JSJitGetterOp)set_defaultChecked },
524
  { prototypes::id::HTMLMenuItemElement },
525
  { PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth },
526
  JSJitInfo::Setter,
527
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
528
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
529
  false,  /* isInfallible. False in setters. */
530
  false,  /* isMovable.  Not relevant for setters. */
531
  false, /* isEliminatable.  Not relevant for setters. */
532
  false, /* isAlwaysInSlot.  Only relevant for getters. */
533
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
534
  false,  /* isTypedMethod.  Only relevant for methods. */
535
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
536
};
537
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
538
static_assert(0 < 1, "There is no slot for us");
539
540
static bool
541
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
542
0
{
543
0
  mozilla::dom::HTMLMenuItemElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLMenuItemElement>(obj);
544
0
  // We don't want to preserve if we don't have a wrapper, and we
545
0
  // obviously can't preserve if we're not initialized.
546
0
  if (self && self->GetWrapperPreserveColor()) {
547
0
    PreserveWrapper(self);
548
0
  }
549
0
  return true;
550
0
}
551
552
static void
553
_finalize(js::FreeOp* fop, JSObject* obj)
554
0
{
555
0
  mozilla::dom::HTMLMenuItemElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLMenuItemElement>(obj);
556
0
  if (self) {
557
0
    ClearWrapper(self, self, obj);
558
0
    AddForDeferredFinalization<mozilla::dom::HTMLMenuItemElement>(self);
559
0
  }
560
0
}
561
562
static size_t
563
_objectMoved(JSObject* obj, JSObject* old)
564
0
{
565
0
  mozilla::dom::HTMLMenuItemElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLMenuItemElement>(obj);
566
0
  if (self) {
567
0
    UpdateWrapper(self, self, obj, old);
568
0
  }
569
0
570
0
  return 0;
571
0
}
572
573
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
574
#if defined(__clang__)
575
#pragma clang diagnostic push
576
#pragma clang diagnostic ignored "-Wmissing-braces"
577
#endif
578
static const JSPropertySpec sAttributes_specs[] = {
579
  { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, GenericSetter<NormalThisPolicy>, &type_setterinfo },
580
  { "label", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &label_getterinfo, GenericSetter<NormalThisPolicy>, &label_setterinfo },
581
  { "icon", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &icon_getterinfo, GenericSetter<NormalThisPolicy>, &icon_setterinfo },
582
  { "disabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &disabled_getterinfo, GenericSetter<NormalThisPolicy>, &disabled_setterinfo },
583
  { "checked", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &checked_getterinfo, GenericSetter<NormalThisPolicy>, &checked_setterinfo },
584
  { "radiogroup", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &radiogroup_getterinfo, GenericSetter<NormalThisPolicy>, &radiogroup_setterinfo },
585
  { "defaultChecked", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &defaultChecked_getterinfo, GenericSetter<NormalThisPolicy>, &defaultChecked_setterinfo },
586
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
587
};
588
#if defined(__clang__)
589
#pragma clang diagnostic pop
590
#endif
591
592
593
static const Prefable<const JSPropertySpec> sAttributes[] = {
594
  { nullptr, &sAttributes_specs[0] },
595
  { nullptr, nullptr }
596
};
597
598
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
599
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
600
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
601
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
602
603
604
static uint16_t sNativeProperties_sortedPropertyIndices[7];
605
static PropertyInfo sNativeProperties_propertyInfos[7];
606
607
static const NativePropertiesN<1> sNativeProperties = {
608
  false, 0,
609
  false, 0,
610
  false, 0,
611
  true,  0 /* sAttributes */,
612
  false, 0,
613
  false, 0,
614
  false, 0,
615
  -1,
616
  7,
617
  sNativeProperties_sortedPropertyIndices,
618
  {
619
    { sAttributes, &sNativeProperties_propertyInfos[0] }
620
  }
621
};
622
static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
623
    "We have a property info count that is oversized");
624
625
static bool
626
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
627
0
{
628
0
  AUTO_PROFILER_LABEL_FAST("HTMLMenuItemElement constructor", DOM, cx);
629
0
630
0
  return HTMLConstructor(cx, argc, vp,
631
0
                         constructors::id::HTMLMenuItemElement,
632
0
                         prototypes::id::HTMLMenuItemElement,
633
0
                         CreateInterfaceObjects);
634
0
}
635
636
static const js::ClassOps sInterfaceObjectClassOps = {
637
    nullptr,               /* addProperty */
638
    nullptr,               /* delProperty */
639
    nullptr,               /* enumerate */
640
    nullptr,               /* newEnumerate */
641
    nullptr,               /* resolve */
642
    nullptr,               /* mayResolve */
643
    nullptr,               /* finalize */
644
    _constructor, /* call */
645
    nullptr,               /* hasInstance */
646
    _constructor, /* construct */
647
    nullptr,               /* trace */
648
};
649
650
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
651
  {
652
    "Function",
653
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
654
    &sInterfaceObjectClassOps,
655
    JS_NULL_CLASS_SPEC,
656
    JS_NULL_CLASS_EXT,
657
    &sInterfaceObjectClassObjectOps
658
  },
659
  eInterface,
660
  true,
661
  prototypes::id::HTMLMenuItemElement,
662
  PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth,
663
  sNativePropertyHooks,
664
  "function HTMLMenuItemElement() {\n    [native code]\n}",
665
  HTMLElement_Binding::GetConstructorObject
666
};
667
668
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
669
  {
670
    "HTMLMenuItemElementPrototype",
671
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
672
    JS_NULL_CLASS_OPS,
673
    JS_NULL_CLASS_SPEC,
674
    JS_NULL_CLASS_EXT,
675
    JS_NULL_OBJECT_OPS
676
  },
677
  eInterfacePrototype,
678
  false,
679
  prototypes::id::HTMLMenuItemElement,
680
  PrototypeTraits<prototypes::id::HTMLMenuItemElement>::Depth,
681
  sNativePropertyHooks,
682
  "[object HTMLMenuItemElementPrototype]",
683
  HTMLElement_Binding::GetProtoObject
684
};
685
686
static const js::ClassOps sClassOps = {
687
  _addProperty, /* addProperty */
688
  nullptr,               /* delProperty */
689
  nullptr,               /* enumerate */
690
  nullptr, /* newEnumerate */
691
  nullptr, /* resolve */
692
  nullptr, /* mayResolve */
693
  _finalize, /* finalize */
694
  nullptr, /* call */
695
  nullptr,               /* hasInstance */
696
  nullptr,               /* construct */
697
  nullptr, /* trace */
698
};
699
700
static const js::ClassExtension sClassExtension = {
701
  nullptr, /* weakmapKeyDelegateOp */
702
  _objectMoved /* objectMovedOp */
703
};
704
705
static const DOMJSClass sClass = {
706
  { "HTMLMenuItemElement",
707
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
708
    &sClassOps,
709
    JS_NULL_CLASS_SPEC,
710
    &sClassExtension,
711
    JS_NULL_OBJECT_OPS
712
  },
713
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLMenuItemElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
714
  IsBaseOf<nsISupports, mozilla::dom::HTMLMenuItemElement >::value,
715
  sNativePropertyHooks,
716
  FindAssociatedGlobalForNative<mozilla::dom::HTMLMenuItemElement>::Get,
717
  GetProtoObjectHandle,
718
  GetCCParticipant<mozilla::dom::HTMLMenuItemElement>::Get()
719
};
720
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
721
              "Must have the right minimal number of reserved slots.");
722
static_assert(1 >= 1,
723
              "Must have enough reserved slots.");
724
725
const JSClass*
726
GetJSClass()
727
0
{
728
0
  return sClass.ToJSClass();
729
0
}
730
731
bool
732
Wrap(JSContext* aCx, mozilla::dom::HTMLMenuItemElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
733
0
{
734
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLMenuItemElement>::value,
735
0
                "Shouldn't have wrappercached things that are not refcounted.");
736
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLMenuItemElement*>(aObject) ==
737
0
             reinterpret_cast<mozilla::dom::HTMLMenuItemElement*>(aObject),
738
0
             "Multiple inheritance for mozilla::dom::HTMLMenuItemElement is broken.");
739
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
740
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
741
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
742
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
743
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
744
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
745
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
746
0
             reinterpret_cast<nsINode*>(aObject),
747
0
             "Multiple inheritance for nsINode is broken.");
748
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
749
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
750
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
751
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
752
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
753
0
  MOZ_ASSERT(!aCache->GetWrapper(),
754
0
             "You should probably not be using Wrap() directly; use "
755
0
             "GetOrCreateDOMReflector instead");
756
0
757
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
758
0
             "nsISupports must be on our primary inheritance chain");
759
0
760
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
761
0
  if (!global) {
762
0
    return false;
763
0
  }
764
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
765
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
766
0
767
0
  // That might have ended up wrapping us already, due to the wonders
768
0
  // of XBL.  Check for that, and bail out as needed.
769
0
  aReflector.set(aCache->GetWrapper());
770
0
  if (aReflector) {
771
#ifdef DEBUG
772
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
773
#endif // DEBUG
774
    return true;
775
0
  }
776
0
777
0
  JSAutoRealm ar(aCx, global);
778
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
779
0
  if (!canonicalProto) {
780
0
    return false;
781
0
  }
782
0
  JS::Rooted<JSObject*> proto(aCx);
783
0
  if (aGivenProto) {
784
0
    proto = aGivenProto;
785
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
786
0
    // coming in, we changed compartments to that of "parent" so may need
787
0
    // to wrap the proto here.
788
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
789
0
      if (!JS_WrapObject(aCx, &proto)) {
790
0
        return false;
791
0
      }
792
0
    }
793
0
  } else {
794
0
    proto = canonicalProto;
795
0
  }
796
0
797
0
  BindingJSObjectCreator<mozilla::dom::HTMLMenuItemElement> creator(aCx);
798
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
799
0
  if (!aReflector) {
800
0
    return false;
801
0
  }
802
0
803
0
  aCache->SetWrapper(aReflector);
804
0
  creator.InitializationSucceeded();
805
0
806
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
807
0
             aCache->GetWrapperPreserveColor() == aReflector);
808
0
  // If proto != canonicalProto, we have to preserve our wrapper;
809
0
  // otherwise we won't be able to properly recreate it later, since
810
0
  // we won't know what proto to use.  Note that we don't check
811
0
  // aGivenProto here, since it's entirely possible (and even
812
0
  // somewhat common) to have a non-null aGivenProto which is the
813
0
  // same as canonicalProto.
814
0
  if (proto != canonicalProto) {
815
0
    PreserveWrapper(aObject);
816
0
  }
817
0
818
0
  return true;
819
0
}
820
821
const NativePropertyHooks sNativePropertyHooks[] = { {
822
  nullptr,
823
  nullptr,
824
  nullptr,
825
  { sNativeProperties.Upcast(), nullptr },
826
  prototypes::id::HTMLMenuItemElement,
827
  constructors::id::HTMLMenuItemElement,
828
  HTMLElement_Binding::sNativePropertyHooks,
829
  &DefaultXrayExpandoObjectClass
830
} };
831
832
void
833
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
834
0
{
835
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
836
0
  if (!parentProto) {
837
0
    return;
838
0
  }
839
0
840
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
841
0
  if (!constructorProto) {
842
0
    return;
843
0
  }
844
0
845
0
  static bool sIdsInited = false;
846
0
  if (!sIdsInited && NS_IsMainThread()) {
847
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
848
0
      return;
849
0
    }
850
0
    sIdsInited = true;
851
0
  }
852
0
853
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLMenuItemElement);
854
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLMenuItemElement);
855
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
856
0
                              &sPrototypeClass.mBase, protoCache,
857
0
                              nullptr,
858
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
859
0
                              interfaceCache,
860
0
                              sNativeProperties.Upcast(),
861
0
                              nullptr,
862
0
                              "HTMLMenuItemElement", aDefineOnGlobal,
863
0
                              nullptr,
864
0
                              false);
865
0
}
866
867
JSObject*
868
GetConstructorObject(JSContext* aCx)
869
0
{
870
0
  return GetConstructorObjectHandle(aCx);
871
0
}
872
873
} // namespace HTMLMenuItemElement_Binding
874
875
876
877
} // namespace dom
878
} // namespace mozilla