Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM UIEvent.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "EventBinding.h"
5 : #include "UIEventBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/NonRefcountedDOMObject.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/ScriptSettings.h"
14 : #include "mozilla/dom/SimpleGlobalObject.h"
15 : #include "mozilla/dom/UIEvent.h"
16 : #include "mozilla/dom/XrayExpandoClass.h"
17 : #include "nsGlobalWindow.h"
18 : #include "nsINode.h"
19 : #include "nsPIDOMWindow.h"
20 :
21 : namespace mozilla {
22 : namespace dom {
23 :
24 :
25 0 : UIEventInit::UIEventInit()
26 0 : : EventInit(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 : UIEventInit::InitIds(JSContext* cx, UIEventInitAtoms* 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->view_id.init(cx, "view") ||
42 0 : !atomsCache->detail_id.init(cx, "detail")) {
43 0 : return false;
44 : }
45 0 : return true;
46 : }
47 :
48 : bool
49 0 : UIEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
50 : {
51 : // Passing a null JSContext is OK only if we're initing from null,
52 : // Since in that case we will not have to do any property gets
53 : // Also evaluate isNullOrUndefined in order to avoid false-positive
54 : // checkers by static analysis tools
55 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
56 0 : UIEventInitAtoms* atomsCache = nullptr;
57 0 : if (cx) {
58 0 : atomsCache = GetAtomCache<UIEventInitAtoms>(cx);
59 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
60 0 : return false;
61 : }
62 : }
63 :
64 : // Per spec, we init the parent's members first
65 0 : if (!EventInit::Init(cx, val)) {
66 0 : return false;
67 : }
68 :
69 0 : bool isNull = val.isNullOrUndefined();
70 : // We only need these if !isNull, in which case we have |cx|.
71 0 : Maybe<JS::Rooted<JSObject *> > object;
72 0 : Maybe<JS::Rooted<JS::Value> > temp;
73 0 : if (!isNull) {
74 0 : MOZ_ASSERT(cx);
75 0 : object.emplace(cx, &val.toObject());
76 0 : temp.emplace(cx);
77 : }
78 0 : if (!isNull) {
79 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->detail_id, temp.ptr())) {
80 0 : return false;
81 : }
82 : }
83 0 : if (!isNull && !temp->isUndefined()) {
84 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mDetail)) {
85 0 : return false;
86 : }
87 : } else {
88 0 : mDetail = 0;
89 : }
90 0 : mIsAnyMemberPresent = true;
91 :
92 0 : if (!isNull) {
93 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->view_id, temp.ptr())) {
94 0 : return false;
95 : }
96 : }
97 0 : if (!isNull && !temp->isUndefined()) {
98 0 : if (temp.ref().isObject()) {
99 : static_assert(IsRefcounted<nsGlobalWindow>::value, "We can only store refcounted classes.");{
100 0 : nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(temp.ptr(), mView);
101 0 : if (NS_FAILED(rv)) {
102 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'view' member of UIEventInit", "Window");
103 0 : return false;
104 : }
105 : }
106 0 : } else if (temp.ref().isNullOrUndefined()) {
107 0 : mView = nullptr;
108 : } else {
109 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'view' member of UIEventInit");
110 0 : return false;
111 : }
112 : } else {
113 0 : mView = nullptr;
114 : }
115 0 : mIsAnyMemberPresent = true;
116 0 : return true;
117 : }
118 :
119 : bool
120 0 : UIEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
121 : {
122 0 : UIEventInitAtoms* atomsCache = GetAtomCache<UIEventInitAtoms>(cx);
123 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
124 0 : return false;
125 : }
126 :
127 : // Per spec, we define the parent's members first
128 0 : if (!EventInit::ToObjectInternal(cx, rval)) {
129 0 : return false;
130 : }
131 0 : JS::Rooted<JSObject*> obj(cx, &rval.toObject());
132 :
133 : do {
134 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
135 0 : JS::Rooted<JS::Value> temp(cx);
136 0 : int32_t const & currentValue = mDetail;
137 0 : temp.setInt32(int32_t(currentValue));
138 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->detail_id, temp, JSPROP_ENUMERATE)) {
139 0 : return false;
140 : }
141 0 : break;
142 : } while(0);
143 :
144 : do {
145 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
146 0 : JS::Rooted<JS::Value> temp(cx);
147 0 : RefPtr<nsGlobalWindow> const & currentValue = mView;
148 0 : if (!currentValue) {
149 0 : temp.setNull();
150 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->view_id, temp, JSPROP_ENUMERATE)) {
151 0 : return false;
152 : }
153 0 : break;
154 : }
155 0 : if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
156 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
157 0 : return false;
158 : }
159 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->view_id, temp, JSPROP_ENUMERATE)) {
160 0 : return false;
161 : }
162 0 : break;
163 : } while(0);
164 :
165 0 : return true;
166 : }
167 :
168 : void
169 0 : UIEventInit::TraceDictionary(JSTracer* trc)
170 : {
171 0 : EventInit::TraceDictionary(trc);
172 0 : }
173 :
174 : UIEventInit&
175 0 : UIEventInit::operator=(const UIEventInit& aOther)
176 : {
177 0 : EventInit::operator=(aOther);
178 0 : mDetail = aOther.mDetail;
179 0 : mView = aOther.mView;
180 0 : return *this;
181 : }
182 :
183 : namespace binding_detail {
184 : } // namespace binding_detail
185 :
186 :
187 :
188 0 : EventModifierInit::EventModifierInit()
189 0 : : UIEventInit(FastDictionaryInitializer())
190 : {
191 : // Safe to pass a null context if we pass a null value
192 0 : Init(nullptr, JS::NullHandleValue);
193 0 : }
194 :
195 :
196 :
197 : bool
198 0 : EventModifierInit::InitIds(JSContext* cx, EventModifierInitAtoms* atomsCache)
199 : {
200 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
201 :
202 : // Initialize these in reverse order so that any failure leaves the first one
203 : // uninitialized.
204 0 : if (!atomsCache->shiftKey_id.init(cx, "shiftKey") ||
205 0 : !atomsCache->modifierSymbolLock_id.init(cx, "modifierSymbolLock") ||
206 0 : !atomsCache->modifierSymbol_id.init(cx, "modifierSymbol") ||
207 0 : !atomsCache->modifierScrollLock_id.init(cx, "modifierScrollLock") ||
208 0 : !atomsCache->modifierOS_id.init(cx, "modifierOS") ||
209 0 : !atomsCache->modifierNumLock_id.init(cx, "modifierNumLock") ||
210 0 : !atomsCache->modifierFnLock_id.init(cx, "modifierFnLock") ||
211 0 : !atomsCache->modifierFn_id.init(cx, "modifierFn") ||
212 0 : !atomsCache->modifierCapsLock_id.init(cx, "modifierCapsLock") ||
213 0 : !atomsCache->modifierAltGraph_id.init(cx, "modifierAltGraph") ||
214 0 : !atomsCache->metaKey_id.init(cx, "metaKey") ||
215 0 : !atomsCache->ctrlKey_id.init(cx, "ctrlKey") ||
216 0 : !atomsCache->altKey_id.init(cx, "altKey")) {
217 0 : return false;
218 : }
219 0 : return true;
220 : }
221 :
222 : bool
223 0 : EventModifierInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
224 : {
225 : // Passing a null JSContext is OK only if we're initing from null,
226 : // Since in that case we will not have to do any property gets
227 : // Also evaluate isNullOrUndefined in order to avoid false-positive
228 : // checkers by static analysis tools
229 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
230 0 : EventModifierInitAtoms* atomsCache = nullptr;
231 0 : if (cx) {
232 0 : atomsCache = GetAtomCache<EventModifierInitAtoms>(cx);
233 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
234 0 : return false;
235 : }
236 : }
237 :
238 : // Per spec, we init the parent's members first
239 0 : if (!UIEventInit::Init(cx, val)) {
240 0 : return false;
241 : }
242 :
243 0 : bool isNull = val.isNullOrUndefined();
244 : // We only need these if !isNull, in which case we have |cx|.
245 0 : Maybe<JS::Rooted<JSObject *> > object;
246 0 : Maybe<JS::Rooted<JS::Value> > temp;
247 0 : if (!isNull) {
248 0 : MOZ_ASSERT(cx);
249 0 : object.emplace(cx, &val.toObject());
250 0 : temp.emplace(cx);
251 : }
252 0 : if (!isNull) {
253 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->altKey_id, temp.ptr())) {
254 0 : return false;
255 : }
256 : }
257 0 : if (!isNull && !temp->isUndefined()) {
258 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAltKey)) {
259 0 : return false;
260 : }
261 : } else {
262 0 : mAltKey = false;
263 : }
264 0 : mIsAnyMemberPresent = true;
265 :
266 0 : if (!isNull) {
267 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->ctrlKey_id, temp.ptr())) {
268 0 : return false;
269 : }
270 : }
271 0 : if (!isNull && !temp->isUndefined()) {
272 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mCtrlKey)) {
273 0 : return false;
274 : }
275 : } else {
276 0 : mCtrlKey = false;
277 : }
278 0 : mIsAnyMemberPresent = true;
279 :
280 0 : if (!isNull) {
281 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->metaKey_id, temp.ptr())) {
282 0 : return false;
283 : }
284 : }
285 0 : if (!isNull && !temp->isUndefined()) {
286 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMetaKey)) {
287 0 : return false;
288 : }
289 : } else {
290 0 : mMetaKey = false;
291 : }
292 0 : mIsAnyMemberPresent = true;
293 :
294 0 : if (!isNull) {
295 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierAltGraph_id, temp.ptr())) {
296 0 : return false;
297 : }
298 : }
299 0 : if (!isNull && !temp->isUndefined()) {
300 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierAltGraph)) {
301 0 : return false;
302 : }
303 : } else {
304 0 : mModifierAltGraph = false;
305 : }
306 0 : mIsAnyMemberPresent = true;
307 :
308 0 : if (!isNull) {
309 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierCapsLock_id, temp.ptr())) {
310 0 : return false;
311 : }
312 : }
313 0 : if (!isNull && !temp->isUndefined()) {
314 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierCapsLock)) {
315 0 : return false;
316 : }
317 : } else {
318 0 : mModifierCapsLock = false;
319 : }
320 0 : mIsAnyMemberPresent = true;
321 :
322 0 : if (!isNull) {
323 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierFn_id, temp.ptr())) {
324 0 : return false;
325 : }
326 : }
327 0 : if (!isNull && !temp->isUndefined()) {
328 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierFn)) {
329 0 : return false;
330 : }
331 : } else {
332 0 : mModifierFn = false;
333 : }
334 0 : mIsAnyMemberPresent = true;
335 :
336 0 : if (!isNull) {
337 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierFnLock_id, temp.ptr())) {
338 0 : return false;
339 : }
340 : }
341 0 : if (!isNull && !temp->isUndefined()) {
342 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierFnLock)) {
343 0 : return false;
344 : }
345 : } else {
346 0 : mModifierFnLock = false;
347 : }
348 0 : mIsAnyMemberPresent = true;
349 :
350 0 : if (!isNull) {
351 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierNumLock_id, temp.ptr())) {
352 0 : return false;
353 : }
354 : }
355 0 : if (!isNull && !temp->isUndefined()) {
356 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierNumLock)) {
357 0 : return false;
358 : }
359 : } else {
360 0 : mModifierNumLock = false;
361 : }
362 0 : mIsAnyMemberPresent = true;
363 :
364 0 : if (!isNull) {
365 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierOS_id, temp.ptr())) {
366 0 : return false;
367 : }
368 : }
369 0 : if (!isNull && !temp->isUndefined()) {
370 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierOS)) {
371 0 : return false;
372 : }
373 : } else {
374 0 : mModifierOS = false;
375 : }
376 0 : mIsAnyMemberPresent = true;
377 :
378 0 : if (!isNull) {
379 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierScrollLock_id, temp.ptr())) {
380 0 : return false;
381 : }
382 : }
383 0 : if (!isNull && !temp->isUndefined()) {
384 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierScrollLock)) {
385 0 : return false;
386 : }
387 : } else {
388 0 : mModifierScrollLock = false;
389 : }
390 0 : mIsAnyMemberPresent = true;
391 :
392 0 : if (!isNull) {
393 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierSymbol_id, temp.ptr())) {
394 0 : return false;
395 : }
396 : }
397 0 : if (!isNull && !temp->isUndefined()) {
398 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierSymbol)) {
399 0 : return false;
400 : }
401 : } else {
402 0 : mModifierSymbol = false;
403 : }
404 0 : mIsAnyMemberPresent = true;
405 :
406 0 : if (!isNull) {
407 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->modifierSymbolLock_id, temp.ptr())) {
408 0 : return false;
409 : }
410 : }
411 0 : if (!isNull && !temp->isUndefined()) {
412 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mModifierSymbolLock)) {
413 0 : return false;
414 : }
415 : } else {
416 0 : mModifierSymbolLock = false;
417 : }
418 0 : mIsAnyMemberPresent = true;
419 :
420 0 : if (!isNull) {
421 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->shiftKey_id, temp.ptr())) {
422 0 : return false;
423 : }
424 : }
425 0 : if (!isNull && !temp->isUndefined()) {
426 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mShiftKey)) {
427 0 : return false;
428 : }
429 : } else {
430 0 : mShiftKey = false;
431 : }
432 0 : mIsAnyMemberPresent = true;
433 0 : return true;
434 : }
435 :
436 : bool
437 0 : EventModifierInit::Init(const nsAString& aJSON)
438 : {
439 0 : AutoJSAPI jsapi;
440 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
441 0 : if (!cleanGlobal) {
442 0 : return false;
443 : }
444 0 : if (!jsapi.Init(cleanGlobal)) {
445 0 : return false;
446 : }
447 0 : JSContext* cx = jsapi.cx();
448 0 : JS::Rooted<JS::Value> json(cx);
449 0 : bool ok = ParseJSON(cx, aJSON, &json);
450 0 : NS_ENSURE_TRUE(ok, false);
451 0 : return Init(cx, json);
452 : }
453 :
454 : bool
455 0 : EventModifierInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
456 : {
457 0 : EventModifierInitAtoms* atomsCache = GetAtomCache<EventModifierInitAtoms>(cx);
458 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
459 0 : return false;
460 : }
461 :
462 : // Per spec, we define the parent's members first
463 0 : if (!UIEventInit::ToObjectInternal(cx, rval)) {
464 0 : return false;
465 : }
466 0 : JS::Rooted<JSObject*> obj(cx, &rval.toObject());
467 :
468 : do {
469 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
470 0 : JS::Rooted<JS::Value> temp(cx);
471 0 : bool const & currentValue = mAltKey;
472 0 : temp.setBoolean(currentValue);
473 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->altKey_id, temp, JSPROP_ENUMERATE)) {
474 0 : return false;
475 : }
476 0 : break;
477 : } while(0);
478 :
479 : do {
480 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
481 0 : JS::Rooted<JS::Value> temp(cx);
482 0 : bool const & currentValue = mCtrlKey;
483 0 : temp.setBoolean(currentValue);
484 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->ctrlKey_id, temp, JSPROP_ENUMERATE)) {
485 0 : return false;
486 : }
487 0 : break;
488 : } while(0);
489 :
490 : do {
491 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
492 0 : JS::Rooted<JS::Value> temp(cx);
493 0 : bool const & currentValue = mMetaKey;
494 0 : temp.setBoolean(currentValue);
495 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->metaKey_id, temp, JSPROP_ENUMERATE)) {
496 0 : return false;
497 : }
498 0 : break;
499 : } while(0);
500 :
501 : do {
502 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
503 0 : JS::Rooted<JS::Value> temp(cx);
504 0 : bool const & currentValue = mModifierAltGraph;
505 0 : temp.setBoolean(currentValue);
506 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierAltGraph_id, temp, JSPROP_ENUMERATE)) {
507 0 : return false;
508 : }
509 0 : break;
510 : } while(0);
511 :
512 : do {
513 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
514 0 : JS::Rooted<JS::Value> temp(cx);
515 0 : bool const & currentValue = mModifierCapsLock;
516 0 : temp.setBoolean(currentValue);
517 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierCapsLock_id, temp, JSPROP_ENUMERATE)) {
518 0 : return false;
519 : }
520 0 : break;
521 : } while(0);
522 :
523 : do {
524 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
525 0 : JS::Rooted<JS::Value> temp(cx);
526 0 : bool const & currentValue = mModifierFn;
527 0 : temp.setBoolean(currentValue);
528 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierFn_id, temp, JSPROP_ENUMERATE)) {
529 0 : return false;
530 : }
531 0 : break;
532 : } while(0);
533 :
534 : do {
535 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
536 0 : JS::Rooted<JS::Value> temp(cx);
537 0 : bool const & currentValue = mModifierFnLock;
538 0 : temp.setBoolean(currentValue);
539 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierFnLock_id, temp, JSPROP_ENUMERATE)) {
540 0 : return false;
541 : }
542 0 : break;
543 : } while(0);
544 :
545 : do {
546 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
547 0 : JS::Rooted<JS::Value> temp(cx);
548 0 : bool const & currentValue = mModifierNumLock;
549 0 : temp.setBoolean(currentValue);
550 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierNumLock_id, temp, JSPROP_ENUMERATE)) {
551 0 : return false;
552 : }
553 0 : break;
554 : } while(0);
555 :
556 : do {
557 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
558 0 : JS::Rooted<JS::Value> temp(cx);
559 0 : bool const & currentValue = mModifierOS;
560 0 : temp.setBoolean(currentValue);
561 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierOS_id, temp, JSPROP_ENUMERATE)) {
562 0 : return false;
563 : }
564 0 : break;
565 : } while(0);
566 :
567 : do {
568 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
569 0 : JS::Rooted<JS::Value> temp(cx);
570 0 : bool const & currentValue = mModifierScrollLock;
571 0 : temp.setBoolean(currentValue);
572 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierScrollLock_id, temp, JSPROP_ENUMERATE)) {
573 0 : return false;
574 : }
575 0 : break;
576 : } while(0);
577 :
578 : do {
579 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
580 0 : JS::Rooted<JS::Value> temp(cx);
581 0 : bool const & currentValue = mModifierSymbol;
582 0 : temp.setBoolean(currentValue);
583 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierSymbol_id, temp, JSPROP_ENUMERATE)) {
584 0 : return false;
585 : }
586 0 : break;
587 : } while(0);
588 :
589 : do {
590 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
591 0 : JS::Rooted<JS::Value> temp(cx);
592 0 : bool const & currentValue = mModifierSymbolLock;
593 0 : temp.setBoolean(currentValue);
594 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->modifierSymbolLock_id, temp, JSPROP_ENUMERATE)) {
595 0 : return false;
596 : }
597 0 : break;
598 : } while(0);
599 :
600 : do {
601 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
602 0 : JS::Rooted<JS::Value> temp(cx);
603 0 : bool const & currentValue = mShiftKey;
604 0 : temp.setBoolean(currentValue);
605 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->shiftKey_id, temp, JSPROP_ENUMERATE)) {
606 0 : return false;
607 : }
608 0 : break;
609 : } while(0);
610 :
611 0 : return true;
612 : }
613 :
614 : bool
615 0 : EventModifierInit::ToJSON(nsAString& aJSON) const
616 : {
617 0 : AutoJSAPI jsapi;
618 0 : jsapi.Init();
619 0 : JSContext *cx = jsapi.cx();
620 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
621 : // because we'll only be creating objects, in ways that have no
622 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
623 : // which likewise guarantees no side-effects for the sorts of
624 : // things we will pass it.
625 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
626 0 : JS::Rooted<JS::Value> val(cx);
627 0 : if (!ToObjectInternal(cx, &val)) {
628 0 : return false;
629 : }
630 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
631 0 : return StringifyToJSON(cx, obj, aJSON);
632 : }
633 :
634 : void
635 0 : EventModifierInit::TraceDictionary(JSTracer* trc)
636 : {
637 0 : UIEventInit::TraceDictionary(trc);
638 0 : }
639 :
640 : EventModifierInit&
641 0 : EventModifierInit::operator=(const EventModifierInit& aOther)
642 : {
643 0 : UIEventInit::operator=(aOther);
644 0 : mAltKey = aOther.mAltKey;
645 0 : mCtrlKey = aOther.mCtrlKey;
646 0 : mMetaKey = aOther.mMetaKey;
647 0 : mModifierAltGraph = aOther.mModifierAltGraph;
648 0 : mModifierCapsLock = aOther.mModifierCapsLock;
649 0 : mModifierFn = aOther.mModifierFn;
650 0 : mModifierFnLock = aOther.mModifierFnLock;
651 0 : mModifierNumLock = aOther.mModifierNumLock;
652 0 : mModifierOS = aOther.mModifierOS;
653 0 : mModifierScrollLock = aOther.mModifierScrollLock;
654 0 : mModifierSymbol = aOther.mModifierSymbol;
655 0 : mModifierSymbolLock = aOther.mModifierSymbolLock;
656 0 : mShiftKey = aOther.mShiftKey;
657 0 : return *this;
658 : }
659 :
660 : namespace binding_detail {
661 : } // namespace binding_detail
662 :
663 :
664 : namespace UIEventBinding {
665 :
666 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventBinding::NativeType>::value,
667 : "Can't inherit from an interface with a different ownership model.");
668 :
669 : static bool
670 0 : get_view(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
671 : {
672 0 : auto result(StrongOrRawPtr<nsPIDOMWindowOuter>(self->GetView()));
673 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
674 0 : if (!result) {
675 0 : args.rval().setNull();
676 0 : return true;
677 : }
678 0 : if (!WrapObject(cx, result, args.rval())) {
679 0 : return false;
680 : }
681 0 : return true;
682 : }
683 :
684 : static const JSJitInfo view_getterinfo = {
685 : { (JSJitGetterOp)get_view },
686 : { prototypes::id::UIEvent },
687 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
688 : JSJitInfo::Getter,
689 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
690 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
691 : false, /* isInfallible. False in setters. */
692 : false, /* isMovable. Not relevant for setters. */
693 : false, /* isEliminatable. Not relevant for setters. */
694 : false, /* isAlwaysInSlot. Only relevant for getters. */
695 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
696 : false, /* isTypedMethod. Only relevant for methods. */
697 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
698 : };
699 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
700 : static_assert(0 < 1, "There is no slot for us");
701 :
702 : static bool
703 7 : get_detail(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
704 : {
705 7 : int32_t result(self->Detail());
706 7 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
707 7 : args.rval().setInt32(int32_t(result));
708 7 : return true;
709 : }
710 :
711 : static const JSJitInfo detail_getterinfo = {
712 : { (JSJitGetterOp)get_detail },
713 : { prototypes::id::UIEvent },
714 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
715 : JSJitInfo::Getter,
716 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
717 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
718 : true, /* isInfallible. False in setters. */
719 : false, /* isMovable. Not relevant for setters. */
720 : false, /* isEliminatable. Not relevant for setters. */
721 : false, /* isAlwaysInSlot. Only relevant for getters. */
722 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
723 : false, /* isTypedMethod. Only relevant for methods. */
724 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
725 : };
726 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
727 : static_assert(0 < 1, "There is no slot for us");
728 :
729 : static bool
730 0 : initUIEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, const JSJitMethodCallArgs& args)
731 : {
732 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
733 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "UIEvent.initUIEvent");
734 : }
735 0 : binding_detail::FakeString arg0;
736 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
737 0 : return false;
738 : }
739 : bool arg1;
740 0 : if (args.hasDefined(1)) {
741 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
742 0 : return false;
743 : }
744 : } else {
745 0 : arg1 = false;
746 : }
747 : bool arg2;
748 0 : if (args.hasDefined(2)) {
749 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
750 0 : return false;
751 : }
752 : } else {
753 0 : arg2 = false;
754 : }
755 : nsGlobalWindow* arg3;
756 0 : if (args.hasDefined(3)) {
757 0 : if (args[3].isObject()) {
758 : {
759 0 : nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[3], arg3);
760 0 : if (NS_FAILED(rv)) {
761 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of UIEvent.initUIEvent", "Window");
762 0 : return false;
763 : }
764 : }
765 0 : } else if (args[3].isNullOrUndefined()) {
766 0 : arg3 = nullptr;
767 : } else {
768 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of UIEvent.initUIEvent");
769 0 : return false;
770 : }
771 : } else {
772 0 : arg3 = nullptr;
773 : }
774 : int32_t arg4;
775 0 : if (args.hasDefined(4)) {
776 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
777 0 : return false;
778 : }
779 : } else {
780 0 : arg4 = 0;
781 : }
782 0 : self->InitUIEvent(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), arg4);
783 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
784 0 : args.rval().setUndefined();
785 0 : return true;
786 : }
787 :
788 : static const JSJitInfo initUIEvent_methodinfo = {
789 : { (JSJitGetterOp)initUIEvent },
790 : { prototypes::id::UIEvent },
791 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
792 : JSJitInfo::Method,
793 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
794 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
795 : false, /* isInfallible. False in setters. */
796 : false, /* isMovable. Not relevant for setters. */
797 : false, /* isEliminatable. Not relevant for setters. */
798 : false, /* isAlwaysInSlot. Only relevant for getters. */
799 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
800 : false, /* isTypedMethod. Only relevant for methods. */
801 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
802 : };
803 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
804 : static_assert(0 < 1, "There is no slot for us");
805 :
806 : static bool
807 0 : get_layerX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
808 : {
809 0 : int32_t result(self->LayerX());
810 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
811 0 : args.rval().setInt32(int32_t(result));
812 0 : return true;
813 : }
814 :
815 : static const JSJitInfo layerX_getterinfo = {
816 : { (JSJitGetterOp)get_layerX },
817 : { prototypes::id::UIEvent },
818 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
819 : JSJitInfo::Getter,
820 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
821 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
822 : true, /* isInfallible. False in setters. */
823 : false, /* isMovable. Not relevant for setters. */
824 : false, /* isEliminatable. Not relevant for setters. */
825 : false, /* isAlwaysInSlot. Only relevant for getters. */
826 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
827 : false, /* isTypedMethod. Only relevant for methods. */
828 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
829 : };
830 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
831 : static_assert(0 < 1, "There is no slot for us");
832 :
833 : static bool
834 0 : get_layerY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
835 : {
836 0 : int32_t result(self->LayerY());
837 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
838 0 : args.rval().setInt32(int32_t(result));
839 0 : return true;
840 : }
841 :
842 : static const JSJitInfo layerY_getterinfo = {
843 : { (JSJitGetterOp)get_layerY },
844 : { prototypes::id::UIEvent },
845 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
846 : JSJitInfo::Getter,
847 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
848 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
849 : true, /* isInfallible. False in setters. */
850 : false, /* isMovable. Not relevant for setters. */
851 : false, /* isEliminatable. Not relevant for setters. */
852 : false, /* isAlwaysInSlot. Only relevant for getters. */
853 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
854 : false, /* isTypedMethod. Only relevant for methods. */
855 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
856 : };
857 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
858 : static_assert(0 < 1, "There is no slot for us");
859 :
860 : static bool
861 0 : get_pageX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
862 : {
863 0 : int32_t result(self->PageX());
864 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
865 0 : args.rval().setInt32(int32_t(result));
866 0 : return true;
867 : }
868 :
869 : static const JSJitInfo pageX_getterinfo = {
870 : { (JSJitGetterOp)get_pageX },
871 : { prototypes::id::UIEvent },
872 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
873 : JSJitInfo::Getter,
874 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
875 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
876 : true, /* isInfallible. False in setters. */
877 : false, /* isMovable. Not relevant for setters. */
878 : false, /* isEliminatable. Not relevant for setters. */
879 : false, /* isAlwaysInSlot. Only relevant for getters. */
880 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
881 : false, /* isTypedMethod. Only relevant for methods. */
882 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
883 : };
884 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
885 : static_assert(0 < 1, "There is no slot for us");
886 :
887 : static bool
888 0 : get_pageY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
889 : {
890 0 : int32_t result(self->PageY());
891 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
892 0 : args.rval().setInt32(int32_t(result));
893 0 : return true;
894 : }
895 :
896 : static const JSJitInfo pageY_getterinfo = {
897 : { (JSJitGetterOp)get_pageY },
898 : { prototypes::id::UIEvent },
899 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
900 : JSJitInfo::Getter,
901 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
902 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
903 : true, /* isInfallible. False in setters. */
904 : false, /* isMovable. Not relevant for setters. */
905 : false, /* isEliminatable. Not relevant for setters. */
906 : false, /* isAlwaysInSlot. Only relevant for getters. */
907 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
908 : false, /* isTypedMethod. Only relevant for methods. */
909 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
910 : };
911 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
912 : static_assert(0 < 1, "There is no slot for us");
913 :
914 : static bool
915 0 : get_which(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
916 : {
917 0 : uint32_t result(self->Which());
918 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
919 0 : args.rval().setNumber(result);
920 0 : return true;
921 : }
922 :
923 : static const JSJitInfo which_getterinfo = {
924 : { (JSJitGetterOp)get_which },
925 : { prototypes::id::UIEvent },
926 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
927 : JSJitInfo::Getter,
928 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
929 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
930 : true, /* isInfallible. False in setters. */
931 : false, /* isMovable. Not relevant for setters. */
932 : false, /* isEliminatable. Not relevant for setters. */
933 : false, /* isAlwaysInSlot. Only relevant for getters. */
934 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
935 : false, /* isTypedMethod. Only relevant for methods. */
936 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
937 : };
938 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
939 : static_assert(0 < 1, "There is no slot for us");
940 :
941 : static bool
942 0 : get_rangeParent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
943 : {
944 0 : auto result(StrongOrRawPtr<nsINode>(self->GetRangeParent()));
945 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
946 0 : if (!result) {
947 0 : args.rval().setNull();
948 0 : return true;
949 : }
950 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
951 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
952 0 : return false;
953 : }
954 0 : return true;
955 : }
956 :
957 : static const JSJitInfo rangeParent_getterinfo = {
958 : { (JSJitGetterOp)get_rangeParent },
959 : { prototypes::id::UIEvent },
960 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
961 : JSJitInfo::Getter,
962 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
963 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
964 : false, /* isInfallible. False in setters. */
965 : false, /* isMovable. Not relevant for setters. */
966 : false, /* isEliminatable. Not relevant for setters. */
967 : false, /* isAlwaysInSlot. Only relevant for getters. */
968 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
969 : false, /* isTypedMethod. Only relevant for methods. */
970 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
971 : };
972 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
973 : static_assert(0 < 1, "There is no slot for us");
974 :
975 : static bool
976 0 : get_rangeOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
977 : {
978 0 : int32_t result(self->RangeOffset());
979 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
980 0 : args.rval().setInt32(int32_t(result));
981 0 : return true;
982 : }
983 :
984 : static const JSJitInfo rangeOffset_getterinfo = {
985 : { (JSJitGetterOp)get_rangeOffset },
986 : { prototypes::id::UIEvent },
987 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
988 : JSJitInfo::Getter,
989 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
990 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
991 : true, /* isInfallible. False in setters. */
992 : false, /* isMovable. Not relevant for setters. */
993 : false, /* isEliminatable. Not relevant for setters. */
994 : false, /* isAlwaysInSlot. Only relevant for getters. */
995 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
996 : false, /* isTypedMethod. Only relevant for methods. */
997 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
998 : };
999 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1000 : static_assert(0 < 1, "There is no slot for us");
1001 :
1002 : static bool
1003 0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::UIEvent* self, JSJitGetterCallArgs args)
1004 : {
1005 0 : bool result(self->IsTrusted());
1006 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1007 0 : args.rval().setBoolean(result);
1008 0 : return true;
1009 : }
1010 :
1011 : static const JSJitInfo isTrusted_getterinfo = {
1012 : { (JSJitGetterOp)get_isTrusted },
1013 : { prototypes::id::UIEvent },
1014 : { PrototypeTraits<prototypes::id::UIEvent>::Depth },
1015 : JSJitInfo::Getter,
1016 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
1017 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
1018 : true, /* isInfallible. False in setters. */
1019 : true, /* isMovable. Not relevant for setters. */
1020 : true, /* isEliminatable. Not relevant for setters. */
1021 : false, /* isAlwaysInSlot. Only relevant for getters. */
1022 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1023 : false, /* isTypedMethod. Only relevant for methods. */
1024 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1025 : };
1026 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1027 : static_assert(0 < 1, "There is no slot for us");
1028 :
1029 : static bool
1030 1 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1031 : {
1032 1 : mozilla::dom::UIEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::UIEvent>(obj);
1033 : // We don't want to preserve if we don't have a wrapper, and we
1034 : // obviously can't preserve if we're not initialized.
1035 1 : if (self && self->GetWrapperPreserveColor()) {
1036 0 : PreserveWrapper(self);
1037 : }
1038 1 : return true;
1039 : }
1040 :
1041 : static void
1042 7 : _finalize(js::FreeOp* fop, JSObject* obj)
1043 : {
1044 7 : mozilla::dom::UIEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::UIEvent>(obj);
1045 7 : if (self) {
1046 7 : ClearWrapper(self, self, obj);
1047 7 : AddForDeferredFinalization<mozilla::dom::UIEvent>(self);
1048 : }
1049 7 : }
1050 :
1051 : static void
1052 2 : _objectMoved(JSObject* obj, const JSObject* old)
1053 : {
1054 2 : mozilla::dom::UIEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::UIEvent>(obj);
1055 2 : if (self) {
1056 1 : UpdateWrapper(self, self, obj, old);
1057 : }
1058 2 : }
1059 :
1060 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1061 : #if defined(__clang__)
1062 : #pragma clang diagnostic push
1063 : #pragma clang diagnostic ignored "-Wmissing-braces"
1064 : #endif
1065 : static const JSFunctionSpec sMethods_specs[] = {
1066 : JS_FNSPEC("initUIEvent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initUIEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1067 : JS_FS_END
1068 : };
1069 : #if defined(__clang__)
1070 : #pragma clang diagnostic pop
1071 : #endif
1072 :
1073 :
1074 : // Can't be const because the pref-enabled boolean needs to be writable
1075 : static Prefable<const JSFunctionSpec> sMethods[] = {
1076 : { nullptr, &sMethods_specs[0] },
1077 : { nullptr, nullptr }
1078 : };
1079 :
1080 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1081 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1082 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1083 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1084 :
1085 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1086 : #if defined(__clang__)
1087 : #pragma clang diagnostic push
1088 : #pragma clang diagnostic ignored "-Wmissing-braces"
1089 : #endif
1090 : static const JSPropertySpec sAttributes_specs[] = {
1091 : { "view", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &view_getterinfo, nullptr, nullptr },
1092 : { "detail", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &detail_getterinfo, nullptr, nullptr },
1093 : { "layerX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &layerX_getterinfo, nullptr, nullptr },
1094 : { "layerY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &layerY_getterinfo, nullptr, nullptr },
1095 : { "pageX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pageX_getterinfo, nullptr, nullptr },
1096 : { "pageY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pageY_getterinfo, nullptr, nullptr },
1097 : { "which", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &which_getterinfo, nullptr, nullptr },
1098 : { "rangeParent", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rangeParent_getterinfo, nullptr, nullptr },
1099 : { "rangeOffset", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &rangeOffset_getterinfo, nullptr, nullptr },
1100 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1101 : };
1102 : #if defined(__clang__)
1103 : #pragma clang diagnostic pop
1104 : #endif
1105 :
1106 :
1107 : // Can't be const because the pref-enabled boolean needs to be writable
1108 : static Prefable<const JSPropertySpec> sAttributes[] = {
1109 : { nullptr, &sAttributes_specs[0] },
1110 : { nullptr, nullptr }
1111 : };
1112 :
1113 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1114 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1115 : static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1116 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1117 :
1118 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1119 : #if defined(__clang__)
1120 : #pragma clang diagnostic push
1121 : #pragma clang diagnostic ignored "-Wmissing-braces"
1122 : #endif
1123 : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
1124 : { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
1125 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1126 : };
1127 : #if defined(__clang__)
1128 : #pragma clang diagnostic pop
1129 : #endif
1130 :
1131 :
1132 : // Can't be const because the pref-enabled boolean needs to be writable
1133 : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
1134 : { nullptr, &sUnforgeableAttributes_specs[0] },
1135 : { nullptr, nullptr }
1136 : };
1137 :
1138 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1139 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1140 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1141 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1142 :
1143 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1144 : #if defined(__clang__)
1145 : #pragma clang diagnostic push
1146 : #pragma clang diagnostic ignored "-Wmissing-braces"
1147 : #endif
1148 : static const ConstantSpec sConstants_specs[] = {
1149 : { "SCROLL_PAGE_UP", JS::Int32Value(-32768) },
1150 : { "SCROLL_PAGE_DOWN", JS::Int32Value(32768) },
1151 : { 0, JS::UndefinedValue() }
1152 : };
1153 : #if defined(__clang__)
1154 : #pragma clang diagnostic pop
1155 : #endif
1156 :
1157 :
1158 : // Can't be const because the pref-enabled boolean needs to be writable
1159 : static Prefable<const ConstantSpec> sConstants[] = {
1160 : { nullptr, &sConstants_specs[0] },
1161 : { nullptr, nullptr }
1162 : };
1163 :
1164 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1165 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1166 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1167 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1168 :
1169 :
1170 : static uint16_t sNativeProperties_sortedPropertyIndices[13];
1171 : static PropertyInfo sNativeProperties_propertyInfos[13];
1172 :
1173 : static const NativePropertiesN<4> sNativeProperties = {
1174 : false, 0,
1175 : false, 0,
1176 : true, 0 /* sMethods */,
1177 : true, 1 /* sAttributes */,
1178 : false, 0,
1179 : true, 2 /* sUnforgeableAttributes */,
1180 : true, 3 /* sConstants */,
1181 : -1,
1182 : 13,
1183 : sNativeProperties_sortedPropertyIndices,
1184 : {
1185 : { sMethods, &sNativeProperties_propertyInfos[0] },
1186 : { sAttributes, &sNativeProperties_propertyInfos[1] },
1187 : { sUnforgeableAttributes, &sNativeProperties_propertyInfos[10] },
1188 : { sConstants, &sNativeProperties_propertyInfos[11] }
1189 : }
1190 : };
1191 : static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1192 : "We have a property info count that is oversized");
1193 :
1194 : static bool
1195 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1196 : {
1197 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1198 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
1199 0 : if (!args.isConstructing()) {
1200 : // XXXbz wish I could get the name from the callee instead of
1201 : // Adding more relocations
1202 0 : return ThrowConstructorWithoutNew(cx, "UIEvent");
1203 : }
1204 :
1205 0 : GlobalObject global(cx, obj);
1206 0 : if (global.Failed()) {
1207 0 : return false;
1208 : }
1209 :
1210 0 : JS::Rooted<JSObject*> desiredProto(cx);
1211 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
1212 0 : return false;
1213 : }
1214 :
1215 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
1216 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "UIEvent");
1217 : }
1218 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1219 0 : binding_detail::FakeString arg0;
1220 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1221 0 : return false;
1222 : }
1223 0 : binding_detail::FastUIEventInit arg1;
1224 0 : if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of UIEvent.constructor", false)) {
1225 0 : return false;
1226 : }
1227 0 : Maybe<JSAutoCompartment> ac;
1228 0 : if (objIsXray) {
1229 0 : obj = js::CheckedUnwrap(obj);
1230 0 : if (!obj) {
1231 0 : return false;
1232 : }
1233 0 : ac.emplace(cx, obj);
1234 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1235 0 : return false;
1236 : }
1237 : }
1238 0 : binding_detail::FastErrorResult rv;
1239 0 : auto result(StrongOrRawPtr<mozilla::dom::UIEvent>(mozilla::dom::UIEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
1240 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1241 0 : return false;
1242 : }
1243 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1244 : static_assert(!IsPointer<decltype(result)>::value,
1245 : "NewObject implies that we need to keep the object alive with a strong reference.");
1246 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1247 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1248 0 : return false;
1249 : }
1250 0 : return true;
1251 : }
1252 :
1253 : static const js::ClassOps sInterfaceObjectClassOps = {
1254 : nullptr, /* addProperty */
1255 : nullptr, /* delProperty */
1256 : nullptr, /* getProperty */
1257 : nullptr, /* setProperty */
1258 : nullptr, /* enumerate */
1259 : nullptr, /* newEnumerate */
1260 : nullptr, /* resolve */
1261 : nullptr, /* mayResolve */
1262 : nullptr, /* finalize */
1263 : _constructor, /* call */
1264 : nullptr, /* hasInstance */
1265 : _constructor, /* construct */
1266 : nullptr, /* trace */
1267 : };
1268 :
1269 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1270 : {
1271 : "Function",
1272 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1273 : &sInterfaceObjectClassOps,
1274 : JS_NULL_CLASS_SPEC,
1275 : JS_NULL_CLASS_EXT,
1276 : &sInterfaceObjectClassObjectOps
1277 : },
1278 : eInterface,
1279 : true,
1280 : prototypes::id::UIEvent,
1281 : PrototypeTraits<prototypes::id::UIEvent>::Depth,
1282 : sNativePropertyHooks,
1283 : "function UIEvent() {\n [native code]\n}",
1284 : EventBinding::GetConstructorObject
1285 : };
1286 :
1287 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1288 : {
1289 : "UIEventPrototype",
1290 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
1291 : JS_NULL_CLASS_OPS,
1292 : JS_NULL_CLASS_SPEC,
1293 : JS_NULL_CLASS_EXT,
1294 : JS_NULL_OBJECT_OPS
1295 : },
1296 : eInterfacePrototype,
1297 : false,
1298 : prototypes::id::UIEvent,
1299 : PrototypeTraits<prototypes::id::UIEvent>::Depth,
1300 : sNativePropertyHooks,
1301 : "[object UIEventPrototype]",
1302 : EventBinding::GetProtoObject
1303 : };
1304 :
1305 : JSObject*
1306 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1307 : {
1308 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1309 : }
1310 :
1311 : static const js::ClassOps sClassOps = {
1312 : _addProperty, /* addProperty */
1313 : nullptr, /* delProperty */
1314 : nullptr, /* getProperty */
1315 : nullptr, /* setProperty */
1316 : nullptr, /* enumerate */
1317 : nullptr, /* newEnumerate */
1318 : nullptr, /* resolve */
1319 : nullptr, /* mayResolve */
1320 : _finalize, /* finalize */
1321 : nullptr, /* call */
1322 : nullptr, /* hasInstance */
1323 : nullptr, /* construct */
1324 : nullptr, /* trace */
1325 : };
1326 :
1327 : static const js::ClassExtension sClassExtension = {
1328 : nullptr, /* weakmapKeyDelegateOp */
1329 : _objectMoved /* objectMovedOp */
1330 : };
1331 :
1332 : static const DOMJSClass sClass = {
1333 : { "UIEvent",
1334 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
1335 : &sClassOps,
1336 : JS_NULL_CLASS_SPEC,
1337 : &sClassExtension,
1338 : JS_NULL_OBJECT_OPS
1339 : },
1340 : { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1341 : IsBaseOf<nsISupports, mozilla::dom::UIEvent >::value,
1342 : sNativePropertyHooks,
1343 : FindAssociatedGlobalForNative<mozilla::dom::UIEvent>::Get,
1344 : GetProtoObjectHandle,
1345 : GetCCParticipant<mozilla::dom::UIEvent>::Get()
1346 : };
1347 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1348 : "Must have the right minimal number of reserved slots.");
1349 : static_assert(1 >= 1,
1350 : "Must have enough reserved slots.");
1351 :
1352 : const JSClass*
1353 0 : GetJSClass()
1354 : {
1355 0 : return sClass.ToJSClass();
1356 : }
1357 :
1358 : bool
1359 8 : Wrap(JSContext* aCx, mozilla::dom::UIEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1360 : {
1361 : MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
1362 : reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
1363 : "Multiple inheritance for mozilla::dom::UIEvent is broken.");
1364 : MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
1365 : reinterpret_cast<mozilla::dom::Event*>(aObject),
1366 : "Multiple inheritance for mozilla::dom::Event is broken.");
1367 8 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1368 8 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1369 8 : MOZ_ASSERT(!aCache->GetWrapper(),
1370 : "You should probably not be using Wrap() directly; use "
1371 : "GetOrCreateDOMReflector instead");
1372 :
1373 8 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1374 : "nsISupports must be on our primary inheritance chain");
1375 :
1376 16 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1377 8 : if (!global) {
1378 0 : return false;
1379 : }
1380 8 : MOZ_ASSERT(JS_IsGlobalObject(global));
1381 8 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1382 :
1383 : // That might have ended up wrapping us already, due to the wonders
1384 : // of XBL. Check for that, and bail out as needed.
1385 8 : aReflector.set(aCache->GetWrapper());
1386 8 : if (aReflector) {
1387 : #ifdef DEBUG
1388 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1389 : #endif // DEBUG
1390 0 : return true;
1391 : }
1392 :
1393 16 : JSAutoCompartment ac(aCx, global);
1394 8 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1395 8 : if (!canonicalProto) {
1396 0 : return false;
1397 : }
1398 16 : JS::Rooted<JSObject*> proto(aCx);
1399 8 : if (aGivenProto) {
1400 0 : proto = aGivenProto;
1401 : // Unfortunately, while aGivenProto was in the compartment of aCx
1402 : // coming in, we changed compartments to that of "parent" so may need
1403 : // to wrap the proto here.
1404 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1405 0 : if (!JS_WrapObject(aCx, &proto)) {
1406 0 : return false;
1407 : }
1408 : }
1409 : } else {
1410 8 : proto = canonicalProto;
1411 : }
1412 :
1413 16 : BindingJSObjectCreator<mozilla::dom::UIEvent> creator(aCx);
1414 8 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1415 8 : if (!aReflector) {
1416 0 : return false;
1417 : }
1418 :
1419 8 : aCache->SetWrapper(aReflector);
1420 :
1421 : // Important: do unforgeable property setup after we have handed
1422 : // over ownership of the C++ object to obj as needed, so that if
1423 : // we fail and it ends up GCed it won't have problems in the
1424 : // finalizer trying to drop its ownership of the C++ object.
1425 : JS::Rooted<JSObject*> unforgeableHolder(aCx,
1426 16 : &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
1427 8 : if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
1428 0 : aCache->ReleaseWrapper(aObject);
1429 0 : aCache->ClearWrapper();
1430 0 : return false;
1431 : }
1432 8 : creator.InitializationSucceeded();
1433 :
1434 8 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1435 : aCache->GetWrapperPreserveColor() == aReflector);
1436 : // If proto != canonicalProto, we have to preserve our wrapper;
1437 : // otherwise we won't be able to properly recreate it later, since
1438 : // we won't know what proto to use. Note that we don't check
1439 : // aGivenProto here, since it's entirely possible (and even
1440 : // somewhat common) to have a non-null aGivenProto which is the
1441 : // same as canonicalProto.
1442 8 : if (proto != canonicalProto) {
1443 0 : PreserveWrapper(aObject);
1444 : }
1445 :
1446 8 : return true;
1447 : }
1448 :
1449 : const NativePropertyHooks sNativePropertyHooks[] = { {
1450 : nullptr,
1451 : nullptr,
1452 : nullptr,
1453 : { sNativeProperties.Upcast(), nullptr },
1454 : prototypes::id::UIEvent,
1455 : constructors::id::UIEvent,
1456 : EventBinding::sNativePropertyHooks,
1457 : &DefaultXrayExpandoObjectClass
1458 : } };
1459 :
1460 : void
1461 1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1462 : {
1463 1 : JS::Handle<JSObject*> parentProto(EventBinding::GetProtoObjectHandle(aCx));
1464 1 : if (!parentProto) {
1465 0 : return;
1466 : }
1467 :
1468 1 : JS::Handle<JSObject*> constructorProto(EventBinding::GetConstructorObjectHandle(aCx));
1469 1 : if (!constructorProto) {
1470 0 : return;
1471 : }
1472 :
1473 : static bool sIdsInited = false;
1474 1 : if (!sIdsInited && NS_IsMainThread()) {
1475 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1476 0 : return;
1477 : }
1478 1 : sIdsInited = true;
1479 : }
1480 :
1481 1 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::UIEvent);
1482 1 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::UIEvent);
1483 1 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1484 : &sPrototypeClass.mBase, protoCache,
1485 : constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1486 : interfaceCache,
1487 : sNativeProperties.Upcast(),
1488 : nullptr,
1489 : "UIEvent", aDefineOnGlobal,
1490 : nullptr,
1491 1 : false);
1492 :
1493 2 : JS::Rooted<JSObject*> unforgeableHolder(aCx);
1494 : {
1495 2 : JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1496 1 : unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1497 1 : if (!unforgeableHolder) {
1498 0 : *protoCache = nullptr;
1499 0 : if (interfaceCache) {
1500 0 : *interfaceCache = nullptr;
1501 : }
1502 0 : return;
1503 : }
1504 : }
1505 :
1506 1 : if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1507 0 : *protoCache = nullptr;
1508 0 : if (interfaceCache) {
1509 0 : *interfaceCache = nullptr;
1510 : }
1511 0 : return;
1512 : }
1513 :
1514 1 : if (*protoCache) {
1515 1 : js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1516 2 : JS::ObjectValue(*unforgeableHolder));
1517 : }
1518 : }
1519 :
1520 : JS::Handle<JSObject*>
1521 9 : GetProtoObjectHandle(JSContext* aCx)
1522 : {
1523 : /* Get the interface prototype object for this class. This will create the
1524 : object as needed. */
1525 9 : bool aDefineOnGlobal = true;
1526 :
1527 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1528 9 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1529 9 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1530 0 : return nullptr;
1531 : }
1532 :
1533 : /* Check to see whether the interface objects are already installed */
1534 9 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1535 9 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::UIEvent)) {
1536 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1537 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1538 : }
1539 :
1540 : /*
1541 : * The object might _still_ be null, but that's OK.
1542 : *
1543 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1544 : * traced by TraceProtoAndIfaceCache() and its contents are never
1545 : * changed after they have been set.
1546 : *
1547 : * Calling address() avoids the read read barrier that does gray
1548 : * unmarking, but it's not possible for the object to be gray here.
1549 : */
1550 :
1551 9 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::UIEvent);
1552 9 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1553 9 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1554 : }
1555 :
1556 : JSObject*
1557 0 : GetProtoObject(JSContext* aCx)
1558 : {
1559 0 : return GetProtoObjectHandle(aCx);
1560 : }
1561 :
1562 : JS::Handle<JSObject*>
1563 1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1564 : {
1565 : /* Get the interface object for this class. This will create the object as
1566 : needed. */
1567 :
1568 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1569 1 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1570 1 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1571 0 : return nullptr;
1572 : }
1573 :
1574 : /* Check to see whether the interface objects are already installed */
1575 1 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1576 1 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::UIEvent)) {
1577 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1578 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1579 : }
1580 :
1581 : /*
1582 : * The object might _still_ be null, but that's OK.
1583 : *
1584 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1585 : * traced by TraceProtoAndIfaceCache() and its contents are never
1586 : * changed after they have been set.
1587 : *
1588 : * Calling address() avoids the read read barrier that does gray
1589 : * unmarking, but it's not possible for the object to be gray here.
1590 : */
1591 :
1592 1 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::UIEvent);
1593 1 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1594 1 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1595 : }
1596 :
1597 : JSObject*
1598 0 : GetConstructorObject(JSContext* aCx)
1599 : {
1600 0 : return GetConstructorObjectHandle(aCx);
1601 : }
1602 :
1603 : } // namespace UIEventBinding
1604 :
1605 :
1606 :
1607 : } // namespace dom
1608 : } // namespace mozilla
|