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