Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SimpleGestureEvent.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "MouseEventBinding.h"
4 : #include "SimpleGestureEventBinding.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/EventTarget.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/PrimitiveConversions.h"
14 : #include "mozilla/dom/SimpleGestureEvent.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 : #include "nsGlobalWindow.h"
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : namespace SimpleGestureEventBinding {
22 :
23 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<MouseEventBinding::NativeType>::value,
24 : "Can't inherit from an interface with a different ownership model.");
25 :
26 : static bool
27 0 : get_allowedDirections(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
28 : {
29 0 : uint32_t result(self->AllowedDirections());
30 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
31 0 : args.rval().setNumber(result);
32 0 : return true;
33 : }
34 :
35 : static bool
36 0 : set_allowedDirections(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitSetterCallArgs args)
37 : {
38 : uint32_t arg0;
39 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
40 0 : return false;
41 : }
42 0 : self->SetAllowedDirections(arg0);
43 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
44 :
45 0 : return true;
46 : }
47 :
48 : static const JSJitInfo allowedDirections_getterinfo = {
49 : { (JSJitGetterOp)get_allowedDirections },
50 : { prototypes::id::SimpleGestureEvent },
51 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
52 : JSJitInfo::Getter,
53 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
54 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
55 : true, /* isInfallible. False in setters. */
56 : false, /* isMovable. Not relevant for setters. */
57 : false, /* isEliminatable. Not relevant for setters. */
58 : false, /* isAlwaysInSlot. Only relevant for getters. */
59 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
60 : false, /* isTypedMethod. Only relevant for methods. */
61 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
62 : };
63 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
64 : static_assert(0 < 1, "There is no slot for us");
65 : static const JSJitInfo allowedDirections_setterinfo = {
66 : { (JSJitGetterOp)set_allowedDirections },
67 : { prototypes::id::SimpleGestureEvent },
68 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
69 : JSJitInfo::Setter,
70 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
71 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
72 : false, /* isInfallible. False in setters. */
73 : false, /* isMovable. Not relevant for setters. */
74 : false, /* isEliminatable. Not relevant for setters. */
75 : false, /* isAlwaysInSlot. Only relevant for getters. */
76 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
77 : false, /* isTypedMethod. Only relevant for methods. */
78 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
79 : };
80 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
81 : static_assert(0 < 1, "There is no slot for us");
82 :
83 : static bool
84 0 : get_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
85 : {
86 0 : uint32_t result(self->Direction());
87 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
88 0 : args.rval().setNumber(result);
89 0 : return true;
90 : }
91 :
92 : static const JSJitInfo direction_getterinfo = {
93 : { (JSJitGetterOp)get_direction },
94 : { prototypes::id::SimpleGestureEvent },
95 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
96 : JSJitInfo::Getter,
97 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
98 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
99 : true, /* isInfallible. False in setters. */
100 : false, /* isMovable. Not relevant for setters. */
101 : false, /* isEliminatable. Not relevant for setters. */
102 : false, /* isAlwaysInSlot. Only relevant for getters. */
103 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
104 : false, /* isTypedMethod. Only relevant for methods. */
105 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
106 : };
107 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
108 : static_assert(0 < 1, "There is no slot for us");
109 :
110 : static bool
111 0 : get_delta(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
112 : {
113 0 : double result(self->Delta());
114 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
115 0 : args.rval().set(JS_NumberValue(double(result)));
116 0 : return true;
117 : }
118 :
119 : static const JSJitInfo delta_getterinfo = {
120 : { (JSJitGetterOp)get_delta },
121 : { prototypes::id::SimpleGestureEvent },
122 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
123 : JSJitInfo::Getter,
124 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
125 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
126 : true, /* isInfallible. False in setters. */
127 : false, /* isMovable. Not relevant for setters. */
128 : false, /* isEliminatable. Not relevant for setters. */
129 : false, /* isAlwaysInSlot. Only relevant for getters. */
130 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
131 : false, /* isTypedMethod. Only relevant for methods. */
132 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
133 : };
134 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
135 : static_assert(0 < 1, "There is no slot for us");
136 :
137 : static bool
138 0 : get_clickCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
139 : {
140 0 : uint32_t result(self->ClickCount());
141 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
142 0 : args.rval().setNumber(result);
143 0 : return true;
144 : }
145 :
146 : static const JSJitInfo clickCount_getterinfo = {
147 : { (JSJitGetterOp)get_clickCount },
148 : { prototypes::id::SimpleGestureEvent },
149 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
150 : JSJitInfo::Getter,
151 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
152 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
153 : true, /* isInfallible. False in setters. */
154 : false, /* isMovable. Not relevant for setters. */
155 : false, /* isEliminatable. Not relevant for setters. */
156 : false, /* isAlwaysInSlot. Only relevant for getters. */
157 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
158 : false, /* isTypedMethod. Only relevant for methods. */
159 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
160 : };
161 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
162 : static_assert(0 < 1, "There is no slot for us");
163 :
164 : static bool
165 0 : initSimpleGestureEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, const JSJitMethodCallArgs& args)
166 : {
167 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
168 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SimpleGestureEvent.initSimpleGestureEvent");
169 : }
170 0 : binding_detail::FakeString arg0;
171 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
172 0 : return false;
173 : }
174 : bool arg1;
175 0 : if (args.hasDefined(1)) {
176 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
177 0 : return false;
178 : }
179 : } else {
180 0 : arg1 = false;
181 : }
182 : bool arg2;
183 0 : if (args.hasDefined(2)) {
184 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
185 0 : return false;
186 : }
187 : } else {
188 0 : arg2 = false;
189 : }
190 : nsGlobalWindow* arg3;
191 0 : if (args.hasDefined(3)) {
192 0 : if (args[3].isObject()) {
193 : {
194 0 : nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[3], arg3);
195 0 : if (NS_FAILED(rv)) {
196 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of SimpleGestureEvent.initSimpleGestureEvent", "Window");
197 0 : return false;
198 : }
199 : }
200 0 : } else if (args[3].isNullOrUndefined()) {
201 0 : arg3 = nullptr;
202 : } else {
203 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of SimpleGestureEvent.initSimpleGestureEvent");
204 0 : return false;
205 : }
206 : } else {
207 0 : arg3 = nullptr;
208 : }
209 : int32_t arg4;
210 0 : if (args.hasDefined(4)) {
211 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
212 0 : return false;
213 : }
214 : } else {
215 0 : arg4 = 0;
216 : }
217 : int32_t arg5;
218 0 : if (args.hasDefined(5)) {
219 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) {
220 0 : return false;
221 : }
222 : } else {
223 0 : arg5 = 0;
224 : }
225 : int32_t arg6;
226 0 : if (args.hasDefined(6)) {
227 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) {
228 0 : return false;
229 : }
230 : } else {
231 0 : arg6 = 0;
232 : }
233 : int32_t arg7;
234 0 : if (args.hasDefined(7)) {
235 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) {
236 0 : return false;
237 : }
238 : } else {
239 0 : arg7 = 0;
240 : }
241 : int32_t arg8;
242 0 : if (args.hasDefined(8)) {
243 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[8], &arg8)) {
244 0 : return false;
245 : }
246 : } else {
247 0 : arg8 = 0;
248 : }
249 : bool arg9;
250 0 : if (args.hasDefined(9)) {
251 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[9], &arg9)) {
252 0 : return false;
253 : }
254 : } else {
255 0 : arg9 = false;
256 : }
257 : bool arg10;
258 0 : if (args.hasDefined(10)) {
259 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[10], &arg10)) {
260 0 : return false;
261 : }
262 : } else {
263 0 : arg10 = false;
264 : }
265 : bool arg11;
266 0 : if (args.hasDefined(11)) {
267 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[11], &arg11)) {
268 0 : return false;
269 : }
270 : } else {
271 0 : arg11 = false;
272 : }
273 : bool arg12;
274 0 : if (args.hasDefined(12)) {
275 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[12], &arg12)) {
276 0 : return false;
277 : }
278 : } else {
279 0 : arg12 = false;
280 : }
281 : int16_t arg13;
282 0 : if (args.hasDefined(13)) {
283 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, args[13], &arg13)) {
284 0 : return false;
285 : }
286 : } else {
287 0 : arg13 = 0;
288 : }
289 : mozilla::dom::EventTarget* arg14;
290 0 : if (args.hasDefined(14)) {
291 0 : if (args[14].isObject()) {
292 : {
293 0 : nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(args[14], arg14);
294 0 : if (NS_FAILED(rv)) {
295 0 : RefPtr<mozilla::dom::EventTarget> objPtr;
296 0 : nsresult rv = UnwrapXPConnect<mozilla::dom::EventTarget>(cx, args[14], getter_AddRefs(objPtr));
297 0 : if (NS_FAILED(rv)) {
298 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 15 of SimpleGestureEvent.initSimpleGestureEvent", "EventTarget");
299 0 : return false;
300 : }
301 : // We should have an object
302 0 : MOZ_ASSERT(objPtr);
303 0 : arg14 = objPtr;
304 : }
305 : }
306 0 : } else if (args[14].isNullOrUndefined()) {
307 0 : arg14 = nullptr;
308 : } else {
309 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 15 of SimpleGestureEvent.initSimpleGestureEvent");
310 0 : return false;
311 : }
312 : } else {
313 0 : arg14 = nullptr;
314 : }
315 : uint32_t arg15;
316 0 : if (args.hasDefined(15)) {
317 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[15], &arg15)) {
318 0 : return false;
319 : }
320 : } else {
321 0 : arg15 = 0U;
322 : }
323 : uint32_t arg16;
324 0 : if (args.hasDefined(16)) {
325 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[16], &arg16)) {
326 0 : return false;
327 : }
328 : } else {
329 0 : arg16 = 0U;
330 : }
331 : double arg17;
332 0 : if (args.hasDefined(17)) {
333 0 : if (!ValueToPrimitive<double, eDefault>(cx, args[17], &arg17)) {
334 0 : return false;
335 0 : } else if (!mozilla::IsFinite(arg17)) {
336 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 18 of SimpleGestureEvent.initSimpleGestureEvent");
337 0 : return false;
338 : }
339 : } else {
340 0 : arg17 = 0.0;
341 : }
342 : uint32_t arg18;
343 0 : if (args.hasDefined(18)) {
344 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[18], &arg18)) {
345 0 : return false;
346 : }
347 : } else {
348 0 : arg18 = 0U;
349 : }
350 0 : self->InitSimpleGestureEvent(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, Constify(arg14), arg15, arg16, arg17, arg18);
351 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
352 0 : args.rval().setUndefined();
353 0 : return true;
354 : }
355 :
356 : static const JSJitInfo initSimpleGestureEvent_methodinfo = {
357 : { (JSJitGetterOp)initSimpleGestureEvent },
358 : { prototypes::id::SimpleGestureEvent },
359 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
360 : JSJitInfo::Method,
361 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
362 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
363 : false, /* isInfallible. False in setters. */
364 : false, /* isMovable. Not relevant for setters. */
365 : false, /* isEliminatable. Not relevant for setters. */
366 : false, /* isAlwaysInSlot. Only relevant for getters. */
367 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
368 : false, /* isTypedMethod. Only relevant for methods. */
369 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
370 : };
371 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
372 : static_assert(0 < 1, "There is no slot for us");
373 :
374 : static bool
375 0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SimpleGestureEvent* self, JSJitGetterCallArgs args)
376 : {
377 0 : bool result(self->IsTrusted());
378 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
379 0 : args.rval().setBoolean(result);
380 0 : return true;
381 : }
382 :
383 : static const JSJitInfo isTrusted_getterinfo = {
384 : { (JSJitGetterOp)get_isTrusted },
385 : { prototypes::id::SimpleGestureEvent },
386 : { PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth },
387 : JSJitInfo::Getter,
388 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
389 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
390 : true, /* isInfallible. False in setters. */
391 : true, /* isMovable. Not relevant for setters. */
392 : true, /* isEliminatable. Not relevant for setters. */
393 : false, /* isAlwaysInSlot. Only relevant for getters. */
394 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
395 : false, /* isTypedMethod. Only relevant for methods. */
396 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
397 : };
398 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
399 : static_assert(0 < 1, "There is no slot for us");
400 :
401 : static bool
402 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
403 : {
404 0 : mozilla::dom::SimpleGestureEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SimpleGestureEvent>(obj);
405 : // We don't want to preserve if we don't have a wrapper, and we
406 : // obviously can't preserve if we're not initialized.
407 0 : if (self && self->GetWrapperPreserveColor()) {
408 0 : PreserveWrapper(self);
409 : }
410 0 : return true;
411 : }
412 :
413 : static void
414 0 : _finalize(js::FreeOp* fop, JSObject* obj)
415 : {
416 0 : mozilla::dom::SimpleGestureEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SimpleGestureEvent>(obj);
417 0 : if (self) {
418 0 : ClearWrapper(self, self, obj);
419 0 : AddForDeferredFinalization<mozilla::dom::SimpleGestureEvent>(self);
420 : }
421 0 : }
422 :
423 : static void
424 0 : _objectMoved(JSObject* obj, const JSObject* old)
425 : {
426 0 : mozilla::dom::SimpleGestureEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SimpleGestureEvent>(obj);
427 0 : if (self) {
428 0 : UpdateWrapper(self, self, obj, old);
429 : }
430 0 : }
431 :
432 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
433 : #if defined(__clang__)
434 : #pragma clang diagnostic push
435 : #pragma clang diagnostic ignored "-Wmissing-braces"
436 : #endif
437 : static const JSFunctionSpec sMethods_specs[] = {
438 : JS_FNSPEC("initSimpleGestureEvent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initSimpleGestureEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
439 : JS_FS_END
440 : };
441 : #if defined(__clang__)
442 : #pragma clang diagnostic pop
443 : #endif
444 :
445 :
446 : // Can't be const because the pref-enabled boolean needs to be writable
447 : static Prefable<const JSFunctionSpec> sMethods[] = {
448 : { nullptr, &sMethods_specs[0] },
449 : { nullptr, nullptr }
450 : };
451 :
452 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
453 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
454 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
455 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
456 :
457 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
458 : #if defined(__clang__)
459 : #pragma clang diagnostic push
460 : #pragma clang diagnostic ignored "-Wmissing-braces"
461 : #endif
462 : static const JSPropertySpec sAttributes_specs[] = {
463 : { "allowedDirections", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &allowedDirections_getterinfo, GenericBindingSetter, &allowedDirections_setterinfo },
464 : { "direction", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &direction_getterinfo, nullptr, nullptr },
465 : { "delta", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &delta_getterinfo, nullptr, nullptr },
466 : { "clickCount", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &clickCount_getterinfo, nullptr, nullptr },
467 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
468 : };
469 : #if defined(__clang__)
470 : #pragma clang diagnostic pop
471 : #endif
472 :
473 :
474 : // Can't be const because the pref-enabled boolean needs to be writable
475 : static Prefable<const JSPropertySpec> sAttributes[] = {
476 : { nullptr, &sAttributes_specs[0] },
477 : { nullptr, nullptr }
478 : };
479 :
480 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
481 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
482 : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
483 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
484 :
485 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
486 : #if defined(__clang__)
487 : #pragma clang diagnostic push
488 : #pragma clang diagnostic ignored "-Wmissing-braces"
489 : #endif
490 : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
491 : { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
492 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
493 : };
494 : #if defined(__clang__)
495 : #pragma clang diagnostic pop
496 : #endif
497 :
498 :
499 : // Can't be const because the pref-enabled boolean needs to be writable
500 : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
501 : { nullptr, &sUnforgeableAttributes_specs[0] },
502 : { nullptr, nullptr }
503 : };
504 :
505 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
506 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
507 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
508 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
509 :
510 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
511 : #if defined(__clang__)
512 : #pragma clang diagnostic push
513 : #pragma clang diagnostic ignored "-Wmissing-braces"
514 : #endif
515 : static const ConstantSpec sConstants_specs[] = {
516 : { "DIRECTION_UP", JS::NumberValue(1U) },
517 : { "DIRECTION_DOWN", JS::NumberValue(2U) },
518 : { "DIRECTION_LEFT", JS::NumberValue(4U) },
519 : { "DIRECTION_RIGHT", JS::NumberValue(8U) },
520 : { "ROTATION_COUNTERCLOCKWISE", JS::NumberValue(1U) },
521 : { "ROTATION_CLOCKWISE", JS::NumberValue(2U) },
522 : { 0, JS::UndefinedValue() }
523 : };
524 : #if defined(__clang__)
525 : #pragma clang diagnostic pop
526 : #endif
527 :
528 :
529 : // Can't be const because the pref-enabled boolean needs to be writable
530 : static Prefable<const ConstantSpec> sConstants[] = {
531 : { nullptr, &sConstants_specs[0] },
532 : { nullptr, nullptr }
533 : };
534 :
535 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
536 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
537 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
538 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
539 :
540 :
541 : static uint16_t sNativeProperties_sortedPropertyIndices[12];
542 : static PropertyInfo sNativeProperties_propertyInfos[12];
543 :
544 : static const NativePropertiesN<4> sNativeProperties = {
545 : false, 0,
546 : false, 0,
547 : true, 0 /* sMethods */,
548 : true, 1 /* sAttributes */,
549 : false, 0,
550 : true, 2 /* sUnforgeableAttributes */,
551 : true, 3 /* sConstants */,
552 : -1,
553 : 12,
554 : sNativeProperties_sortedPropertyIndices,
555 : {
556 : { sMethods, &sNativeProperties_propertyInfos[0] },
557 : { sAttributes, &sNativeProperties_propertyInfos[1] },
558 : { sUnforgeableAttributes, &sNativeProperties_propertyInfos[5] },
559 : { sConstants, &sNativeProperties_propertyInfos[6] }
560 : }
561 : };
562 : static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
563 : "We have a property info count that is oversized");
564 :
565 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
566 : {
567 : "Function",
568 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
569 : &sBoringInterfaceObjectClassClassOps,
570 : JS_NULL_CLASS_SPEC,
571 : JS_NULL_CLASS_EXT,
572 : &sInterfaceObjectClassObjectOps
573 : },
574 : eInterface,
575 : true,
576 : prototypes::id::SimpleGestureEvent,
577 : PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth,
578 : sNativePropertyHooks,
579 : "function SimpleGestureEvent() {\n [native code]\n}",
580 : MouseEventBinding::GetConstructorObject
581 : };
582 :
583 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
584 : {
585 : "SimpleGestureEventPrototype",
586 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
587 : JS_NULL_CLASS_OPS,
588 : JS_NULL_CLASS_SPEC,
589 : JS_NULL_CLASS_EXT,
590 : JS_NULL_OBJECT_OPS
591 : },
592 : eInterfacePrototype,
593 : false,
594 : prototypes::id::SimpleGestureEvent,
595 : PrototypeTraits<prototypes::id::SimpleGestureEvent>::Depth,
596 : sNativePropertyHooks,
597 : "[object SimpleGestureEventPrototype]",
598 : MouseEventBinding::GetProtoObject
599 : };
600 :
601 : bool
602 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
603 : {
604 0 : return IsChromeOrXBL(aCx, aObj);
605 : }
606 :
607 : JSObject*
608 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
609 : {
610 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
611 : }
612 :
613 : static const js::ClassOps sClassOps = {
614 : _addProperty, /* addProperty */
615 : nullptr, /* delProperty */
616 : nullptr, /* getProperty */
617 : nullptr, /* setProperty */
618 : nullptr, /* enumerate */
619 : nullptr, /* newEnumerate */
620 : nullptr, /* resolve */
621 : nullptr, /* mayResolve */
622 : _finalize, /* finalize */
623 : nullptr, /* call */
624 : nullptr, /* hasInstance */
625 : nullptr, /* construct */
626 : nullptr, /* trace */
627 : };
628 :
629 : static const js::ClassExtension sClassExtension = {
630 : nullptr, /* weakmapKeyDelegateOp */
631 : _objectMoved /* objectMovedOp */
632 : };
633 :
634 : static const DOMJSClass sClass = {
635 : { "SimpleGestureEvent",
636 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
637 : &sClassOps,
638 : JS_NULL_CLASS_SPEC,
639 : &sClassExtension,
640 : JS_NULL_OBJECT_OPS
641 : },
642 : { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::MouseEvent, prototypes::id::SimpleGestureEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
643 : IsBaseOf<nsISupports, mozilla::dom::SimpleGestureEvent >::value,
644 : sNativePropertyHooks,
645 : FindAssociatedGlobalForNative<mozilla::dom::SimpleGestureEvent>::Get,
646 : GetProtoObjectHandle,
647 : GetCCParticipant<mozilla::dom::SimpleGestureEvent>::Get()
648 : };
649 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
650 : "Must have the right minimal number of reserved slots.");
651 : static_assert(1 >= 1,
652 : "Must have enough reserved slots.");
653 :
654 : const JSClass*
655 0 : GetJSClass()
656 : {
657 0 : return sClass.ToJSClass();
658 : }
659 :
660 : bool
661 0 : Wrap(JSContext* aCx, mozilla::dom::SimpleGestureEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
662 : {
663 : MOZ_ASSERT(static_cast<mozilla::dom::SimpleGestureEvent*>(aObject) ==
664 : reinterpret_cast<mozilla::dom::SimpleGestureEvent*>(aObject),
665 : "Multiple inheritance for mozilla::dom::SimpleGestureEvent is broken.");
666 : MOZ_ASSERT(static_cast<mozilla::dom::MouseEvent*>(aObject) ==
667 : reinterpret_cast<mozilla::dom::MouseEvent*>(aObject),
668 : "Multiple inheritance for mozilla::dom::MouseEvent is broken.");
669 : MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
670 : reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
671 : "Multiple inheritance for mozilla::dom::UIEvent is broken.");
672 : MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
673 : reinterpret_cast<mozilla::dom::Event*>(aObject),
674 : "Multiple inheritance for mozilla::dom::Event is broken.");
675 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
676 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
677 0 : MOZ_ASSERT(!aCache->GetWrapper(),
678 : "You should probably not be using Wrap() directly; use "
679 : "GetOrCreateDOMReflector instead");
680 :
681 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
682 : "nsISupports must be on our primary inheritance chain");
683 :
684 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
685 0 : if (!global) {
686 0 : return false;
687 : }
688 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
689 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
690 :
691 : // That might have ended up wrapping us already, due to the wonders
692 : // of XBL. Check for that, and bail out as needed.
693 0 : aReflector.set(aCache->GetWrapper());
694 0 : if (aReflector) {
695 : #ifdef DEBUG
696 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
697 : #endif // DEBUG
698 0 : return true;
699 : }
700 :
701 0 : JSAutoCompartment ac(aCx, global);
702 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
703 0 : if (!canonicalProto) {
704 0 : return false;
705 : }
706 0 : JS::Rooted<JSObject*> proto(aCx);
707 0 : if (aGivenProto) {
708 0 : proto = aGivenProto;
709 : // Unfortunately, while aGivenProto was in the compartment of aCx
710 : // coming in, we changed compartments to that of "parent" so may need
711 : // to wrap the proto here.
712 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
713 0 : if (!JS_WrapObject(aCx, &proto)) {
714 0 : return false;
715 : }
716 : }
717 : } else {
718 0 : proto = canonicalProto;
719 : }
720 :
721 0 : BindingJSObjectCreator<mozilla::dom::SimpleGestureEvent> creator(aCx);
722 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
723 0 : if (!aReflector) {
724 0 : return false;
725 : }
726 :
727 0 : aCache->SetWrapper(aReflector);
728 :
729 : // Important: do unforgeable property setup after we have handed
730 : // over ownership of the C++ object to obj as needed, so that if
731 : // we fail and it ends up GCed it won't have problems in the
732 : // finalizer trying to drop its ownership of the C++ object.
733 : JS::Rooted<JSObject*> unforgeableHolder(aCx,
734 0 : &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
735 0 : if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
736 0 : aCache->ReleaseWrapper(aObject);
737 0 : aCache->ClearWrapper();
738 0 : return false;
739 : }
740 0 : creator.InitializationSucceeded();
741 :
742 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
743 : aCache->GetWrapperPreserveColor() == aReflector);
744 : // If proto != canonicalProto, we have to preserve our wrapper;
745 : // otherwise we won't be able to properly recreate it later, since
746 : // we won't know what proto to use. Note that we don't check
747 : // aGivenProto here, since it's entirely possible (and even
748 : // somewhat common) to have a non-null aGivenProto which is the
749 : // same as canonicalProto.
750 0 : if (proto != canonicalProto) {
751 0 : PreserveWrapper(aObject);
752 : }
753 :
754 0 : return true;
755 : }
756 :
757 : const NativePropertyHooks sNativePropertyHooks[] = { {
758 : nullptr,
759 : nullptr,
760 : nullptr,
761 : { sNativeProperties.Upcast(), nullptr },
762 : prototypes::id::SimpleGestureEvent,
763 : constructors::id::SimpleGestureEvent,
764 : MouseEventBinding::sNativePropertyHooks,
765 : &DefaultXrayExpandoObjectClass
766 : } };
767 :
768 : void
769 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
770 : {
771 0 : JS::Handle<JSObject*> parentProto(MouseEventBinding::GetProtoObjectHandle(aCx));
772 0 : if (!parentProto) {
773 0 : return;
774 : }
775 :
776 0 : JS::Handle<JSObject*> constructorProto(MouseEventBinding::GetConstructorObjectHandle(aCx));
777 0 : if (!constructorProto) {
778 0 : return;
779 : }
780 :
781 : static bool sIdsInited = false;
782 0 : if (!sIdsInited && NS_IsMainThread()) {
783 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
784 0 : return;
785 : }
786 0 : sIdsInited = true;
787 : }
788 :
789 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SimpleGestureEvent);
790 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SimpleGestureEvent);
791 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
792 : &sPrototypeClass.mBase, protoCache,
793 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
794 : interfaceCache,
795 : sNativeProperties.Upcast(),
796 : nullptr,
797 : "SimpleGestureEvent", aDefineOnGlobal,
798 : nullptr,
799 0 : false);
800 :
801 0 : JS::Rooted<JSObject*> unforgeableHolder(aCx);
802 : {
803 0 : JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
804 0 : unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
805 0 : if (!unforgeableHolder) {
806 0 : *protoCache = nullptr;
807 0 : if (interfaceCache) {
808 0 : *interfaceCache = nullptr;
809 : }
810 0 : return;
811 : }
812 : }
813 :
814 0 : if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
815 0 : *protoCache = nullptr;
816 0 : if (interfaceCache) {
817 0 : *interfaceCache = nullptr;
818 : }
819 0 : return;
820 : }
821 :
822 0 : if (*protoCache) {
823 0 : js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
824 0 : JS::ObjectValue(*unforgeableHolder));
825 : }
826 : }
827 :
828 : JS::Handle<JSObject*>
829 0 : GetProtoObjectHandle(JSContext* aCx)
830 : {
831 : /* Get the interface prototype object for this class. This will create the
832 : object as needed. */
833 0 : bool aDefineOnGlobal = true;
834 :
835 : /* Make sure our global is sane. Hopefully we can remove this sometime */
836 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
837 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
838 0 : return nullptr;
839 : }
840 :
841 : /* Check to see whether the interface objects are already installed */
842 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
843 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SimpleGestureEvent)) {
844 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
845 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
846 : }
847 :
848 : /*
849 : * The object might _still_ be null, but that's OK.
850 : *
851 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
852 : * traced by TraceProtoAndIfaceCache() and its contents are never
853 : * changed after they have been set.
854 : *
855 : * Calling address() avoids the read read barrier that does gray
856 : * unmarking, but it's not possible for the object to be gray here.
857 : */
858 :
859 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SimpleGestureEvent);
860 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
861 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
862 : }
863 :
864 : JS::Handle<JSObject*>
865 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
866 : {
867 : /* Get the interface object for this class. This will create the object as
868 : needed. */
869 :
870 : /* Make sure our global is sane. Hopefully we can remove this sometime */
871 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
872 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
873 0 : return nullptr;
874 : }
875 :
876 : /* Check to see whether the interface objects are already installed */
877 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
878 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SimpleGestureEvent)) {
879 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
880 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
881 : }
882 :
883 : /*
884 : * The object might _still_ be null, but that's OK.
885 : *
886 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
887 : * traced by TraceProtoAndIfaceCache() and its contents are never
888 : * changed after they have been set.
889 : *
890 : * Calling address() avoids the read read barrier that does gray
891 : * unmarking, but it's not possible for the object to be gray here.
892 : */
893 :
894 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SimpleGestureEvent);
895 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
896 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
897 : }
898 :
899 : JSObject*
900 0 : GetConstructorObject(JSContext* aCx)
901 : {
902 0 : return GetConstructorObjectHandle(aCx);
903 : }
904 :
905 : } // namespace SimpleGestureEventBinding
906 :
907 :
908 :
909 : } // namespace dom
910 : } // namespace mozilla
|