Coverage Report

Created: 2018-09-25 14:53

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