/work/obj-fuzz/dom/bindings/XULPopupElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM XULPopupElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "XULElementBinding.h" |
6 | | #include "XULPopupElementBinding.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/DOMRect.h" |
11 | | #include "mozilla/dom/Element.h" |
12 | | #include "mozilla/dom/Event.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/ScriptSettings.h" |
17 | | #include "mozilla/dom/UnionConversions.h" |
18 | | #include "mozilla/dom/XULPopupElement.h" |
19 | | #include "mozilla/dom/XrayExpandoClass.h" |
20 | | #include "nsINode.h" |
21 | | |
22 | | namespace mozilla { |
23 | | namespace dom { |
24 | | |
25 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
26 | | using namespace mozilla::dom::binding_detail; |
27 | | |
28 | | |
29 | | void |
30 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningStringOrOpenPopupOptions& aUnion, const char* aName, uint32_t aFlags) |
31 | 0 | { |
32 | 0 | if (aUnion.IsOpenPopupOptions()) { |
33 | 0 | ImplCycleCollectionTraverse(aCallback, aUnion.GetAsOpenPopupOptions(), "mOpenPopupOptions", aFlags); |
34 | 0 | } |
35 | 0 | } |
36 | | |
37 | | |
38 | | void |
39 | | ImplCycleCollectionUnlink(OwningStringOrOpenPopupOptions& aUnion) |
40 | 0 | { |
41 | 0 | aUnion.Uninit(); |
42 | 0 | } |
43 | | |
44 | | |
45 | | |
46 | | OpenPopupOptions::OpenPopupOptions() |
47 | 0 | { |
48 | 0 | // Safe to pass a null context if we pass a null value |
49 | 0 | Init(nullptr, JS::NullHandleValue); |
50 | 0 | } |
51 | | |
52 | | |
53 | | |
54 | | bool |
55 | | OpenPopupOptions::InitIds(JSContext* cx, OpenPopupOptionsAtoms* atomsCache) |
56 | 0 | { |
57 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
58 | 0 |
|
59 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
60 | 0 | // uninitialized. |
61 | 0 | if (!atomsCache->y_id.init(cx, "y") || |
62 | 0 | !atomsCache->x_id.init(cx, "x") || |
63 | 0 | !atomsCache->triggerEvent_id.init(cx, "triggerEvent") || |
64 | 0 | !atomsCache->position_id.init(cx, "position") || |
65 | 0 | !atomsCache->isContextMenu_id.init(cx, "isContextMenu") || |
66 | 0 | !atomsCache->attributesOverride_id.init(cx, "attributesOverride")) { |
67 | 0 | return false; |
68 | 0 | } |
69 | 0 | return true; |
70 | 0 | } |
71 | | |
72 | | bool |
73 | | OpenPopupOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
74 | 0 | { |
75 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
76 | 0 | // Since in that case we will not have to do any property gets |
77 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
78 | 0 | // checkers by static analysis tools |
79 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
80 | 0 | OpenPopupOptionsAtoms* atomsCache = nullptr; |
81 | 0 | if (cx) { |
82 | 0 | atomsCache = GetAtomCache<OpenPopupOptionsAtoms>(cx); |
83 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
84 | 0 | return false; |
85 | 0 | } |
86 | 0 | } |
87 | 0 | |
88 | 0 | if (!IsConvertibleToDictionary(val)) { |
89 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
90 | 0 | } |
91 | 0 | |
92 | 0 | bool isNull = val.isNullOrUndefined(); |
93 | 0 | // We only need these if !isNull, in which case we have |cx|. |
94 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
95 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
96 | 0 | if (!isNull) { |
97 | 0 | MOZ_ASSERT(cx); |
98 | 0 | object.emplace(cx, &val.toObject()); |
99 | 0 | temp.emplace(cx); |
100 | 0 | } |
101 | 0 | if (!isNull) { |
102 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->attributesOverride_id, temp.ptr())) { |
103 | 0 | return false; |
104 | 0 | } |
105 | 0 | } |
106 | 0 | if (!isNull && !temp->isUndefined()) { |
107 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAttributesOverride)) { |
108 | 0 | return false; |
109 | 0 | } |
110 | 0 | } else { |
111 | 0 | mAttributesOverride = false; |
112 | 0 | } |
113 | 0 | mIsAnyMemberPresent = true; |
114 | 0 |
|
115 | 0 | if (!isNull) { |
116 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->isContextMenu_id, temp.ptr())) { |
117 | 0 | return false; |
118 | 0 | } |
119 | 0 | } |
120 | 0 | if (!isNull && !temp->isUndefined()) { |
121 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIsContextMenu)) { |
122 | 0 | return false; |
123 | 0 | } |
124 | 0 | } else { |
125 | 0 | mIsContextMenu = false; |
126 | 0 | } |
127 | 0 | mIsAnyMemberPresent = true; |
128 | 0 |
|
129 | 0 | if (!isNull) { |
130 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->position_id, temp.ptr())) { |
131 | 0 | return false; |
132 | 0 | } |
133 | 0 | } |
134 | 0 | if (!isNull && !temp->isUndefined()) { |
135 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPosition)) { |
136 | 0 | return false; |
137 | 0 | } |
138 | 0 | } else { |
139 | 0 | static const char16_t data[] = { 0 }; |
140 | 0 | mPosition.Rebind(data, ArrayLength(data) - 1); |
141 | 0 | } |
142 | 0 | mIsAnyMemberPresent = true; |
143 | 0 |
|
144 | 0 | if (!isNull) { |
145 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->triggerEvent_id, temp.ptr())) { |
146 | 0 | return false; |
147 | 0 | } |
148 | 0 | } |
149 | 0 | if (!isNull && !temp->isUndefined()) { |
150 | 0 | if (temp.ref().isObject()) { |
151 | 0 | static_assert(IsRefcounted<mozilla::dom::Event>::value, "We can only store refcounted classes.");{ |
152 | 0 | nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(temp.ptr(), mTriggerEvent); |
153 | 0 | if (NS_FAILED(rv)) { |
154 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'triggerEvent' member of OpenPopupOptions", "Event"); |
155 | 0 | return false; |
156 | 0 | } |
157 | 0 | } |
158 | 0 | } else if (temp.ref().isNullOrUndefined()) { |
159 | 0 | mTriggerEvent = nullptr; |
160 | 0 | } else { |
161 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'triggerEvent' member of OpenPopupOptions"); |
162 | 0 | return false; |
163 | 0 | } |
164 | 0 | } else { |
165 | 0 | mTriggerEvent = nullptr; |
166 | 0 | } |
167 | 0 | mIsAnyMemberPresent = true; |
168 | 0 |
|
169 | 0 | if (!isNull) { |
170 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->x_id, temp.ptr())) { |
171 | 0 | return false; |
172 | 0 | } |
173 | 0 | } |
174 | 0 | if (!isNull && !temp->isUndefined()) { |
175 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mX)) { |
176 | 0 | return false; |
177 | 0 | } |
178 | 0 | } else { |
179 | 0 | mX = 0; |
180 | 0 | } |
181 | 0 | mIsAnyMemberPresent = true; |
182 | 0 |
|
183 | 0 | if (!isNull) { |
184 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->y_id, temp.ptr())) { |
185 | 0 | return false; |
186 | 0 | } |
187 | 0 | } |
188 | 0 | if (!isNull && !temp->isUndefined()) { |
189 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mY)) { |
190 | 0 | return false; |
191 | 0 | } |
192 | 0 | } else { |
193 | 0 | mY = 0; |
194 | 0 | } |
195 | 0 | mIsAnyMemberPresent = true; |
196 | 0 | return true; |
197 | 0 | } |
198 | | |
199 | | bool |
200 | | OpenPopupOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
201 | 0 | { |
202 | 0 | OpenPopupOptionsAtoms* atomsCache = GetAtomCache<OpenPopupOptionsAtoms>(cx); |
203 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
204 | 0 | return false; |
205 | 0 | } |
206 | 0 | |
207 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
208 | 0 | if (!obj) { |
209 | 0 | return false; |
210 | 0 | } |
211 | 0 | rval.set(JS::ObjectValue(*obj)); |
212 | 0 |
|
213 | 0 | do { |
214 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
215 | 0 | JS::Rooted<JS::Value> temp(cx); |
216 | 0 | bool const & currentValue = mAttributesOverride; |
217 | 0 | temp.setBoolean(currentValue); |
218 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->attributesOverride_id, temp, JSPROP_ENUMERATE)) { |
219 | 0 | return false; |
220 | 0 | } |
221 | 0 | break; |
222 | 0 | } while(false); |
223 | 0 |
|
224 | 0 | do { |
225 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
226 | 0 | JS::Rooted<JS::Value> temp(cx); |
227 | 0 | bool const & currentValue = mIsContextMenu; |
228 | 0 | temp.setBoolean(currentValue); |
229 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->isContextMenu_id, temp, JSPROP_ENUMERATE)) { |
230 | 0 | return false; |
231 | 0 | } |
232 | 0 | break; |
233 | 0 | } while(false); |
234 | 0 |
|
235 | 0 | do { |
236 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
237 | 0 | JS::Rooted<JS::Value> temp(cx); |
238 | 0 | nsString const & currentValue = mPosition; |
239 | 0 | if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) { |
240 | 0 | return false; |
241 | 0 | } |
242 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->position_id, temp, JSPROP_ENUMERATE)) { |
243 | 0 | return false; |
244 | 0 | } |
245 | 0 | break; |
246 | 0 | } while(false); |
247 | 0 |
|
248 | 0 | do { |
249 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
250 | 0 | JS::Rooted<JS::Value> temp(cx); |
251 | 0 | RefPtr<mozilla::dom::Event> const & currentValue = mTriggerEvent; |
252 | 0 | if (!currentValue) { |
253 | 0 | temp.setNull(); |
254 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->triggerEvent_id, temp, JSPROP_ENUMERATE)) { |
255 | 0 | return false; |
256 | 0 | } |
257 | 0 | break; |
258 | 0 | } |
259 | 0 | if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) { |
260 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
261 | 0 | return false; |
262 | 0 | } |
263 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->triggerEvent_id, temp, JSPROP_ENUMERATE)) { |
264 | 0 | return false; |
265 | 0 | } |
266 | 0 | break; |
267 | 0 | } while(false); |
268 | 0 |
|
269 | 0 | do { |
270 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
271 | 0 | JS::Rooted<JS::Value> temp(cx); |
272 | 0 | int32_t const & currentValue = mX; |
273 | 0 | temp.setInt32(int32_t(currentValue)); |
274 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->x_id, temp, JSPROP_ENUMERATE)) { |
275 | 0 | return false; |
276 | 0 | } |
277 | 0 | break; |
278 | 0 | } while(false); |
279 | 0 |
|
280 | 0 | do { |
281 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
282 | 0 | JS::Rooted<JS::Value> temp(cx); |
283 | 0 | int32_t const & currentValue = mY; |
284 | 0 | temp.setInt32(int32_t(currentValue)); |
285 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->y_id, temp, JSPROP_ENUMERATE)) { |
286 | 0 | return false; |
287 | 0 | } |
288 | 0 | break; |
289 | 0 | } while(false); |
290 | 0 |
|
291 | 0 | return true; |
292 | 0 | } |
293 | | |
294 | | void |
295 | | OpenPopupOptions::TraceDictionary(JSTracer* trc) |
296 | 0 | { |
297 | 0 | } |
298 | | |
299 | | |
300 | | |
301 | | OpenPopupOptions& |
302 | | OpenPopupOptions::operator=(const OpenPopupOptions& aOther) |
303 | 0 | { |
304 | 0 | DictionaryBase::operator=(aOther); |
305 | 0 | mAttributesOverride = aOther.mAttributesOverride; |
306 | 0 | mIsContextMenu = aOther.mIsContextMenu; |
307 | 0 | mPosition = aOther.mPosition; |
308 | 0 | mTriggerEvent = aOther.mTriggerEvent; |
309 | 0 | mX = aOther.mX; |
310 | 0 | mY = aOther.mY; |
311 | 0 | return *this; |
312 | 0 | } |
313 | | |
314 | | namespace binding_detail { |
315 | | } // namespace binding_detail |
316 | | |
317 | | |
318 | | bool |
319 | | StringOrOpenPopupOptions::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
320 | 0 | { |
321 | 0 | switch (mType) { |
322 | 0 | case eUninitialized: { |
323 | 0 | return false; |
324 | 0 | break; |
325 | 0 | } |
326 | 0 | case eString: { |
327 | 0 | if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) { |
328 | 0 | return false; |
329 | 0 | } |
330 | 0 | return true; |
331 | 0 | break; |
332 | 0 | } |
333 | 0 | case eOpenPopupOptions: { |
334 | 0 | if (!mValue.mOpenPopupOptions.Value().ToObjectInternal(cx, rval)) { |
335 | 0 | return false; |
336 | 0 | } |
337 | 0 | return true; |
338 | 0 | break; |
339 | 0 | } |
340 | 0 | default: { |
341 | 0 | return false; |
342 | 0 | break; |
343 | 0 | } |
344 | 0 | } |
345 | 0 | |
346 | 0 | return false; |
347 | 0 | } |
348 | | |
349 | | |
350 | | nsString& |
351 | | OwningStringOrOpenPopupOptions::RawSetAsString() |
352 | 0 | { |
353 | 0 | if (mType == eString) { |
354 | 0 | return mValue.mString.Value(); |
355 | 0 | } |
356 | 0 | MOZ_ASSERT(mType == eUninitialized); |
357 | 0 | mType = eString; |
358 | 0 | return mValue.mString.SetValue(); |
359 | 0 | } |
360 | | |
361 | | nsString& |
362 | | OwningStringOrOpenPopupOptions::SetAsString() |
363 | 0 | { |
364 | 0 | if (mType == eString) { |
365 | 0 | return mValue.mString.Value(); |
366 | 0 | } |
367 | 0 | Uninit(); |
368 | 0 | mType = eString; |
369 | 0 | return mValue.mString.SetValue(); |
370 | 0 | } |
371 | | |
372 | | bool |
373 | | OwningStringOrOpenPopupOptions::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
374 | 0 | { |
375 | 0 | tryNext = false; |
376 | 0 | { // scope for memberSlot |
377 | 0 | nsString& memberSlot = RawSetAsString(); |
378 | 0 | if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) { |
379 | 0 | return false; |
380 | 0 | } |
381 | 0 | } |
382 | 0 | return true; |
383 | 0 | } |
384 | | |
385 | | |
386 | | void |
387 | | OwningStringOrOpenPopupOptions::DestroyString() |
388 | 0 | { |
389 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
390 | 0 | mValue.mString.Destroy(); |
391 | 0 | mType = eUninitialized; |
392 | 0 | } |
393 | | |
394 | | |
395 | | |
396 | | |
397 | | OpenPopupOptions& |
398 | | OwningStringOrOpenPopupOptions::RawSetAsOpenPopupOptions() |
399 | 0 | { |
400 | 0 | if (mType == eOpenPopupOptions) { |
401 | 0 | return mValue.mOpenPopupOptions.Value(); |
402 | 0 | } |
403 | 0 | MOZ_ASSERT(mType == eUninitialized); |
404 | 0 | mType = eOpenPopupOptions; |
405 | 0 | return mValue.mOpenPopupOptions.SetValue(); |
406 | 0 | } |
407 | | |
408 | | OpenPopupOptions& |
409 | | OwningStringOrOpenPopupOptions::SetAsOpenPopupOptions() |
410 | 0 | { |
411 | 0 | if (mType == eOpenPopupOptions) { |
412 | 0 | return mValue.mOpenPopupOptions.Value(); |
413 | 0 | } |
414 | 0 | Uninit(); |
415 | 0 | mType = eOpenPopupOptions; |
416 | 0 | return mValue.mOpenPopupOptions.SetValue(); |
417 | 0 | } |
418 | | |
419 | | bool |
420 | | OwningStringOrOpenPopupOptions::TrySetToOpenPopupOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
421 | 0 | { |
422 | 0 | tryNext = false; |
423 | 0 | { // scope for memberSlot |
424 | 0 | OpenPopupOptions& memberSlot = RawSetAsOpenPopupOptions(); |
425 | 0 | if (!IsConvertibleToDictionary(value)) { |
426 | 0 | DestroyOpenPopupOptions(); |
427 | 0 | tryNext = true; |
428 | 0 | return true; |
429 | 0 | } |
430 | 0 | if (!memberSlot.Init(cx, value, "Member of StringOrOpenPopupOptions", passedToJSImpl)) { |
431 | 0 | return false; |
432 | 0 | } |
433 | 0 | } |
434 | 0 | return true; |
435 | 0 | } |
436 | | |
437 | | void |
438 | | OwningStringOrOpenPopupOptions::DestroyOpenPopupOptions() |
439 | 0 | { |
440 | 0 | MOZ_ASSERT(IsOpenPopupOptions(), "Wrong type!"); |
441 | 0 | mValue.mOpenPopupOptions.Destroy(); |
442 | 0 | mType = eUninitialized; |
443 | 0 | } |
444 | | |
445 | | |
446 | | |
447 | | |
448 | | void |
449 | | OwningStringOrOpenPopupOptions::Uninit() |
450 | | { |
451 | | switch (mType) { |
452 | | case eUninitialized: { |
453 | | break; |
454 | | } |
455 | | case eString: { |
456 | | DestroyString(); |
457 | | break; |
458 | | } |
459 | | case eOpenPopupOptions: { |
460 | | DestroyOpenPopupOptions(); |
461 | | break; |
462 | | } |
463 | | } |
464 | | } |
465 | | |
466 | | bool |
467 | | OwningStringOrOpenPopupOptions::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
468 | 0 | { |
469 | 0 | switch (mType) { |
470 | 0 | case eUninitialized: { |
471 | 0 | return false; |
472 | 0 | break; |
473 | 0 | } |
474 | 0 | case eString: { |
475 | 0 | if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) { |
476 | 0 | return false; |
477 | 0 | } |
478 | 0 | return true; |
479 | 0 | break; |
480 | 0 | } |
481 | 0 | case eOpenPopupOptions: { |
482 | 0 | if (!mValue.mOpenPopupOptions.Value().ToObjectInternal(cx, rval)) { |
483 | 0 | return false; |
484 | 0 | } |
485 | 0 | return true; |
486 | 0 | break; |
487 | 0 | } |
488 | 0 | default: { |
489 | 0 | return false; |
490 | 0 | break; |
491 | 0 | } |
492 | 0 | } |
493 | 0 | |
494 | 0 | return false; |
495 | 0 | } |
496 | | |
497 | | void |
498 | | OwningStringOrOpenPopupOptions::TraceUnion(JSTracer* trc) |
499 | 0 | { |
500 | 0 | } |
501 | | |
502 | | OwningStringOrOpenPopupOptions& |
503 | | OwningStringOrOpenPopupOptions::operator=(const OwningStringOrOpenPopupOptions& aOther) |
504 | 0 | { |
505 | 0 | switch (aOther.mType) { |
506 | 0 | case eUninitialized: { |
507 | 0 | MOZ_ASSERT(mType == eUninitialized, |
508 | 0 | "We need to destroy ourselves?"); |
509 | 0 | break; |
510 | 0 | } |
511 | 0 | case eString: { |
512 | 0 | SetAsString() = aOther.GetAsString(); |
513 | 0 | break; |
514 | 0 | } |
515 | 0 | case eOpenPopupOptions: { |
516 | 0 | SetAsOpenPopupOptions() = aOther.GetAsOpenPopupOptions(); |
517 | 0 | break; |
518 | 0 | } |
519 | 0 | } |
520 | 0 | return *this; |
521 | 0 | } |
522 | | |
523 | | |
524 | | namespace XULPopupElement_Binding { |
525 | | |
526 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<XULElement_Binding::NativeType>::value, |
527 | | "Can't inherit from an interface with a different ownership model."); |
528 | | |
529 | | MOZ_CAN_RUN_SCRIPT static bool |
530 | | get_autoPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
531 | 0 | { |
532 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.autoPosition", DOM, cx); |
533 | 0 |
|
534 | 0 | bool result(self->AutoPosition()); |
535 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
536 | 0 | args.rval().setBoolean(result); |
537 | 0 | return true; |
538 | 0 | } |
539 | | |
540 | | MOZ_CAN_RUN_SCRIPT static bool |
541 | | set_autoPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitSetterCallArgs args) |
542 | 0 | { |
543 | 0 | AUTO_PROFILER_LABEL_FAST("set XULPopupElement.autoPosition", DOM, cx); |
544 | 0 |
|
545 | 0 | bool arg0; |
546 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
547 | 0 | return false; |
548 | 0 | } |
549 | 0 | self->SetAutoPosition(arg0); |
550 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
551 | 0 |
|
552 | 0 | return true; |
553 | 0 | } |
554 | | |
555 | | static const JSJitInfo autoPosition_getterinfo = { |
556 | | { (JSJitGetterOp)get_autoPosition }, |
557 | | { prototypes::id::XULPopupElement }, |
558 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
559 | | JSJitInfo::Getter, |
560 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
561 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
562 | | true, /* isInfallible. False in setters. */ |
563 | | false, /* isMovable. Not relevant for setters. */ |
564 | | false, /* isEliminatable. Not relevant for setters. */ |
565 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
566 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
567 | | false, /* isTypedMethod. Only relevant for methods. */ |
568 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
569 | | }; |
570 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
571 | | static_assert(0 < 1, "There is no slot for us"); |
572 | | static const JSJitInfo autoPosition_setterinfo = { |
573 | | { (JSJitGetterOp)set_autoPosition }, |
574 | | { prototypes::id::XULPopupElement }, |
575 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
576 | | JSJitInfo::Setter, |
577 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
578 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
579 | | false, /* isInfallible. False in setters. */ |
580 | | false, /* isMovable. Not relevant for setters. */ |
581 | | false, /* isEliminatable. Not relevant for setters. */ |
582 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
583 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
584 | | false, /* isTypedMethod. Only relevant for methods. */ |
585 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
586 | | }; |
587 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
588 | | static_assert(0 < 1, "There is no slot for us"); |
589 | | |
590 | | MOZ_CAN_RUN_SCRIPT static bool |
591 | | openPopup(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
592 | 0 | { |
593 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.openPopup", DOM, cx); |
594 | 0 |
|
595 | 0 | mozilla::dom::Element* arg0; |
596 | 0 | if (args.hasDefined(0)) { |
597 | 0 | if (args[0].isObject()) { |
598 | 0 | { |
599 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0); |
600 | 0 | if (NS_FAILED(rv)) { |
601 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULPopupElement.openPopup", "Element"); |
602 | 0 | return false; |
603 | 0 | } |
604 | 0 | } |
605 | 0 | } else if (args[0].isNullOrUndefined()) { |
606 | 0 | arg0 = nullptr; |
607 | 0 | } else { |
608 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULPopupElement.openPopup"); |
609 | 0 | return false; |
610 | 0 | } |
611 | 0 | } else { |
612 | 0 | arg0 = nullptr; |
613 | 0 | } |
614 | 0 | StringOrOpenPopupOptions arg1; |
615 | 0 | StringOrOpenPopupOptionsArgument arg1_holder(arg1); |
616 | 0 | if (!(args.hasDefined(1))) { |
617 | 0 | if (!arg1.RawSetAsOpenPopupOptions().Init(cx, JS::NullHandleValue, "Member of StringOrOpenPopupOptions")) { |
618 | 0 | return false; |
619 | 0 | } |
620 | 0 | } else { |
621 | 0 | { |
622 | 0 | bool done = false, failed = false, tryNext; |
623 | 0 | if (!done) { |
624 | 0 | done = (failed = !arg1_holder.TrySetToOpenPopupOptions(cx, args[1], tryNext, false)) || !tryNext; |
625 | 0 | } |
626 | 0 | if (!done) { |
627 | 0 | do { |
628 | 0 | done = (failed = !arg1_holder.TrySetToString(cx, args[1], tryNext)) || !tryNext; |
629 | 0 | break; |
630 | 0 | } while (false); |
631 | 0 | } |
632 | 0 | if (failed) { |
633 | 0 | return false; |
634 | 0 | } |
635 | 0 | if (!done) { |
636 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of XULPopupElement.openPopup", "OpenPopupOptions"); |
637 | 0 | return false; |
638 | 0 | } |
639 | 0 | } |
640 | 0 | } |
641 | 0 | int32_t arg2; |
642 | 0 | if (args.hasDefined(2)) { |
643 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
644 | 0 | return false; |
645 | 0 | } |
646 | 0 | } else { |
647 | 0 | arg2 = 0; |
648 | 0 | } |
649 | 0 | int32_t arg3; |
650 | 0 | if (args.hasDefined(3)) { |
651 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
652 | 0 | return false; |
653 | 0 | } |
654 | 0 | } else { |
655 | 0 | arg3 = 0; |
656 | 0 | } |
657 | 0 | bool arg4; |
658 | 0 | if (args.hasDefined(4)) { |
659 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[4], &arg4)) { |
660 | 0 | return false; |
661 | 0 | } |
662 | 0 | } else { |
663 | 0 | arg4 = false; |
664 | 0 | } |
665 | 0 | bool arg5; |
666 | 0 | if (args.hasDefined(5)) { |
667 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) { |
668 | 0 | return false; |
669 | 0 | } |
670 | 0 | } else { |
671 | 0 | arg5 = false; |
672 | 0 | } |
673 | 0 | mozilla::dom::Event* arg6; |
674 | 0 | if (args.hasDefined(6)) { |
675 | 0 | if (args[6].isObject()) { |
676 | 0 | { |
677 | 0 | nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(args[6], arg6); |
678 | 0 | if (NS_FAILED(rv)) { |
679 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 7 of XULPopupElement.openPopup", "Event"); |
680 | 0 | return false; |
681 | 0 | } |
682 | 0 | } |
683 | 0 | } else if (args[6].isNullOrUndefined()) { |
684 | 0 | arg6 = nullptr; |
685 | 0 | } else { |
686 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 7 of XULPopupElement.openPopup"); |
687 | 0 | return false; |
688 | 0 | } |
689 | 0 | } else { |
690 | 0 | arg6 = nullptr; |
691 | 0 | } |
692 | 0 | self->OpenPopup(MOZ_KnownLive(Constify(arg0)), Constify(arg1), arg2, arg3, arg4, arg5, MOZ_KnownLive(Constify(arg6))); |
693 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
694 | 0 | args.rval().setUndefined(); |
695 | 0 | return true; |
696 | 0 | } |
697 | | |
698 | | static const JSJitInfo openPopup_methodinfo = { |
699 | | { (JSJitGetterOp)openPopup }, |
700 | | { prototypes::id::XULPopupElement }, |
701 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
702 | | JSJitInfo::Method, |
703 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
704 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
705 | | false, /* isInfallible. False in setters. */ |
706 | | false, /* isMovable. Not relevant for setters. */ |
707 | | false, /* isEliminatable. Not relevant for setters. */ |
708 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
709 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
710 | | false, /* isTypedMethod. Only relevant for methods. */ |
711 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
712 | | }; |
713 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
714 | | static_assert(0 < 1, "There is no slot for us"); |
715 | | |
716 | | MOZ_CAN_RUN_SCRIPT static bool |
717 | | openPopupAtScreen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
718 | 0 | { |
719 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.openPopupAtScreen", DOM, cx); |
720 | 0 |
|
721 | 0 | int32_t arg0; |
722 | 0 | if (args.hasDefined(0)) { |
723 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
724 | 0 | return false; |
725 | 0 | } |
726 | 0 | } else { |
727 | 0 | arg0 = 0; |
728 | 0 | } |
729 | 0 | int32_t arg1; |
730 | 0 | if (args.hasDefined(1)) { |
731 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
732 | 0 | return false; |
733 | 0 | } |
734 | 0 | } else { |
735 | 0 | arg1 = 0; |
736 | 0 | } |
737 | 0 | bool arg2; |
738 | 0 | if (args.hasDefined(2)) { |
739 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) { |
740 | 0 | return false; |
741 | 0 | } |
742 | 0 | } else { |
743 | 0 | arg2 = false; |
744 | 0 | } |
745 | 0 | mozilla::dom::Event* arg3; |
746 | 0 | if (args.hasDefined(3)) { |
747 | 0 | if (args[3].isObject()) { |
748 | 0 | { |
749 | 0 | nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(args[3], arg3); |
750 | 0 | if (NS_FAILED(rv)) { |
751 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of XULPopupElement.openPopupAtScreen", "Event"); |
752 | 0 | return false; |
753 | 0 | } |
754 | 0 | } |
755 | 0 | } else if (args[3].isNullOrUndefined()) { |
756 | 0 | arg3 = nullptr; |
757 | 0 | } else { |
758 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of XULPopupElement.openPopupAtScreen"); |
759 | 0 | return false; |
760 | 0 | } |
761 | 0 | } else { |
762 | 0 | arg3 = nullptr; |
763 | 0 | } |
764 | 0 | self->OpenPopupAtScreen(arg0, arg1, arg2, MOZ_KnownLive(Constify(arg3))); |
765 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
766 | 0 | args.rval().setUndefined(); |
767 | 0 | return true; |
768 | 0 | } |
769 | | |
770 | | static const JSJitInfo openPopupAtScreen_methodinfo = { |
771 | | { (JSJitGetterOp)openPopupAtScreen }, |
772 | | { prototypes::id::XULPopupElement }, |
773 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
774 | | JSJitInfo::Method, |
775 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
776 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
777 | | false, /* isInfallible. False in setters. */ |
778 | | false, /* isMovable. Not relevant for setters. */ |
779 | | false, /* isEliminatable. Not relevant for setters. */ |
780 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
781 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
782 | | false, /* isTypedMethod. Only relevant for methods. */ |
783 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
784 | | }; |
785 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
786 | | static_assert(0 < 1, "There is no slot for us"); |
787 | | |
788 | | MOZ_CAN_RUN_SCRIPT static bool |
789 | | openPopupAtScreenRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
790 | 0 | { |
791 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.openPopupAtScreenRect", DOM, cx); |
792 | 0 |
|
793 | 0 | binding_detail::FakeString arg0; |
794 | 0 | if (args.hasDefined(0)) { |
795 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
796 | 0 | return false; |
797 | 0 | } |
798 | 0 | } else { |
799 | 0 | static const char16_t data[] = { 0 }; |
800 | 0 | arg0.Rebind(data, ArrayLength(data) - 1); |
801 | 0 | } |
802 | 0 | int32_t arg1; |
803 | 0 | if (args.hasDefined(1)) { |
804 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
805 | 0 | return false; |
806 | 0 | } |
807 | 0 | } else { |
808 | 0 | arg1 = 0; |
809 | 0 | } |
810 | 0 | int32_t arg2; |
811 | 0 | if (args.hasDefined(2)) { |
812 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
813 | 0 | return false; |
814 | 0 | } |
815 | 0 | } else { |
816 | 0 | arg2 = 0; |
817 | 0 | } |
818 | 0 | int32_t arg3; |
819 | 0 | if (args.hasDefined(3)) { |
820 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
821 | 0 | return false; |
822 | 0 | } |
823 | 0 | } else { |
824 | 0 | arg3 = 0; |
825 | 0 | } |
826 | 0 | int32_t arg4; |
827 | 0 | if (args.hasDefined(4)) { |
828 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
829 | 0 | return false; |
830 | 0 | } |
831 | 0 | } else { |
832 | 0 | arg4 = 0; |
833 | 0 | } |
834 | 0 | bool arg5; |
835 | 0 | if (args.hasDefined(5)) { |
836 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) { |
837 | 0 | return false; |
838 | 0 | } |
839 | 0 | } else { |
840 | 0 | arg5 = false; |
841 | 0 | } |
842 | 0 | bool arg6; |
843 | 0 | if (args.hasDefined(6)) { |
844 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[6], &arg6)) { |
845 | 0 | return false; |
846 | 0 | } |
847 | 0 | } else { |
848 | 0 | arg6 = false; |
849 | 0 | } |
850 | 0 | mozilla::dom::Event* arg7; |
851 | 0 | if (args.hasDefined(7)) { |
852 | 0 | if (args[7].isObject()) { |
853 | 0 | { |
854 | 0 | nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(args[7], arg7); |
855 | 0 | if (NS_FAILED(rv)) { |
856 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 8 of XULPopupElement.openPopupAtScreenRect", "Event"); |
857 | 0 | return false; |
858 | 0 | } |
859 | 0 | } |
860 | 0 | } else if (args[7].isNullOrUndefined()) { |
861 | 0 | arg7 = nullptr; |
862 | 0 | } else { |
863 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 8 of XULPopupElement.openPopupAtScreenRect"); |
864 | 0 | return false; |
865 | 0 | } |
866 | 0 | } else { |
867 | 0 | arg7 = nullptr; |
868 | 0 | } |
869 | 0 | self->OpenPopupAtScreenRect(NonNullHelper(Constify(arg0)), arg1, arg2, arg3, arg4, arg5, arg6, MOZ_KnownLive(Constify(arg7))); |
870 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
871 | 0 | args.rval().setUndefined(); |
872 | 0 | return true; |
873 | 0 | } |
874 | | |
875 | | static const JSJitInfo openPopupAtScreenRect_methodinfo = { |
876 | | { (JSJitGetterOp)openPopupAtScreenRect }, |
877 | | { prototypes::id::XULPopupElement }, |
878 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
879 | | JSJitInfo::Method, |
880 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
881 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
882 | | false, /* isInfallible. False in setters. */ |
883 | | false, /* isMovable. Not relevant for setters. */ |
884 | | false, /* isEliminatable. Not relevant for setters. */ |
885 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
886 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
887 | | false, /* isTypedMethod. Only relevant for methods. */ |
888 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
889 | | }; |
890 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
891 | | static_assert(0 < 1, "There is no slot for us"); |
892 | | |
893 | | MOZ_CAN_RUN_SCRIPT static bool |
894 | | hidePopup(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
895 | 0 | { |
896 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.hidePopup", DOM, cx); |
897 | 0 |
|
898 | 0 | bool arg0; |
899 | 0 | if (args.hasDefined(0)) { |
900 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
901 | 0 | return false; |
902 | 0 | } |
903 | 0 | } else { |
904 | 0 | arg0 = false; |
905 | 0 | } |
906 | 0 | self->HidePopup(arg0); |
907 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
908 | 0 | args.rval().setUndefined(); |
909 | 0 | return true; |
910 | 0 | } |
911 | | |
912 | | static const JSJitInfo hidePopup_methodinfo = { |
913 | | { (JSJitGetterOp)hidePopup }, |
914 | | { prototypes::id::XULPopupElement }, |
915 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
916 | | JSJitInfo::Method, |
917 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
918 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
919 | | false, /* isInfallible. False in setters. */ |
920 | | false, /* isMovable. Not relevant for setters. */ |
921 | | false, /* isEliminatable. Not relevant for setters. */ |
922 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
923 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
924 | | false, /* isTypedMethod. Only relevant for methods. */ |
925 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
926 | | }; |
927 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
928 | | static_assert(0 < 1, "There is no slot for us"); |
929 | | |
930 | | MOZ_CAN_RUN_SCRIPT static bool |
931 | | get_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
932 | 0 | { |
933 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.label", DOM, cx); |
934 | 0 |
|
935 | 0 | DOMString result; |
936 | 0 | self->GetLabel(result); |
937 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
938 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
939 | 0 | return false; |
940 | 0 | } |
941 | 0 | return true; |
942 | 0 | } |
943 | | |
944 | | MOZ_CAN_RUN_SCRIPT static bool |
945 | | set_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitSetterCallArgs args) |
946 | 0 | { |
947 | 0 | AUTO_PROFILER_LABEL_FAST("set XULPopupElement.label", DOM, cx); |
948 | 0 |
|
949 | 0 | binding_detail::FakeString arg0; |
950 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
951 | 0 | return false; |
952 | 0 | } |
953 | 0 | FastErrorResult rv; |
954 | 0 | self->SetLabel(NonNullHelper(Constify(arg0)), rv); |
955 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
956 | 0 | return false; |
957 | 0 | } |
958 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
959 | 0 |
|
960 | 0 | return true; |
961 | 0 | } |
962 | | |
963 | | static const JSJitInfo label_getterinfo = { |
964 | | { (JSJitGetterOp)get_label }, |
965 | | { prototypes::id::XULPopupElement }, |
966 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
967 | | JSJitInfo::Getter, |
968 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
969 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
970 | | false, /* isInfallible. False in setters. */ |
971 | | false, /* isMovable. Not relevant for setters. */ |
972 | | false, /* isEliminatable. Not relevant for setters. */ |
973 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
974 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
975 | | false, /* isTypedMethod. Only relevant for methods. */ |
976 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
977 | | }; |
978 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
979 | | static_assert(0 < 1, "There is no slot for us"); |
980 | | static const JSJitInfo label_setterinfo = { |
981 | | { (JSJitGetterOp)set_label }, |
982 | | { prototypes::id::XULPopupElement }, |
983 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
984 | | JSJitInfo::Setter, |
985 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
986 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
987 | | false, /* isInfallible. False in setters. */ |
988 | | false, /* isMovable. Not relevant for setters. */ |
989 | | false, /* isEliminatable. Not relevant for setters. */ |
990 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
991 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
992 | | false, /* isTypedMethod. Only relevant for methods. */ |
993 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
994 | | }; |
995 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
996 | | static_assert(0 < 1, "There is no slot for us"); |
997 | | |
998 | | MOZ_CAN_RUN_SCRIPT static bool |
999 | | get_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
1000 | 0 | { |
1001 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.position", DOM, cx); |
1002 | 0 |
|
1003 | 0 | DOMString result; |
1004 | 0 | self->GetPosition(result); |
1005 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1006 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1007 | 0 | return false; |
1008 | 0 | } |
1009 | 0 | return true; |
1010 | 0 | } |
1011 | | |
1012 | | MOZ_CAN_RUN_SCRIPT static bool |
1013 | | set_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitSetterCallArgs args) |
1014 | 0 | { |
1015 | 0 | AUTO_PROFILER_LABEL_FAST("set XULPopupElement.position", DOM, cx); |
1016 | 0 |
|
1017 | 0 | binding_detail::FakeString arg0; |
1018 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1019 | 0 | return false; |
1020 | 0 | } |
1021 | 0 | FastErrorResult rv; |
1022 | 0 | self->SetPosition(NonNullHelper(Constify(arg0)), rv); |
1023 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1024 | 0 | return false; |
1025 | 0 | } |
1026 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1027 | 0 |
|
1028 | 0 | return true; |
1029 | 0 | } |
1030 | | |
1031 | | static const JSJitInfo position_getterinfo = { |
1032 | | { (JSJitGetterOp)get_position }, |
1033 | | { prototypes::id::XULPopupElement }, |
1034 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1035 | | JSJitInfo::Getter, |
1036 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1037 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1038 | | false, /* isInfallible. False in setters. */ |
1039 | | false, /* isMovable. Not relevant for setters. */ |
1040 | | false, /* isEliminatable. Not relevant for setters. */ |
1041 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1042 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1043 | | false, /* isTypedMethod. Only relevant for methods. */ |
1044 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1045 | | }; |
1046 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1047 | | static_assert(0 < 1, "There is no slot for us"); |
1048 | | static const JSJitInfo position_setterinfo = { |
1049 | | { (JSJitGetterOp)set_position }, |
1050 | | { prototypes::id::XULPopupElement }, |
1051 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1052 | | JSJitInfo::Setter, |
1053 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1054 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1055 | | false, /* isInfallible. False in setters. */ |
1056 | | false, /* isMovable. Not relevant for setters. */ |
1057 | | false, /* isEliminatable. Not relevant for setters. */ |
1058 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1059 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1060 | | false, /* isTypedMethod. Only relevant for methods. */ |
1061 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1062 | | }; |
1063 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1064 | | static_assert(0 < 1, "There is no slot for us"); |
1065 | | |
1066 | | MOZ_CAN_RUN_SCRIPT static bool |
1067 | | get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
1068 | 0 | { |
1069 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.state", DOM, cx); |
1070 | 0 |
|
1071 | 0 | DOMString result; |
1072 | 0 | self->GetState(result); |
1073 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1074 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1075 | 0 | return false; |
1076 | 0 | } |
1077 | 0 | return true; |
1078 | 0 | } |
1079 | | |
1080 | | static const JSJitInfo state_getterinfo = { |
1081 | | { (JSJitGetterOp)get_state }, |
1082 | | { prototypes::id::XULPopupElement }, |
1083 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1084 | | JSJitInfo::Getter, |
1085 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1086 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1087 | | false, /* isInfallible. False in setters. */ |
1088 | | false, /* isMovable. Not relevant for setters. */ |
1089 | | false, /* isEliminatable. Not relevant for setters. */ |
1090 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1091 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1092 | | false, /* isTypedMethod. Only relevant for methods. */ |
1093 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1094 | | }; |
1095 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1096 | | static_assert(0 < 1, "There is no slot for us"); |
1097 | | |
1098 | | MOZ_CAN_RUN_SCRIPT static bool |
1099 | | get_triggerNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
1100 | 0 | { |
1101 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.triggerNode", DOM, cx); |
1102 | 0 |
|
1103 | 0 | auto result(StrongOrRawPtr<nsINode>(self->GetTriggerNode())); |
1104 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1105 | 0 | if (!result) { |
1106 | 0 | args.rval().setNull(); |
1107 | 0 | return true; |
1108 | 0 | } |
1109 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1110 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1111 | 0 | return false; |
1112 | 0 | } |
1113 | 0 | return true; |
1114 | 0 | } |
1115 | | |
1116 | | static const JSJitInfo triggerNode_getterinfo = { |
1117 | | { (JSJitGetterOp)get_triggerNode }, |
1118 | | { prototypes::id::XULPopupElement }, |
1119 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1120 | | JSJitInfo::Getter, |
1121 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1122 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1123 | | false, /* isInfallible. False in setters. */ |
1124 | | false, /* isMovable. Not relevant for setters. */ |
1125 | | false, /* isEliminatable. Not relevant for setters. */ |
1126 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1127 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1128 | | false, /* isTypedMethod. Only relevant for methods. */ |
1129 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1130 | | }; |
1131 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1132 | | static_assert(0 < 1, "There is no slot for us"); |
1133 | | |
1134 | | MOZ_CAN_RUN_SCRIPT static bool |
1135 | | get_anchorNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
1136 | 0 | { |
1137 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.anchorNode", DOM, cx); |
1138 | 0 |
|
1139 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetAnchorNode())); |
1140 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1141 | 0 | if (!result) { |
1142 | 0 | args.rval().setNull(); |
1143 | 0 | return true; |
1144 | 0 | } |
1145 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1146 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1147 | 0 | return false; |
1148 | 0 | } |
1149 | 0 | return true; |
1150 | 0 | } |
1151 | | |
1152 | | static const JSJitInfo anchorNode_getterinfo = { |
1153 | | { (JSJitGetterOp)get_anchorNode }, |
1154 | | { prototypes::id::XULPopupElement }, |
1155 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1156 | | JSJitInfo::Getter, |
1157 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1158 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1159 | | false, /* isInfallible. False in setters. */ |
1160 | | false, /* isMovable. Not relevant for setters. */ |
1161 | | false, /* isEliminatable. Not relevant for setters. */ |
1162 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1163 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1164 | | false, /* isTypedMethod. Only relevant for methods. */ |
1165 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1166 | | }; |
1167 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1168 | | static_assert(0 < 1, "There is no slot for us"); |
1169 | | |
1170 | | MOZ_CAN_RUN_SCRIPT static bool |
1171 | | getOuterScreenRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
1172 | 0 | { |
1173 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.getOuterScreenRect", DOM, cx); |
1174 | 0 |
|
1175 | 0 | auto result(StrongOrRawPtr<mozilla::dom::DOMRect>(self->GetOuterScreenRect())); |
1176 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1177 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
1178 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1179 | 0 | return false; |
1180 | 0 | } |
1181 | 0 | return true; |
1182 | 0 | } |
1183 | | |
1184 | | static const JSJitInfo getOuterScreenRect_methodinfo = { |
1185 | | { (JSJitGetterOp)getOuterScreenRect }, |
1186 | | { prototypes::id::XULPopupElement }, |
1187 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1188 | | JSJitInfo::Method, |
1189 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1190 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1191 | | false, /* isInfallible. False in setters. */ |
1192 | | false, /* isMovable. Not relevant for setters. */ |
1193 | | false, /* isEliminatable. Not relevant for setters. */ |
1194 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1195 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1196 | | false, /* isTypedMethod. Only relevant for methods. */ |
1197 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1198 | | }; |
1199 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1200 | | static_assert(0 < 1, "There is no slot for us"); |
1201 | | |
1202 | | MOZ_CAN_RUN_SCRIPT static bool |
1203 | | moveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
1204 | 0 | { |
1205 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.moveTo", DOM, cx); |
1206 | 0 |
|
1207 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1208 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULPopupElement.moveTo"); |
1209 | 0 | } |
1210 | 0 | int32_t arg0; |
1211 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
1212 | 0 | return false; |
1213 | 0 | } |
1214 | 0 | int32_t arg1; |
1215 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
1216 | 0 | return false; |
1217 | 0 | } |
1218 | 0 | self->MoveTo(arg0, arg1); |
1219 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1220 | 0 | args.rval().setUndefined(); |
1221 | 0 | return true; |
1222 | 0 | } |
1223 | | |
1224 | | static const JSJitInfo moveTo_methodinfo = { |
1225 | | { (JSJitGetterOp)moveTo }, |
1226 | | { prototypes::id::XULPopupElement }, |
1227 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1228 | | JSJitInfo::Method, |
1229 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1230 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1231 | | false, /* isInfallible. False in setters. */ |
1232 | | false, /* isMovable. Not relevant for setters. */ |
1233 | | false, /* isEliminatable. Not relevant for setters. */ |
1234 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1235 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1236 | | false, /* isTypedMethod. Only relevant for methods. */ |
1237 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1238 | | }; |
1239 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1240 | | static_assert(0 < 1, "There is no slot for us"); |
1241 | | |
1242 | | MOZ_CAN_RUN_SCRIPT static bool |
1243 | | moveToAnchor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
1244 | 0 | { |
1245 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.moveToAnchor", DOM, cx); |
1246 | 0 |
|
1247 | 0 | mozilla::dom::Element* arg0; |
1248 | 0 | if (args.hasDefined(0)) { |
1249 | 0 | if (args[0].isObject()) { |
1250 | 0 | { |
1251 | 0 | nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0); |
1252 | 0 | if (NS_FAILED(rv)) { |
1253 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULPopupElement.moveToAnchor", "Element"); |
1254 | 0 | return false; |
1255 | 0 | } |
1256 | 0 | } |
1257 | 0 | } else if (args[0].isNullOrUndefined()) { |
1258 | 0 | arg0 = nullptr; |
1259 | 0 | } else { |
1260 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULPopupElement.moveToAnchor"); |
1261 | 0 | return false; |
1262 | 0 | } |
1263 | 0 | } else { |
1264 | 0 | arg0 = nullptr; |
1265 | 0 | } |
1266 | 0 | binding_detail::FakeString arg1; |
1267 | 0 | if (args.hasDefined(1)) { |
1268 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
1269 | 0 | return false; |
1270 | 0 | } |
1271 | 0 | } else { |
1272 | 0 | static const char16_t data[] = { 0 }; |
1273 | 0 | arg1.Rebind(data, ArrayLength(data) - 1); |
1274 | 0 | } |
1275 | 0 | int32_t arg2; |
1276 | 0 | if (args.hasDefined(2)) { |
1277 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
1278 | 0 | return false; |
1279 | 0 | } |
1280 | 0 | } else { |
1281 | 0 | arg2 = 0; |
1282 | 0 | } |
1283 | 0 | int32_t arg3; |
1284 | 0 | if (args.hasDefined(3)) { |
1285 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
1286 | 0 | return false; |
1287 | 0 | } |
1288 | 0 | } else { |
1289 | 0 | arg3 = 0; |
1290 | 0 | } |
1291 | 0 | bool arg4; |
1292 | 0 | if (args.hasDefined(4)) { |
1293 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[4], &arg4)) { |
1294 | 0 | return false; |
1295 | 0 | } |
1296 | 0 | } else { |
1297 | 0 | arg4 = false; |
1298 | 0 | } |
1299 | 0 | self->MoveToAnchor(MOZ_KnownLive(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2, arg3, arg4); |
1300 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1301 | 0 | args.rval().setUndefined(); |
1302 | 0 | return true; |
1303 | 0 | } |
1304 | | |
1305 | | static const JSJitInfo moveToAnchor_methodinfo = { |
1306 | | { (JSJitGetterOp)moveToAnchor }, |
1307 | | { prototypes::id::XULPopupElement }, |
1308 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1309 | | JSJitInfo::Method, |
1310 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1311 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1312 | | false, /* isInfallible. False in setters. */ |
1313 | | false, /* isMovable. Not relevant for setters. */ |
1314 | | false, /* isEliminatable. Not relevant for setters. */ |
1315 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1316 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1317 | | false, /* isTypedMethod. Only relevant for methods. */ |
1318 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1319 | | }; |
1320 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1321 | | static_assert(0 < 1, "There is no slot for us"); |
1322 | | |
1323 | | MOZ_CAN_RUN_SCRIPT static bool |
1324 | | sizeTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
1325 | 0 | { |
1326 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.sizeTo", DOM, cx); |
1327 | 0 |
|
1328 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1329 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULPopupElement.sizeTo"); |
1330 | 0 | } |
1331 | 0 | int32_t arg0; |
1332 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
1333 | 0 | return false; |
1334 | 0 | } |
1335 | 0 | int32_t arg1; |
1336 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
1337 | 0 | return false; |
1338 | 0 | } |
1339 | 0 | self->SizeTo(arg0, arg1); |
1340 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1341 | 0 | args.rval().setUndefined(); |
1342 | 0 | return true; |
1343 | 0 | } |
1344 | | |
1345 | | static const JSJitInfo sizeTo_methodinfo = { |
1346 | | { (JSJitGetterOp)sizeTo }, |
1347 | | { prototypes::id::XULPopupElement }, |
1348 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1349 | | JSJitInfo::Method, |
1350 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1351 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1352 | | false, /* isInfallible. False in setters. */ |
1353 | | false, /* isMovable. Not relevant for setters. */ |
1354 | | false, /* isEliminatable. Not relevant for setters. */ |
1355 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1356 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1357 | | false, /* isTypedMethod. Only relevant for methods. */ |
1358 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1359 | | }; |
1360 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1361 | | static_assert(0 < 1, "There is no slot for us"); |
1362 | | |
1363 | | MOZ_CAN_RUN_SCRIPT static bool |
1364 | | get_alignmentPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
1365 | 0 | { |
1366 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.alignmentPosition", DOM, cx); |
1367 | 0 |
|
1368 | 0 | DOMString result; |
1369 | 0 | self->GetAlignmentPosition(result); |
1370 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1371 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1372 | 0 | return false; |
1373 | 0 | } |
1374 | 0 | return true; |
1375 | 0 | } |
1376 | | |
1377 | | static const JSJitInfo alignmentPosition_getterinfo = { |
1378 | | { (JSJitGetterOp)get_alignmentPosition }, |
1379 | | { prototypes::id::XULPopupElement }, |
1380 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1381 | | JSJitInfo::Getter, |
1382 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1383 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1384 | | false, /* isInfallible. False in setters. */ |
1385 | | false, /* isMovable. Not relevant for setters. */ |
1386 | | false, /* isEliminatable. Not relevant for setters. */ |
1387 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1388 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1389 | | false, /* isTypedMethod. Only relevant for methods. */ |
1390 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1391 | | }; |
1392 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1393 | | static_assert(0 < 1, "There is no slot for us"); |
1394 | | |
1395 | | MOZ_CAN_RUN_SCRIPT static bool |
1396 | | get_alignmentOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, JSJitGetterCallArgs args) |
1397 | 0 | { |
1398 | 0 | AUTO_PROFILER_LABEL_FAST("get XULPopupElement.alignmentOffset", DOM, cx); |
1399 | 0 |
|
1400 | 0 | int32_t result(self->AlignmentOffset()); |
1401 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1402 | 0 | args.rval().setInt32(int32_t(result)); |
1403 | 0 | return true; |
1404 | 0 | } |
1405 | | |
1406 | | static const JSJitInfo alignmentOffset_getterinfo = { |
1407 | | { (JSJitGetterOp)get_alignmentOffset }, |
1408 | | { prototypes::id::XULPopupElement }, |
1409 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1410 | | JSJitInfo::Getter, |
1411 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1412 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
1413 | | true, /* isInfallible. False in setters. */ |
1414 | | false, /* isMovable. Not relevant for setters. */ |
1415 | | false, /* isEliminatable. Not relevant for setters. */ |
1416 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1417 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1418 | | false, /* isTypedMethod. Only relevant for methods. */ |
1419 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1420 | | }; |
1421 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1422 | | static_assert(0 < 1, "There is no slot for us"); |
1423 | | |
1424 | | MOZ_CAN_RUN_SCRIPT static bool |
1425 | | setConstraintRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULPopupElement* self, const JSJitMethodCallArgs& args) |
1426 | 0 | { |
1427 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement.setConstraintRect", DOM, cx); |
1428 | 0 |
|
1429 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1430 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULPopupElement.setConstraintRect"); |
1431 | 0 | } |
1432 | 0 | NonNull<mozilla::dom::DOMRectReadOnly> arg0; |
1433 | 0 | if (args[0].isObject()) { |
1434 | 0 | { |
1435 | 0 | nsresult rv = UnwrapObject<prototypes::id::DOMRectReadOnly, mozilla::dom::DOMRectReadOnly>(args[0], arg0); |
1436 | 0 | if (NS_FAILED(rv)) { |
1437 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XULPopupElement.setConstraintRect", "DOMRectReadOnly"); |
1438 | 0 | return false; |
1439 | 0 | } |
1440 | 0 | } |
1441 | 0 | } else { |
1442 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XULPopupElement.setConstraintRect"); |
1443 | 0 | return false; |
1444 | 0 | } |
1445 | 0 | self->SetConstraintRect(MOZ_KnownLive(NonNullHelper(arg0))); |
1446 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1447 | 0 | args.rval().setUndefined(); |
1448 | 0 | return true; |
1449 | 0 | } |
1450 | | |
1451 | | static const JSJitInfo setConstraintRect_methodinfo = { |
1452 | | { (JSJitGetterOp)setConstraintRect }, |
1453 | | { prototypes::id::XULPopupElement }, |
1454 | | { PrototypeTraits<prototypes::id::XULPopupElement>::Depth }, |
1455 | | JSJitInfo::Method, |
1456 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1457 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1458 | | false, /* isInfallible. False in setters. */ |
1459 | | false, /* isMovable. Not relevant for setters. */ |
1460 | | false, /* isEliminatable. Not relevant for setters. */ |
1461 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1462 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1463 | | false, /* isTypedMethod. Only relevant for methods. */ |
1464 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1465 | | }; |
1466 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1467 | | static_assert(0 < 1, "There is no slot for us"); |
1468 | | |
1469 | | static bool |
1470 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1471 | 0 | { |
1472 | 0 | mozilla::dom::XULPopupElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULPopupElement>(obj); |
1473 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1474 | 0 | // obviously can't preserve if we're not initialized. |
1475 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1476 | 0 | PreserveWrapper(self); |
1477 | 0 | } |
1478 | 0 | return true; |
1479 | 0 | } |
1480 | | |
1481 | | static void |
1482 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1483 | 0 | { |
1484 | 0 | mozilla::dom::XULPopupElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULPopupElement>(obj); |
1485 | 0 | if (self) { |
1486 | 0 | ClearWrapper(self, self, obj); |
1487 | 0 | AddForDeferredFinalization<mozilla::dom::XULPopupElement>(self); |
1488 | 0 | } |
1489 | 0 | } |
1490 | | |
1491 | | static size_t |
1492 | | _objectMoved(JSObject* obj, JSObject* old) |
1493 | 0 | { |
1494 | 0 | mozilla::dom::XULPopupElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULPopupElement>(obj); |
1495 | 0 | if (self) { |
1496 | 0 | UpdateWrapper(self, self, obj, old); |
1497 | 0 | } |
1498 | 0 |
|
1499 | 0 | return 0; |
1500 | 0 | } |
1501 | | |
1502 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1503 | | #if defined(__clang__) |
1504 | | #pragma clang diagnostic push |
1505 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1506 | | #endif |
1507 | | static const JSFunctionSpec sMethods_specs[] = { |
1508 | | JS_FNSPEC("openPopup", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&openPopup_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1509 | | JS_FNSPEC("openPopupAtScreen", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&openPopupAtScreen_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1510 | | JS_FNSPEC("openPopupAtScreenRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&openPopupAtScreenRect_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1511 | | JS_FNSPEC("hidePopup", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hidePopup_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1512 | | JS_FNSPEC("getOuterScreenRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getOuterScreenRect_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1513 | | JS_FNSPEC("moveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&moveTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1514 | | JS_FNSPEC("moveToAnchor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&moveToAnchor_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1515 | | JS_FNSPEC("sizeTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&sizeTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1516 | | JS_FNSPEC("setConstraintRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setConstraintRect_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1517 | | JS_FS_END |
1518 | | }; |
1519 | | #if defined(__clang__) |
1520 | | #pragma clang diagnostic pop |
1521 | | #endif |
1522 | | |
1523 | | |
1524 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1525 | | { nullptr, &sMethods_specs[0] }, |
1526 | | { nullptr, nullptr } |
1527 | | }; |
1528 | | |
1529 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1530 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1531 | | static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1532 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1533 | | |
1534 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1535 | | #if defined(__clang__) |
1536 | | #pragma clang diagnostic push |
1537 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1538 | | #endif |
1539 | | static const JSPropertySpec sAttributes_specs[] = { |
1540 | | { "autoPosition", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &autoPosition_getterinfo, GenericSetter<NormalThisPolicy>, &autoPosition_setterinfo }, |
1541 | | { "label", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &label_getterinfo, GenericSetter<NormalThisPolicy>, &label_setterinfo }, |
1542 | | { "position", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &position_getterinfo, GenericSetter<NormalThisPolicy>, &position_setterinfo }, |
1543 | | { "state", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &state_getterinfo, nullptr, nullptr }, |
1544 | | { "triggerNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &triggerNode_getterinfo, nullptr, nullptr }, |
1545 | | { "anchorNode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &anchorNode_getterinfo, nullptr, nullptr }, |
1546 | | { "alignmentPosition", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &alignmentPosition_getterinfo, nullptr, nullptr }, |
1547 | | { "alignmentOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &alignmentOffset_getterinfo, nullptr, nullptr }, |
1548 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1549 | | }; |
1550 | | #if defined(__clang__) |
1551 | | #pragma clang diagnostic pop |
1552 | | #endif |
1553 | | |
1554 | | |
1555 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1556 | | { nullptr, &sAttributes_specs[0] }, |
1557 | | { nullptr, nullptr } |
1558 | | }; |
1559 | | |
1560 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1561 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1562 | | static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1563 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1564 | | |
1565 | | |
1566 | | static uint16_t sNativeProperties_sortedPropertyIndices[17]; |
1567 | | static PropertyInfo sNativeProperties_propertyInfos[17]; |
1568 | | |
1569 | | static const NativePropertiesN<2> sNativeProperties = { |
1570 | | false, 0, |
1571 | | false, 0, |
1572 | | true, 0 /* sMethods */, |
1573 | | true, 1 /* sAttributes */, |
1574 | | false, 0, |
1575 | | false, 0, |
1576 | | false, 0, |
1577 | | -1, |
1578 | | 17, |
1579 | | sNativeProperties_sortedPropertyIndices, |
1580 | | { |
1581 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1582 | | { sAttributes, &sNativeProperties_propertyInfos[9] } |
1583 | | } |
1584 | | }; |
1585 | | static_assert(17 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1586 | | "We have a property info count that is oversized"); |
1587 | | |
1588 | | static bool |
1589 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
1590 | 0 | { |
1591 | 0 | AUTO_PROFILER_LABEL_FAST("XULPopupElement constructor", DOM, cx); |
1592 | 0 |
|
1593 | 0 | return HTMLConstructor(cx, argc, vp, |
1594 | 0 | constructors::id::XULPopupElement, |
1595 | 0 | prototypes::id::XULPopupElement, |
1596 | 0 | CreateInterfaceObjects); |
1597 | 0 | } |
1598 | | |
1599 | | static const js::ClassOps sInterfaceObjectClassOps = { |
1600 | | nullptr, /* addProperty */ |
1601 | | nullptr, /* delProperty */ |
1602 | | nullptr, /* enumerate */ |
1603 | | nullptr, /* newEnumerate */ |
1604 | | nullptr, /* resolve */ |
1605 | | nullptr, /* mayResolve */ |
1606 | | nullptr, /* finalize */ |
1607 | | _constructor, /* call */ |
1608 | | nullptr, /* hasInstance */ |
1609 | | _constructor, /* construct */ |
1610 | | nullptr, /* trace */ |
1611 | | }; |
1612 | | |
1613 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1614 | | { |
1615 | | "Function", |
1616 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1617 | | &sInterfaceObjectClassOps, |
1618 | | JS_NULL_CLASS_SPEC, |
1619 | | JS_NULL_CLASS_EXT, |
1620 | | &sInterfaceObjectClassObjectOps |
1621 | | }, |
1622 | | eInterface, |
1623 | | true, |
1624 | | prototypes::id::XULPopupElement, |
1625 | | PrototypeTraits<prototypes::id::XULPopupElement>::Depth, |
1626 | | sNativePropertyHooks, |
1627 | | "function XULPopupElement() {\n [native code]\n}", |
1628 | | XULElement_Binding::GetConstructorObject |
1629 | | }; |
1630 | | |
1631 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1632 | | { |
1633 | | "XULPopupElementPrototype", |
1634 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1635 | | JS_NULL_CLASS_OPS, |
1636 | | JS_NULL_CLASS_SPEC, |
1637 | | JS_NULL_CLASS_EXT, |
1638 | | JS_NULL_OBJECT_OPS |
1639 | | }, |
1640 | | eInterfacePrototype, |
1641 | | false, |
1642 | | prototypes::id::XULPopupElement, |
1643 | | PrototypeTraits<prototypes::id::XULPopupElement>::Depth, |
1644 | | sNativePropertyHooks, |
1645 | | "[object XULPopupElementPrototype]", |
1646 | | XULElement_Binding::GetProtoObject |
1647 | | }; |
1648 | | |
1649 | | bool |
1650 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1651 | 0 | { |
1652 | 0 | return IsChromeOrXBL(aCx, aObj); |
1653 | 0 | } |
1654 | | |
1655 | | static const js::ClassOps sClassOps = { |
1656 | | _addProperty, /* addProperty */ |
1657 | | nullptr, /* delProperty */ |
1658 | | nullptr, /* enumerate */ |
1659 | | nullptr, /* newEnumerate */ |
1660 | | nullptr, /* resolve */ |
1661 | | nullptr, /* mayResolve */ |
1662 | | _finalize, /* finalize */ |
1663 | | nullptr, /* call */ |
1664 | | nullptr, /* hasInstance */ |
1665 | | nullptr, /* construct */ |
1666 | | nullptr, /* trace */ |
1667 | | }; |
1668 | | |
1669 | | static const js::ClassExtension sClassExtension = { |
1670 | | nullptr, /* weakmapKeyDelegateOp */ |
1671 | | _objectMoved /* objectMovedOp */ |
1672 | | }; |
1673 | | |
1674 | | static const DOMJSClass sClass = { |
1675 | | { "XULPopupElement", |
1676 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1677 | | &sClassOps, |
1678 | | JS_NULL_CLASS_SPEC, |
1679 | | &sClassExtension, |
1680 | | JS_NULL_OBJECT_OPS |
1681 | | }, |
1682 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::XULElement, prototypes::id::XULPopupElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1683 | | IsBaseOf<nsISupports, mozilla::dom::XULPopupElement >::value, |
1684 | | sNativePropertyHooks, |
1685 | | FindAssociatedGlobalForNative<mozilla::dom::XULPopupElement>::Get, |
1686 | | GetProtoObjectHandle, |
1687 | | GetCCParticipant<mozilla::dom::XULPopupElement>::Get() |
1688 | | }; |
1689 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1690 | | "Must have the right minimal number of reserved slots."); |
1691 | | static_assert(1 >= 1, |
1692 | | "Must have enough reserved slots."); |
1693 | | |
1694 | | const JSClass* |
1695 | | GetJSClass() |
1696 | 0 | { |
1697 | 0 | return sClass.ToJSClass(); |
1698 | 0 | } |
1699 | | |
1700 | | bool |
1701 | | Wrap(JSContext* aCx, mozilla::dom::XULPopupElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1702 | 0 | { |
1703 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::XULPopupElement>::value, |
1704 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1705 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::XULPopupElement*>(aObject) == |
1706 | 0 | reinterpret_cast<mozilla::dom::XULPopupElement*>(aObject), |
1707 | 0 | "Multiple inheritance for mozilla::dom::XULPopupElement is broken."); |
1708 | 0 | MOZ_ASSERT(static_cast<nsXULElement*>(aObject) == |
1709 | 0 | reinterpret_cast<nsXULElement*>(aObject), |
1710 | 0 | "Multiple inheritance for nsXULElement is broken."); |
1711 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
1712 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
1713 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
1714 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
1715 | 0 | reinterpret_cast<nsINode*>(aObject), |
1716 | 0 | "Multiple inheritance for nsINode is broken."); |
1717 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1718 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1719 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1720 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1721 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1722 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1723 | 0 | "You should probably not be using Wrap() directly; use " |
1724 | 0 | "GetOrCreateDOMReflector instead"); |
1725 | 0 |
|
1726 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1727 | 0 | "nsISupports must be on our primary inheritance chain"); |
1728 | 0 |
|
1729 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1730 | 0 | if (!global) { |
1731 | 0 | return false; |
1732 | 0 | } |
1733 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1734 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1735 | 0 |
|
1736 | 0 | // That might have ended up wrapping us already, due to the wonders |
1737 | 0 | // of XBL. Check for that, and bail out as needed. |
1738 | 0 | aReflector.set(aCache->GetWrapper()); |
1739 | 0 | if (aReflector) { |
1740 | | #ifdef DEBUG |
1741 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1742 | | #endif // DEBUG |
1743 | | return true; |
1744 | 0 | } |
1745 | 0 |
|
1746 | 0 | JSAutoRealm ar(aCx, global); |
1747 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1748 | 0 | if (!canonicalProto) { |
1749 | 0 | return false; |
1750 | 0 | } |
1751 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1752 | 0 | if (aGivenProto) { |
1753 | 0 | proto = aGivenProto; |
1754 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1755 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1756 | 0 | // to wrap the proto here. |
1757 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1758 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1759 | 0 | return false; |
1760 | 0 | } |
1761 | 0 | } |
1762 | 0 | } else { |
1763 | 0 | proto = canonicalProto; |
1764 | 0 | } |
1765 | 0 |
|
1766 | 0 | BindingJSObjectCreator<mozilla::dom::XULPopupElement> creator(aCx); |
1767 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1768 | 0 | if (!aReflector) { |
1769 | 0 | return false; |
1770 | 0 | } |
1771 | 0 | |
1772 | 0 | aCache->SetWrapper(aReflector); |
1773 | 0 | creator.InitializationSucceeded(); |
1774 | 0 |
|
1775 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1776 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1777 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1778 | 0 | // otherwise we won't be able to properly recreate it later, since |
1779 | 0 | // we won't know what proto to use. Note that we don't check |
1780 | 0 | // aGivenProto here, since it's entirely possible (and even |
1781 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1782 | 0 | // same as canonicalProto. |
1783 | 0 | if (proto != canonicalProto) { |
1784 | 0 | PreserveWrapper(aObject); |
1785 | 0 | } |
1786 | 0 |
|
1787 | 0 | return true; |
1788 | 0 | } |
1789 | | |
1790 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1791 | | nullptr, |
1792 | | nullptr, |
1793 | | nullptr, |
1794 | | { sNativeProperties.Upcast(), nullptr }, |
1795 | | prototypes::id::XULPopupElement, |
1796 | | constructors::id::XULPopupElement, |
1797 | | XULElement_Binding::sNativePropertyHooks, |
1798 | | &DefaultXrayExpandoObjectClass |
1799 | | } }; |
1800 | | |
1801 | | void |
1802 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1803 | 0 | { |
1804 | 0 | JS::Handle<JSObject*> parentProto(XULElement_Binding::GetProtoObjectHandle(aCx)); |
1805 | 0 | if (!parentProto) { |
1806 | 0 | return; |
1807 | 0 | } |
1808 | 0 | |
1809 | 0 | JS::Handle<JSObject*> constructorProto(XULElement_Binding::GetConstructorObjectHandle(aCx)); |
1810 | 0 | if (!constructorProto) { |
1811 | 0 | return; |
1812 | 0 | } |
1813 | 0 | |
1814 | 0 | static bool sIdsInited = false; |
1815 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1816 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1817 | 0 | return; |
1818 | 0 | } |
1819 | 0 | sIdsInited = true; |
1820 | 0 | } |
1821 | 0 |
|
1822 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XULPopupElement); |
1823 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XULPopupElement); |
1824 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1825 | 0 | &sPrototypeClass.mBase, protoCache, |
1826 | 0 | nullptr, |
1827 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1828 | 0 | interfaceCache, |
1829 | 0 | sNativeProperties.Upcast(), |
1830 | 0 | nullptr, |
1831 | 0 | "XULPopupElement", aDefineOnGlobal, |
1832 | 0 | nullptr, |
1833 | 0 | false); |
1834 | 0 | } |
1835 | | |
1836 | | JSObject* |
1837 | | GetConstructorObject(JSContext* aCx) |
1838 | 0 | { |
1839 | 0 | return GetConstructorObjectHandle(aCx); |
1840 | 0 | } |
1841 | | |
1842 | | } // namespace XULPopupElement_Binding |
1843 | | |
1844 | | |
1845 | | |
1846 | | } // namespace dom |
1847 | | } // namespace mozilla |