/work/obj-fuzz/dom/bindings/XULCommandEventBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM XULCommandEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "UIEventBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "XULCommandEventBinding.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/Event.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/Nullable.h" |
12 | | #include "mozilla/dom/PrimitiveConversions.h" |
13 | | #include "mozilla/dom/XULCommandEvent.h" |
14 | | #include "mozilla/dom/XrayExpandoClass.h" |
15 | | #include "nsGlobalWindow.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
21 | | using namespace mozilla::dom::binding_detail; |
22 | | |
23 | | |
24 | | namespace XULCommandEvent_Binding { |
25 | | |
26 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<UIEvent_Binding::NativeType>::value, |
27 | | "Can't inherit from an interface with a different ownership model."); |
28 | | |
29 | | MOZ_CAN_RUN_SCRIPT static bool |
30 | | get_ctrlKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
31 | 0 | { |
32 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.ctrlKey", DOM, cx); |
33 | 0 |
|
34 | 0 | bool result(self->CtrlKey()); |
35 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
36 | 0 | args.rval().setBoolean(result); |
37 | 0 | return true; |
38 | 0 | } |
39 | | |
40 | | static const JSJitInfo ctrlKey_getterinfo = { |
41 | | { (JSJitGetterOp)get_ctrlKey }, |
42 | | { prototypes::id::XULCommandEvent }, |
43 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
44 | | JSJitInfo::Getter, |
45 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
46 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
47 | | true, /* isInfallible. False in setters. */ |
48 | | false, /* isMovable. Not relevant for setters. */ |
49 | | false, /* isEliminatable. Not relevant for setters. */ |
50 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
51 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
52 | | false, /* isTypedMethod. Only relevant for methods. */ |
53 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
54 | | }; |
55 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
56 | | static_assert(0 < 1, "There is no slot for us"); |
57 | | |
58 | | MOZ_CAN_RUN_SCRIPT static bool |
59 | | get_shiftKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
60 | 0 | { |
61 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.shiftKey", DOM, cx); |
62 | 0 |
|
63 | 0 | bool result(self->ShiftKey()); |
64 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
65 | 0 | args.rval().setBoolean(result); |
66 | 0 | return true; |
67 | 0 | } |
68 | | |
69 | | static const JSJitInfo shiftKey_getterinfo = { |
70 | | { (JSJitGetterOp)get_shiftKey }, |
71 | | { prototypes::id::XULCommandEvent }, |
72 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
73 | | JSJitInfo::Getter, |
74 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
75 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
76 | | true, /* isInfallible. False in setters. */ |
77 | | false, /* isMovable. Not relevant for setters. */ |
78 | | false, /* isEliminatable. Not relevant for setters. */ |
79 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
80 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
81 | | false, /* isTypedMethod. Only relevant for methods. */ |
82 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
83 | | }; |
84 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
85 | | static_assert(0 < 1, "There is no slot for us"); |
86 | | |
87 | | MOZ_CAN_RUN_SCRIPT static bool |
88 | | get_altKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
89 | 0 | { |
90 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.altKey", DOM, cx); |
91 | 0 |
|
92 | 0 | bool result(self->AltKey()); |
93 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
94 | 0 | args.rval().setBoolean(result); |
95 | 0 | return true; |
96 | 0 | } |
97 | | |
98 | | static const JSJitInfo altKey_getterinfo = { |
99 | | { (JSJitGetterOp)get_altKey }, |
100 | | { prototypes::id::XULCommandEvent }, |
101 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
102 | | JSJitInfo::Getter, |
103 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
104 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
105 | | true, /* isInfallible. False in setters. */ |
106 | | false, /* isMovable. Not relevant for setters. */ |
107 | | false, /* isEliminatable. Not relevant for setters. */ |
108 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
109 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
110 | | false, /* isTypedMethod. Only relevant for methods. */ |
111 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
112 | | }; |
113 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
114 | | static_assert(0 < 1, "There is no slot for us"); |
115 | | |
116 | | MOZ_CAN_RUN_SCRIPT static bool |
117 | | get_metaKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
118 | 0 | { |
119 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.metaKey", DOM, cx); |
120 | 0 |
|
121 | 0 | bool result(self->MetaKey()); |
122 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
123 | 0 | args.rval().setBoolean(result); |
124 | 0 | return true; |
125 | 0 | } |
126 | | |
127 | | static const JSJitInfo metaKey_getterinfo = { |
128 | | { (JSJitGetterOp)get_metaKey }, |
129 | | { prototypes::id::XULCommandEvent }, |
130 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
131 | | JSJitInfo::Getter, |
132 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
133 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
134 | | true, /* isInfallible. False in setters. */ |
135 | | false, /* isMovable. Not relevant for setters. */ |
136 | | false, /* isEliminatable. Not relevant for setters. */ |
137 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
138 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
139 | | false, /* isTypedMethod. Only relevant for methods. */ |
140 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
141 | | }; |
142 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
143 | | static_assert(0 < 1, "There is no slot for us"); |
144 | | |
145 | | MOZ_CAN_RUN_SCRIPT static bool |
146 | | get_inputSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
147 | 0 | { |
148 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.inputSource", DOM, cx); |
149 | 0 |
|
150 | 0 | uint16_t result(self->InputSource()); |
151 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
152 | 0 | args.rval().setInt32(int32_t(result)); |
153 | 0 | return true; |
154 | 0 | } |
155 | | |
156 | | static const JSJitInfo inputSource_getterinfo = { |
157 | | { (JSJitGetterOp)get_inputSource }, |
158 | | { prototypes::id::XULCommandEvent }, |
159 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
160 | | JSJitInfo::Getter, |
161 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
162 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
163 | | true, /* isInfallible. False in setters. */ |
164 | | false, /* isMovable. Not relevant for setters. */ |
165 | | false, /* isEliminatable. Not relevant for setters. */ |
166 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
167 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
168 | | false, /* isTypedMethod. Only relevant for methods. */ |
169 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
170 | | }; |
171 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
172 | | static_assert(0 < 1, "There is no slot for us"); |
173 | | |
174 | | MOZ_CAN_RUN_SCRIPT static bool |
175 | | get_sourceEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
176 | 0 | { |
177 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.sourceEvent", DOM, cx); |
178 | 0 |
|
179 | 0 | auto result(StrongOrRawPtr<mozilla::dom::Event>(self->GetSourceEvent())); |
180 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
181 | 0 | if (!result) { |
182 | 0 | args.rval().setNull(); |
183 | 0 | return true; |
184 | 0 | } |
185 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
186 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
187 | 0 | return false; |
188 | 0 | } |
189 | 0 | return true; |
190 | 0 | } |
191 | | |
192 | | static const JSJitInfo sourceEvent_getterinfo = { |
193 | | { (JSJitGetterOp)get_sourceEvent }, |
194 | | { prototypes::id::XULCommandEvent }, |
195 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
196 | | JSJitInfo::Getter, |
197 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
198 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
199 | | false, /* isInfallible. False in setters. */ |
200 | | false, /* isMovable. Not relevant for setters. */ |
201 | | false, /* isEliminatable. Not relevant for setters. */ |
202 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
203 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
204 | | false, /* isTypedMethod. Only relevant for methods. */ |
205 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
206 | | }; |
207 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
208 | | static_assert(0 < 1, "There is no slot for us"); |
209 | | |
210 | | MOZ_CAN_RUN_SCRIPT static bool |
211 | | initCommandEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, const JSJitMethodCallArgs& args) |
212 | 0 | { |
213 | 0 | AUTO_PROFILER_LABEL_FAST("XULCommandEvent.initCommandEvent", DOM, cx); |
214 | 0 |
|
215 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
216 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XULCommandEvent.initCommandEvent"); |
217 | 0 | } |
218 | 0 | binding_detail::FakeString arg0; |
219 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
220 | 0 | return false; |
221 | 0 | } |
222 | 0 | bool arg1; |
223 | 0 | if (args.hasDefined(1)) { |
224 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) { |
225 | 0 | return false; |
226 | 0 | } |
227 | 0 | } else { |
228 | 0 | arg1 = false; |
229 | 0 | } |
230 | 0 | bool arg2; |
231 | 0 | if (args.hasDefined(2)) { |
232 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) { |
233 | 0 | return false; |
234 | 0 | } |
235 | 0 | } else { |
236 | 0 | arg2 = false; |
237 | 0 | } |
238 | 0 | nsGlobalWindowInner* arg3; |
239 | 0 | if (args.hasDefined(3)) { |
240 | 0 | if (args[3].isObject()) { |
241 | 0 | { |
242 | 0 | nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(args[3], arg3); |
243 | 0 | if (NS_FAILED(rv)) { |
244 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of XULCommandEvent.initCommandEvent", "Window"); |
245 | 0 | return false; |
246 | 0 | } |
247 | 0 | } |
248 | 0 | } else if (args[3].isNullOrUndefined()) { |
249 | 0 | arg3 = nullptr; |
250 | 0 | } else { |
251 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of XULCommandEvent.initCommandEvent"); |
252 | 0 | return false; |
253 | 0 | } |
254 | 0 | } else { |
255 | 0 | arg3 = nullptr; |
256 | 0 | } |
257 | 0 | int32_t arg4; |
258 | 0 | if (args.hasDefined(4)) { |
259 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
260 | 0 | return false; |
261 | 0 | } |
262 | 0 | } else { |
263 | 0 | arg4 = 0; |
264 | 0 | } |
265 | 0 | bool arg5; |
266 | 0 | if (args.hasDefined(5)) { |
267 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) { |
268 | 0 | return false; |
269 | 0 | } |
270 | 0 | } else { |
271 | 0 | arg5 = false; |
272 | 0 | } |
273 | 0 | bool arg6; |
274 | 0 | if (args.hasDefined(6)) { |
275 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[6], &arg6)) { |
276 | 0 | return false; |
277 | 0 | } |
278 | 0 | } else { |
279 | 0 | arg6 = false; |
280 | 0 | } |
281 | 0 | bool arg7; |
282 | 0 | if (args.hasDefined(7)) { |
283 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) { |
284 | 0 | return false; |
285 | 0 | } |
286 | 0 | } else { |
287 | 0 | arg7 = false; |
288 | 0 | } |
289 | 0 | bool arg8; |
290 | 0 | if (args.hasDefined(8)) { |
291 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[8], &arg8)) { |
292 | 0 | return false; |
293 | 0 | } |
294 | 0 | } else { |
295 | 0 | arg8 = false; |
296 | 0 | } |
297 | 0 | mozilla::dom::Event* arg9; |
298 | 0 | if (args.hasDefined(9)) { |
299 | 0 | if (args[9].isObject()) { |
300 | 0 | { |
301 | 0 | nsresult rv = UnwrapObject<prototypes::id::Event, mozilla::dom::Event>(args[9], arg9); |
302 | 0 | if (NS_FAILED(rv)) { |
303 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 10 of XULCommandEvent.initCommandEvent", "Event"); |
304 | 0 | return false; |
305 | 0 | } |
306 | 0 | } |
307 | 0 | } else if (args[9].isNullOrUndefined()) { |
308 | 0 | arg9 = nullptr; |
309 | 0 | } else { |
310 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 10 of XULCommandEvent.initCommandEvent"); |
311 | 0 | return false; |
312 | 0 | } |
313 | 0 | } else { |
314 | 0 | arg9 = nullptr; |
315 | 0 | } |
316 | 0 | uint16_t arg10; |
317 | 0 | if (args.hasDefined(10)) { |
318 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[10], &arg10)) { |
319 | 0 | return false; |
320 | 0 | } |
321 | 0 | } else { |
322 | 0 | arg10 = 0; |
323 | 0 | } |
324 | 0 | FastErrorResult rv; |
325 | 0 | self->InitCommandEvent(NonNullHelper(Constify(arg0)), arg1, arg2, MOZ_KnownLive(Constify(arg3)), arg4, arg5, arg6, arg7, arg8, MOZ_KnownLive(Constify(arg9)), arg10, rv); |
326 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
327 | 0 | return false; |
328 | 0 | } |
329 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
330 | 0 | args.rval().setUndefined(); |
331 | 0 | return true; |
332 | 0 | } |
333 | | |
334 | | static const JSJitInfo initCommandEvent_methodinfo = { |
335 | | { (JSJitGetterOp)initCommandEvent }, |
336 | | { prototypes::id::XULCommandEvent }, |
337 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
338 | | JSJitInfo::Method, |
339 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
340 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
341 | | false, /* isInfallible. False in setters. */ |
342 | | false, /* isMovable. Not relevant for setters. */ |
343 | | false, /* isEliminatable. Not relevant for setters. */ |
344 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
345 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
346 | | false, /* isTypedMethod. Only relevant for methods. */ |
347 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
348 | | }; |
349 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
350 | | static_assert(0 < 1, "There is no slot for us"); |
351 | | |
352 | | MOZ_CAN_RUN_SCRIPT static bool |
353 | | get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::XULCommandEvent* self, JSJitGetterCallArgs args) |
354 | 0 | { |
355 | 0 | AUTO_PROFILER_LABEL_FAST("get XULCommandEvent.isTrusted", DOM, cx); |
356 | 0 |
|
357 | 0 | bool result(self->IsTrusted()); |
358 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
359 | 0 | args.rval().setBoolean(result); |
360 | 0 | return true; |
361 | 0 | } |
362 | | |
363 | | static const JSJitInfo isTrusted_getterinfo = { |
364 | | { (JSJitGetterOp)get_isTrusted }, |
365 | | { prototypes::id::XULCommandEvent }, |
366 | | { PrototypeTraits<prototypes::id::XULCommandEvent>::Depth }, |
367 | | JSJitInfo::Getter, |
368 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
369 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
370 | | true, /* isInfallible. False in setters. */ |
371 | | true, /* isMovable. Not relevant for setters. */ |
372 | | true, /* isEliminatable. Not relevant for setters. */ |
373 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
374 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
375 | | false, /* isTypedMethod. Only relevant for methods. */ |
376 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
377 | | }; |
378 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
379 | | static_assert(0 < 1, "There is no slot for us"); |
380 | | |
381 | | static bool |
382 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
383 | 0 | { |
384 | 0 | mozilla::dom::XULCommandEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULCommandEvent>(obj); |
385 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
386 | 0 | // obviously can't preserve if we're not initialized. |
387 | 0 | if (self && self->GetWrapperPreserveColor()) { |
388 | 0 | PreserveWrapper(self); |
389 | 0 | } |
390 | 0 | return true; |
391 | 0 | } |
392 | | |
393 | | static void |
394 | | _finalize(js::FreeOp* fop, JSObject* obj) |
395 | 0 | { |
396 | 0 | mozilla::dom::XULCommandEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULCommandEvent>(obj); |
397 | 0 | if (self) { |
398 | 0 | ClearWrapper(self, self, obj); |
399 | 0 | AddForDeferredFinalization<mozilla::dom::XULCommandEvent>(self); |
400 | 0 | } |
401 | 0 | } |
402 | | |
403 | | static size_t |
404 | | _objectMoved(JSObject* obj, JSObject* old) |
405 | 0 | { |
406 | 0 | mozilla::dom::XULCommandEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::XULCommandEvent>(obj); |
407 | 0 | if (self) { |
408 | 0 | UpdateWrapper(self, self, obj, old); |
409 | 0 | } |
410 | 0 |
|
411 | 0 | return 0; |
412 | 0 | } |
413 | | |
414 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
415 | | #if defined(__clang__) |
416 | | #pragma clang diagnostic push |
417 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
418 | | #endif |
419 | | static const JSFunctionSpec sMethods_specs[] = { |
420 | | JS_FNSPEC("initCommandEvent", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&initCommandEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
421 | | JS_FS_END |
422 | | }; |
423 | | #if defined(__clang__) |
424 | | #pragma clang diagnostic pop |
425 | | #endif |
426 | | |
427 | | |
428 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
429 | | { nullptr, &sMethods_specs[0] }, |
430 | | { nullptr, nullptr } |
431 | | }; |
432 | | |
433 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
434 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
435 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
436 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
437 | | |
438 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
439 | | #if defined(__clang__) |
440 | | #pragma clang diagnostic push |
441 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
442 | | #endif |
443 | | static const JSPropertySpec sAttributes_specs[] = { |
444 | | { "ctrlKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &ctrlKey_getterinfo, nullptr, nullptr }, |
445 | | { "shiftKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shiftKey_getterinfo, nullptr, nullptr }, |
446 | | { "altKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &altKey_getterinfo, nullptr, nullptr }, |
447 | | { "metaKey", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &metaKey_getterinfo, nullptr, nullptr }, |
448 | | { "inputSource", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &inputSource_getterinfo, nullptr, nullptr }, |
449 | | { "sourceEvent", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sourceEvent_getterinfo, nullptr, nullptr }, |
450 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
451 | | }; |
452 | | #if defined(__clang__) |
453 | | #pragma clang diagnostic pop |
454 | | #endif |
455 | | |
456 | | |
457 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
458 | | { nullptr, &sAttributes_specs[0] }, |
459 | | { nullptr, nullptr } |
460 | | }; |
461 | | |
462 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
463 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
464 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
465 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
466 | | |
467 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
468 | | #if defined(__clang__) |
469 | | #pragma clang diagnostic push |
470 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
471 | | #endif |
472 | | static const JSPropertySpec sUnforgeableAttributes_specs[] = { |
473 | | { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr }, |
474 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
475 | | }; |
476 | | #if defined(__clang__) |
477 | | #pragma clang diagnostic pop |
478 | | #endif |
479 | | |
480 | | |
481 | | static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = { |
482 | | { nullptr, &sUnforgeableAttributes_specs[0] }, |
483 | | { nullptr, nullptr } |
484 | | }; |
485 | | |
486 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
487 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
488 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
489 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
490 | | |
491 | | |
492 | | static uint16_t sNativeProperties_sortedPropertyIndices[8]; |
493 | | static PropertyInfo sNativeProperties_propertyInfos[8]; |
494 | | |
495 | | static const NativePropertiesN<3> sNativeProperties = { |
496 | | false, 0, |
497 | | false, 0, |
498 | | true, 0 /* sMethods */, |
499 | | true, 1 /* sAttributes */, |
500 | | false, 0, |
501 | | true, 2 /* sUnforgeableAttributes */, |
502 | | false, 0, |
503 | | -1, |
504 | | 8, |
505 | | sNativeProperties_sortedPropertyIndices, |
506 | | { |
507 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
508 | | { sAttributes, &sNativeProperties_propertyInfos[1] }, |
509 | | { sUnforgeableAttributes, &sNativeProperties_propertyInfos[7] } |
510 | | } |
511 | | }; |
512 | | static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
513 | | "We have a property info count that is oversized"); |
514 | | |
515 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
516 | | { |
517 | | "Function", |
518 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
519 | | &sBoringInterfaceObjectClassClassOps, |
520 | | JS_NULL_CLASS_SPEC, |
521 | | JS_NULL_CLASS_EXT, |
522 | | &sInterfaceObjectClassObjectOps |
523 | | }, |
524 | | eInterface, |
525 | | true, |
526 | | prototypes::id::XULCommandEvent, |
527 | | PrototypeTraits<prototypes::id::XULCommandEvent>::Depth, |
528 | | sNativePropertyHooks, |
529 | | "function XULCommandEvent() {\n [native code]\n}", |
530 | | UIEvent_Binding::GetConstructorObject |
531 | | }; |
532 | | |
533 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
534 | | { |
535 | | "XULCommandEventPrototype", |
536 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */), |
537 | | JS_NULL_CLASS_OPS, |
538 | | JS_NULL_CLASS_SPEC, |
539 | | JS_NULL_CLASS_EXT, |
540 | | JS_NULL_OBJECT_OPS |
541 | | }, |
542 | | eInterfacePrototype, |
543 | | false, |
544 | | prototypes::id::XULCommandEvent, |
545 | | PrototypeTraits<prototypes::id::XULCommandEvent>::Depth, |
546 | | sNativePropertyHooks, |
547 | | "[object XULCommandEventPrototype]", |
548 | | UIEvent_Binding::GetProtoObject |
549 | | }; |
550 | | |
551 | | bool |
552 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
553 | 0 | { |
554 | 0 | return IsChromeOrXBL(aCx, aObj); |
555 | 0 | } |
556 | | |
557 | | static const js::ClassOps sClassOps = { |
558 | | _addProperty, /* addProperty */ |
559 | | nullptr, /* delProperty */ |
560 | | nullptr, /* enumerate */ |
561 | | nullptr, /* newEnumerate */ |
562 | | nullptr, /* resolve */ |
563 | | nullptr, /* mayResolve */ |
564 | | _finalize, /* finalize */ |
565 | | nullptr, /* call */ |
566 | | nullptr, /* hasInstance */ |
567 | | nullptr, /* construct */ |
568 | | nullptr, /* trace */ |
569 | | }; |
570 | | |
571 | | static const js::ClassExtension sClassExtension = { |
572 | | nullptr, /* weakmapKeyDelegateOp */ |
573 | | _objectMoved /* objectMovedOp */ |
574 | | }; |
575 | | |
576 | | static const DOMJSClass sClass = { |
577 | | { "XULCommandEvent", |
578 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE, |
579 | | &sClassOps, |
580 | | JS_NULL_CLASS_SPEC, |
581 | | &sClassExtension, |
582 | | JS_NULL_OBJECT_OPS |
583 | | }, |
584 | | { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::XULCommandEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
585 | | IsBaseOf<nsISupports, mozilla::dom::XULCommandEvent >::value, |
586 | | sNativePropertyHooks, |
587 | | FindAssociatedGlobalForNative<mozilla::dom::XULCommandEvent>::Get, |
588 | | GetProtoObjectHandle, |
589 | | GetCCParticipant<mozilla::dom::XULCommandEvent>::Get() |
590 | | }; |
591 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
592 | | "Must have the right minimal number of reserved slots."); |
593 | | static_assert(1 >= 1, |
594 | | "Must have enough reserved slots."); |
595 | | |
596 | | const JSClass* |
597 | | GetJSClass() |
598 | 0 | { |
599 | 0 | return sClass.ToJSClass(); |
600 | 0 | } |
601 | | |
602 | | bool |
603 | | Wrap(JSContext* aCx, mozilla::dom::XULCommandEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
604 | 0 | { |
605 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::XULCommandEvent>::value, |
606 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
607 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::XULCommandEvent*>(aObject) == |
608 | 0 | reinterpret_cast<mozilla::dom::XULCommandEvent*>(aObject), |
609 | 0 | "Multiple inheritance for mozilla::dom::XULCommandEvent is broken."); |
610 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) == |
611 | 0 | reinterpret_cast<mozilla::dom::UIEvent*>(aObject), |
612 | 0 | "Multiple inheritance for mozilla::dom::UIEvent is broken."); |
613 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) == |
614 | 0 | reinterpret_cast<mozilla::dom::Event*>(aObject), |
615 | 0 | "Multiple inheritance for mozilla::dom::Event is broken."); |
616 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
617 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
618 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
619 | 0 | "You should probably not be using Wrap() directly; use " |
620 | 0 | "GetOrCreateDOMReflector instead"); |
621 | 0 |
|
622 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
623 | 0 | "nsISupports must be on our primary inheritance chain"); |
624 | 0 |
|
625 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
626 | 0 | if (!global) { |
627 | 0 | return false; |
628 | 0 | } |
629 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
630 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
631 | 0 |
|
632 | 0 | // That might have ended up wrapping us already, due to the wonders |
633 | 0 | // of XBL. Check for that, and bail out as needed. |
634 | 0 | aReflector.set(aCache->GetWrapper()); |
635 | 0 | if (aReflector) { |
636 | | #ifdef DEBUG |
637 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
638 | | #endif // DEBUG |
639 | | return true; |
640 | 0 | } |
641 | 0 |
|
642 | 0 | JSAutoRealm ar(aCx, global); |
643 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
644 | 0 | if (!canonicalProto) { |
645 | 0 | return false; |
646 | 0 | } |
647 | 0 | JS::Rooted<JSObject*> proto(aCx); |
648 | 0 | if (aGivenProto) { |
649 | 0 | proto = aGivenProto; |
650 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
651 | 0 | // coming in, we changed compartments to that of "parent" so may need |
652 | 0 | // to wrap the proto here. |
653 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
654 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
655 | 0 | return false; |
656 | 0 | } |
657 | 0 | } |
658 | 0 | } else { |
659 | 0 | proto = canonicalProto; |
660 | 0 | } |
661 | 0 |
|
662 | 0 | BindingJSObjectCreator<mozilla::dom::XULCommandEvent> creator(aCx); |
663 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
664 | 0 | if (!aReflector) { |
665 | 0 | return false; |
666 | 0 | } |
667 | 0 | |
668 | 0 | aCache->SetWrapper(aReflector); |
669 | 0 |
|
670 | 0 | // Important: do unforgeable property setup after we have handed |
671 | 0 | // over ownership of the C++ object to obj as needed, so that if |
672 | 0 | // we fail and it ends up GCed it won't have problems in the |
673 | 0 | // finalizer trying to drop its ownership of the C++ object. |
674 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx, |
675 | 0 | &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject()); |
676 | 0 | if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) { |
677 | 0 | aCache->ReleaseWrapper(aObject); |
678 | 0 | aCache->ClearWrapper(); |
679 | 0 | return false; |
680 | 0 | } |
681 | 0 | creator.InitializationSucceeded(); |
682 | 0 |
|
683 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
684 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
685 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
686 | 0 | // otherwise we won't be able to properly recreate it later, since |
687 | 0 | // we won't know what proto to use. Note that we don't check |
688 | 0 | // aGivenProto here, since it's entirely possible (and even |
689 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
690 | 0 | // same as canonicalProto. |
691 | 0 | if (proto != canonicalProto) { |
692 | 0 | PreserveWrapper(aObject); |
693 | 0 | } |
694 | 0 |
|
695 | 0 | return true; |
696 | 0 | } |
697 | | |
698 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
699 | | nullptr, |
700 | | nullptr, |
701 | | nullptr, |
702 | | { sNativeProperties.Upcast(), nullptr }, |
703 | | prototypes::id::XULCommandEvent, |
704 | | constructors::id::XULCommandEvent, |
705 | | UIEvent_Binding::sNativePropertyHooks, |
706 | | &DefaultXrayExpandoObjectClass |
707 | | } }; |
708 | | |
709 | | void |
710 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
711 | 0 | { |
712 | 0 | JS::Handle<JSObject*> parentProto(UIEvent_Binding::GetProtoObjectHandle(aCx)); |
713 | 0 | if (!parentProto) { |
714 | 0 | return; |
715 | 0 | } |
716 | 0 | |
717 | 0 | JS::Handle<JSObject*> constructorProto(UIEvent_Binding::GetConstructorObjectHandle(aCx)); |
718 | 0 | if (!constructorProto) { |
719 | 0 | return; |
720 | 0 | } |
721 | 0 | |
722 | 0 | static bool sIdsInited = false; |
723 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
724 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
725 | 0 | return; |
726 | 0 | } |
727 | 0 | sIdsInited = true; |
728 | 0 | } |
729 | 0 |
|
730 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XULCommandEvent); |
731 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XULCommandEvent); |
732 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
733 | 0 | &sPrototypeClass.mBase, protoCache, |
734 | 0 | nullptr, |
735 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
736 | 0 | interfaceCache, |
737 | 0 | sNativeProperties.Upcast(), |
738 | 0 | nullptr, |
739 | 0 | "XULCommandEvent", aDefineOnGlobal, |
740 | 0 | nullptr, |
741 | 0 | false); |
742 | 0 |
|
743 | 0 | JS::Rooted<JSObject*> unforgeableHolder(aCx); |
744 | 0 | { |
745 | 0 | JS::Rooted<JSObject*> holderProto(aCx, *protoCache); |
746 | 0 | unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto); |
747 | 0 | if (!unforgeableHolder) { |
748 | 0 | *protoCache = nullptr; |
749 | 0 | if (interfaceCache) { |
750 | 0 | *interfaceCache = nullptr; |
751 | 0 | } |
752 | 0 | return; |
753 | 0 | } |
754 | 0 | } |
755 | 0 |
|
756 | 0 | if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) { |
757 | 0 | *protoCache = nullptr; |
758 | 0 | if (interfaceCache) { |
759 | 0 | *interfaceCache = nullptr; |
760 | 0 | } |
761 | 0 | return; |
762 | 0 | } |
763 | 0 |
|
764 | 0 | if (*protoCache) { |
765 | 0 | js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE, |
766 | 0 | JS::ObjectValue(*unforgeableHolder)); |
767 | 0 | } |
768 | 0 | } |
769 | | |
770 | | JSObject* |
771 | | GetConstructorObject(JSContext* aCx) |
772 | 0 | { |
773 | 0 | return GetConstructorObjectHandle(aCx); |
774 | 0 | } |
775 | | |
776 | | } // namespace XULCommandEvent_Binding |
777 | | |
778 | | |
779 | | |
780 | | } // namespace dom |
781 | | } // namespace mozilla |