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