Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM XULDocument.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "DocumentBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "XULDocument.h"
6 : #include "XULDocumentBinding.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/BoxObject.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/Element.h"
12 : #include "mozilla/dom/Location.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 : #include "nsContentUtils.h"
18 : #include "nsIDOMXULCommandDispatcher.h"
19 : #include "nsINode.h"
20 : #include "nsINodeList.h"
21 : #include "nsIObserver.h"
22 :
23 : namespace mozilla {
24 : namespace dom {
25 :
26 : namespace XULDocumentBinding {
27 :
28 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<DocumentBinding::NativeType>::value,
29 : "Can't inherit from an interface with a different ownership model.");
30 :
31 : static bool
32 3 : get_popupNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
33 : {
34 6 : auto result(StrongOrRawPtr<nsINode>(self->GetPopupNode()));
35 3 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
36 3 : if (!result) {
37 3 : args.rval().setNull();
38 3 : return true;
39 : }
40 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
41 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
42 0 : return false;
43 : }
44 0 : return true;
45 : }
46 :
47 : static bool
48 0 : set_popupNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitSetterCallArgs args)
49 : {
50 : nsINode* arg0;
51 0 : if (args[0].isObject()) {
52 : {
53 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
54 0 : if (NS_FAILED(rv)) {
55 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to XULDocument.popupNode", "Node");
56 0 : return false;
57 : }
58 : }
59 0 : } else if (args[0].isNullOrUndefined()) {
60 0 : arg0 = nullptr;
61 : } else {
62 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to XULDocument.popupNode");
63 0 : return false;
64 : }
65 0 : self->SetPopupNode(Constify(arg0));
66 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
67 :
68 0 : return true;
69 : }
70 :
71 : static const JSJitInfo popupNode_getterinfo = {
72 : { (JSJitGetterOp)get_popupNode },
73 : { prototypes::id::XULDocument },
74 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
75 : JSJitInfo::Getter,
76 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
77 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
78 : false, /* isInfallible. False in setters. */
79 : false, /* isMovable. Not relevant for setters. */
80 : false, /* isEliminatable. Not relevant for setters. */
81 : false, /* isAlwaysInSlot. Only relevant for getters. */
82 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
83 : false, /* isTypedMethod. Only relevant for methods. */
84 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
85 : };
86 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
87 : static_assert(0 < 1, "There is no slot for us");
88 : static const JSJitInfo popupNode_setterinfo = {
89 : { (JSJitGetterOp)set_popupNode },
90 : { prototypes::id::XULDocument },
91 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
92 : JSJitInfo::Setter,
93 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
94 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
95 : false, /* isInfallible. False in setters. */
96 : false, /* isMovable. Not relevant for setters. */
97 : false, /* isEliminatable. Not relevant for setters. */
98 : false, /* isAlwaysInSlot. Only relevant for getters. */
99 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
100 : false, /* isTypedMethod. Only relevant for methods. */
101 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
102 : };
103 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
104 : static_assert(0 < 1, "There is no slot for us");
105 :
106 : static bool
107 0 : get_popupRangeParent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
108 : {
109 0 : binding_detail::FastErrorResult rv;
110 0 : auto result(StrongOrRawPtr<nsINode>(self->GetPopupRangeParent(rv)));
111 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
112 0 : return false;
113 : }
114 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
115 0 : if (!result) {
116 0 : args.rval().setNull();
117 0 : return true;
118 : }
119 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
120 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
121 0 : return false;
122 : }
123 0 : return true;
124 : }
125 :
126 : static const JSJitInfo popupRangeParent_getterinfo = {
127 : { (JSJitGetterOp)get_popupRangeParent },
128 : { prototypes::id::XULDocument },
129 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
130 : JSJitInfo::Getter,
131 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
132 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
133 : false, /* isInfallible. False in setters. */
134 : false, /* isMovable. Not relevant for setters. */
135 : false, /* isEliminatable. Not relevant for setters. */
136 : false, /* isAlwaysInSlot. Only relevant for getters. */
137 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
138 : false, /* isTypedMethod. Only relevant for methods. */
139 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
140 : };
141 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
142 : static_assert(0 < 1, "There is no slot for us");
143 :
144 : static bool
145 0 : get_popupRangeOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
146 : {
147 0 : binding_detail::FastErrorResult rv;
148 0 : int32_t result(self->GetPopupRangeOffset(rv));
149 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
150 0 : return false;
151 : }
152 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
153 0 : args.rval().setInt32(int32_t(result));
154 0 : return true;
155 : }
156 :
157 : static const JSJitInfo popupRangeOffset_getterinfo = {
158 : { (JSJitGetterOp)get_popupRangeOffset },
159 : { prototypes::id::XULDocument },
160 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
161 : JSJitInfo::Getter,
162 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
163 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
164 : false, /* isInfallible. False in setters. */
165 : false, /* isMovable. Not relevant for setters. */
166 : false, /* isEliminatable. Not relevant for setters. */
167 : false, /* isAlwaysInSlot. Only relevant for getters. */
168 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
169 : false, /* isTypedMethod. Only relevant for methods. */
170 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
171 : };
172 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
173 : static_assert(0 < 1, "There is no slot for us");
174 :
175 : static bool
176 0 : get_tooltipNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
177 : {
178 0 : auto result(StrongOrRawPtr<nsINode>(self->GetTooltipNode()));
179 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
180 0 : if (!result) {
181 0 : args.rval().setNull();
182 0 : return true;
183 : }
184 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
185 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
186 0 : return false;
187 : }
188 0 : return true;
189 : }
190 :
191 : static bool
192 0 : set_tooltipNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitSetterCallArgs args)
193 : {
194 : nsINode* arg0;
195 0 : if (args[0].isObject()) {
196 : {
197 0 : nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
198 0 : if (NS_FAILED(rv)) {
199 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to XULDocument.tooltipNode", "Node");
200 0 : return false;
201 : }
202 : }
203 0 : } else if (args[0].isNullOrUndefined()) {
204 0 : arg0 = nullptr;
205 : } else {
206 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to XULDocument.tooltipNode");
207 0 : return false;
208 : }
209 0 : self->SetTooltipNode(Constify(arg0));
210 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
211 :
212 0 : return true;
213 : }
214 :
215 : static const JSJitInfo tooltipNode_getterinfo = {
216 : { (JSJitGetterOp)get_tooltipNode },
217 : { prototypes::id::XULDocument },
218 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
219 : JSJitInfo::Getter,
220 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
221 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
222 : false, /* isInfallible. False in setters. */
223 : false, /* isMovable. Not relevant for setters. */
224 : false, /* isEliminatable. Not relevant for setters. */
225 : false, /* isAlwaysInSlot. Only relevant for getters. */
226 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
227 : false, /* isTypedMethod. Only relevant for methods. */
228 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
229 : };
230 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
231 : static_assert(0 < 1, "There is no slot for us");
232 : static const JSJitInfo tooltipNode_setterinfo = {
233 : { (JSJitGetterOp)set_tooltipNode },
234 : { prototypes::id::XULDocument },
235 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
236 : JSJitInfo::Setter,
237 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
238 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
239 : false, /* isInfallible. False in setters. */
240 : false, /* isMovable. Not relevant for setters. */
241 : false, /* isEliminatable. Not relevant for setters. */
242 : false, /* isAlwaysInSlot. Only relevant for getters. */
243 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
244 : false, /* isTypedMethod. Only relevant for methods. */
245 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
246 : };
247 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
248 : static_assert(0 < 1, "There is no slot for us");
249 :
250 : static bool
251 13 : get_commandDispatcher(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
252 : {
253 13 : auto result(StrongOrRawPtr<nsIDOMXULCommandDispatcher>(self->GetCommandDispatcher()));
254 13 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
255 13 : if (!result) {
256 0 : args.rval().setNull();
257 0 : return true;
258 : }
259 13 : if (!WrapObject(cx, result, &NS_GET_IID(nsIDOMXULCommandDispatcher), args.rval())) {
260 0 : return false;
261 : }
262 13 : return true;
263 : }
264 :
265 : static const JSJitInfo commandDispatcher_getterinfo = {
266 : { (JSJitGetterOp)get_commandDispatcher },
267 : { prototypes::id::XULDocument },
268 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
269 : JSJitInfo::Getter,
270 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
271 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
272 : false, /* isInfallible. False in setters. */
273 : false, /* isMovable. Not relevant for setters. */
274 : false, /* isEliminatable. Not relevant for setters. */
275 : false, /* isAlwaysInSlot. Only relevant for getters. */
276 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
277 : false, /* isTypedMethod. Only relevant for methods. */
278 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
279 : };
280 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
281 : static_assert(0 < 1, "There is no slot for us");
282 :
283 : static bool
284 0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
285 : {
286 0 : binding_detail::FastErrorResult rv;
287 0 : int32_t result(self->GetWidth(rv));
288 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
289 0 : return false;
290 : }
291 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
292 0 : args.rval().setInt32(int32_t(result));
293 0 : return true;
294 : }
295 :
296 : static const JSJitInfo width_getterinfo = {
297 : { (JSJitGetterOp)get_width },
298 : { prototypes::id::XULDocument },
299 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
300 : JSJitInfo::Getter,
301 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
302 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
303 : false, /* isInfallible. False in setters. */
304 : false, /* isMovable. Not relevant for setters. */
305 : false, /* isEliminatable. Not relevant for setters. */
306 : false, /* isAlwaysInSlot. Only relevant for getters. */
307 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
308 : false, /* isTypedMethod. Only relevant for methods. */
309 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
310 : };
311 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
312 : static_assert(0 < 1, "There is no slot for us");
313 :
314 : static bool
315 0 : get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
316 : {
317 0 : binding_detail::FastErrorResult rv;
318 0 : int32_t result(self->GetHeight(rv));
319 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
320 0 : return false;
321 : }
322 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
323 0 : args.rval().setInt32(int32_t(result));
324 0 : return true;
325 : }
326 :
327 : static const JSJitInfo height_getterinfo = {
328 : { (JSJitGetterOp)get_height },
329 : { prototypes::id::XULDocument },
330 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
331 : JSJitInfo::Getter,
332 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
333 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
334 : false, /* isInfallible. False in setters. */
335 : false, /* isMovable. Not relevant for setters. */
336 : false, /* 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 :
345 : static bool
346 0 : getElementsByAttribute(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
347 : {
348 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
349 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.getElementsByAttribute");
350 : }
351 0 : binding_detail::FakeString arg0;
352 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
353 0 : return false;
354 : }
355 0 : binding_detail::FakeString arg1;
356 0 : if (!ConvertJSValueToString(cx, args[1], eEmpty, eStringify, arg1)) {
357 0 : return false;
358 : }
359 0 : auto result(StrongOrRawPtr<nsINodeList>(self->GetElementsByAttribute(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)))));
360 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
361 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
362 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
363 0 : return false;
364 : }
365 0 : return true;
366 : }
367 :
368 : static const JSJitInfo getElementsByAttribute_methodinfo = {
369 : { (JSJitGetterOp)getElementsByAttribute },
370 : { prototypes::id::XULDocument },
371 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
372 : JSJitInfo::Method,
373 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
374 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
375 : false, /* isInfallible. False in setters. */
376 : false, /* isMovable. Not relevant for setters. */
377 : false, /* isEliminatable. Not relevant for setters. */
378 : false, /* isAlwaysInSlot. Only relevant for getters. */
379 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
380 : false, /* isTypedMethod. Only relevant for methods. */
381 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
382 : };
383 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
384 : static_assert(0 < 1, "There is no slot for us");
385 :
386 : static bool
387 0 : getElementsByAttributeNS(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
388 : {
389 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
390 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.getElementsByAttributeNS");
391 : }
392 0 : binding_detail::FakeString arg0;
393 0 : if (!ConvertJSValueToString(cx, args[0], eNull, eNull, arg0)) {
394 0 : return false;
395 : }
396 0 : binding_detail::FakeString arg1;
397 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
398 0 : return false;
399 : }
400 0 : binding_detail::FakeString arg2;
401 0 : if (!ConvertJSValueToString(cx, args[2], eEmpty, eStringify, arg2)) {
402 0 : return false;
403 : }
404 0 : binding_detail::FastErrorResult rv;
405 0 : auto result(StrongOrRawPtr<nsINodeList>(self->GetElementsByAttributeNS(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv)));
406 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
407 0 : return false;
408 : }
409 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
410 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
411 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
412 0 : return false;
413 : }
414 0 : return true;
415 : }
416 :
417 : static const JSJitInfo getElementsByAttributeNS_methodinfo = {
418 : { (JSJitGetterOp)getElementsByAttributeNS },
419 : { prototypes::id::XULDocument },
420 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
421 : JSJitInfo::Method,
422 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
423 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
424 : false, /* isInfallible. False in setters. */
425 : false, /* isMovable. Not relevant for setters. */
426 : false, /* isEliminatable. Not relevant for setters. */
427 : false, /* isAlwaysInSlot. Only relevant for getters. */
428 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
429 : false, /* isTypedMethod. Only relevant for methods. */
430 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
431 : };
432 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
433 : static_assert(0 < 1, "There is no slot for us");
434 :
435 : static bool
436 0 : addBroadcastListenerFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
437 : {
438 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
439 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.addBroadcastListenerFor");
440 : }
441 0 : NonNull<mozilla::dom::Element> arg0;
442 0 : if (args[0].isObject()) {
443 : {
444 0 : nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
445 0 : if (NS_FAILED(rv)) {
446 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULDocument.addBroadcastListenerFor", "Element");
447 0 : return false;
448 : }
449 : }
450 : } else {
451 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULDocument.addBroadcastListenerFor");
452 0 : return false;
453 : }
454 0 : NonNull<mozilla::dom::Element> arg1;
455 0 : if (args[1].isObject()) {
456 : {
457 0 : nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[1], arg1);
458 0 : if (NS_FAILED(rv)) {
459 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of XULDocument.addBroadcastListenerFor", "Element");
460 0 : return false;
461 : }
462 : }
463 : } else {
464 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of XULDocument.addBroadcastListenerFor");
465 0 : return false;
466 : }
467 0 : binding_detail::FakeString arg2;
468 0 : if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
469 0 : return false;
470 : }
471 0 : binding_detail::FastErrorResult rv;
472 0 : self->AddBroadcastListenerFor(NonNullHelper(arg0), NonNullHelper(arg1), NonNullHelper(Constify(arg2)), rv);
473 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
474 0 : return false;
475 : }
476 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
477 0 : args.rval().setUndefined();
478 0 : return true;
479 : }
480 :
481 : static const JSJitInfo addBroadcastListenerFor_methodinfo = {
482 : { (JSJitGetterOp)addBroadcastListenerFor },
483 : { prototypes::id::XULDocument },
484 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
485 : JSJitInfo::Method,
486 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
487 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
488 : false, /* isInfallible. False in setters. */
489 : false, /* isMovable. Not relevant for setters. */
490 : false, /* isEliminatable. Not relevant for setters. */
491 : false, /* isAlwaysInSlot. Only relevant for getters. */
492 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
493 : false, /* isTypedMethod. Only relevant for methods. */
494 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
495 : };
496 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
497 : static_assert(0 < 1, "There is no slot for us");
498 :
499 : static bool
500 0 : removeBroadcastListenerFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
501 : {
502 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
503 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.removeBroadcastListenerFor");
504 : }
505 0 : NonNull<mozilla::dom::Element> arg0;
506 0 : if (args[0].isObject()) {
507 : {
508 0 : nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
509 0 : if (NS_FAILED(rv)) {
510 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULDocument.removeBroadcastListenerFor", "Element");
511 0 : return false;
512 : }
513 : }
514 : } else {
515 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULDocument.removeBroadcastListenerFor");
516 0 : return false;
517 : }
518 0 : NonNull<mozilla::dom::Element> arg1;
519 0 : if (args[1].isObject()) {
520 : {
521 0 : nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[1], arg1);
522 0 : if (NS_FAILED(rv)) {
523 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of XULDocument.removeBroadcastListenerFor", "Element");
524 0 : return false;
525 : }
526 : }
527 : } else {
528 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of XULDocument.removeBroadcastListenerFor");
529 0 : return false;
530 : }
531 0 : binding_detail::FakeString arg2;
532 0 : if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
533 0 : return false;
534 : }
535 0 : self->RemoveBroadcastListenerFor(NonNullHelper(arg0), NonNullHelper(arg1), NonNullHelper(Constify(arg2)));
536 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
537 0 : args.rval().setUndefined();
538 0 : return true;
539 : }
540 :
541 : static const JSJitInfo removeBroadcastListenerFor_methodinfo = {
542 : { (JSJitGetterOp)removeBroadcastListenerFor },
543 : { prototypes::id::XULDocument },
544 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
545 : JSJitInfo::Method,
546 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
547 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
548 : false, /* isInfallible. False in setters. */
549 : false, /* isMovable. Not relevant for setters. */
550 : false, /* isEliminatable. Not relevant for setters. */
551 : false, /* isAlwaysInSlot. Only relevant for getters. */
552 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
553 : false, /* isTypedMethod. Only relevant for methods. */
554 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
555 : };
556 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
557 : static_assert(0 < 1, "There is no slot for us");
558 :
559 : static bool
560 0 : persist(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
561 : {
562 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
563 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.persist");
564 : }
565 0 : binding_detail::FakeString arg0;
566 0 : if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
567 0 : return false;
568 : }
569 0 : binding_detail::FakeString arg1;
570 0 : if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
571 0 : return false;
572 : }
573 0 : binding_detail::FastErrorResult rv;
574 0 : self->Persist(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv);
575 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
576 0 : return false;
577 : }
578 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
579 0 : args.rval().setUndefined();
580 0 : return true;
581 : }
582 :
583 : static const JSJitInfo persist_methodinfo = {
584 : { (JSJitGetterOp)persist },
585 : { prototypes::id::XULDocument },
586 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
587 : JSJitInfo::Method,
588 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
589 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
590 : false, /* isInfallible. False in setters. */
591 : false, /* isMovable. Not relevant for setters. */
592 : false, /* isEliminatable. Not relevant for setters. */
593 : false, /* isAlwaysInSlot. Only relevant for getters. */
594 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
595 : false, /* isTypedMethod. Only relevant for methods. */
596 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
597 : };
598 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
599 : static_assert(0 < 1, "There is no slot for us");
600 :
601 : static bool
602 0 : getBoxObjectFor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
603 : {
604 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
605 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.getBoxObjectFor");
606 : }
607 : mozilla::dom::Element* arg0;
608 0 : if (args[0].isObject()) {
609 : {
610 0 : nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
611 0 : if (NS_FAILED(rv)) {
612 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULDocument.getBoxObjectFor", "Element");
613 0 : return false;
614 : }
615 : }
616 0 : } else if (args[0].isNullOrUndefined()) {
617 0 : arg0 = nullptr;
618 : } else {
619 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULDocument.getBoxObjectFor");
620 0 : return false;
621 : }
622 0 : binding_detail::FastErrorResult rv;
623 0 : auto result(StrongOrRawPtr<mozilla::dom::BoxObject>(self->GetBoxObjectFor(Constify(arg0), rv)));
624 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
625 0 : return false;
626 : }
627 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
628 0 : if (!result) {
629 0 : args.rval().setNull();
630 0 : return true;
631 : }
632 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
633 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
634 0 : return false;
635 : }
636 0 : return true;
637 : }
638 :
639 : static const JSJitInfo getBoxObjectFor_methodinfo = {
640 : { (JSJitGetterOp)getBoxObjectFor },
641 : { prototypes::id::XULDocument },
642 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
643 : JSJitInfo::Method,
644 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
645 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
646 : false, /* isInfallible. False in setters. */
647 : false, /* isMovable. Not relevant for setters. */
648 : false, /* isEliminatable. Not relevant for setters. */
649 : false, /* isAlwaysInSlot. Only relevant for getters. */
650 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
651 : false, /* isTypedMethod. Only relevant for methods. */
652 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
653 : };
654 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
655 : static_assert(0 < 1, "There is no slot for us");
656 :
657 : static bool
658 0 : loadOverlay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, const JSJitMethodCallArgs& args)
659 : {
660 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
661 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULDocument.loadOverlay");
662 : }
663 0 : binding_detail::FakeString arg0;
664 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
665 0 : return false;
666 : }
667 : nsIObserver* arg1;
668 0 : RefPtr<nsIObserver> arg1_holder;
669 0 : if (args[1].isObject()) {
670 0 : JS::Rooted<JSObject*> source(cx, &args[1].toObject());
671 0 : if (NS_FAILED(UnwrapArg<nsIObserver>(cx, source, getter_AddRefs(arg1_holder)))) {
672 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of XULDocument.loadOverlay", "MozObserver");
673 0 : return false;
674 : }
675 0 : MOZ_ASSERT(arg1_holder);
676 0 : arg1 = arg1_holder;
677 0 : } else if (args[1].isNullOrUndefined()) {
678 0 : arg1 = nullptr;
679 : } else {
680 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of XULDocument.loadOverlay");
681 0 : return false;
682 : }
683 0 : binding_detail::FastErrorResult rv;
684 0 : self->LoadOverlay(NonNullHelper(Constify(arg0)), Constify(arg1), rv);
685 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
686 0 : return false;
687 : }
688 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
689 0 : args.rval().setUndefined();
690 0 : return true;
691 : }
692 :
693 : static const JSJitInfo loadOverlay_methodinfo = {
694 : { (JSJitGetterOp)loadOverlay },
695 : { prototypes::id::XULDocument },
696 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
697 : JSJitInfo::Method,
698 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
699 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
700 : false, /* isInfallible. False in setters. */
701 : false, /* isMovable. Not relevant for setters. */
702 : false, /* isEliminatable. Not relevant for setters. */
703 : false, /* isAlwaysInSlot. Only relevant for getters. */
704 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
705 : false, /* isTypedMethod. Only relevant for methods. */
706 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
707 : };
708 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
709 : static_assert(0 < 1, "There is no slot for us");
710 :
711 : static bool
712 0 : get_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitGetterCallArgs args)
713 : {
714 0 : auto result(StrongOrRawPtr<mozilla::dom::Location>(self->GetLocation()));
715 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
716 0 : if (!result) {
717 0 : args.rval().setNull();
718 0 : return true;
719 : }
720 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
721 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
722 0 : return false;
723 : }
724 0 : return true;
725 : }
726 :
727 : static bool
728 0 : set_location(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULDocument* self, JSJitSetterCallArgs args)
729 : {
730 0 : JS::Rooted<JS::Value> v(cx);
731 0 : if (!JS_GetProperty(cx, obj, "location", &v)) {
732 0 : return false;
733 : }
734 :
735 0 : if (!v.isObject()) {
736 0 : return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "XULDocument.location");
737 : }
738 :
739 0 : JS::Rooted<JSObject*> targetObj(cx, &v.toObject());
740 0 : return JS_SetProperty(cx, targetObj, "href", args[0]);
741 : }
742 :
743 : static const JSJitInfo location_getterinfo = {
744 : { (JSJitGetterOp)get_location },
745 : { prototypes::id::XULDocument },
746 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
747 : JSJitInfo::Getter,
748 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
749 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
750 : false, /* isInfallible. False in setters. */
751 : false, /* isMovable. Not relevant for setters. */
752 : false, /* isEliminatable. Not relevant for setters. */
753 : false, /* isAlwaysInSlot. Only relevant for getters. */
754 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
755 : false, /* isTypedMethod. Only relevant for methods. */
756 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
757 : };
758 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
759 : static_assert(0 < 1, "There is no slot for us");
760 : static const JSJitInfo location_setterinfo = {
761 : { (JSJitGetterOp)set_location },
762 : { prototypes::id::XULDocument },
763 : { PrototypeTraits<prototypes::id::XULDocument>::Depth },
764 : JSJitInfo::Setter,
765 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
766 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
767 : false, /* isInfallible. False in setters. */
768 : false, /* isMovable. Not relevant for setters. */
769 : false, /* isEliminatable. Not relevant for setters. */
770 : false, /* isAlwaysInSlot. Only relevant for getters. */
771 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
772 : false, /* isTypedMethod. Only relevant for methods. */
773 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
774 : };
775 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
776 : static_assert(0 < 1, "There is no slot for us");
777 :
778 : static bool
779 1 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
780 : {
781 1 : mozilla::dom::XULDocument* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULDocument>(obj);
782 : // We don't want to preserve if we don't have a wrapper, and we
783 : // obviously can't preserve if we're not initialized.
784 1 : if (self && self->GetWrapperPreserveColor()) {
785 0 : PreserveWrapper(self);
786 : }
787 1 : return true;
788 : }
789 :
790 : static void
791 0 : _finalize(js::FreeOp* fop, JSObject* obj)
792 : {
793 0 : mozilla::dom::XULDocument* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULDocument>(obj);
794 0 : if (self) {
795 0 : ClearWrapper(self, self, obj);
796 0 : AddForDeferredFinalization<mozilla::dom::XULDocument>(self);
797 : }
798 0 : }
799 :
800 : static void
801 0 : _objectMoved(JSObject* obj, const JSObject* old)
802 : {
803 0 : mozilla::dom::XULDocument* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULDocument>(obj);
804 0 : if (self) {
805 0 : UpdateWrapper(self, self, obj, old);
806 : }
807 0 : }
808 :
809 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
810 : #if defined(__clang__)
811 : #pragma clang diagnostic push
812 : #pragma clang diagnostic ignored "-Wmissing-braces"
813 : #endif
814 : static const JSFunctionSpec sMethods_specs[] = {
815 : JS_FNSPEC("getElementsByAttribute", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getElementsByAttribute_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
816 : JS_FNSPEC("getElementsByAttributeNS", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getElementsByAttributeNS_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
817 : JS_FNSPEC("addBroadcastListenerFor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&addBroadcastListenerFor_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
818 : JS_FNSPEC("removeBroadcastListenerFor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeBroadcastListenerFor_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
819 : JS_FNSPEC("persist", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&persist_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
820 : JS_FNSPEC("getBoxObjectFor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getBoxObjectFor_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
821 : JS_FNSPEC("loadOverlay", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&loadOverlay_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
822 : JS_FS_END
823 : };
824 : #if defined(__clang__)
825 : #pragma clang diagnostic pop
826 : #endif
827 :
828 :
829 : // Can't be const because the pref-enabled boolean needs to be writable
830 : static Prefable<const JSFunctionSpec> sMethods[] = {
831 : { nullptr, &sMethods_specs[0] },
832 : { nullptr, nullptr }
833 : };
834 :
835 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
836 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
837 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
838 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
839 :
840 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
841 : #if defined(__clang__)
842 : #pragma clang diagnostic push
843 : #pragma clang diagnostic ignored "-Wmissing-braces"
844 : #endif
845 : static const JSPropertySpec sAttributes_specs[] = {
846 : { "popupNode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &popupNode_getterinfo, GenericBindingSetter, &popupNode_setterinfo },
847 : { "tooltipNode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &tooltipNode_getterinfo, GenericBindingSetter, &tooltipNode_setterinfo },
848 : { "commandDispatcher", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &commandDispatcher_getterinfo, nullptr, nullptr },
849 : { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, nullptr, nullptr },
850 : { "height", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &height_getterinfo, nullptr, nullptr },
851 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
852 : };
853 : #if defined(__clang__)
854 : #pragma clang diagnostic pop
855 : #endif
856 :
857 :
858 : // Can't be const because the pref-enabled boolean needs to be writable
859 : static Prefable<const JSPropertySpec> sAttributes[] = {
860 : { nullptr, &sAttributes_specs[0] },
861 : { nullptr, nullptr }
862 : };
863 :
864 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
865 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
866 : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
867 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
868 :
869 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
870 : #if defined(__clang__)
871 : #pragma clang diagnostic push
872 : #pragma clang diagnostic ignored "-Wmissing-braces"
873 : #endif
874 : static const JSPropertySpec sChromeAttributes_specs[] = {
875 : { "popupRangeParent", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &popupRangeParent_getterinfo, nullptr, nullptr },
876 : { "popupRangeOffset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &popupRangeOffset_getterinfo, nullptr, nullptr },
877 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
878 : };
879 : #if defined(__clang__)
880 : #pragma clang diagnostic pop
881 : #endif
882 :
883 :
884 : // Can't be const because the pref-enabled boolean needs to be writable
885 : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
886 : { nullptr, &sChromeAttributes_specs[0] },
887 : { nullptr, nullptr }
888 : };
889 :
890 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
891 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
892 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
893 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
894 :
895 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
896 : #if defined(__clang__)
897 : #pragma clang diagnostic push
898 : #pragma clang diagnostic ignored "-Wmissing-braces"
899 : #endif
900 : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
901 : { "location", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &location_getterinfo, GenericBindingSetter, &location_setterinfo },
902 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
903 : };
904 : #if defined(__clang__)
905 : #pragma clang diagnostic pop
906 : #endif
907 :
908 :
909 : // Can't be const because the pref-enabled boolean needs to be writable
910 : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
911 : { nullptr, &sUnforgeableAttributes_specs[0] },
912 : { nullptr, nullptr }
913 : };
914 :
915 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
916 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
917 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
918 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
919 :
920 :
921 : static uint16_t sNativeProperties_sortedPropertyIndices[13];
922 : static PropertyInfo sNativeProperties_propertyInfos[13];
923 :
924 : static const NativePropertiesN<3> sNativeProperties = {
925 : false, 0,
926 : false, 0,
927 : true, 0 /* sMethods */,
928 : true, 1 /* sAttributes */,
929 : false, 0,
930 : true, 2 /* sUnforgeableAttributes */,
931 : false, 0,
932 : -1,
933 : 13,
934 : sNativeProperties_sortedPropertyIndices,
935 : {
936 : { sMethods, &sNativeProperties_propertyInfos[0] },
937 : { sAttributes, &sNativeProperties_propertyInfos[7] },
938 : { sUnforgeableAttributes, &sNativeProperties_propertyInfos[12] }
939 : }
940 : };
941 : static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
942 : "We have a property info count that is oversized");
943 :
944 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2];
945 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2];
946 :
947 : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
948 : false, 0,
949 : false, 0,
950 : false, 0,
951 : true, 0 /* sChromeAttributes */,
952 : false, 0,
953 : false, 0,
954 : false, 0,
955 : -1,
956 : 2,
957 : sChromeOnlyNativeProperties_sortedPropertyIndices,
958 : {
959 : { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
960 : }
961 : };
962 : static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
963 : "We have a property info count that is oversized");
964 :
965 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
966 : {
967 : "Function",
968 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
969 : &sBoringInterfaceObjectClassClassOps,
970 : JS_NULL_CLASS_SPEC,
971 : JS_NULL_CLASS_EXT,
972 : &sInterfaceObjectClassObjectOps
973 : },
974 : eInterface,
975 : true,
976 : prototypes::id::XULDocument,
977 : PrototypeTraits<prototypes::id::XULDocument>::Depth,
978 : sNativePropertyHooks,
979 : "function XULDocument() {\n [native code]\n}",
980 : DocumentBinding::GetConstructorObject
981 : };
982 :
983 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
984 : {
985 : "XULDocumentPrototype",
986 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
987 : JS_NULL_CLASS_OPS,
988 : JS_NULL_CLASS_SPEC,
989 : JS_NULL_CLASS_EXT,
990 : JS_NULL_OBJECT_OPS
991 : },
992 : eInterfacePrototype,
993 : false,
994 : prototypes::id::XULDocument,
995 : PrototypeTraits<prototypes::id::XULDocument>::Depth,
996 : sNativePropertyHooks,
997 : "[object XULDocumentPrototype]",
998 : DocumentBinding::GetProtoObject
999 : };
1000 :
1001 : bool
1002 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1003 : {
1004 0 : return IsChromeOrXBL(aCx, aObj);
1005 : }
1006 :
1007 : JSObject*
1008 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1009 : {
1010 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1011 : }
1012 :
1013 : static const js::ClassOps sClassOps = {
1014 : _addProperty, /* addProperty */
1015 : nullptr, /* delProperty */
1016 : nullptr, /* getProperty */
1017 : nullptr, /* setProperty */
1018 : nullptr, /* enumerate */
1019 : nullptr, /* newEnumerate */
1020 : nullptr, /* resolve */
1021 : nullptr, /* mayResolve */
1022 : _finalize, /* finalize */
1023 : nullptr, /* call */
1024 : nullptr, /* hasInstance */
1025 : nullptr, /* construct */
1026 : nullptr, /* trace */
1027 : };
1028 :
1029 : static const js::ClassExtension sClassExtension = {
1030 : nullptr, /* weakmapKeyDelegateOp */
1031 : _objectMoved /* objectMovedOp */
1032 : };
1033 :
1034 : static const DOMJSClass sClass = {
1035 : { "XULDocument",
1036 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1037 : &sClassOps,
1038 : JS_NULL_CLASS_SPEC,
1039 : &sClassExtension,
1040 : JS_NULL_OBJECT_OPS
1041 : },
1042 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Document, prototypes::id::XULDocument, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1043 : IsBaseOf<nsISupports, mozilla::dom::XULDocument >::value,
1044 : sNativePropertyHooks,
1045 : FindAssociatedGlobalForNative<mozilla::dom::XULDocument>::Get,
1046 : GetProtoObjectHandle,
1047 : GetCCParticipant<mozilla::dom::XULDocument>::Get()
1048 : };
1049 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1050 : "Must have the right minimal number of reserved slots.");
1051 : static_assert(1 >= 1,
1052 : "Must have enough reserved slots.");
1053 :
1054 : const JSClass*
1055 0 : GetJSClass()
1056 : {
1057 0 : return sClass.ToJSClass();
1058 : }
1059 :
1060 : bool
1061 1 : Wrap(JSContext* aCx, mozilla::dom::XULDocument* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1062 : {
1063 : MOZ_ASSERT(static_cast<mozilla::dom::XULDocument*>(aObject) ==
1064 : reinterpret_cast<mozilla::dom::XULDocument*>(aObject),
1065 : "Multiple inheritance for mozilla::dom::XULDocument is broken.");
1066 : MOZ_ASSERT(static_cast<nsIDocument*>(aObject) ==
1067 : reinterpret_cast<nsIDocument*>(aObject),
1068 : "Multiple inheritance for nsIDocument is broken.");
1069 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
1070 : reinterpret_cast<nsINode*>(aObject),
1071 : "Multiple inheritance for nsINode is broken.");
1072 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1073 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1074 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1075 1 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1076 1 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1077 1 : MOZ_ASSERT(!aCache->GetWrapper(),
1078 : "You should probably not be using Wrap() directly; use "
1079 : "GetOrCreateDOMReflector instead");
1080 :
1081 1 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1082 : "nsISupports must be on our primary inheritance chain");
1083 :
1084 2 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1085 1 : if (!global) {
1086 0 : return false;
1087 : }
1088 1 : MOZ_ASSERT(JS_IsGlobalObject(global));
1089 1 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1090 :
1091 : // That might have ended up wrapping us already, due to the wonders
1092 : // of XBL. Check for that, and bail out as needed.
1093 1 : aReflector.set(aCache->GetWrapper());
1094 1 : if (aReflector) {
1095 : #ifdef DEBUG
1096 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1097 : #endif // DEBUG
1098 0 : return true;
1099 : }
1100 :
1101 2 : JSAutoCompartment ac(aCx, global);
1102 1 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1103 1 : if (!canonicalProto) {
1104 0 : return false;
1105 : }
1106 2 : JS::Rooted<JSObject*> proto(aCx);
1107 1 : if (aGivenProto) {
1108 0 : proto = aGivenProto;
1109 : // Unfortunately, while aGivenProto was in the compartment of aCx
1110 : // coming in, we changed compartments to that of "parent" so may need
1111 : // to wrap the proto here.
1112 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1113 0 : if (!JS_WrapObject(aCx, &proto)) {
1114 0 : return false;
1115 : }
1116 : }
1117 : } else {
1118 1 : proto = canonicalProto;
1119 : }
1120 :
1121 2 : BindingJSObjectCreator<mozilla::dom::XULDocument> creator(aCx);
1122 1 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1123 1 : if (!aReflector) {
1124 0 : return false;
1125 : }
1126 :
1127 1 : aCache->SetWrapper(aReflector);
1128 :
1129 : // Important: do unforgeable property setup after we have handed
1130 : // over ownership of the C++ object to obj as needed, so that if
1131 : // we fail and it ends up GCed it won't have problems in the
1132 : // finalizer trying to drop its ownership of the C++ object.
1133 : JS::Rooted<JSObject*> unforgeableHolder(aCx,
1134 2 : &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
1135 1 : if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
1136 0 : aCache->ReleaseWrapper(aObject);
1137 0 : aCache->ClearWrapper();
1138 0 : return false;
1139 : }
1140 1 : creator.InitializationSucceeded();
1141 :
1142 1 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1143 : aCache->GetWrapperPreserveColor() == aReflector);
1144 : // If proto != canonicalProto, we have to preserve our wrapper;
1145 : // otherwise we won't be able to properly recreate it later, since
1146 : // we won't know what proto to use. Note that we don't check
1147 : // aGivenProto here, since it's entirely possible (and even
1148 : // somewhat common) to have a non-null aGivenProto which is the
1149 : // same as canonicalProto.
1150 1 : if (proto != canonicalProto) {
1151 0 : PreserveWrapper(aObject);
1152 : }
1153 :
1154 1 : return true;
1155 : }
1156 :
1157 : const NativePropertyHooks sNativePropertyHooks[] = { {
1158 : nullptr,
1159 : nullptr,
1160 : nullptr,
1161 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1162 : prototypes::id::XULDocument,
1163 : constructors::id::XULDocument,
1164 : DocumentBinding::sNativePropertyHooks,
1165 : &DefaultXrayExpandoObjectClass
1166 : } };
1167 :
1168 : void
1169 1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1170 : {
1171 1 : JS::Handle<JSObject*> parentProto(DocumentBinding::GetProtoObjectHandle(aCx));
1172 1 : if (!parentProto) {
1173 0 : return;
1174 : }
1175 :
1176 1 : JS::Handle<JSObject*> constructorProto(DocumentBinding::GetConstructorObjectHandle(aCx));
1177 1 : if (!constructorProto) {
1178 0 : return;
1179 : }
1180 :
1181 : static bool sIdsInited = false;
1182 1 : if (!sIdsInited && NS_IsMainThread()) {
1183 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1184 0 : return;
1185 : }
1186 1 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1187 0 : return;
1188 : }
1189 1 : sIdsInited = true;
1190 : }
1191 :
1192 1 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XULDocument);
1193 1 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XULDocument);
1194 2 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1195 : &sPrototypeClass.mBase, protoCache,
1196 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1197 : interfaceCache,
1198 : sNativeProperties.Upcast(),
1199 1 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
1200 : "XULDocument", aDefineOnGlobal,
1201 : nullptr,
1202 1 : false);
1203 :
1204 2 : JS::Rooted<JSObject*> unforgeableHolder(aCx);
1205 : {
1206 2 : JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1207 1 : unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1208 1 : if (!unforgeableHolder) {
1209 0 : *protoCache = nullptr;
1210 0 : if (interfaceCache) {
1211 0 : *interfaceCache = nullptr;
1212 : }
1213 0 : return;
1214 : }
1215 : }
1216 :
1217 1 : if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1218 0 : *protoCache = nullptr;
1219 0 : if (interfaceCache) {
1220 0 : *interfaceCache = nullptr;
1221 : }
1222 0 : return;
1223 : }
1224 :
1225 1 : if (*protoCache) {
1226 1 : js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1227 2 : JS::ObjectValue(*unforgeableHolder));
1228 : }
1229 : }
1230 :
1231 : JS::Handle<JSObject*>
1232 1 : GetProtoObjectHandle(JSContext* aCx)
1233 : {
1234 : /* Get the interface prototype object for this class. This will create the
1235 : object as needed. */
1236 1 : bool aDefineOnGlobal = true;
1237 :
1238 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1239 1 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1240 1 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1241 0 : return nullptr;
1242 : }
1243 :
1244 : /* Check to see whether the interface objects are already installed */
1245 1 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1246 1 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::XULDocument)) {
1247 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1248 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1249 : }
1250 :
1251 : /*
1252 : * The object might _still_ be null, but that's OK.
1253 : *
1254 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1255 : * traced by TraceProtoAndIfaceCache() and its contents are never
1256 : * changed after they have been set.
1257 : *
1258 : * Calling address() avoids the read read barrier that does gray
1259 : * unmarking, but it's not possible for the object to be gray here.
1260 : */
1261 :
1262 1 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::XULDocument);
1263 1 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1264 1 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1265 : }
1266 :
1267 : JS::Handle<JSObject*>
1268 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1269 : {
1270 : /* Get the interface object for this class. This will create the object as
1271 : needed. */
1272 :
1273 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1274 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1275 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1276 0 : return nullptr;
1277 : }
1278 :
1279 : /* Check to see whether the interface objects are already installed */
1280 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1281 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::XULDocument)) {
1282 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1283 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1284 : }
1285 :
1286 : /*
1287 : * The object might _still_ be null, but that's OK.
1288 : *
1289 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1290 : * traced by TraceProtoAndIfaceCache() and its contents are never
1291 : * changed after they have been set.
1292 : *
1293 : * Calling address() avoids the read read barrier that does gray
1294 : * unmarking, but it's not possible for the object to be gray here.
1295 : */
1296 :
1297 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::XULDocument);
1298 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1299 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1300 : }
1301 :
1302 : JSObject*
1303 0 : GetConstructorObject(JSContext* aCx)
1304 : {
1305 0 : return GetConstructorObjectHandle(aCx);
1306 : }
1307 :
1308 : } // namespace XULDocumentBinding
1309 :
1310 :
1311 :
1312 : } // namespace dom
1313 : } // namespace mozilla
|