Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM HTMLOutputElement.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "HTMLElementBinding.h"
4 : #include "HTMLOutputElementBinding.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/HTMLFormElement.h"
11 : #include "mozilla/dom/HTMLOutputElement.h"
12 : #include "mozilla/dom/NonRefcountedDOMObject.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/PrimitiveConversions.h"
15 : #include "mozilla/dom/ValidityState.h"
16 : #include "mozilla/dom/XrayExpandoClass.h"
17 : #include "nsDOMTokenList.h"
18 : #include "nsINodeList.h"
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : namespace HTMLOutputElementBinding {
24 :
25 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
26 : "Can't inherit from an interface with a different ownership model.");
27 :
28 : static bool
29 0 : get_htmlFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
30 : {
31 0 : auto result(StrongOrRawPtr<nsDOMTokenList>(self->HtmlFor()));
32 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
33 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
34 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
35 0 : return false;
36 : }
37 0 : return true;
38 : }
39 :
40 : static bool
41 0 : set_htmlFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitSetterCallArgs args)
42 : {
43 0 : JS::Rooted<JS::Value> v(cx);
44 0 : if (!JS_GetProperty(cx, obj, "htmlFor", &v)) {
45 0 : return false;
46 : }
47 :
48 0 : if (!v.isObject()) {
49 0 : return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "HTMLOutputElement.htmlFor");
50 : }
51 :
52 0 : JS::Rooted<JSObject*> targetObj(cx, &v.toObject());
53 0 : return JS_SetProperty(cx, targetObj, "value", args[0]);
54 : }
55 :
56 : static const JSJitInfo htmlFor_getterinfo = {
57 : { (JSJitGetterOp)get_htmlFor },
58 : { prototypes::id::HTMLOutputElement },
59 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
60 : JSJitInfo::Getter,
61 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
62 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
63 : false, /* isInfallible. False in setters. */
64 : true, /* isMovable. Not relevant for setters. */
65 : true, /* isEliminatable. Not relevant for setters. */
66 : false, /* isAlwaysInSlot. Only relevant for getters. */
67 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
68 : false, /* isTypedMethod. Only relevant for methods. */
69 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
70 : };
71 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
72 : static_assert(0 < 1, "There is no slot for us");
73 : static const JSJitInfo htmlFor_setterinfo = {
74 : { (JSJitGetterOp)set_htmlFor },
75 : { prototypes::id::HTMLOutputElement },
76 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
77 : JSJitInfo::Setter,
78 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
79 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
80 : false, /* isInfallible. False in setters. */
81 : false, /* isMovable. Not relevant for setters. */
82 : false, /* isEliminatable. Not relevant for setters. */
83 : false, /* isAlwaysInSlot. Only relevant for getters. */
84 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
85 : false, /* isTypedMethod. Only relevant for methods. */
86 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
87 : };
88 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
89 : static_assert(0 < 1, "There is no slot for us");
90 :
91 : static bool
92 0 : get_form(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
93 : {
94 0 : auto result(StrongOrRawPtr<mozilla::dom::HTMLFormElement>(self->GetForm()));
95 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
96 0 : if (!result) {
97 0 : args.rval().setNull();
98 0 : return true;
99 : }
100 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
101 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
102 0 : return false;
103 : }
104 0 : return true;
105 : }
106 :
107 : static const JSJitInfo form_getterinfo = {
108 : { (JSJitGetterOp)get_form },
109 : { prototypes::id::HTMLOutputElement },
110 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
111 : JSJitInfo::Getter,
112 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
113 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
114 : false, /* isInfallible. False in setters. */
115 : false, /* isMovable. Not relevant for setters. */
116 : false, /* isEliminatable. Not relevant for setters. */
117 : false, /* isAlwaysInSlot. Only relevant for getters. */
118 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
119 : false, /* isTypedMethod. Only relevant for methods. */
120 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
121 : };
122 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
123 : static_assert(0 < 1, "There is no slot for us");
124 :
125 : static bool
126 0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
127 : {
128 0 : DOMString result;
129 0 : self->GetName(result);
130 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
131 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
132 0 : return false;
133 : }
134 0 : return true;
135 : }
136 :
137 : static bool
138 0 : set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitSetterCallArgs args)
139 : {
140 0 : binding_detail::FakeString arg0;
141 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
142 0 : return false;
143 : }
144 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
145 0 : Maybe<AutoCEReaction> ceReaction;
146 0 : if (reactionsStack) {
147 0 : ceReaction.emplace(reactionsStack);
148 : }
149 0 : binding_detail::FastErrorResult rv;
150 0 : self->SetName(NonNullHelper(Constify(arg0)), rv);
151 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
152 0 : return false;
153 : }
154 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
155 :
156 0 : return true;
157 : }
158 :
159 : static const JSJitInfo name_getterinfo = {
160 : { (JSJitGetterOp)get_name },
161 : { prototypes::id::HTMLOutputElement },
162 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
163 : JSJitInfo::Getter,
164 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
165 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
166 : false, /* isInfallible. False in setters. */
167 : true, /* isMovable. Not relevant for setters. */
168 : true, /* isEliminatable. Not relevant for setters. */
169 : false, /* isAlwaysInSlot. Only relevant for getters. */
170 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
171 : false, /* isTypedMethod. Only relevant for methods. */
172 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
173 : };
174 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
175 : static_assert(0 < 1, "There is no slot for us");
176 : static const JSJitInfo name_setterinfo = {
177 : { (JSJitGetterOp)set_name },
178 : { prototypes::id::HTMLOutputElement },
179 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
180 : JSJitInfo::Setter,
181 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
182 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
183 : false, /* isInfallible. False in setters. */
184 : false, /* isMovable. Not relevant for setters. */
185 : false, /* isEliminatable. Not relevant for setters. */
186 : false, /* isAlwaysInSlot. Only relevant for getters. */
187 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
188 : false, /* isTypedMethod. Only relevant for methods. */
189 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
190 : };
191 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
192 : static_assert(0 < 1, "There is no slot for us");
193 :
194 : static bool
195 0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
196 : {
197 0 : DOMString result;
198 0 : self->GetType(result);
199 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
200 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
201 0 : return false;
202 : }
203 0 : return true;
204 : }
205 :
206 : static const JSJitInfo type_getterinfo = {
207 : { (JSJitGetterOp)get_type },
208 : { prototypes::id::HTMLOutputElement },
209 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
210 : JSJitInfo::Getter,
211 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
212 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
213 : false, /* isInfallible. False in setters. */
214 : true, /* isMovable. Not relevant for setters. */
215 : true, /* isEliminatable. Not relevant for setters. */
216 : false, /* isAlwaysInSlot. Only relevant for getters. */
217 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
218 : false, /* isTypedMethod. Only relevant for methods. */
219 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
220 : };
221 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
222 : static_assert(0 < 1, "There is no slot for us");
223 :
224 : static bool
225 0 : get_defaultValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
226 : {
227 0 : DOMString result;
228 0 : self->GetDefaultValue(result);
229 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
230 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
231 0 : return false;
232 : }
233 0 : return true;
234 : }
235 :
236 : static bool
237 0 : set_defaultValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitSetterCallArgs args)
238 : {
239 0 : binding_detail::FakeString arg0;
240 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
241 0 : return false;
242 : }
243 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
244 0 : Maybe<AutoCEReaction> ceReaction;
245 0 : if (reactionsStack) {
246 0 : ceReaction.emplace(reactionsStack);
247 : }
248 0 : binding_detail::FastErrorResult rv;
249 0 : self->SetDefaultValue(NonNullHelper(Constify(arg0)), rv);
250 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
251 0 : return false;
252 : }
253 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
254 :
255 0 : return true;
256 : }
257 :
258 : static const JSJitInfo defaultValue_getterinfo = {
259 : { (JSJitGetterOp)get_defaultValue },
260 : { prototypes::id::HTMLOutputElement },
261 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
262 : JSJitInfo::Getter,
263 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
264 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
265 : false, /* isInfallible. False in setters. */
266 : true, /* isMovable. Not relevant for setters. */
267 : true, /* isEliminatable. Not relevant for setters. */
268 : false, /* isAlwaysInSlot. Only relevant for getters. */
269 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
270 : false, /* isTypedMethod. Only relevant for methods. */
271 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
272 : };
273 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
274 : static_assert(0 < 1, "There is no slot for us");
275 : static const JSJitInfo defaultValue_setterinfo = {
276 : { (JSJitGetterOp)set_defaultValue },
277 : { prototypes::id::HTMLOutputElement },
278 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
279 : JSJitInfo::Setter,
280 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
281 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
282 : false, /* isInfallible. False in setters. */
283 : false, /* isMovable. Not relevant for setters. */
284 : false, /* isEliminatable. Not relevant for setters. */
285 : false, /* isAlwaysInSlot. Only relevant for getters. */
286 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
287 : false, /* isTypedMethod. Only relevant for methods. */
288 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
289 : };
290 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
291 : static_assert(0 < 1, "There is no slot for us");
292 :
293 : static bool
294 0 : get_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
295 : {
296 0 : DOMString result;
297 0 : self->GetValue(result);
298 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
299 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
300 0 : return false;
301 : }
302 0 : return true;
303 : }
304 :
305 : static bool
306 0 : set_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitSetterCallArgs args)
307 : {
308 0 : binding_detail::FakeString arg0;
309 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
310 0 : return false;
311 : }
312 0 : CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
313 0 : Maybe<AutoCEReaction> ceReaction;
314 0 : if (reactionsStack) {
315 0 : ceReaction.emplace(reactionsStack);
316 : }
317 0 : binding_detail::FastErrorResult rv;
318 0 : self->SetValue(NonNullHelper(Constify(arg0)), rv);
319 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
320 0 : return false;
321 : }
322 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
323 :
324 0 : return true;
325 : }
326 :
327 : static const JSJitInfo value_getterinfo = {
328 : { (JSJitGetterOp)get_value },
329 : { prototypes::id::HTMLOutputElement },
330 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
331 : JSJitInfo::Getter,
332 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
333 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
334 : false, /* isInfallible. False in setters. */
335 : true, /* isMovable. Not relevant for setters. */
336 : true, /* isEliminatable. Not relevant for setters. */
337 : false, /* isAlwaysInSlot. Only relevant for getters. */
338 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
339 : false, /* isTypedMethod. Only relevant for methods. */
340 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
341 : };
342 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
343 : static_assert(0 < 1, "There is no slot for us");
344 : static const JSJitInfo value_setterinfo = {
345 : { (JSJitGetterOp)set_value },
346 : { prototypes::id::HTMLOutputElement },
347 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
348 : JSJitInfo::Setter,
349 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
350 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
351 : false, /* isInfallible. False in setters. */
352 : false, /* isMovable. Not relevant for setters. */
353 : false, /* isEliminatable. Not relevant for setters. */
354 : false, /* isAlwaysInSlot. Only relevant for getters. */
355 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
356 : false, /* isTypedMethod. Only relevant for methods. */
357 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
358 : };
359 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
360 : static_assert(0 < 1, "There is no slot for us");
361 :
362 : static bool
363 0 : get_willValidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
364 : {
365 0 : bool result(self->WillValidate());
366 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
367 0 : args.rval().setBoolean(result);
368 0 : return true;
369 : }
370 :
371 : static const JSJitInfo willValidate_getterinfo = {
372 : { (JSJitGetterOp)get_willValidate },
373 : { prototypes::id::HTMLOutputElement },
374 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
375 : JSJitInfo::Getter,
376 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
377 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
378 : true, /* isInfallible. False in setters. */
379 : false, /* isMovable. Not relevant for setters. */
380 : false, /* isEliminatable. Not relevant for setters. */
381 : false, /* isAlwaysInSlot. Only relevant for getters. */
382 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
383 : false, /* isTypedMethod. Only relevant for methods. */
384 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
385 : };
386 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
387 : static_assert(0 < 1, "There is no slot for us");
388 :
389 : static bool
390 0 : get_validity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
391 : {
392 0 : auto result(StrongOrRawPtr<mozilla::dom::ValidityState>(self->Validity()));
393 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
394 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
395 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
396 0 : return false;
397 : }
398 0 : return true;
399 : }
400 :
401 : static const JSJitInfo validity_getterinfo = {
402 : { (JSJitGetterOp)get_validity },
403 : { prototypes::id::HTMLOutputElement },
404 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
405 : JSJitInfo::Getter,
406 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
407 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
408 : false, /* isInfallible. False in setters. */
409 : false, /* isMovable. Not relevant for setters. */
410 : false, /* isEliminatable. Not relevant for setters. */
411 : false, /* isAlwaysInSlot. Only relevant for getters. */
412 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
413 : false, /* isTypedMethod. Only relevant for methods. */
414 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
415 : };
416 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
417 : static_assert(0 < 1, "There is no slot for us");
418 :
419 : static bool
420 0 : get_validationMessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
421 : {
422 0 : DOMString result;
423 0 : self->GetValidationMessage(result);
424 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
425 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
426 0 : return false;
427 : }
428 0 : return true;
429 : }
430 :
431 : static const JSJitInfo validationMessage_getterinfo = {
432 : { (JSJitGetterOp)get_validationMessage },
433 : { prototypes::id::HTMLOutputElement },
434 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
435 : JSJitInfo::Getter,
436 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
437 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
438 : false, /* isInfallible. False in setters. */
439 : false, /* isMovable. Not relevant for setters. */
440 : false, /* isEliminatable. Not relevant for setters. */
441 : false, /* isAlwaysInSlot. Only relevant for getters. */
442 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
443 : false, /* isTypedMethod. Only relevant for methods. */
444 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
445 : };
446 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
447 : static_assert(0 < 1, "There is no slot for us");
448 :
449 : static bool
450 0 : checkValidity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, const JSJitMethodCallArgs& args)
451 : {
452 0 : bool result(self->CheckValidity());
453 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
454 0 : args.rval().setBoolean(result);
455 0 : return true;
456 : }
457 :
458 : static const JSJitInfo checkValidity_methodinfo = {
459 : { (JSJitGetterOp)checkValidity },
460 : { prototypes::id::HTMLOutputElement },
461 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
462 : JSJitInfo::Method,
463 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
464 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
465 : true, /* isInfallible. False in setters. */
466 : false, /* isMovable. Not relevant for setters. */
467 : false, /* isEliminatable. Not relevant for setters. */
468 : false, /* isAlwaysInSlot. Only relevant for getters. */
469 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
470 : false, /* isTypedMethod. Only relevant for methods. */
471 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
472 : };
473 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
474 : static_assert(0 < 1, "There is no slot for us");
475 :
476 : static bool
477 0 : reportValidity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, const JSJitMethodCallArgs& args)
478 : {
479 0 : bool result(self->ReportValidity());
480 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
481 0 : args.rval().setBoolean(result);
482 0 : return true;
483 : }
484 :
485 : static const JSJitInfo reportValidity_methodinfo = {
486 : { (JSJitGetterOp)reportValidity },
487 : { prototypes::id::HTMLOutputElement },
488 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
489 : JSJitInfo::Method,
490 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
491 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
492 : true, /* isInfallible. False in setters. */
493 : false, /* isMovable. Not relevant for setters. */
494 : false, /* isEliminatable. Not relevant for setters. */
495 : false, /* isAlwaysInSlot. Only relevant for getters. */
496 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
497 : false, /* isTypedMethod. Only relevant for methods. */
498 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
499 : };
500 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
501 : static_assert(0 < 1, "There is no slot for us");
502 :
503 : static bool
504 0 : setCustomValidity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, const JSJitMethodCallArgs& args)
505 : {
506 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
507 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "HTMLOutputElement.setCustomValidity");
508 : }
509 0 : binding_detail::FakeString arg0;
510 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
511 0 : return false;
512 : }
513 0 : self->SetCustomValidity(NonNullHelper(Constify(arg0)));
514 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
515 0 : args.rval().setUndefined();
516 0 : return true;
517 : }
518 :
519 : static const JSJitInfo setCustomValidity_methodinfo = {
520 : { (JSJitGetterOp)setCustomValidity },
521 : { prototypes::id::HTMLOutputElement },
522 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
523 : JSJitInfo::Method,
524 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
525 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
526 : false, /* isInfallible. False in setters. */
527 : false, /* isMovable. Not relevant for setters. */
528 : false, /* isEliminatable. Not relevant for setters. */
529 : false, /* isAlwaysInSlot. Only relevant for getters. */
530 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
531 : false, /* isTypedMethod. Only relevant for methods. */
532 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
533 : };
534 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
535 : static_assert(0 < 1, "There is no slot for us");
536 :
537 : static bool
538 0 : get_labels(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLOutputElement* self, JSJitGetterCallArgs args)
539 : {
540 0 : auto result(StrongOrRawPtr<nsINodeList>(self->Labels()));
541 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
542 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
543 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
544 0 : return false;
545 : }
546 0 : return true;
547 : }
548 :
549 : static const JSJitInfo labels_getterinfo = {
550 : { (JSJitGetterOp)get_labels },
551 : { prototypes::id::HTMLOutputElement },
552 : { PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth },
553 : JSJitInfo::Getter,
554 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
555 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
556 : false, /* isInfallible. False in setters. */
557 : false, /* isMovable. Not relevant for setters. */
558 : false, /* isEliminatable. Not relevant for setters. */
559 : false, /* isAlwaysInSlot. Only relevant for getters. */
560 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
561 : false, /* isTypedMethod. Only relevant for methods. */
562 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
563 : };
564 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
565 : static_assert(0 < 1, "There is no slot for us");
566 :
567 : static bool
568 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
569 : {
570 0 : mozilla::dom::HTMLOutputElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLOutputElement>(obj);
571 : // We don't want to preserve if we don't have a wrapper, and we
572 : // obviously can't preserve if we're not initialized.
573 0 : if (self && self->GetWrapperPreserveColor()) {
574 0 : PreserveWrapper(self);
575 : }
576 0 : return true;
577 : }
578 :
579 : static void
580 0 : _finalize(js::FreeOp* fop, JSObject* obj)
581 : {
582 0 : mozilla::dom::HTMLOutputElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLOutputElement>(obj);
583 0 : if (self) {
584 0 : ClearWrapper(self, self, obj);
585 0 : AddForDeferredFinalization<mozilla::dom::HTMLOutputElement>(self);
586 : }
587 0 : }
588 :
589 : static void
590 0 : _objectMoved(JSObject* obj, const JSObject* old)
591 : {
592 0 : mozilla::dom::HTMLOutputElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLOutputElement>(obj);
593 0 : if (self) {
594 0 : UpdateWrapper(self, self, obj, old);
595 : }
596 0 : }
597 :
598 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
599 : #if defined(__clang__)
600 : #pragma clang diagnostic push
601 : #pragma clang diagnostic ignored "-Wmissing-braces"
602 : #endif
603 : static const JSFunctionSpec sMethods_specs[] = {
604 : JS_FNSPEC("checkValidity", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&checkValidity_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
605 : JS_FNSPEC("reportValidity", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&reportValidity_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
606 : JS_FNSPEC("setCustomValidity", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setCustomValidity_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
607 : JS_FS_END
608 : };
609 : #if defined(__clang__)
610 : #pragma clang diagnostic pop
611 : #endif
612 :
613 :
614 : // Can't be const because the pref-enabled boolean needs to be writable
615 : static Prefable<const JSFunctionSpec> sMethods[] = {
616 : { nullptr, &sMethods_specs[0] },
617 : { nullptr, nullptr }
618 : };
619 :
620 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
621 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
622 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
623 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
624 :
625 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
626 : #if defined(__clang__)
627 : #pragma clang diagnostic push
628 : #pragma clang diagnostic ignored "-Wmissing-braces"
629 : #endif
630 : static const JSPropertySpec sAttributes_specs[] = {
631 : { "htmlFor", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &htmlFor_getterinfo, GenericBindingSetter, &htmlFor_setterinfo },
632 : { "form", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &form_getterinfo, nullptr, nullptr },
633 : { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, GenericBindingSetter, &name_setterinfo },
634 : { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
635 : { "defaultValue", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &defaultValue_getterinfo, GenericBindingSetter, &defaultValue_setterinfo },
636 : { "value", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &value_getterinfo, GenericBindingSetter, &value_setterinfo },
637 : { "willValidate", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &willValidate_getterinfo, nullptr, nullptr },
638 : { "validity", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &validity_getterinfo, nullptr, nullptr },
639 : { "validationMessage", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &validationMessage_getterinfo, nullptr, nullptr },
640 : { "labels", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &labels_getterinfo, nullptr, nullptr },
641 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
642 : };
643 : #if defined(__clang__)
644 : #pragma clang diagnostic pop
645 : #endif
646 :
647 :
648 : // Can't be const because the pref-enabled boolean needs to be writable
649 : static Prefable<const JSPropertySpec> sAttributes[] = {
650 : { nullptr, &sAttributes_specs[0] },
651 : { nullptr, nullptr }
652 : };
653 :
654 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
655 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
656 : static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
657 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
658 :
659 :
660 : static uint16_t sNativeProperties_sortedPropertyIndices[13];
661 : static PropertyInfo sNativeProperties_propertyInfos[13];
662 :
663 : static const NativePropertiesN<2> sNativeProperties = {
664 : false, 0,
665 : false, 0,
666 : true, 0 /* sMethods */,
667 : true, 1 /* sAttributes */,
668 : false, 0,
669 : false, 0,
670 : false, 0,
671 : -1,
672 : 13,
673 : sNativeProperties_sortedPropertyIndices,
674 : {
675 : { sMethods, &sNativeProperties_propertyInfos[0] },
676 : { sAttributes, &sNativeProperties_propertyInfos[3] }
677 : }
678 : };
679 : static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
680 : "We have a property info count that is oversized");
681 :
682 : static bool
683 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
684 : {
685 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
686 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
687 0 : if (!args.isConstructing()) {
688 : // XXXbz wish I could get the name from the callee instead of
689 : // Adding more relocations
690 0 : return ThrowConstructorWithoutNew(cx, "HTMLOutputElement");
691 : }
692 :
693 0 : GlobalObject global(cx, obj);
694 0 : if (global.Failed()) {
695 0 : return false;
696 : }
697 :
698 : // The newTarget might be a cross-compartment wrapper. Get the underlying object
699 : // so we can do the spec's object-identity checks.
700 0 : JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
701 0 : if (!newTarget) {
702 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
703 : }
704 :
705 : // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
706 : // Enter the compartment of our underlying newTarget object, so we end
707 : // up comparing to the constructor object for our interface from that global.
708 : {
709 0 : JSAutoCompartment ac(cx, newTarget);
710 0 : JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
711 0 : if (!constructor) {
712 0 : return false;
713 : }
714 0 : if (newTarget == constructor) {
715 0 : return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
716 : }
717 : }
718 :
719 0 : JS::Rooted<JSObject*> desiredProto(cx);
720 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
721 0 : return false;
722 : }
723 0 : if (!desiredProto) {
724 : // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
725 : // This fallback behavior is designed to match analogous behavior for the
726 : // JavaScript built-ins. So we enter the compartment of our underlying
727 : // newTarget object and fall back to the prototype object from that global.
728 : // XXX The spec says to use GetFunctionRealm(), which is not actually
729 : // the same thing as what we have here (e.g. in the case of scripted callable proxies
730 : // whose target is not same-compartment with the proxy, or bound functions, etc).
731 : // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
732 : {
733 0 : JSAutoCompartment ac(cx, newTarget);
734 0 : desiredProto = GetProtoObjectHandle(cx);
735 0 : if (!desiredProto) {
736 0 : return false;
737 : }
738 : }
739 :
740 : // desiredProto is in the compartment of the underlying newTarget object.
741 : // Wrap it into the context compartment.
742 0 : if (!JS_WrapObject(cx, &desiredProto)) {
743 0 : return false;
744 : }
745 : }
746 :
747 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
748 0 : Maybe<JSAutoCompartment> ac;
749 0 : if (objIsXray) {
750 0 : obj = js::CheckedUnwrap(obj);
751 0 : if (!obj) {
752 0 : return false;
753 : }
754 0 : ac.emplace(cx, obj);
755 0 : if (!JS_WrapObject(cx, &desiredProto)) {
756 0 : return false;
757 : }
758 : }
759 0 : binding_detail::FastErrorResult rv;
760 0 : auto result(StrongOrRawPtr<mozilla::dom::HTMLOutputElement>(CreateHTMLElement(global, args, rv)));
761 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
762 0 : return false;
763 : }
764 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
765 : static_assert(!IsPointer<decltype(result)>::value,
766 : "NewObject implies that we need to keep the object alive with a strong reference.");
767 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
768 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
769 0 : return false;
770 : }
771 0 : return true;
772 : }
773 :
774 : static const js::ClassOps sInterfaceObjectClassOps = {
775 : nullptr, /* addProperty */
776 : nullptr, /* delProperty */
777 : nullptr, /* getProperty */
778 : nullptr, /* setProperty */
779 : nullptr, /* enumerate */
780 : nullptr, /* newEnumerate */
781 : nullptr, /* resolve */
782 : nullptr, /* mayResolve */
783 : nullptr, /* finalize */
784 : _constructor, /* call */
785 : nullptr, /* hasInstance */
786 : _constructor, /* construct */
787 : nullptr, /* trace */
788 : };
789 :
790 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
791 : {
792 : "Function",
793 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
794 : &sInterfaceObjectClassOps,
795 : JS_NULL_CLASS_SPEC,
796 : JS_NULL_CLASS_EXT,
797 : &sInterfaceObjectClassObjectOps
798 : },
799 : eInterface,
800 : true,
801 : prototypes::id::HTMLOutputElement,
802 : PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth,
803 : sNativePropertyHooks,
804 : "function HTMLOutputElement() {\n [native code]\n}",
805 : HTMLElementBinding::GetConstructorObject
806 : };
807 :
808 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
809 : {
810 : "HTMLOutputElementPrototype",
811 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
812 : JS_NULL_CLASS_OPS,
813 : JS_NULL_CLASS_SPEC,
814 : JS_NULL_CLASS_EXT,
815 : JS_NULL_OBJECT_OPS
816 : },
817 : eInterfacePrototype,
818 : false,
819 : prototypes::id::HTMLOutputElement,
820 : PrototypeTraits<prototypes::id::HTMLOutputElement>::Depth,
821 : sNativePropertyHooks,
822 : "[object HTMLOutputElementPrototype]",
823 : HTMLElementBinding::GetProtoObject
824 : };
825 :
826 : JSObject*
827 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
828 : {
829 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
830 : }
831 :
832 : static const js::ClassOps sClassOps = {
833 : _addProperty, /* addProperty */
834 : nullptr, /* delProperty */
835 : nullptr, /* getProperty */
836 : nullptr, /* setProperty */
837 : nullptr, /* enumerate */
838 : nullptr, /* newEnumerate */
839 : nullptr, /* resolve */
840 : nullptr, /* mayResolve */
841 : _finalize, /* finalize */
842 : nullptr, /* call */
843 : nullptr, /* hasInstance */
844 : nullptr, /* construct */
845 : nullptr, /* trace */
846 : };
847 :
848 : static const js::ClassExtension sClassExtension = {
849 : nullptr, /* weakmapKeyDelegateOp */
850 : _objectMoved /* objectMovedOp */
851 : };
852 :
853 : static const DOMJSClass sClass = {
854 : { "HTMLOutputElement",
855 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
856 : &sClassOps,
857 : JS_NULL_CLASS_SPEC,
858 : &sClassExtension,
859 : JS_NULL_OBJECT_OPS
860 : },
861 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLOutputElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
862 : IsBaseOf<nsISupports, mozilla::dom::HTMLOutputElement >::value,
863 : sNativePropertyHooks,
864 : FindAssociatedGlobalForNative<mozilla::dom::HTMLOutputElement>::Get,
865 : GetProtoObjectHandle,
866 : GetCCParticipant<mozilla::dom::HTMLOutputElement>::Get()
867 : };
868 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
869 : "Must have the right minimal number of reserved slots.");
870 : static_assert(1 >= 1,
871 : "Must have enough reserved slots.");
872 :
873 : const JSClass*
874 0 : GetJSClass()
875 : {
876 0 : return sClass.ToJSClass();
877 : }
878 :
879 : bool
880 0 : Wrap(JSContext* aCx, mozilla::dom::HTMLOutputElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
881 : {
882 : MOZ_ASSERT(static_cast<mozilla::dom::HTMLOutputElement*>(aObject) ==
883 : reinterpret_cast<mozilla::dom::HTMLOutputElement*>(aObject),
884 : "Multiple inheritance for mozilla::dom::HTMLOutputElement is broken.");
885 : MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
886 : reinterpret_cast<nsGenericHTMLElement*>(aObject),
887 : "Multiple inheritance for nsGenericHTMLElement is broken.");
888 : MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
889 : reinterpret_cast<mozilla::dom::Element*>(aObject),
890 : "Multiple inheritance for mozilla::dom::Element is broken.");
891 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
892 : reinterpret_cast<nsINode*>(aObject),
893 : "Multiple inheritance for nsINode is broken.");
894 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
895 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
896 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
897 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
898 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
899 0 : MOZ_ASSERT(!aCache->GetWrapper(),
900 : "You should probably not be using Wrap() directly; use "
901 : "GetOrCreateDOMReflector instead");
902 :
903 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
904 : "nsISupports must be on our primary inheritance chain");
905 :
906 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
907 0 : if (!global) {
908 0 : return false;
909 : }
910 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
911 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
912 :
913 : // That might have ended up wrapping us already, due to the wonders
914 : // of XBL. Check for that, and bail out as needed.
915 0 : aReflector.set(aCache->GetWrapper());
916 0 : if (aReflector) {
917 : #ifdef DEBUG
918 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
919 : #endif // DEBUG
920 0 : return true;
921 : }
922 :
923 0 : JSAutoCompartment ac(aCx, global);
924 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
925 0 : if (!canonicalProto) {
926 0 : return false;
927 : }
928 0 : JS::Rooted<JSObject*> proto(aCx);
929 0 : if (aGivenProto) {
930 0 : proto = aGivenProto;
931 : // Unfortunately, while aGivenProto was in the compartment of aCx
932 : // coming in, we changed compartments to that of "parent" so may need
933 : // to wrap the proto here.
934 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
935 0 : if (!JS_WrapObject(aCx, &proto)) {
936 0 : return false;
937 : }
938 : }
939 : } else {
940 0 : proto = canonicalProto;
941 : }
942 :
943 0 : BindingJSObjectCreator<mozilla::dom::HTMLOutputElement> creator(aCx);
944 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
945 0 : if (!aReflector) {
946 0 : return false;
947 : }
948 :
949 0 : aCache->SetWrapper(aReflector);
950 0 : creator.InitializationSucceeded();
951 :
952 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
953 : aCache->GetWrapperPreserveColor() == aReflector);
954 : // If proto != canonicalProto, we have to preserve our wrapper;
955 : // otherwise we won't be able to properly recreate it later, since
956 : // we won't know what proto to use. Note that we don't check
957 : // aGivenProto here, since it's entirely possible (and even
958 : // somewhat common) to have a non-null aGivenProto which is the
959 : // same as canonicalProto.
960 0 : if (proto != canonicalProto) {
961 0 : PreserveWrapper(aObject);
962 : }
963 :
964 0 : return true;
965 : }
966 :
967 : const NativePropertyHooks sNativePropertyHooks[] = { {
968 : nullptr,
969 : nullptr,
970 : nullptr,
971 : { sNativeProperties.Upcast(), nullptr },
972 : prototypes::id::HTMLOutputElement,
973 : constructors::id::HTMLOutputElement,
974 : HTMLElementBinding::sNativePropertyHooks,
975 : &DefaultXrayExpandoObjectClass
976 : } };
977 :
978 : void
979 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
980 : {
981 0 : JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
982 0 : if (!parentProto) {
983 0 : return;
984 : }
985 :
986 0 : JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
987 0 : if (!constructorProto) {
988 0 : return;
989 : }
990 :
991 : static bool sIdsInited = false;
992 0 : if (!sIdsInited && NS_IsMainThread()) {
993 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
994 0 : return;
995 : }
996 0 : sIdsInited = true;
997 : }
998 :
999 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLOutputElement);
1000 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLOutputElement);
1001 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1002 : &sPrototypeClass.mBase, protoCache,
1003 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1004 : interfaceCache,
1005 : sNativeProperties.Upcast(),
1006 : nullptr,
1007 : "HTMLOutputElement", aDefineOnGlobal,
1008 : nullptr,
1009 0 : false);
1010 : }
1011 :
1012 : JS::Handle<JSObject*>
1013 0 : GetProtoObjectHandle(JSContext* aCx)
1014 : {
1015 : /* Get the interface prototype object for this class. This will create the
1016 : object as needed. */
1017 0 : bool aDefineOnGlobal = true;
1018 :
1019 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1020 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1021 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1022 0 : return nullptr;
1023 : }
1024 :
1025 : /* Check to see whether the interface objects are already installed */
1026 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1027 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLOutputElement)) {
1028 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1029 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1030 : }
1031 :
1032 : /*
1033 : * The object might _still_ be null, but that's OK.
1034 : *
1035 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1036 : * traced by TraceProtoAndIfaceCache() and its contents are never
1037 : * changed after they have been set.
1038 : *
1039 : * Calling address() avoids the read read barrier that does gray
1040 : * unmarking, but it's not possible for the object to be gray here.
1041 : */
1042 :
1043 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLOutputElement);
1044 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1045 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1046 : }
1047 :
1048 : JS::Handle<JSObject*>
1049 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1050 : {
1051 : /* Get the interface object for this class. This will create the object as
1052 : needed. */
1053 :
1054 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1055 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1056 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1057 0 : return nullptr;
1058 : }
1059 :
1060 : /* Check to see whether the interface objects are already installed */
1061 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1062 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLOutputElement)) {
1063 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1064 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1065 : }
1066 :
1067 : /*
1068 : * The object might _still_ be null, but that's OK.
1069 : *
1070 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1071 : * traced by TraceProtoAndIfaceCache() and its contents are never
1072 : * changed after they have been set.
1073 : *
1074 : * Calling address() avoids the read read barrier that does gray
1075 : * unmarking, but it's not possible for the object to be gray here.
1076 : */
1077 :
1078 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLOutputElement);
1079 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1080 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1081 : }
1082 :
1083 : JSObject*
1084 0 : GetConstructorObject(JSContext* aCx)
1085 : {
1086 0 : return GetConstructorObjectHandle(aCx);
1087 : }
1088 :
1089 : } // namespace HTMLOutputElementBinding
1090 :
1091 :
1092 :
1093 : } // namespace dom
1094 : } // namespace mozilla
|