Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM MouseEvent.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "MouseEventBinding.h"
5 : #include "UIEventBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "mozilla/FloatingPoint.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/EventTarget.h"
12 : #include "mozilla/dom/MouseEvent.h"
13 : #include "mozilla/dom/NonRefcountedDOMObject.h"
14 : #include "mozilla/dom/Nullable.h"
15 : #include "mozilla/dom/PrimitiveConversions.h"
16 : #include "mozilla/dom/ScriptSettings.h"
17 : #include "mozilla/dom/XrayExpandoClass.h"
18 : #include "nsContentUtils.h"
19 : #include "nsGlobalWindow.h"
20 :
21 : namespace mozilla {
22 : namespace dom {
23 :
24 :
25 0 : MouseEventInit::MouseEventInit()
26 0 : : EventModifierInit(FastDictionaryInitializer())
27 : {
28 : // Safe to pass a null context if we pass a null value
29 0 : Init(nullptr, JS::NullHandleValue);
30 0 : }
31 :
32 :
33 :
34 : bool
35 0 : MouseEventInit::InitIds(JSContext* cx, MouseEventInitAtoms* atomsCache)
36 : {
37 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
38 :
39 : // Initialize these in reverse order so that any failure leaves the first one
40 : // uninitialized.
41 0 : if (!atomsCache->screenY_id.init(cx, "screenY") ||
42 0 : !atomsCache->screenX_id.init(cx, "screenX") ||
43 0 : !atomsCache->relatedTarget_id.init(cx, "relatedTarget") ||
44 0 : !atomsCache->movementY_id.init(cx, "movementY") ||
45 0 : !atomsCache->movementX_id.init(cx, "movementX") ||
46 0 : !atomsCache->clientY_id.init(cx, "clientY") ||
47 0 : !atomsCache->clientX_id.init(cx, "clientX") ||
48 0 : !atomsCache->buttons_id.init(cx, "buttons") ||
49 0 : !atomsCache->button_id.init(cx, "button")) {
50 0 : return false;
51 : }
52 0 : return true;
53 : }
54 :
55 : bool
56 0 : MouseEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
57 : {
58 : // Passing a null JSContext is OK only if we're initing from null,
59 : // Since in that case we will not have to do any property gets
60 : // Also evaluate isNullOrUndefined in order to avoid false-positive
61 : // checkers by static analysis tools
62 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
63 0 : MouseEventInitAtoms* atomsCache = nullptr;
64 0 : if (cx) {
65 0 : atomsCache = GetAtomCache<MouseEventInitAtoms>(cx);
66 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
67 0 : return false;
68 : }
69 : }
70 :
71 : // Per spec, we init the parent's members first
72 0 : if (!EventModifierInit::Init(cx, val)) {
73 0 : return false;
74 : }
75 :
76 0 : bool isNull = val.isNullOrUndefined();
77 : // We only need these if !isNull, in which case we have |cx|.
78 0 : Maybe<JS::Rooted<JSObject *> > object;
79 0 : Maybe<JS::Rooted<JS::Value> > temp;
80 0 : if (!isNull) {
81 0 : MOZ_ASSERT(cx);
82 0 : object.emplace(cx, &val.toObject());
83 0 : temp.emplace(cx);
84 : }
85 0 : if (!isNull) {
86 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->button_id, temp.ptr())) {
87 0 : return false;
88 : }
89 : }
90 0 : if (!isNull && !temp->isUndefined()) {
91 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, temp.ref(), &mButton)) {
92 0 : return false;
93 : }
94 : } else {
95 0 : mButton = 0;
96 : }
97 0 : mIsAnyMemberPresent = true;
98 :
99 0 : if (!isNull) {
100 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->buttons_id, temp.ptr())) {
101 0 : return false;
102 : }
103 : }
104 0 : if (!isNull && !temp->isUndefined()) {
105 0 : if (!ValueToPrimitive<uint16_t, eDefault>(cx, temp.ref(), &mButtons)) {
106 0 : return false;
107 : }
108 : } else {
109 0 : mButtons = 0;
110 : }
111 0 : mIsAnyMemberPresent = true;
112 :
113 0 : if (!isNull) {
114 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->clientX_id, temp.ptr())) {
115 0 : return false;
116 : }
117 : }
118 0 : if (!isNull && !temp->isUndefined()) {
119 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mClientX)) {
120 0 : return false;
121 : }
122 : } else {
123 0 : mClientX = 0;
124 : }
125 0 : mIsAnyMemberPresent = true;
126 :
127 0 : if (!isNull) {
128 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->clientY_id, temp.ptr())) {
129 0 : return false;
130 : }
131 : }
132 0 : if (!isNull && !temp->isUndefined()) {
133 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mClientY)) {
134 0 : return false;
135 : }
136 : } else {
137 0 : mClientY = 0;
138 : }
139 0 : mIsAnyMemberPresent = true;
140 :
141 0 : if (!isNull) {
142 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->movementX_id, temp.ptr())) {
143 0 : return false;
144 : }
145 : }
146 0 : if (!isNull && !temp->isUndefined()) {
147 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mMovementX)) {
148 0 : return false;
149 : }
150 : } else {
151 0 : mMovementX = 0;
152 : }
153 0 : mIsAnyMemberPresent = true;
154 :
155 0 : if (!isNull) {
156 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->movementY_id, temp.ptr())) {
157 0 : return false;
158 : }
159 : }
160 0 : if (!isNull && !temp->isUndefined()) {
161 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mMovementY)) {
162 0 : return false;
163 : }
164 : } else {
165 0 : mMovementY = 0;
166 : }
167 0 : mIsAnyMemberPresent = true;
168 :
169 0 : if (!isNull) {
170 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->relatedTarget_id, temp.ptr())) {
171 0 : return false;
172 : }
173 : }
174 0 : if (!isNull && !temp->isUndefined()) {
175 0 : if (temp.ref().isObject()) {
176 : static_assert(IsRefcounted<mozilla::dom::EventTarget>::value, "We can only store refcounted classes.");{
177 0 : nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(temp.ptr(), mRelatedTarget);
178 0 : if (NS_FAILED(rv)) {
179 0 : RefPtr<mozilla::dom::EventTarget> objPtr;
180 0 : nsresult rv = UnwrapXPConnect<mozilla::dom::EventTarget>(cx, temp.ptr(), getter_AddRefs(objPtr));
181 0 : if (NS_FAILED(rv)) {
182 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'relatedTarget' member of MouseEventInit", "EventTarget");
183 0 : return false;
184 : }
185 : // We should have an object
186 0 : MOZ_ASSERT(objPtr);
187 0 : mRelatedTarget = objPtr;
188 : }
189 : }
190 0 : } else if (temp.ref().isNullOrUndefined()) {
191 0 : mRelatedTarget = nullptr;
192 : } else {
193 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'relatedTarget' member of MouseEventInit");
194 0 : return false;
195 : }
196 : } else {
197 0 : mRelatedTarget = nullptr;
198 : }
199 0 : mIsAnyMemberPresent = true;
200 :
201 0 : if (!isNull) {
202 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->screenX_id, temp.ptr())) {
203 0 : return false;
204 : }
205 : }
206 0 : if (!isNull && !temp->isUndefined()) {
207 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mScreenX)) {
208 0 : return false;
209 : }
210 : } else {
211 0 : mScreenX = 0;
212 : }
213 0 : mIsAnyMemberPresent = true;
214 :
215 0 : if (!isNull) {
216 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->screenY_id, temp.ptr())) {
217 0 : return false;
218 : }
219 : }
220 0 : if (!isNull && !temp->isUndefined()) {
221 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mScreenY)) {
222 0 : return false;
223 : }
224 : } else {
225 0 : mScreenY = 0;
226 : }
227 0 : mIsAnyMemberPresent = true;
228 0 : return true;
229 : }
230 :
231 : bool
232 0 : MouseEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
233 : {
234 0 : MouseEventInitAtoms* atomsCache = GetAtomCache<MouseEventInitAtoms>(cx);
235 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
236 0 : return false;
237 : }
238 :
239 : // Per spec, we define the parent's members first
240 0 : if (!EventModifierInit::ToObjectInternal(cx, rval)) {
241 0 : return false;
242 : }
243 0 : JS::Rooted<JSObject*> obj(cx, &rval.toObject());
244 :
245 : do {
246 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
247 0 : JS::Rooted<JS::Value> temp(cx);
248 0 : int16_t const & currentValue = mButton;
249 0 : temp.setInt32(int32_t(currentValue));
250 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->button_id, temp, JSPROP_ENUMERATE)) {
251 0 : return false;
252 : }
253 0 : break;
254 : } while(0);
255 :
256 : do {
257 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
258 0 : JS::Rooted<JS::Value> temp(cx);
259 0 : uint16_t const & currentValue = mButtons;
260 0 : temp.setInt32(int32_t(currentValue));
261 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->buttons_id, temp, JSPROP_ENUMERATE)) {
262 0 : return false;
263 : }
264 0 : break;
265 : } while(0);
266 :
267 : do {
268 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
269 0 : JS::Rooted<JS::Value> temp(cx);
270 0 : int32_t const & currentValue = mClientX;
271 0 : temp.setInt32(int32_t(currentValue));
272 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->clientX_id, temp, JSPROP_ENUMERATE)) {
273 0 : return false;
274 : }
275 0 : break;
276 : } while(0);
277 :
278 : do {
279 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
280 0 : JS::Rooted<JS::Value> temp(cx);
281 0 : int32_t const & currentValue = mClientY;
282 0 : temp.setInt32(int32_t(currentValue));
283 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->clientY_id, temp, JSPROP_ENUMERATE)) {
284 0 : return false;
285 : }
286 0 : break;
287 : } while(0);
288 :
289 : do {
290 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
291 0 : JS::Rooted<JS::Value> temp(cx);
292 0 : int32_t const & currentValue = mMovementX;
293 0 : temp.setInt32(int32_t(currentValue));
294 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->movementX_id, temp, JSPROP_ENUMERATE)) {
295 0 : return false;
296 : }
297 0 : break;
298 : } while(0);
299 :
300 : do {
301 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
302 0 : JS::Rooted<JS::Value> temp(cx);
303 0 : int32_t const & currentValue = mMovementY;
304 0 : temp.setInt32(int32_t(currentValue));
305 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->movementY_id, temp, JSPROP_ENUMERATE)) {
306 0 : return false;
307 : }
308 0 : break;
309 : } while(0);
310 :
311 : do {
312 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
313 0 : JS::Rooted<JS::Value> temp(cx);
314 0 : RefPtr<mozilla::dom::EventTarget> const & currentValue = mRelatedTarget;
315 0 : if (!currentValue) {
316 0 : temp.setNull();
317 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->relatedTarget_id, temp, JSPROP_ENUMERATE)) {
318 0 : return false;
319 : }
320 0 : break;
321 : }
322 0 : if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
323 0 : if (!HandleNewBindingWrappingFailure(cx, obj, currentValue, &temp)) {
324 0 : return false;
325 : }
326 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->relatedTarget_id, temp, JSPROP_ENUMERATE)) {
327 0 : return false;
328 : }
329 0 : break;
330 : }
331 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->relatedTarget_id, temp, JSPROP_ENUMERATE)) {
332 0 : return false;
333 : }
334 0 : break;
335 : } while(0);
336 :
337 : do {
338 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
339 0 : JS::Rooted<JS::Value> temp(cx);
340 0 : int32_t const & currentValue = mScreenX;
341 0 : temp.setInt32(int32_t(currentValue));
342 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->screenX_id, temp, JSPROP_ENUMERATE)) {
343 0 : return false;
344 : }
345 0 : break;
346 : } while(0);
347 :
348 : do {
349 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
350 0 : JS::Rooted<JS::Value> temp(cx);
351 0 : int32_t const & currentValue = mScreenY;
352 0 : temp.setInt32(int32_t(currentValue));
353 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->screenY_id, temp, JSPROP_ENUMERATE)) {
354 0 : return false;
355 : }
356 0 : break;
357 : } while(0);
358 :
359 0 : return true;
360 : }
361 :
362 : void
363 0 : MouseEventInit::TraceDictionary(JSTracer* trc)
364 : {
365 0 : EventModifierInit::TraceDictionary(trc);
366 0 : }
367 :
368 : MouseEventInit&
369 0 : MouseEventInit::operator=(const MouseEventInit& aOther)
370 : {
371 0 : EventModifierInit::operator=(aOther);
372 0 : mButton = aOther.mButton;
373 0 : mButtons = aOther.mButtons;
374 0 : mClientX = aOther.mClientX;
375 0 : mClientY = aOther.mClientY;
376 0 : mMovementX = aOther.mMovementX;
377 0 : mMovementY = aOther.mMovementY;
378 0 : mRelatedTarget = aOther.mRelatedTarget;
379 0 : mScreenX = aOther.mScreenX;
380 0 : mScreenY = aOther.mScreenY;
381 0 : return *this;
382 : }
383 :
384 : namespace binding_detail {
385 : } // namespace binding_detail
386 :
387 :
388 : namespace MouseEventBinding {
389 :
390 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<UIEventBinding::NativeType>::value,
391 : "Can't inherit from an interface with a different ownership model.");
392 :
393 : static bool
394 4 : get_screenX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
395 : {
396 4 : int32_t result(self->ScreenX(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
397 4 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
398 4 : args.rval().setInt32(int32_t(result));
399 4 : return true;
400 : }
401 :
402 : static const JSJitInfo screenX_getterinfo = {
403 : { (JSJitGetterOp)get_screenX },
404 : { prototypes::id::MouseEvent },
405 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
406 : JSJitInfo::Getter,
407 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
408 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
409 : true, /* isInfallible. False in setters. */
410 : false, /* isMovable. Not relevant for setters. */
411 : false, /* isEliminatable. Not relevant for setters. */
412 : false, /* isAlwaysInSlot. Only relevant for getters. */
413 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
414 : false, /* isTypedMethod. Only relevant for methods. */
415 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
416 : };
417 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
418 : static_assert(0 < 1, "There is no slot for us");
419 :
420 : static bool
421 4 : get_screenY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
422 : {
423 4 : int32_t result(self->ScreenY(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
424 4 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
425 4 : args.rval().setInt32(int32_t(result));
426 4 : return true;
427 : }
428 :
429 : static const JSJitInfo screenY_getterinfo = {
430 : { (JSJitGetterOp)get_screenY },
431 : { prototypes::id::MouseEvent },
432 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
433 : JSJitInfo::Getter,
434 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
435 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
436 : true, /* isInfallible. False in setters. */
437 : false, /* isMovable. Not relevant for setters. */
438 : false, /* isEliminatable. Not relevant for setters. */
439 : false, /* isAlwaysInSlot. Only relevant for getters. */
440 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
441 : false, /* isTypedMethod. Only relevant for methods. */
442 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
443 : };
444 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
445 : static_assert(0 < 1, "There is no slot for us");
446 :
447 : static bool
448 0 : get_clientX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
449 : {
450 0 : int32_t result(self->ClientX());
451 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
452 0 : args.rval().setInt32(int32_t(result));
453 0 : return true;
454 : }
455 :
456 : static const JSJitInfo clientX_getterinfo = {
457 : { (JSJitGetterOp)get_clientX },
458 : { prototypes::id::MouseEvent },
459 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
460 : JSJitInfo::Getter,
461 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
462 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
463 : true, /* isInfallible. False in setters. */
464 : false, /* isMovable. Not relevant for setters. */
465 : false, /* isEliminatable. Not relevant for setters. */
466 : false, /* isAlwaysInSlot. Only relevant for getters. */
467 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
468 : false, /* isTypedMethod. Only relevant for methods. */
469 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
470 : };
471 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
472 : static_assert(0 < 1, "There is no slot for us");
473 :
474 : static bool
475 0 : get_clientY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
476 : {
477 0 : int32_t result(self->ClientY());
478 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
479 0 : args.rval().setInt32(int32_t(result));
480 0 : return true;
481 : }
482 :
483 : static const JSJitInfo clientY_getterinfo = {
484 : { (JSJitGetterOp)get_clientY },
485 : { prototypes::id::MouseEvent },
486 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
487 : JSJitInfo::Getter,
488 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
489 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
490 : true, /* isInfallible. False in setters. */
491 : false, /* isMovable. Not relevant for setters. */
492 : false, /* isEliminatable. Not relevant for setters. */
493 : false, /* isAlwaysInSlot. Only relevant for getters. */
494 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
495 : false, /* isTypedMethod. Only relevant for methods. */
496 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
497 : };
498 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
499 : static_assert(0 < 1, "There is no slot for us");
500 :
501 : static bool
502 0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
503 : {
504 0 : int32_t result(self->ClientX());
505 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
506 0 : args.rval().setInt32(int32_t(result));
507 0 : return true;
508 : }
509 :
510 : static const JSJitInfo x_getterinfo = {
511 : { (JSJitGetterOp)get_x },
512 : { prototypes::id::MouseEvent },
513 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
514 : JSJitInfo::Getter,
515 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
516 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
517 : true, /* isInfallible. False in setters. */
518 : false, /* isMovable. Not relevant for setters. */
519 : false, /* isEliminatable. Not relevant for setters. */
520 : false, /* isAlwaysInSlot. Only relevant for getters. */
521 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
522 : false, /* isTypedMethod. Only relevant for methods. */
523 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
524 : };
525 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
526 : static_assert(0 < 1, "There is no slot for us");
527 :
528 : static bool
529 0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
530 : {
531 0 : int32_t result(self->ClientY());
532 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
533 0 : args.rval().setInt32(int32_t(result));
534 0 : return true;
535 : }
536 :
537 : static const JSJitInfo y_getterinfo = {
538 : { (JSJitGetterOp)get_y },
539 : { prototypes::id::MouseEvent },
540 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
541 : JSJitInfo::Getter,
542 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
543 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
544 : true, /* isInfallible. False in setters. */
545 : false, /* isMovable. Not relevant for setters. */
546 : false, /* isEliminatable. Not relevant for setters. */
547 : false, /* isAlwaysInSlot. Only relevant for getters. */
548 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
549 : false, /* isTypedMethod. Only relevant for methods. */
550 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
551 : };
552 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
553 : static_assert(0 < 1, "There is no slot for us");
554 :
555 : static bool
556 0 : get_offsetX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
557 : {
558 0 : int32_t result(self->OffsetX());
559 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
560 0 : args.rval().setInt32(int32_t(result));
561 0 : return true;
562 : }
563 :
564 : static const JSJitInfo offsetX_getterinfo = {
565 : { (JSJitGetterOp)get_offsetX },
566 : { prototypes::id::MouseEvent },
567 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
568 : JSJitInfo::Getter,
569 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
570 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
571 : true, /* isInfallible. False in setters. */
572 : false, /* isMovable. Not relevant for setters. */
573 : false, /* isEliminatable. Not relevant for setters. */
574 : false, /* isAlwaysInSlot. Only relevant for getters. */
575 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
576 : false, /* isTypedMethod. Only relevant for methods. */
577 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
578 : };
579 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
580 : static_assert(0 < 1, "There is no slot for us");
581 :
582 : static bool
583 0 : get_offsetY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
584 : {
585 0 : int32_t result(self->OffsetY());
586 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
587 0 : args.rval().setInt32(int32_t(result));
588 0 : return true;
589 : }
590 :
591 : static const JSJitInfo offsetY_getterinfo = {
592 : { (JSJitGetterOp)get_offsetY },
593 : { prototypes::id::MouseEvent },
594 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
595 : JSJitInfo::Getter,
596 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
597 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
598 : true, /* isInfallible. False in setters. */
599 : false, /* isMovable. Not relevant for setters. */
600 : false, /* isEliminatable. Not relevant for setters. */
601 : false, /* isAlwaysInSlot. Only relevant for getters. */
602 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
603 : false, /* isTypedMethod. Only relevant for methods. */
604 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
605 : };
606 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
607 : static_assert(0 < 1, "There is no slot for us");
608 :
609 : static bool
610 0 : get_ctrlKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
611 : {
612 0 : bool result(self->CtrlKey());
613 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
614 0 : args.rval().setBoolean(result);
615 0 : return true;
616 : }
617 :
618 : static const JSJitInfo ctrlKey_getterinfo = {
619 : { (JSJitGetterOp)get_ctrlKey },
620 : { prototypes::id::MouseEvent },
621 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
622 : JSJitInfo::Getter,
623 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
624 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
625 : true, /* isInfallible. False in setters. */
626 : false, /* isMovable. Not relevant for setters. */
627 : false, /* isEliminatable. Not relevant for setters. */
628 : false, /* isAlwaysInSlot. Only relevant for getters. */
629 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
630 : false, /* isTypedMethod. Only relevant for methods. */
631 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
632 : };
633 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
634 : static_assert(0 < 1, "There is no slot for us");
635 :
636 : static bool
637 0 : get_shiftKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
638 : {
639 0 : bool result(self->ShiftKey());
640 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
641 0 : args.rval().setBoolean(result);
642 0 : return true;
643 : }
644 :
645 : static const JSJitInfo shiftKey_getterinfo = {
646 : { (JSJitGetterOp)get_shiftKey },
647 : { prototypes::id::MouseEvent },
648 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
649 : JSJitInfo::Getter,
650 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
651 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
652 : true, /* isInfallible. False in setters. */
653 : false, /* isMovable. Not relevant for setters. */
654 : false, /* isEliminatable. Not relevant for setters. */
655 : false, /* isAlwaysInSlot. Only relevant for getters. */
656 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
657 : false, /* isTypedMethod. Only relevant for methods. */
658 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
659 : };
660 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
661 : static_assert(0 < 1, "There is no slot for us");
662 :
663 : static bool
664 0 : get_altKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
665 : {
666 0 : bool result(self->AltKey());
667 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
668 0 : args.rval().setBoolean(result);
669 0 : return true;
670 : }
671 :
672 : static const JSJitInfo altKey_getterinfo = {
673 : { (JSJitGetterOp)get_altKey },
674 : { prototypes::id::MouseEvent },
675 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
676 : JSJitInfo::Getter,
677 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
678 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
679 : true, /* isInfallible. False in setters. */
680 : false, /* isMovable. Not relevant for setters. */
681 : false, /* isEliminatable. Not relevant for setters. */
682 : false, /* isAlwaysInSlot. Only relevant for getters. */
683 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
684 : false, /* isTypedMethod. Only relevant for methods. */
685 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
686 : };
687 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
688 : static_assert(0 < 1, "There is no slot for us");
689 :
690 : static bool
691 0 : get_metaKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
692 : {
693 0 : bool result(self->MetaKey());
694 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
695 0 : args.rval().setBoolean(result);
696 0 : return true;
697 : }
698 :
699 : static const JSJitInfo metaKey_getterinfo = {
700 : { (JSJitGetterOp)get_metaKey },
701 : { prototypes::id::MouseEvent },
702 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
703 : JSJitInfo::Getter,
704 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
705 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
706 : true, /* isInfallible. False in setters. */
707 : false, /* isMovable. Not relevant for setters. */
708 : false, /* isEliminatable. Not relevant for setters. */
709 : false, /* isAlwaysInSlot. Only relevant for getters. */
710 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
711 : false, /* isTypedMethod. Only relevant for methods. */
712 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
713 : };
714 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
715 : static_assert(0 < 1, "There is no slot for us");
716 :
717 : static bool
718 0 : get_button(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
719 : {
720 0 : int16_t result(self->Button());
721 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
722 0 : args.rval().setInt32(int32_t(result));
723 0 : return true;
724 : }
725 :
726 : static const JSJitInfo button_getterinfo = {
727 : { (JSJitGetterOp)get_button },
728 : { prototypes::id::MouseEvent },
729 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
730 : JSJitInfo::Getter,
731 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
732 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
733 : true, /* isInfallible. False in setters. */
734 : false, /* isMovable. Not relevant for setters. */
735 : false, /* isEliminatable. Not relevant for setters. */
736 : false, /* isAlwaysInSlot. Only relevant for getters. */
737 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
738 : false, /* isTypedMethod. Only relevant for methods. */
739 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
740 : };
741 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
742 : static_assert(0 < 1, "There is no slot for us");
743 :
744 : static bool
745 0 : get_buttons(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
746 : {
747 0 : uint16_t result(self->Buttons());
748 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
749 0 : args.rval().setInt32(int32_t(result));
750 0 : return true;
751 : }
752 :
753 : static const JSJitInfo buttons_getterinfo = {
754 : { (JSJitGetterOp)get_buttons },
755 : { prototypes::id::MouseEvent },
756 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
757 : JSJitInfo::Getter,
758 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
759 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
760 : true, /* isInfallible. False in setters. */
761 : false, /* isMovable. Not relevant for setters. */
762 : false, /* isEliminatable. Not relevant for setters. */
763 : false, /* isAlwaysInSlot. Only relevant for getters. */
764 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
765 : false, /* isTypedMethod. Only relevant for methods. */
766 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
767 : };
768 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
769 : static_assert(0 < 1, "There is no slot for us");
770 :
771 : static bool
772 0 : get_relatedTarget(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
773 : {
774 0 : auto result(StrongOrRawPtr<mozilla::dom::EventTarget>(self->GetRelatedTarget()));
775 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
776 0 : if (!result) {
777 0 : args.rval().setNull();
778 0 : return true;
779 : }
780 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
781 0 : if (!HandleNewBindingWrappingFailure(cx, obj, result, args.rval())) {
782 0 : return false;
783 : }
784 0 : return true;
785 : }
786 0 : return true;
787 : }
788 :
789 : static const JSJitInfo relatedTarget_getterinfo = {
790 : { (JSJitGetterOp)get_relatedTarget },
791 : { prototypes::id::MouseEvent },
792 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
793 : JSJitInfo::Getter,
794 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
795 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
796 : false, /* isInfallible. False in setters. */
797 : false, /* isMovable. Not relevant for setters. */
798 : false, /* isEliminatable. Not relevant for setters. */
799 : false, /* isAlwaysInSlot. Only relevant for getters. */
800 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
801 : false, /* isTypedMethod. Only relevant for methods. */
802 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
803 : };
804 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
805 : static_assert(0 < 1, "There is no slot for us");
806 :
807 : static bool
808 0 : get_region(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
809 : {
810 0 : DOMString result;
811 0 : self->GetRegion(result);
812 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
813 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
814 0 : return false;
815 : }
816 0 : return true;
817 : }
818 :
819 : static const JSJitInfo region_getterinfo = {
820 : { (JSJitGetterOp)get_region },
821 : { prototypes::id::MouseEvent },
822 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
823 : JSJitInfo::Getter,
824 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
825 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
826 : false, /* isInfallible. False in setters. */
827 : false, /* isMovable. Not relevant for setters. */
828 : false, /* isEliminatable. Not relevant for setters. */
829 : false, /* isAlwaysInSlot. Only relevant for getters. */
830 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
831 : false, /* isTypedMethod. Only relevant for methods. */
832 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
833 : };
834 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
835 : static_assert(0 < 1, "There is no slot for us");
836 :
837 : static bool
838 0 : get_movementX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
839 : {
840 0 : int32_t result(self->MovementX());
841 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
842 0 : args.rval().setInt32(int32_t(result));
843 0 : return true;
844 : }
845 :
846 : static const JSJitInfo movementX_getterinfo = {
847 : { (JSJitGetterOp)get_movementX },
848 : { prototypes::id::MouseEvent },
849 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
850 : JSJitInfo::Getter,
851 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
852 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
853 : true, /* isInfallible. False in setters. */
854 : false, /* isMovable. Not relevant for setters. */
855 : false, /* isEliminatable. Not relevant for setters. */
856 : false, /* isAlwaysInSlot. Only relevant for getters. */
857 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
858 : false, /* isTypedMethod. Only relevant for methods. */
859 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
860 : };
861 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
862 : static_assert(0 < 1, "There is no slot for us");
863 :
864 : static bool
865 0 : get_movementY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
866 : {
867 0 : int32_t result(self->MovementY());
868 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
869 0 : args.rval().setInt32(int32_t(result));
870 0 : return true;
871 : }
872 :
873 : static const JSJitInfo movementY_getterinfo = {
874 : { (JSJitGetterOp)get_movementY },
875 : { prototypes::id::MouseEvent },
876 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
877 : JSJitInfo::Getter,
878 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
879 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
880 : true, /* isInfallible. False in setters. */
881 : false, /* isMovable. Not relevant for setters. */
882 : false, /* isEliminatable. Not relevant for setters. */
883 : false, /* isAlwaysInSlot. Only relevant for getters. */
884 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
885 : false, /* isTypedMethod. Only relevant for methods. */
886 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
887 : };
888 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
889 : static_assert(0 < 1, "There is no slot for us");
890 :
891 : static bool
892 0 : initMouseEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, const JSJitMethodCallArgs& args)
893 : {
894 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
895 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent.initMouseEvent");
896 : }
897 0 : binding_detail::FakeString arg0;
898 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
899 0 : return false;
900 : }
901 : bool arg1;
902 0 : if (args.hasDefined(1)) {
903 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
904 0 : return false;
905 : }
906 : } else {
907 0 : arg1 = false;
908 : }
909 : bool arg2;
910 0 : if (args.hasDefined(2)) {
911 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
912 0 : return false;
913 : }
914 : } else {
915 0 : arg2 = false;
916 : }
917 : nsGlobalWindow* arg3;
918 0 : if (args.hasDefined(3)) {
919 0 : if (args[3].isObject()) {
920 : {
921 0 : nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[3], arg3);
922 0 : if (NS_FAILED(rv)) {
923 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of MouseEvent.initMouseEvent", "Window");
924 0 : return false;
925 : }
926 : }
927 0 : } else if (args[3].isNullOrUndefined()) {
928 0 : arg3 = nullptr;
929 : } else {
930 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of MouseEvent.initMouseEvent");
931 0 : return false;
932 : }
933 : } else {
934 0 : arg3 = nullptr;
935 : }
936 : int32_t arg4;
937 0 : if (args.hasDefined(4)) {
938 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
939 0 : return false;
940 : }
941 : } else {
942 0 : arg4 = 0;
943 : }
944 : int32_t arg5;
945 0 : if (args.hasDefined(5)) {
946 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) {
947 0 : return false;
948 : }
949 : } else {
950 0 : arg5 = 0;
951 : }
952 : int32_t arg6;
953 0 : if (args.hasDefined(6)) {
954 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) {
955 0 : return false;
956 : }
957 : } else {
958 0 : arg6 = 0;
959 : }
960 : int32_t arg7;
961 0 : if (args.hasDefined(7)) {
962 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) {
963 0 : return false;
964 : }
965 : } else {
966 0 : arg7 = 0;
967 : }
968 : int32_t arg8;
969 0 : if (args.hasDefined(8)) {
970 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[8], &arg8)) {
971 0 : return false;
972 : }
973 : } else {
974 0 : arg8 = 0;
975 : }
976 : bool arg9;
977 0 : if (args.hasDefined(9)) {
978 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[9], &arg9)) {
979 0 : return false;
980 : }
981 : } else {
982 0 : arg9 = false;
983 : }
984 : bool arg10;
985 0 : if (args.hasDefined(10)) {
986 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[10], &arg10)) {
987 0 : return false;
988 : }
989 : } else {
990 0 : arg10 = false;
991 : }
992 : bool arg11;
993 0 : if (args.hasDefined(11)) {
994 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[11], &arg11)) {
995 0 : return false;
996 : }
997 : } else {
998 0 : arg11 = false;
999 : }
1000 : bool arg12;
1001 0 : if (args.hasDefined(12)) {
1002 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[12], &arg12)) {
1003 0 : return false;
1004 : }
1005 : } else {
1006 0 : arg12 = false;
1007 : }
1008 : int16_t arg13;
1009 0 : if (args.hasDefined(13)) {
1010 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, args[13], &arg13)) {
1011 0 : return false;
1012 : }
1013 : } else {
1014 0 : arg13 = 0;
1015 : }
1016 : mozilla::dom::EventTarget* arg14;
1017 0 : if (args.hasDefined(14)) {
1018 0 : if (args[14].isObject()) {
1019 : {
1020 0 : nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(args[14], arg14);
1021 0 : if (NS_FAILED(rv)) {
1022 0 : RefPtr<mozilla::dom::EventTarget> objPtr;
1023 0 : nsresult rv = UnwrapXPConnect<mozilla::dom::EventTarget>(cx, args[14], getter_AddRefs(objPtr));
1024 0 : if (NS_FAILED(rv)) {
1025 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 15 of MouseEvent.initMouseEvent", "EventTarget");
1026 0 : return false;
1027 : }
1028 : // We should have an object
1029 0 : MOZ_ASSERT(objPtr);
1030 0 : arg14 = objPtr;
1031 : }
1032 : }
1033 0 : } else if (args[14].isNullOrUndefined()) {
1034 0 : arg14 = nullptr;
1035 : } else {
1036 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 15 of MouseEvent.initMouseEvent");
1037 0 : return false;
1038 : }
1039 : } else {
1040 0 : arg14 = nullptr;
1041 : }
1042 0 : self->InitMouseEvent(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, Constify(arg14));
1043 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1044 0 : args.rval().setUndefined();
1045 0 : return true;
1046 : }
1047 :
1048 : static const JSJitInfo initMouseEvent_methodinfo = {
1049 : { (JSJitGetterOp)initMouseEvent },
1050 : { prototypes::id::MouseEvent },
1051 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1052 : JSJitInfo::Method,
1053 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1054 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1055 : false, /* isInfallible. False in setters. */
1056 : false, /* isMovable. Not relevant for setters. */
1057 : false, /* isEliminatable. Not relevant for setters. */
1058 : false, /* isAlwaysInSlot. Only relevant for getters. */
1059 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1060 : false, /* isTypedMethod. Only relevant for methods. */
1061 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1062 : };
1063 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1064 : static_assert(0 < 1, "There is no slot for us");
1065 :
1066 : static bool
1067 0 : getModifierState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, const JSJitMethodCallArgs& args)
1068 : {
1069 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1070 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent.getModifierState");
1071 : }
1072 0 : binding_detail::FakeString arg0;
1073 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1074 0 : return false;
1075 : }
1076 0 : bool result(self->GetModifierState(NonNullHelper(Constify(arg0))));
1077 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1078 0 : args.rval().setBoolean(result);
1079 0 : return true;
1080 : }
1081 :
1082 : static const JSJitInfo getModifierState_methodinfo = {
1083 : { (JSJitGetterOp)getModifierState },
1084 : { prototypes::id::MouseEvent },
1085 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1086 : JSJitInfo::Method,
1087 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1088 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1089 : false, /* isInfallible. False in setters. */
1090 : false, /* isMovable. Not relevant for setters. */
1091 : false, /* isEliminatable. Not relevant for setters. */
1092 : false, /* isAlwaysInSlot. Only relevant for getters. */
1093 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1094 : false, /* isTypedMethod. Only relevant for methods. */
1095 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1096 : };
1097 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1098 : static_assert(0 < 1, "There is no slot for us");
1099 :
1100 : static bool
1101 0 : get_mozPressure(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1102 : {
1103 0 : float result(self->MozPressure());
1104 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1105 0 : args.rval().set(JS_NumberValue(double(result)));
1106 0 : return true;
1107 : }
1108 :
1109 : static const JSJitInfo mozPressure_getterinfo = {
1110 : { (JSJitGetterOp)get_mozPressure },
1111 : { prototypes::id::MouseEvent },
1112 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1113 : JSJitInfo::Getter,
1114 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1115 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
1116 : true, /* isInfallible. False in setters. */
1117 : false, /* isMovable. Not relevant for setters. */
1118 : false, /* isEliminatable. Not relevant for setters. */
1119 : false, /* isAlwaysInSlot. Only relevant for getters. */
1120 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1121 : false, /* isTypedMethod. Only relevant for methods. */
1122 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1123 : };
1124 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1125 : static_assert(0 < 1, "There is no slot for us");
1126 :
1127 : static bool
1128 0 : get_mozInputSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1129 : {
1130 0 : uint16_t result(self->MozInputSource());
1131 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1132 0 : args.rval().setInt32(int32_t(result));
1133 0 : return true;
1134 : }
1135 :
1136 : static const JSJitInfo mozInputSource_getterinfo = {
1137 : { (JSJitGetterOp)get_mozInputSource },
1138 : { prototypes::id::MouseEvent },
1139 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1140 : JSJitInfo::Getter,
1141 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1142 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
1143 : true, /* isInfallible. False in setters. */
1144 : false, /* isMovable. Not relevant for setters. */
1145 : false, /* isEliminatable. Not relevant for setters. */
1146 : false, /* isAlwaysInSlot. Only relevant for getters. */
1147 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1148 : false, /* isTypedMethod. Only relevant for methods. */
1149 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1150 : };
1151 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1152 : static_assert(0 < 1, "There is no slot for us");
1153 :
1154 : static bool
1155 0 : initNSMouseEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, const JSJitMethodCallArgs& args)
1156 : {
1157 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1158 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent.initNSMouseEvent");
1159 : }
1160 0 : binding_detail::FakeString arg0;
1161 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1162 0 : return false;
1163 : }
1164 : bool arg1;
1165 0 : if (args.hasDefined(1)) {
1166 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
1167 0 : return false;
1168 : }
1169 : } else {
1170 0 : arg1 = false;
1171 : }
1172 : bool arg2;
1173 0 : if (args.hasDefined(2)) {
1174 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
1175 0 : return false;
1176 : }
1177 : } else {
1178 0 : arg2 = false;
1179 : }
1180 : nsGlobalWindow* arg3;
1181 0 : if (args.hasDefined(3)) {
1182 0 : if (args[3].isObject()) {
1183 : {
1184 0 : nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[3], arg3);
1185 0 : if (NS_FAILED(rv)) {
1186 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of MouseEvent.initNSMouseEvent", "Window");
1187 0 : return false;
1188 : }
1189 : }
1190 0 : } else if (args[3].isNullOrUndefined()) {
1191 0 : arg3 = nullptr;
1192 : } else {
1193 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of MouseEvent.initNSMouseEvent");
1194 0 : return false;
1195 : }
1196 : } else {
1197 0 : arg3 = nullptr;
1198 : }
1199 : int32_t arg4;
1200 0 : if (args.hasDefined(4)) {
1201 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
1202 0 : return false;
1203 : }
1204 : } else {
1205 0 : arg4 = 0;
1206 : }
1207 : int32_t arg5;
1208 0 : if (args.hasDefined(5)) {
1209 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) {
1210 0 : return false;
1211 : }
1212 : } else {
1213 0 : arg5 = 0;
1214 : }
1215 : int32_t arg6;
1216 0 : if (args.hasDefined(6)) {
1217 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) {
1218 0 : return false;
1219 : }
1220 : } else {
1221 0 : arg6 = 0;
1222 : }
1223 : int32_t arg7;
1224 0 : if (args.hasDefined(7)) {
1225 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) {
1226 0 : return false;
1227 : }
1228 : } else {
1229 0 : arg7 = 0;
1230 : }
1231 : int32_t arg8;
1232 0 : if (args.hasDefined(8)) {
1233 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[8], &arg8)) {
1234 0 : return false;
1235 : }
1236 : } else {
1237 0 : arg8 = 0;
1238 : }
1239 : bool arg9;
1240 0 : if (args.hasDefined(9)) {
1241 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[9], &arg9)) {
1242 0 : return false;
1243 : }
1244 : } else {
1245 0 : arg9 = false;
1246 : }
1247 : bool arg10;
1248 0 : if (args.hasDefined(10)) {
1249 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[10], &arg10)) {
1250 0 : return false;
1251 : }
1252 : } else {
1253 0 : arg10 = false;
1254 : }
1255 : bool arg11;
1256 0 : if (args.hasDefined(11)) {
1257 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[11], &arg11)) {
1258 0 : return false;
1259 : }
1260 : } else {
1261 0 : arg11 = false;
1262 : }
1263 : bool arg12;
1264 0 : if (args.hasDefined(12)) {
1265 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[12], &arg12)) {
1266 0 : return false;
1267 : }
1268 : } else {
1269 0 : arg12 = false;
1270 : }
1271 : int16_t arg13;
1272 0 : if (args.hasDefined(13)) {
1273 0 : if (!ValueToPrimitive<int16_t, eDefault>(cx, args[13], &arg13)) {
1274 0 : return false;
1275 : }
1276 : } else {
1277 0 : arg13 = 0;
1278 : }
1279 : mozilla::dom::EventTarget* arg14;
1280 0 : if (args.hasDefined(14)) {
1281 0 : if (args[14].isObject()) {
1282 : {
1283 0 : nsresult rv = UnwrapObject<prototypes::id::EventTarget, mozilla::dom::EventTarget>(args[14], arg14);
1284 0 : if (NS_FAILED(rv)) {
1285 0 : RefPtr<mozilla::dom::EventTarget> objPtr;
1286 0 : nsresult rv = UnwrapXPConnect<mozilla::dom::EventTarget>(cx, args[14], getter_AddRefs(objPtr));
1287 0 : if (NS_FAILED(rv)) {
1288 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 15 of MouseEvent.initNSMouseEvent", "EventTarget");
1289 0 : return false;
1290 : }
1291 : // We should have an object
1292 0 : MOZ_ASSERT(objPtr);
1293 0 : arg14 = objPtr;
1294 : }
1295 : }
1296 0 : } else if (args[14].isNullOrUndefined()) {
1297 0 : arg14 = nullptr;
1298 : } else {
1299 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 15 of MouseEvent.initNSMouseEvent");
1300 0 : return false;
1301 : }
1302 : } else {
1303 0 : arg14 = nullptr;
1304 : }
1305 : float arg15;
1306 0 : if (args.hasDefined(15)) {
1307 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[15], &arg15)) {
1308 0 : return false;
1309 0 : } else if (!mozilla::IsFinite(arg15)) {
1310 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 16 of MouseEvent.initNSMouseEvent");
1311 0 : return false;
1312 : }
1313 : } else {
1314 0 : arg15 = 0.0F;
1315 : }
1316 : uint16_t arg16;
1317 0 : if (args.hasDefined(16)) {
1318 0 : if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[16], &arg16)) {
1319 0 : return false;
1320 : }
1321 : } else {
1322 0 : arg16 = 0;
1323 : }
1324 0 : self->InitNSMouseEvent(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, Constify(arg14), arg15, arg16);
1325 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1326 0 : args.rval().setUndefined();
1327 0 : return true;
1328 : }
1329 :
1330 : static const JSJitInfo initNSMouseEvent_methodinfo = {
1331 : { (JSJitGetterOp)initNSMouseEvent },
1332 : { prototypes::id::MouseEvent },
1333 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1334 : JSJitInfo::Method,
1335 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1336 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
1337 : false, /* isInfallible. False in setters. */
1338 : false, /* isMovable. Not relevant for setters. */
1339 : false, /* isEliminatable. Not relevant for setters. */
1340 : false, /* isAlwaysInSlot. Only relevant for getters. */
1341 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1342 : false, /* isTypedMethod. Only relevant for methods. */
1343 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1344 : };
1345 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1346 : static_assert(0 < 1, "There is no slot for us");
1347 :
1348 : static bool
1349 0 : get_hitCluster(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1350 : {
1351 0 : bool result(self->HitCluster());
1352 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1353 0 : args.rval().setBoolean(result);
1354 0 : return true;
1355 : }
1356 :
1357 : static const JSJitInfo hitCluster_getterinfo = {
1358 : { (JSJitGetterOp)get_hitCluster },
1359 : { prototypes::id::MouseEvent },
1360 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1361 : JSJitInfo::Getter,
1362 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1363 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1364 : true, /* isInfallible. False in setters. */
1365 : false, /* isMovable. Not relevant for setters. */
1366 : false, /* isEliminatable. Not relevant for setters. */
1367 : false, /* isAlwaysInSlot. Only relevant for getters. */
1368 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1369 : false, /* isTypedMethod. Only relevant for methods. */
1370 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1371 : };
1372 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1373 : static_assert(0 < 1, "There is no slot for us");
1374 :
1375 : static bool
1376 0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MouseEvent* self, JSJitGetterCallArgs args)
1377 : {
1378 0 : bool result(self->IsTrusted());
1379 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1380 0 : args.rval().setBoolean(result);
1381 0 : return true;
1382 : }
1383 :
1384 : static const JSJitInfo isTrusted_getterinfo = {
1385 : { (JSJitGetterOp)get_isTrusted },
1386 : { prototypes::id::MouseEvent },
1387 : { PrototypeTraits<prototypes::id::MouseEvent>::Depth },
1388 : JSJitInfo::Getter,
1389 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
1390 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1391 : true, /* isInfallible. False in setters. */
1392 : true, /* isMovable. Not relevant for setters. */
1393 : true, /* isEliminatable. Not relevant for setters. */
1394 : false, /* isAlwaysInSlot. Only relevant for getters. */
1395 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1396 : false, /* isTypedMethod. Only relevant for methods. */
1397 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1398 : };
1399 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1400 : static_assert(0 < 1, "There is no slot for us");
1401 :
1402 : static bool
1403 1 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1404 : {
1405 1 : mozilla::dom::MouseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MouseEvent>(obj);
1406 : // We don't want to preserve if we don't have a wrapper, and we
1407 : // obviously can't preserve if we're not initialized.
1408 1 : if (self && self->GetWrapperPreserveColor()) {
1409 0 : PreserveWrapper(self);
1410 : }
1411 1 : return true;
1412 : }
1413 :
1414 : static void
1415 4 : _finalize(js::FreeOp* fop, JSObject* obj)
1416 : {
1417 4 : mozilla::dom::MouseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MouseEvent>(obj);
1418 4 : if (self) {
1419 4 : ClearWrapper(self, self, obj);
1420 4 : AddForDeferredFinalization<mozilla::dom::MouseEvent>(self);
1421 : }
1422 4 : }
1423 :
1424 : static void
1425 1 : _objectMoved(JSObject* obj, const JSObject* old)
1426 : {
1427 1 : mozilla::dom::MouseEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MouseEvent>(obj);
1428 1 : if (self) {
1429 0 : UpdateWrapper(self, self, obj, old);
1430 : }
1431 1 : }
1432 :
1433 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1434 : #if defined(__clang__)
1435 : #pragma clang diagnostic push
1436 : #pragma clang diagnostic ignored "-Wmissing-braces"
1437 : #endif
1438 : static const JSFunctionSpec sMethods_specs[] = {
1439 : JS_FNSPEC("initMouseEvent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initMouseEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1440 : JS_FNSPEC("getModifierState", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getModifierState_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1441 : JS_FNSPEC("initNSMouseEvent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initNSMouseEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1442 : JS_FS_END
1443 : };
1444 : #if defined(__clang__)
1445 : #pragma clang diagnostic pop
1446 : #endif
1447 :
1448 :
1449 : // Can't be const because the pref-enabled boolean needs to be writable
1450 : static Prefable<const JSFunctionSpec> sMethods[] = {
1451 : { nullptr, &sMethods_specs[0] },
1452 : { nullptr, nullptr }
1453 : };
1454 :
1455 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1456 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1457 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1458 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1459 :
1460 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1461 : #if defined(__clang__)
1462 : #pragma clang diagnostic push
1463 : #pragma clang diagnostic ignored "-Wmissing-braces"
1464 : #endif
1465 : static const JSPropertySpec sAttributes_specs[] = {
1466 : { "screenX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &screenX_getterinfo, nullptr, nullptr },
1467 : { "screenY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &screenY_getterinfo, nullptr, nullptr },
1468 : { "clientX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &clientX_getterinfo, nullptr, nullptr },
1469 : { "clientY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &clientY_getterinfo, nullptr, nullptr },
1470 : { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, nullptr, nullptr },
1471 : { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, nullptr, nullptr },
1472 : { "offsetX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &offsetX_getterinfo, nullptr, nullptr },
1473 : { "offsetY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &offsetY_getterinfo, nullptr, nullptr },
1474 : { "ctrlKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ctrlKey_getterinfo, nullptr, nullptr },
1475 : { "shiftKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shiftKey_getterinfo, nullptr, nullptr },
1476 : { "altKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &altKey_getterinfo, nullptr, nullptr },
1477 : { "metaKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &metaKey_getterinfo, nullptr, nullptr },
1478 : { "button", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &button_getterinfo, nullptr, nullptr },
1479 : { "buttons", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &buttons_getterinfo, nullptr, nullptr },
1480 : { "relatedTarget", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &relatedTarget_getterinfo, nullptr, nullptr },
1481 : { "region", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, ®ion_getterinfo, nullptr, nullptr },
1482 : { "movementX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &movementX_getterinfo, nullptr, nullptr },
1483 : { "movementY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &movementY_getterinfo, nullptr, nullptr },
1484 : { "mozPressure", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozPressure_getterinfo, nullptr, nullptr },
1485 : { "mozInputSource", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozInputSource_getterinfo, nullptr, nullptr },
1486 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1487 : };
1488 : #if defined(__clang__)
1489 : #pragma clang diagnostic pop
1490 : #endif
1491 :
1492 :
1493 : // Can't be const because the pref-enabled boolean needs to be writable
1494 : static Prefable<const JSPropertySpec> sAttributes[] = {
1495 : { nullptr, &sAttributes_specs[0] },
1496 : { nullptr, nullptr }
1497 : };
1498 :
1499 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1500 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1501 : static_assert(20 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1502 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1503 :
1504 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1505 : #if defined(__clang__)
1506 : #pragma clang diagnostic push
1507 : #pragma clang diagnostic ignored "-Wmissing-braces"
1508 : #endif
1509 : static const JSPropertySpec sChromeAttributes_specs[] = {
1510 : { "hitCluster", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hitCluster_getterinfo, nullptr, nullptr },
1511 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1512 : };
1513 : #if defined(__clang__)
1514 : #pragma clang diagnostic pop
1515 : #endif
1516 :
1517 :
1518 : // Can't be const because the pref-enabled boolean needs to be writable
1519 : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
1520 : { nullptr, &sChromeAttributes_specs[0] },
1521 : { nullptr, nullptr }
1522 : };
1523 :
1524 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1525 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1526 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1527 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1528 :
1529 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1530 : #if defined(__clang__)
1531 : #pragma clang diagnostic push
1532 : #pragma clang diagnostic ignored "-Wmissing-braces"
1533 : #endif
1534 : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
1535 : { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
1536 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1537 : };
1538 : #if defined(__clang__)
1539 : #pragma clang diagnostic pop
1540 : #endif
1541 :
1542 :
1543 : // Can't be const because the pref-enabled boolean needs to be writable
1544 : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
1545 : { nullptr, &sUnforgeableAttributes_specs[0] },
1546 : { nullptr, nullptr }
1547 : };
1548 :
1549 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1550 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1551 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1552 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1553 :
1554 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1555 : #if defined(__clang__)
1556 : #pragma clang diagnostic push
1557 : #pragma clang diagnostic ignored "-Wmissing-braces"
1558 : #endif
1559 : static const ConstantSpec sConstants_specs[] = {
1560 : { "MOZ_SOURCE_UNKNOWN", JS::Int32Value(0) },
1561 : { "MOZ_SOURCE_MOUSE", JS::Int32Value(1) },
1562 : { "MOZ_SOURCE_PEN", JS::Int32Value(2) },
1563 : { "MOZ_SOURCE_ERASER", JS::Int32Value(3) },
1564 : { "MOZ_SOURCE_CURSOR", JS::Int32Value(4) },
1565 : { "MOZ_SOURCE_TOUCH", JS::Int32Value(5) },
1566 : { "MOZ_SOURCE_KEYBOARD", JS::Int32Value(6) },
1567 : { 0, JS::UndefinedValue() }
1568 : };
1569 : #if defined(__clang__)
1570 : #pragma clang diagnostic pop
1571 : #endif
1572 :
1573 :
1574 : // Can't be const because the pref-enabled boolean needs to be writable
1575 : static Prefable<const ConstantSpec> sConstants[] = {
1576 : { nullptr, &sConstants_specs[0] },
1577 : { nullptr, nullptr }
1578 : };
1579 :
1580 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1581 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1582 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1583 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1584 :
1585 :
1586 : static uint16_t sNativeProperties_sortedPropertyIndices[31];
1587 : static PropertyInfo sNativeProperties_propertyInfos[31];
1588 :
1589 : static const NativePropertiesN<4> sNativeProperties = {
1590 : false, 0,
1591 : false, 0,
1592 : true, 0 /* sMethods */,
1593 : true, 1 /* sAttributes */,
1594 : false, 0,
1595 : true, 2 /* sUnforgeableAttributes */,
1596 : true, 3 /* sConstants */,
1597 : -1,
1598 : 31,
1599 : sNativeProperties_sortedPropertyIndices,
1600 : {
1601 : { sMethods, &sNativeProperties_propertyInfos[0] },
1602 : { sAttributes, &sNativeProperties_propertyInfos[3] },
1603 : { sUnforgeableAttributes, &sNativeProperties_propertyInfos[23] },
1604 : { sConstants, &sNativeProperties_propertyInfos[24] }
1605 : }
1606 : };
1607 : static_assert(31 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1608 : "We have a property info count that is oversized");
1609 :
1610 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
1611 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
1612 :
1613 : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1614 : false, 0,
1615 : false, 0,
1616 : false, 0,
1617 : true, 0 /* sChromeAttributes */,
1618 : false, 0,
1619 : false, 0,
1620 : false, 0,
1621 : -1,
1622 : 1,
1623 : sChromeOnlyNativeProperties_sortedPropertyIndices,
1624 : {
1625 : { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
1626 : }
1627 : };
1628 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1629 : "We have a property info count that is oversized");
1630 :
1631 : static bool
1632 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1633 : {
1634 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1635 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
1636 0 : if (!args.isConstructing()) {
1637 : // XXXbz wish I could get the name from the callee instead of
1638 : // Adding more relocations
1639 0 : return ThrowConstructorWithoutNew(cx, "MouseEvent");
1640 : }
1641 :
1642 0 : GlobalObject global(cx, obj);
1643 0 : if (global.Failed()) {
1644 0 : return false;
1645 : }
1646 :
1647 0 : JS::Rooted<JSObject*> desiredProto(cx);
1648 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
1649 0 : return false;
1650 : }
1651 :
1652 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1653 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MouseEvent");
1654 : }
1655 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1656 0 : binding_detail::FakeString arg0;
1657 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1658 0 : return false;
1659 : }
1660 0 : binding_detail::FastMouseEventInit arg1;
1661 0 : if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of MouseEvent.constructor", false)) {
1662 0 : return false;
1663 : }
1664 0 : Maybe<JSAutoCompartment> ac;
1665 0 : if (objIsXray) {
1666 0 : obj = js::CheckedUnwrap(obj);
1667 0 : if (!obj) {
1668 0 : return false;
1669 : }
1670 0 : ac.emplace(cx, obj);
1671 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1672 0 : return false;
1673 : }
1674 : }
1675 0 : binding_detail::FastErrorResult rv;
1676 0 : auto result(StrongOrRawPtr<mozilla::dom::MouseEvent>(mozilla::dom::MouseEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
1677 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1678 0 : return false;
1679 : }
1680 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1681 : static_assert(!IsPointer<decltype(result)>::value,
1682 : "NewObject implies that we need to keep the object alive with a strong reference.");
1683 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1684 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1685 0 : return false;
1686 : }
1687 0 : return true;
1688 : }
1689 :
1690 : static const js::ClassOps sInterfaceObjectClassOps = {
1691 : nullptr, /* addProperty */
1692 : nullptr, /* delProperty */
1693 : nullptr, /* getProperty */
1694 : nullptr, /* setProperty */
1695 : nullptr, /* enumerate */
1696 : nullptr, /* newEnumerate */
1697 : nullptr, /* resolve */
1698 : nullptr, /* mayResolve */
1699 : nullptr, /* finalize */
1700 : _constructor, /* call */
1701 : nullptr, /* hasInstance */
1702 : _constructor, /* construct */
1703 : nullptr, /* trace */
1704 : };
1705 :
1706 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1707 : {
1708 : "Function",
1709 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1710 : &sInterfaceObjectClassOps,
1711 : JS_NULL_CLASS_SPEC,
1712 : JS_NULL_CLASS_EXT,
1713 : &sInterfaceObjectClassObjectOps
1714 : },
1715 : eInterface,
1716 : true,
1717 : prototypes::id::MouseEvent,
1718 : PrototypeTraits<prototypes::id::MouseEvent>::Depth,
1719 : sNativePropertyHooks,
1720 : "function MouseEvent() {\n [native code]\n}",
1721 : UIEventBinding::GetConstructorObject
1722 : };
1723 :
1724 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1725 : {
1726 : "MouseEventPrototype",
1727 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
1728 : JS_NULL_CLASS_OPS,
1729 : JS_NULL_CLASS_SPEC,
1730 : JS_NULL_CLASS_EXT,
1731 : JS_NULL_OBJECT_OPS
1732 : },
1733 : eInterfacePrototype,
1734 : false,
1735 : prototypes::id::MouseEvent,
1736 : PrototypeTraits<prototypes::id::MouseEvent>::Depth,
1737 : sNativePropertyHooks,
1738 : "[object MouseEventPrototype]",
1739 : UIEventBinding::GetProtoObject
1740 : };
1741 :
1742 : JSObject*
1743 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1744 : {
1745 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1746 : }
1747 :
1748 : static const js::ClassOps sClassOps = {
1749 : _addProperty, /* addProperty */
1750 : nullptr, /* delProperty */
1751 : nullptr, /* getProperty */
1752 : nullptr, /* setProperty */
1753 : nullptr, /* enumerate */
1754 : nullptr, /* newEnumerate */
1755 : nullptr, /* resolve */
1756 : nullptr, /* mayResolve */
1757 : _finalize, /* finalize */
1758 : nullptr, /* call */
1759 : nullptr, /* hasInstance */
1760 : nullptr, /* construct */
1761 : nullptr, /* trace */
1762 : };
1763 :
1764 : static const js::ClassExtension sClassExtension = {
1765 : nullptr, /* weakmapKeyDelegateOp */
1766 : _objectMoved /* objectMovedOp */
1767 : };
1768 :
1769 : static const DOMJSClass sClass = {
1770 : { "MouseEvent",
1771 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
1772 : &sClassOps,
1773 : JS_NULL_CLASS_SPEC,
1774 : &sClassExtension,
1775 : JS_NULL_OBJECT_OPS
1776 : },
1777 : { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::MouseEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1778 : IsBaseOf<nsISupports, mozilla::dom::MouseEvent >::value,
1779 : sNativePropertyHooks,
1780 : FindAssociatedGlobalForNative<mozilla::dom::MouseEvent>::Get,
1781 : GetProtoObjectHandle,
1782 : GetCCParticipant<mozilla::dom::MouseEvent>::Get()
1783 : };
1784 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1785 : "Must have the right minimal number of reserved slots.");
1786 : static_assert(1 >= 1,
1787 : "Must have enough reserved slots.");
1788 :
1789 : const JSClass*
1790 0 : GetJSClass()
1791 : {
1792 0 : return sClass.ToJSClass();
1793 : }
1794 :
1795 : bool
1796 4 : Wrap(JSContext* aCx, mozilla::dom::MouseEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1797 : {
1798 : MOZ_ASSERT(static_cast<mozilla::dom::MouseEvent*>(aObject) ==
1799 : reinterpret_cast<mozilla::dom::MouseEvent*>(aObject),
1800 : "Multiple inheritance for mozilla::dom::MouseEvent is broken.");
1801 : MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
1802 : reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
1803 : "Multiple inheritance for mozilla::dom::UIEvent is broken.");
1804 : MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
1805 : reinterpret_cast<mozilla::dom::Event*>(aObject),
1806 : "Multiple inheritance for mozilla::dom::Event is broken.");
1807 4 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1808 4 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1809 4 : MOZ_ASSERT(!aCache->GetWrapper(),
1810 : "You should probably not be using Wrap() directly; use "
1811 : "GetOrCreateDOMReflector instead");
1812 :
1813 4 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1814 : "nsISupports must be on our primary inheritance chain");
1815 :
1816 8 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1817 4 : if (!global) {
1818 0 : return false;
1819 : }
1820 4 : MOZ_ASSERT(JS_IsGlobalObject(global));
1821 4 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1822 :
1823 : // That might have ended up wrapping us already, due to the wonders
1824 : // of XBL. Check for that, and bail out as needed.
1825 4 : aReflector.set(aCache->GetWrapper());
1826 4 : if (aReflector) {
1827 : #ifdef DEBUG
1828 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1829 : #endif // DEBUG
1830 0 : return true;
1831 : }
1832 :
1833 8 : JSAutoCompartment ac(aCx, global);
1834 4 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1835 4 : if (!canonicalProto) {
1836 0 : return false;
1837 : }
1838 8 : JS::Rooted<JSObject*> proto(aCx);
1839 4 : if (aGivenProto) {
1840 0 : proto = aGivenProto;
1841 : // Unfortunately, while aGivenProto was in the compartment of aCx
1842 : // coming in, we changed compartments to that of "parent" so may need
1843 : // to wrap the proto here.
1844 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1845 0 : if (!JS_WrapObject(aCx, &proto)) {
1846 0 : return false;
1847 : }
1848 : }
1849 : } else {
1850 4 : proto = canonicalProto;
1851 : }
1852 :
1853 8 : BindingJSObjectCreator<mozilla::dom::MouseEvent> creator(aCx);
1854 4 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1855 4 : if (!aReflector) {
1856 0 : return false;
1857 : }
1858 :
1859 4 : aCache->SetWrapper(aReflector);
1860 :
1861 : // Important: do unforgeable property setup after we have handed
1862 : // over ownership of the C++ object to obj as needed, so that if
1863 : // we fail and it ends up GCed it won't have problems in the
1864 : // finalizer trying to drop its ownership of the C++ object.
1865 : JS::Rooted<JSObject*> unforgeableHolder(aCx,
1866 8 : &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
1867 4 : if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
1868 0 : aCache->ReleaseWrapper(aObject);
1869 0 : aCache->ClearWrapper();
1870 0 : return false;
1871 : }
1872 4 : creator.InitializationSucceeded();
1873 :
1874 4 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1875 : aCache->GetWrapperPreserveColor() == aReflector);
1876 : // If proto != canonicalProto, we have to preserve our wrapper;
1877 : // otherwise we won't be able to properly recreate it later, since
1878 : // we won't know what proto to use. Note that we don't check
1879 : // aGivenProto here, since it's entirely possible (and even
1880 : // somewhat common) to have a non-null aGivenProto which is the
1881 : // same as canonicalProto.
1882 4 : if (proto != canonicalProto) {
1883 0 : PreserveWrapper(aObject);
1884 : }
1885 :
1886 4 : return true;
1887 : }
1888 :
1889 : const NativePropertyHooks sNativePropertyHooks[] = { {
1890 : nullptr,
1891 : nullptr,
1892 : nullptr,
1893 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1894 : prototypes::id::MouseEvent,
1895 : constructors::id::MouseEvent,
1896 : UIEventBinding::sNativePropertyHooks,
1897 : &DefaultXrayExpandoObjectClass
1898 : } };
1899 :
1900 : void
1901 1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1902 : {
1903 1 : JS::Handle<JSObject*> parentProto(UIEventBinding::GetProtoObjectHandle(aCx));
1904 1 : if (!parentProto) {
1905 0 : return;
1906 : }
1907 :
1908 1 : JS::Handle<JSObject*> constructorProto(UIEventBinding::GetConstructorObjectHandle(aCx));
1909 1 : if (!constructorProto) {
1910 0 : return;
1911 : }
1912 :
1913 : static bool sIdsInited = false;
1914 1 : if (!sIdsInited && NS_IsMainThread()) {
1915 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1916 0 : return;
1917 : }
1918 1 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1919 0 : return;
1920 : }
1921 1 : sIdsInited = true;
1922 : }
1923 :
1924 1 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MouseEvent);
1925 1 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MouseEvent);
1926 2 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1927 : &sPrototypeClass.mBase, protoCache,
1928 : constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1929 : interfaceCache,
1930 : sNativeProperties.Upcast(),
1931 1 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
1932 : "MouseEvent", aDefineOnGlobal,
1933 : nullptr,
1934 1 : false);
1935 :
1936 2 : JS::Rooted<JSObject*> unforgeableHolder(aCx);
1937 : {
1938 2 : JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1939 1 : unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1940 1 : if (!unforgeableHolder) {
1941 0 : *protoCache = nullptr;
1942 0 : if (interfaceCache) {
1943 0 : *interfaceCache = nullptr;
1944 : }
1945 0 : return;
1946 : }
1947 : }
1948 :
1949 1 : if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1950 0 : *protoCache = nullptr;
1951 0 : if (interfaceCache) {
1952 0 : *interfaceCache = nullptr;
1953 : }
1954 0 : return;
1955 : }
1956 :
1957 1 : if (*protoCache) {
1958 1 : js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1959 2 : JS::ObjectValue(*unforgeableHolder));
1960 : }
1961 : }
1962 :
1963 : JS::Handle<JSObject*>
1964 4 : GetProtoObjectHandle(JSContext* aCx)
1965 : {
1966 : /* Get the interface prototype object for this class. This will create the
1967 : object as needed. */
1968 4 : bool aDefineOnGlobal = true;
1969 :
1970 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1971 4 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1972 4 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1973 0 : return nullptr;
1974 : }
1975 :
1976 : /* Check to see whether the interface objects are already installed */
1977 4 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1978 4 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MouseEvent)) {
1979 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1980 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1981 : }
1982 :
1983 : /*
1984 : * The object might _still_ be null, but that's OK.
1985 : *
1986 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1987 : * traced by TraceProtoAndIfaceCache() and its contents are never
1988 : * changed after they have been set.
1989 : *
1990 : * Calling address() avoids the read read barrier that does gray
1991 : * unmarking, but it's not possible for the object to be gray here.
1992 : */
1993 :
1994 4 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MouseEvent);
1995 4 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1996 4 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1997 : }
1998 :
1999 : JSObject*
2000 0 : GetProtoObject(JSContext* aCx)
2001 : {
2002 0 : return GetProtoObjectHandle(aCx);
2003 : }
2004 :
2005 : JS::Handle<JSObject*>
2006 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
2007 : {
2008 : /* Get the interface object for this class. This will create the object as
2009 : needed. */
2010 :
2011 : /* Make sure our global is sane. Hopefully we can remove this sometime */
2012 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
2013 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
2014 0 : return nullptr;
2015 : }
2016 :
2017 : /* Check to see whether the interface objects are already installed */
2018 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
2019 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::MouseEvent)) {
2020 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
2021 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
2022 : }
2023 :
2024 : /*
2025 : * The object might _still_ be null, but that's OK.
2026 : *
2027 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
2028 : * traced by TraceProtoAndIfaceCache() and its contents are never
2029 : * changed after they have been set.
2030 : *
2031 : * Calling address() avoids the read read barrier that does gray
2032 : * unmarking, but it's not possible for the object to be gray here.
2033 : */
2034 :
2035 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::MouseEvent);
2036 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
2037 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
2038 : }
2039 :
2040 : JSObject*
2041 0 : GetConstructorObject(JSContext* aCx)
2042 : {
2043 0 : return GetConstructorObjectHandle(aCx);
2044 : }
2045 :
2046 : } // namespace MouseEventBinding
2047 :
2048 :
2049 :
2050 : } // namespace dom
2051 : } // namespace mozilla
|