/work/obj-fuzz/dom/bindings/HTMLOptionElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM HTMLOptionElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "HTMLElementBinding.h" |
4 | | #include "HTMLOptionElementBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/CustomElementRegistry.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/DocGroup.h" |
11 | | #include "mozilla/dom/HTMLFormElement.h" |
12 | | #include "mozilla/dom/HTMLOptionElement.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/XrayExpandoClass.h" |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
22 | | using namespace mozilla::dom::binding_detail; |
23 | | |
24 | | |
25 | | namespace HTMLOptionElement_Binding { |
26 | | |
27 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value, |
28 | | "Can't inherit from an interface with a different ownership model."); |
29 | | |
30 | | static bool |
31 | | _Option(JSContext* cx, unsigned argc, JS::Value* vp) |
32 | 0 | { |
33 | 0 | AUTO_PROFILER_LABEL_FAST("Option constructor", DOM, cx); |
34 | 0 |
|
35 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
36 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
37 | 0 | if (!args.isConstructing()) { |
38 | 0 | // XXXbz wish I could get the name from the callee instead of |
39 | 0 | // Adding more relocations |
40 | 0 | return ThrowConstructorWithoutNew(cx, "Option"); |
41 | 0 | } |
42 | 0 | |
43 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
44 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | |
48 | 0 | GlobalObject global(cx, obj); |
49 | 0 | if (global.Failed()) { |
50 | 0 | return false; |
51 | 0 | } |
52 | 0 | |
53 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
54 | 0 | binding_detail::FakeString arg0; |
55 | 0 | if (args.hasDefined(0)) { |
56 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
57 | 0 | return false; |
58 | 0 | } |
59 | 0 | } else { |
60 | 0 | static const char16_t data[] = { 0 }; |
61 | 0 | arg0.Rebind(data, ArrayLength(data) - 1); |
62 | 0 | } |
63 | 0 | Optional<nsAString> arg1; |
64 | 0 | binding_detail::FakeString arg1_holder; |
65 | 0 | if (args.hasDefined(1)) { |
66 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) { |
67 | 0 | return false; |
68 | 0 | } |
69 | 0 | arg1 = &arg1_holder; |
70 | 0 | } |
71 | 0 | bool arg2; |
72 | 0 | if (args.hasDefined(2)) { |
73 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) { |
74 | 0 | return false; |
75 | 0 | } |
76 | 0 | } else { |
77 | 0 | arg2 = false; |
78 | 0 | } |
79 | 0 | bool arg3; |
80 | 0 | if (args.hasDefined(3)) { |
81 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3)) { |
82 | 0 | return false; |
83 | 0 | } |
84 | 0 | } else { |
85 | 0 | arg3 = false; |
86 | 0 | } |
87 | 0 | Maybe<JSAutoRealm> ar; |
88 | 0 | if (objIsXray) { |
89 | 0 | obj = js::CheckedUnwrap(obj); |
90 | 0 | if (!obj) { |
91 | 0 | return false; |
92 | 0 | } |
93 | 0 | ar.emplace(cx, obj); |
94 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
95 | 0 | return false; |
96 | 0 | } |
97 | 0 | } |
98 | 0 | FastErrorResult rv; |
99 | 0 | auto result(StrongOrRawPtr<mozilla::dom::HTMLOptionElement>(mozilla::dom::HTMLOptionElement::Option(global, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2, arg3, rv))); |
100 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
101 | 0 | return false; |
102 | 0 | } |
103 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
104 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
105 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
106 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
107 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
108 | 0 | return false; |
109 | 0 | } |
110 | 0 | return true; |
111 | 0 | } |
112 | | |
113 | | MOZ_CAN_RUN_SCRIPT static bool |
114 | | get_disabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
115 | 0 | { |
116 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.disabled", DOM, cx); |
117 | 0 |
|
118 | 0 | bool result(self->Disabled()); |
119 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
120 | 0 | args.rval().setBoolean(result); |
121 | 0 | return true; |
122 | 0 | } |
123 | | |
124 | | MOZ_CAN_RUN_SCRIPT static bool |
125 | | set_disabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitSetterCallArgs args) |
126 | 0 | { |
127 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLOptionElement.disabled", DOM, cx); |
128 | 0 |
|
129 | 0 | bool arg0; |
130 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
131 | 0 | return false; |
132 | 0 | } |
133 | 0 | Maybe<AutoCEReaction> ceReaction; |
134 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
135 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
136 | 0 | if (docGroup) { |
137 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
138 | 0 | } |
139 | 0 | } |
140 | 0 | FastErrorResult rv; |
141 | 0 | self->SetDisabled(arg0, rv); |
142 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
143 | 0 | return false; |
144 | 0 | } |
145 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
146 | 0 |
|
147 | 0 | return true; |
148 | 0 | } |
149 | | |
150 | | static const JSJitInfo disabled_getterinfo = { |
151 | | { (JSJitGetterOp)get_disabled }, |
152 | | { prototypes::id::HTMLOptionElement }, |
153 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
154 | | JSJitInfo::Getter, |
155 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
156 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
157 | | true, /* isInfallible. False in setters. */ |
158 | | false, /* isMovable. Not relevant for setters. */ |
159 | | false, /* isEliminatable. Not relevant for setters. */ |
160 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
161 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
162 | | false, /* isTypedMethod. Only relevant for methods. */ |
163 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
164 | | }; |
165 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
166 | | static_assert(0 < 1, "There is no slot for us"); |
167 | | static const JSJitInfo disabled_setterinfo = { |
168 | | { (JSJitGetterOp)set_disabled }, |
169 | | { prototypes::id::HTMLOptionElement }, |
170 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
171 | | JSJitInfo::Setter, |
172 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
173 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
174 | | false, /* isInfallible. False in setters. */ |
175 | | false, /* isMovable. Not relevant for setters. */ |
176 | | false, /* isEliminatable. Not relevant for setters. */ |
177 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
178 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
179 | | false, /* isTypedMethod. Only relevant for methods. */ |
180 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
181 | | }; |
182 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
183 | | static_assert(0 < 1, "There is no slot for us"); |
184 | | |
185 | | MOZ_CAN_RUN_SCRIPT static bool |
186 | | get_form(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
187 | 0 | { |
188 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.form", DOM, cx); |
189 | 0 |
|
190 | 0 | auto result(StrongOrRawPtr<mozilla::dom::HTMLFormElement>(self->GetForm())); |
191 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
192 | 0 | if (!result) { |
193 | 0 | args.rval().setNull(); |
194 | 0 | return true; |
195 | 0 | } |
196 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
197 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
198 | 0 | return false; |
199 | 0 | } |
200 | 0 | return true; |
201 | 0 | } |
202 | | |
203 | | static const JSJitInfo form_getterinfo = { |
204 | | { (JSJitGetterOp)get_form }, |
205 | | { prototypes::id::HTMLOptionElement }, |
206 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
207 | | JSJitInfo::Getter, |
208 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
209 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
210 | | false, /* isInfallible. False in setters. */ |
211 | | false, /* isMovable. Not relevant for setters. */ |
212 | | false, /* 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 | | |
221 | | MOZ_CAN_RUN_SCRIPT static bool |
222 | | get_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
223 | 0 | { |
224 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.label", DOM, cx); |
225 | 0 |
|
226 | 0 | DOMString result; |
227 | 0 | self->GetLabel(result); |
228 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
229 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
230 | 0 | return false; |
231 | 0 | } |
232 | 0 | return true; |
233 | 0 | } |
234 | | |
235 | | MOZ_CAN_RUN_SCRIPT static bool |
236 | | set_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitSetterCallArgs args) |
237 | 0 | { |
238 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLOptionElement.label", DOM, cx); |
239 | 0 |
|
240 | 0 | binding_detail::FakeString arg0; |
241 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
242 | 0 | return false; |
243 | 0 | } |
244 | 0 | Maybe<AutoCEReaction> ceReaction; |
245 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
246 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
247 | 0 | if (docGroup) { |
248 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
249 | 0 | } |
250 | 0 | } |
251 | 0 | FastErrorResult rv; |
252 | 0 | self->SetLabel(NonNullHelper(Constify(arg0)), rv); |
253 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
254 | 0 | return false; |
255 | 0 | } |
256 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
257 | 0 |
|
258 | 0 | return true; |
259 | 0 | } |
260 | | |
261 | | static const JSJitInfo label_getterinfo = { |
262 | | { (JSJitGetterOp)get_label }, |
263 | | { prototypes::id::HTMLOptionElement }, |
264 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
265 | | JSJitInfo::Getter, |
266 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
267 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
268 | | false, /* isInfallible. False in setters. */ |
269 | | false, /* isMovable. Not relevant for setters. */ |
270 | | false, /* isEliminatable. Not relevant for setters. */ |
271 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
272 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
273 | | false, /* isTypedMethod. Only relevant for methods. */ |
274 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
275 | | }; |
276 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
277 | | static_assert(0 < 1, "There is no slot for us"); |
278 | | static const JSJitInfo label_setterinfo = { |
279 | | { (JSJitGetterOp)set_label }, |
280 | | { prototypes::id::HTMLOptionElement }, |
281 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
282 | | JSJitInfo::Setter, |
283 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
284 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
285 | | false, /* isInfallible. False in setters. */ |
286 | | false, /* isMovable. Not relevant for setters. */ |
287 | | false, /* isEliminatable. Not relevant for setters. */ |
288 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
289 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
290 | | false, /* isTypedMethod. Only relevant for methods. */ |
291 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
292 | | }; |
293 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
294 | | static_assert(0 < 1, "There is no slot for us"); |
295 | | |
296 | | MOZ_CAN_RUN_SCRIPT static bool |
297 | | get_defaultSelected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
298 | 0 | { |
299 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.defaultSelected", DOM, cx); |
300 | 0 |
|
301 | 0 | bool result(self->DefaultSelected()); |
302 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
303 | 0 | args.rval().setBoolean(result); |
304 | 0 | return true; |
305 | 0 | } |
306 | | |
307 | | MOZ_CAN_RUN_SCRIPT static bool |
308 | | set_defaultSelected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitSetterCallArgs args) |
309 | 0 | { |
310 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLOptionElement.defaultSelected", DOM, cx); |
311 | 0 |
|
312 | 0 | bool arg0; |
313 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
314 | 0 | return false; |
315 | 0 | } |
316 | 0 | Maybe<AutoCEReaction> ceReaction; |
317 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
318 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
319 | 0 | if (docGroup) { |
320 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
321 | 0 | } |
322 | 0 | } |
323 | 0 | FastErrorResult rv; |
324 | 0 | self->SetDefaultSelected(arg0, rv); |
325 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
326 | 0 | return false; |
327 | 0 | } |
328 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
329 | 0 |
|
330 | 0 | return true; |
331 | 0 | } |
332 | | |
333 | | static const JSJitInfo defaultSelected_getterinfo = { |
334 | | { (JSJitGetterOp)get_defaultSelected }, |
335 | | { prototypes::id::HTMLOptionElement }, |
336 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
337 | | JSJitInfo::Getter, |
338 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
339 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
340 | | true, /* isInfallible. False in setters. */ |
341 | | false, /* isMovable. Not relevant for setters. */ |
342 | | false, /* isEliminatable. Not relevant for setters. */ |
343 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
344 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
345 | | false, /* isTypedMethod. Only relevant for methods. */ |
346 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
347 | | }; |
348 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
349 | | static_assert(0 < 1, "There is no slot for us"); |
350 | | static const JSJitInfo defaultSelected_setterinfo = { |
351 | | { (JSJitGetterOp)set_defaultSelected }, |
352 | | { prototypes::id::HTMLOptionElement }, |
353 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
354 | | JSJitInfo::Setter, |
355 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
356 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
357 | | false, /* isInfallible. False in setters. */ |
358 | | false, /* isMovable. Not relevant for setters. */ |
359 | | false, /* isEliminatable. Not relevant for setters. */ |
360 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
361 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
362 | | false, /* isTypedMethod. Only relevant for methods. */ |
363 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
364 | | }; |
365 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
366 | | static_assert(0 < 1, "There is no slot for us"); |
367 | | |
368 | | MOZ_CAN_RUN_SCRIPT static bool |
369 | | get_selected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
370 | 0 | { |
371 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.selected", DOM, cx); |
372 | 0 |
|
373 | 0 | bool result(self->Selected()); |
374 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
375 | 0 | args.rval().setBoolean(result); |
376 | 0 | return true; |
377 | 0 | } |
378 | | |
379 | | MOZ_CAN_RUN_SCRIPT static bool |
380 | | set_selected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitSetterCallArgs args) |
381 | 0 | { |
382 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLOptionElement.selected", DOM, cx); |
383 | 0 |
|
384 | 0 | bool arg0; |
385 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
386 | 0 | return false; |
387 | 0 | } |
388 | 0 | self->SetSelected(arg0); |
389 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
390 | 0 |
|
391 | 0 | return true; |
392 | 0 | } |
393 | | |
394 | | static const JSJitInfo selected_getterinfo = { |
395 | | { (JSJitGetterOp)get_selected }, |
396 | | { prototypes::id::HTMLOptionElement }, |
397 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
398 | | JSJitInfo::Getter, |
399 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
400 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
401 | | true, /* isInfallible. False in setters. */ |
402 | | false, /* isMovable. Not relevant for setters. */ |
403 | | false, /* isEliminatable. Not relevant for setters. */ |
404 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
405 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
406 | | false, /* isTypedMethod. Only relevant for methods. */ |
407 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
408 | | }; |
409 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
410 | | static_assert(0 < 1, "There is no slot for us"); |
411 | | static const JSJitInfo selected_setterinfo = { |
412 | | { (JSJitGetterOp)set_selected }, |
413 | | { prototypes::id::HTMLOptionElement }, |
414 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
415 | | JSJitInfo::Setter, |
416 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
417 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
418 | | false, /* isInfallible. False in setters. */ |
419 | | false, /* isMovable. Not relevant for setters. */ |
420 | | false, /* isEliminatable. Not relevant for setters. */ |
421 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
422 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
423 | | false, /* isTypedMethod. Only relevant for methods. */ |
424 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
425 | | }; |
426 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
427 | | static_assert(0 < 1, "There is no slot for us"); |
428 | | |
429 | | MOZ_CAN_RUN_SCRIPT static bool |
430 | | get_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
431 | 0 | { |
432 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.value", DOM, cx); |
433 | 0 |
|
434 | 0 | DOMString result; |
435 | 0 | self->GetValue(result); |
436 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
437 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
438 | 0 | return false; |
439 | 0 | } |
440 | 0 | return true; |
441 | 0 | } |
442 | | |
443 | | MOZ_CAN_RUN_SCRIPT static bool |
444 | | set_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitSetterCallArgs args) |
445 | 0 | { |
446 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLOptionElement.value", DOM, cx); |
447 | 0 |
|
448 | 0 | binding_detail::FakeString arg0; |
449 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
450 | 0 | return false; |
451 | 0 | } |
452 | 0 | Maybe<AutoCEReaction> ceReaction; |
453 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
454 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
455 | 0 | if (docGroup) { |
456 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
457 | 0 | } |
458 | 0 | } |
459 | 0 | FastErrorResult rv; |
460 | 0 | self->SetValue(NonNullHelper(Constify(arg0)), rv); |
461 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
462 | 0 | return false; |
463 | 0 | } |
464 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
465 | 0 |
|
466 | 0 | return true; |
467 | 0 | } |
468 | | |
469 | | static const JSJitInfo value_getterinfo = { |
470 | | { (JSJitGetterOp)get_value }, |
471 | | { prototypes::id::HTMLOptionElement }, |
472 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
473 | | JSJitInfo::Getter, |
474 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
475 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
476 | | false, /* isInfallible. False in setters. */ |
477 | | false, /* isMovable. Not relevant for setters. */ |
478 | | false, /* isEliminatable. Not relevant for setters. */ |
479 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
480 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
481 | | false, /* isTypedMethod. Only relevant for methods. */ |
482 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
483 | | }; |
484 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
485 | | static_assert(0 < 1, "There is no slot for us"); |
486 | | static const JSJitInfo value_setterinfo = { |
487 | | { (JSJitGetterOp)set_value }, |
488 | | { prototypes::id::HTMLOptionElement }, |
489 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
490 | | JSJitInfo::Setter, |
491 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
492 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
493 | | false, /* isInfallible. False in setters. */ |
494 | | false, /* isMovable. Not relevant for setters. */ |
495 | | false, /* isEliminatable. Not relevant for setters. */ |
496 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
497 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
498 | | false, /* isTypedMethod. Only relevant for methods. */ |
499 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
500 | | }; |
501 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
502 | | static_assert(0 < 1, "There is no slot for us"); |
503 | | |
504 | | MOZ_CAN_RUN_SCRIPT static bool |
505 | | get_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
506 | 0 | { |
507 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.text", DOM, cx); |
508 | 0 |
|
509 | 0 | DOMString result; |
510 | 0 | self->GetText(result); |
511 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
512 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
513 | 0 | return false; |
514 | 0 | } |
515 | 0 | return true; |
516 | 0 | } |
517 | | |
518 | | MOZ_CAN_RUN_SCRIPT static bool |
519 | | set_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitSetterCallArgs args) |
520 | 0 | { |
521 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLOptionElement.text", DOM, cx); |
522 | 0 |
|
523 | 0 | binding_detail::FakeString arg0; |
524 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
525 | 0 | return false; |
526 | 0 | } |
527 | 0 | Maybe<AutoCEReaction> ceReaction; |
528 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
529 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
530 | 0 | if (docGroup) { |
531 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
532 | 0 | } |
533 | 0 | } |
534 | 0 | FastErrorResult rv; |
535 | 0 | self->SetText(NonNullHelper(Constify(arg0)), rv); |
536 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
537 | 0 | return false; |
538 | 0 | } |
539 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
540 | 0 |
|
541 | 0 | return true; |
542 | 0 | } |
543 | | |
544 | | static const JSJitInfo text_getterinfo = { |
545 | | { (JSJitGetterOp)get_text }, |
546 | | { prototypes::id::HTMLOptionElement }, |
547 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
548 | | JSJitInfo::Getter, |
549 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
550 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
551 | | false, /* isInfallible. False in setters. */ |
552 | | false, /* isMovable. Not relevant for setters. */ |
553 | | false, /* isEliminatable. Not relevant for setters. */ |
554 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
555 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
556 | | false, /* isTypedMethod. Only relevant for methods. */ |
557 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
558 | | }; |
559 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
560 | | static_assert(0 < 1, "There is no slot for us"); |
561 | | static const JSJitInfo text_setterinfo = { |
562 | | { (JSJitGetterOp)set_text }, |
563 | | { prototypes::id::HTMLOptionElement }, |
564 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
565 | | JSJitInfo::Setter, |
566 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
567 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
568 | | false, /* isInfallible. False in setters. */ |
569 | | false, /* isMovable. Not relevant for setters. */ |
570 | | false, /* isEliminatable. Not relevant for setters. */ |
571 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
572 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
573 | | false, /* isTypedMethod. Only relevant for methods. */ |
574 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
575 | | }; |
576 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
577 | | static_assert(0 < 1, "There is no slot for us"); |
578 | | |
579 | | MOZ_CAN_RUN_SCRIPT static bool |
580 | | get_index(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOptionElement* self, JSJitGetterCallArgs args) |
581 | 0 | { |
582 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLOptionElement.index", DOM, cx); |
583 | 0 |
|
584 | 0 | int32_t result(self->Index()); |
585 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
586 | 0 | args.rval().setInt32(int32_t(result)); |
587 | 0 | return true; |
588 | 0 | } |
589 | | |
590 | | static const JSJitInfo index_getterinfo = { |
591 | | { (JSJitGetterOp)get_index }, |
592 | | { prototypes::id::HTMLOptionElement }, |
593 | | { PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth }, |
594 | | JSJitInfo::Getter, |
595 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
596 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
597 | | true, /* isInfallible. False in setters. */ |
598 | | false, /* isMovable. Not relevant for setters. */ |
599 | | false, /* isEliminatable. Not relevant for setters. */ |
600 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
601 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
602 | | false, /* isTypedMethod. Only relevant for methods. */ |
603 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
604 | | }; |
605 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
606 | | static_assert(0 < 1, "There is no slot for us"); |
607 | | |
608 | | static bool |
609 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
610 | 0 | { |
611 | 0 | mozilla::dom::HTMLOptionElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLOptionElement>(obj); |
612 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
613 | 0 | // obviously can't preserve if we're not initialized. |
614 | 0 | if (self && self->GetWrapperPreserveColor()) { |
615 | 0 | PreserveWrapper(self); |
616 | 0 | } |
617 | 0 | return true; |
618 | 0 | } |
619 | | |
620 | | static void |
621 | | _finalize(js::FreeOp* fop, JSObject* obj) |
622 | 0 | { |
623 | 0 | mozilla::dom::HTMLOptionElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLOptionElement>(obj); |
624 | 0 | if (self) { |
625 | 0 | ClearWrapper(self, self, obj); |
626 | 0 | AddForDeferredFinalization<mozilla::dom::HTMLOptionElement>(self); |
627 | 0 | } |
628 | 0 | } |
629 | | |
630 | | static size_t |
631 | | _objectMoved(JSObject* obj, JSObject* old) |
632 | 0 | { |
633 | 0 | mozilla::dom::HTMLOptionElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLOptionElement>(obj); |
634 | 0 | if (self) { |
635 | 0 | UpdateWrapper(self, self, obj, old); |
636 | 0 | } |
637 | 0 |
|
638 | 0 | return 0; |
639 | 0 | } |
640 | | |
641 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
642 | | #if defined(__clang__) |
643 | | #pragma clang diagnostic push |
644 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
645 | | #endif |
646 | | static const JSPropertySpec sAttributes_specs[] = { |
647 | | { "disabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &disabled_getterinfo, GenericSetter<NormalThisPolicy>, &disabled_setterinfo }, |
648 | | { "form", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &form_getterinfo, nullptr, nullptr }, |
649 | | { "label", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &label_getterinfo, GenericSetter<NormalThisPolicy>, &label_setterinfo }, |
650 | | { "defaultSelected", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &defaultSelected_getterinfo, GenericSetter<NormalThisPolicy>, &defaultSelected_setterinfo }, |
651 | | { "selected", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &selected_getterinfo, GenericSetter<NormalThisPolicy>, &selected_setterinfo }, |
652 | | { "value", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &value_getterinfo, GenericSetter<NormalThisPolicy>, &value_setterinfo }, |
653 | | { "text", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &text_getterinfo, GenericSetter<NormalThisPolicy>, &text_setterinfo }, |
654 | | { "index", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &index_getterinfo, nullptr, nullptr }, |
655 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
656 | | }; |
657 | | #if defined(__clang__) |
658 | | #pragma clang diagnostic pop |
659 | | #endif |
660 | | |
661 | | |
662 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
663 | | { nullptr, &sAttributes_specs[0] }, |
664 | | { nullptr, nullptr } |
665 | | }; |
666 | | |
667 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
668 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
669 | | static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
670 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
671 | | |
672 | | |
673 | | static uint16_t sNativeProperties_sortedPropertyIndices[8]; |
674 | | static PropertyInfo sNativeProperties_propertyInfos[8]; |
675 | | |
676 | | static const NativePropertiesN<1> sNativeProperties = { |
677 | | false, 0, |
678 | | false, 0, |
679 | | false, 0, |
680 | | true, 0 /* sAttributes */, |
681 | | false, 0, |
682 | | false, 0, |
683 | | false, 0, |
684 | | -1, |
685 | | 8, |
686 | | sNativeProperties_sortedPropertyIndices, |
687 | | { |
688 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
689 | | } |
690 | | }; |
691 | | static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
692 | | "We have a property info count that is oversized"); |
693 | | |
694 | | static bool |
695 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
696 | 0 | { |
697 | 0 | AUTO_PROFILER_LABEL_FAST("HTMLOptionElement constructor", DOM, cx); |
698 | 0 |
|
699 | 0 | return HTMLConstructor(cx, argc, vp, |
700 | 0 | constructors::id::HTMLOptionElement, |
701 | 0 | prototypes::id::HTMLOptionElement, |
702 | 0 | CreateInterfaceObjects); |
703 | 0 | } |
704 | | |
705 | | static const js::ClassOps sInterfaceObjectClassOps = { |
706 | | nullptr, /* addProperty */ |
707 | | nullptr, /* delProperty */ |
708 | | nullptr, /* enumerate */ |
709 | | nullptr, /* newEnumerate */ |
710 | | nullptr, /* resolve */ |
711 | | nullptr, /* mayResolve */ |
712 | | nullptr, /* finalize */ |
713 | | _constructor, /* call */ |
714 | | nullptr, /* hasInstance */ |
715 | | _constructor, /* construct */ |
716 | | nullptr, /* trace */ |
717 | | }; |
718 | | |
719 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
720 | | { |
721 | | "Function", |
722 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE + 1 /* slots for the named constructors */), |
723 | | &sInterfaceObjectClassOps, |
724 | | JS_NULL_CLASS_SPEC, |
725 | | JS_NULL_CLASS_EXT, |
726 | | &sInterfaceObjectClassObjectOps |
727 | | }, |
728 | | eInterface, |
729 | | true, |
730 | | prototypes::id::HTMLOptionElement, |
731 | | PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth, |
732 | | sNativePropertyHooks, |
733 | | "function HTMLOptionElement() {\n [native code]\n}", |
734 | | HTMLElement_Binding::GetConstructorObject |
735 | | }; |
736 | | |
737 | | const NativePropertyHooks sNamedConstructorNativePropertyHooks = { |
738 | | nullptr, |
739 | | nullptr, |
740 | | nullptr, |
741 | | { nullptr, nullptr }, |
742 | | prototypes::id::HTMLOptionElement, |
743 | | constructors::id::HTMLOptionElement, |
744 | | nullptr |
745 | | }; |
746 | | |
747 | | static const NamedConstructor namedConstructors[] = { |
748 | | { "Option", { _Option, &sNamedConstructorNativePropertyHooks }, 0 }, |
749 | | { nullptr, { nullptr, nullptr }, 0 } |
750 | | }; |
751 | | |
752 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
753 | | { |
754 | | "HTMLOptionElementPrototype", |
755 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
756 | | JS_NULL_CLASS_OPS, |
757 | | JS_NULL_CLASS_SPEC, |
758 | | JS_NULL_CLASS_EXT, |
759 | | JS_NULL_OBJECT_OPS |
760 | | }, |
761 | | eInterfacePrototype, |
762 | | false, |
763 | | prototypes::id::HTMLOptionElement, |
764 | | PrototypeTraits<prototypes::id::HTMLOptionElement>::Depth, |
765 | | sNativePropertyHooks, |
766 | | "[object HTMLOptionElementPrototype]", |
767 | | HTMLElement_Binding::GetProtoObject |
768 | | }; |
769 | | |
770 | | static const js::ClassOps sClassOps = { |
771 | | _addProperty, /* addProperty */ |
772 | | nullptr, /* delProperty */ |
773 | | nullptr, /* enumerate */ |
774 | | nullptr, /* newEnumerate */ |
775 | | nullptr, /* resolve */ |
776 | | nullptr, /* mayResolve */ |
777 | | _finalize, /* finalize */ |
778 | | nullptr, /* call */ |
779 | | nullptr, /* hasInstance */ |
780 | | nullptr, /* construct */ |
781 | | nullptr, /* trace */ |
782 | | }; |
783 | | |
784 | | static const js::ClassExtension sClassExtension = { |
785 | | nullptr, /* weakmapKeyDelegateOp */ |
786 | | _objectMoved /* objectMovedOp */ |
787 | | }; |
788 | | |
789 | | static const DOMJSClass sClass = { |
790 | | { "HTMLOptionElement", |
791 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
792 | | &sClassOps, |
793 | | JS_NULL_CLASS_SPEC, |
794 | | &sClassExtension, |
795 | | JS_NULL_OBJECT_OPS |
796 | | }, |
797 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLOptionElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
798 | | IsBaseOf<nsISupports, mozilla::dom::HTMLOptionElement >::value, |
799 | | sNativePropertyHooks, |
800 | | FindAssociatedGlobalForNative<mozilla::dom::HTMLOptionElement>::Get, |
801 | | GetProtoObjectHandle, |
802 | | GetCCParticipant<mozilla::dom::HTMLOptionElement>::Get() |
803 | | }; |
804 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
805 | | "Must have the right minimal number of reserved slots."); |
806 | | static_assert(1 >= 1, |
807 | | "Must have enough reserved slots."); |
808 | | |
809 | | const JSClass* |
810 | | GetJSClass() |
811 | 0 | { |
812 | 0 | return sClass.ToJSClass(); |
813 | 0 | } |
814 | | |
815 | | bool |
816 | | Wrap(JSContext* aCx, mozilla::dom::HTMLOptionElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
817 | 0 | { |
818 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLOptionElement>::value, |
819 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
820 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::HTMLOptionElement*>(aObject) == |
821 | 0 | reinterpret_cast<mozilla::dom::HTMLOptionElement*>(aObject), |
822 | 0 | "Multiple inheritance for mozilla::dom::HTMLOptionElement is broken."); |
823 | 0 | MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) == |
824 | 0 | reinterpret_cast<nsGenericHTMLElement*>(aObject), |
825 | 0 | "Multiple inheritance for nsGenericHTMLElement is broken."); |
826 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
827 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
828 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
829 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
830 | 0 | reinterpret_cast<nsINode*>(aObject), |
831 | 0 | "Multiple inheritance for nsINode is broken."); |
832 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
833 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
834 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
835 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
836 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
837 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
838 | 0 | "You should probably not be using Wrap() directly; use " |
839 | 0 | "GetOrCreateDOMReflector instead"); |
840 | 0 |
|
841 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
842 | 0 | "nsISupports must be on our primary inheritance chain"); |
843 | 0 |
|
844 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
845 | 0 | if (!global) { |
846 | 0 | return false; |
847 | 0 | } |
848 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
849 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
850 | 0 |
|
851 | 0 | // That might have ended up wrapping us already, due to the wonders |
852 | 0 | // of XBL. Check for that, and bail out as needed. |
853 | 0 | aReflector.set(aCache->GetWrapper()); |
854 | 0 | if (aReflector) { |
855 | | #ifdef DEBUG |
856 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
857 | | #endif // DEBUG |
858 | | return true; |
859 | 0 | } |
860 | 0 |
|
861 | 0 | JSAutoRealm ar(aCx, global); |
862 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
863 | 0 | if (!canonicalProto) { |
864 | 0 | return false; |
865 | 0 | } |
866 | 0 | JS::Rooted<JSObject*> proto(aCx); |
867 | 0 | if (aGivenProto) { |
868 | 0 | proto = aGivenProto; |
869 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
870 | 0 | // coming in, we changed compartments to that of "parent" so may need |
871 | 0 | // to wrap the proto here. |
872 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
873 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
874 | 0 | return false; |
875 | 0 | } |
876 | 0 | } |
877 | 0 | } else { |
878 | 0 | proto = canonicalProto; |
879 | 0 | } |
880 | 0 |
|
881 | 0 | BindingJSObjectCreator<mozilla::dom::HTMLOptionElement> creator(aCx); |
882 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
883 | 0 | if (!aReflector) { |
884 | 0 | return false; |
885 | 0 | } |
886 | 0 | |
887 | 0 | aCache->SetWrapper(aReflector); |
888 | 0 | creator.InitializationSucceeded(); |
889 | 0 |
|
890 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
891 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
892 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
893 | 0 | // otherwise we won't be able to properly recreate it later, since |
894 | 0 | // we won't know what proto to use. Note that we don't check |
895 | 0 | // aGivenProto here, since it's entirely possible (and even |
896 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
897 | 0 | // same as canonicalProto. |
898 | 0 | if (proto != canonicalProto) { |
899 | 0 | PreserveWrapper(aObject); |
900 | 0 | } |
901 | 0 |
|
902 | 0 | return true; |
903 | 0 | } |
904 | | |
905 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
906 | | nullptr, |
907 | | nullptr, |
908 | | nullptr, |
909 | | { sNativeProperties.Upcast(), nullptr }, |
910 | | prototypes::id::HTMLOptionElement, |
911 | | constructors::id::HTMLOptionElement, |
912 | | HTMLElement_Binding::sNativePropertyHooks, |
913 | | &DefaultXrayExpandoObjectClass |
914 | | } }; |
915 | | |
916 | | void |
917 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
918 | 0 | { |
919 | 0 | JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx)); |
920 | 0 | if (!parentProto) { |
921 | 0 | return; |
922 | 0 | } |
923 | 0 | |
924 | 0 | JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx)); |
925 | 0 | if (!constructorProto) { |
926 | 0 | return; |
927 | 0 | } |
928 | 0 | |
929 | 0 | static bool sIdsInited = false; |
930 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
931 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
932 | 0 | return; |
933 | 0 | } |
934 | 0 | sIdsInited = true; |
935 | 0 | } |
936 | 0 |
|
937 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLOptionElement); |
938 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLOptionElement); |
939 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
940 | 0 | &sPrototypeClass.mBase, protoCache, |
941 | 0 | nullptr, |
942 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, namedConstructors, |
943 | 0 | interfaceCache, |
944 | 0 | sNativeProperties.Upcast(), |
945 | 0 | nullptr, |
946 | 0 | "HTMLOptionElement", aDefineOnGlobal, |
947 | 0 | nullptr, |
948 | 0 | false); |
949 | 0 | } |
950 | | |
951 | | JSObject* |
952 | | GetConstructorObject(JSContext* aCx) |
953 | 0 | { |
954 | 0 | return GetConstructorObjectHandle(aCx); |
955 | 0 | } |
956 | | |
957 | | } // namespace HTMLOptionElement_Binding |
958 | | |
959 | | |
960 | | |
961 | | } // namespace dom |
962 | | } // namespace mozilla |