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