Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM TouchEvent.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "TouchEventBinding.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/TouchEvent.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 : #include "nsGlobalWindow.h"
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 :
22 0 : TouchEventInit::TouchEventInit()
23 0 : : EventModifierInit(FastDictionaryInitializer())
24 : {
25 : // Safe to pass a null context if we pass a null value
26 0 : Init(nullptr, JS::NullHandleValue);
27 0 : }
28 :
29 :
30 :
31 : bool
32 0 : TouchEventInit::InitIds(JSContext* cx, TouchEventInitAtoms* atomsCache)
33 : {
34 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
35 :
36 : // Initialize these in reverse order so that any failure leaves the first one
37 : // uninitialized.
38 0 : if (!atomsCache->touches_id.init(cx, "touches") ||
39 0 : !atomsCache->targetTouches_id.init(cx, "targetTouches") ||
40 0 : !atomsCache->changedTouches_id.init(cx, "changedTouches")) {
41 0 : return false;
42 : }
43 0 : return true;
44 : }
45 :
46 : bool
47 0 : TouchEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
48 : {
49 : // Passing a null JSContext is OK only if we're initing from null,
50 : // Since in that case we will not have to do any property gets
51 : // Also evaluate isNullOrUndefined in order to avoid false-positive
52 : // checkers by static analysis tools
53 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
54 0 : TouchEventInitAtoms* atomsCache = nullptr;
55 0 : if (cx) {
56 0 : atomsCache = GetAtomCache<TouchEventInitAtoms>(cx);
57 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
58 0 : return false;
59 : }
60 : }
61 :
62 : // Per spec, we init the parent's members first
63 0 : if (!EventModifierInit::Init(cx, val)) {
64 0 : return false;
65 : }
66 :
67 0 : bool isNull = val.isNullOrUndefined();
68 : // We only need these if !isNull, in which case we have |cx|.
69 0 : Maybe<JS::Rooted<JSObject *> > object;
70 0 : Maybe<JS::Rooted<JS::Value> > temp;
71 0 : if (!isNull) {
72 0 : MOZ_ASSERT(cx);
73 0 : object.emplace(cx, &val.toObject());
74 0 : temp.emplace(cx);
75 : }
76 0 : if (!isNull) {
77 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->changedTouches_id, temp.ptr())) {
78 0 : return false;
79 : }
80 : }
81 0 : if (!isNull && !temp->isUndefined()) {
82 0 : if (temp.ref().isObject()) {
83 0 : JS::ForOfIterator iter(cx);
84 0 : if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
85 0 : return false;
86 : }
87 0 : if (!iter.valueIsIterable()) {
88 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'changedTouches' member of TouchEventInit");
89 0 : return false;
90 : }
91 0 : Sequence<OwningNonNull<mozilla::dom::Touch>> &arr = mChangedTouches;
92 0 : JS::Rooted<JS::Value> temp(cx);
93 : while (true) {
94 : bool done;
95 0 : if (!iter.next(&temp, &done)) {
96 0 : return false;
97 : }
98 0 : if (done) {
99 0 : break;
100 : }
101 0 : OwningNonNull<mozilla::dom::Touch>* slotPtr = arr.AppendElement(mozilla::fallible);
102 0 : if (!slotPtr) {
103 0 : JS_ReportOutOfMemory(cx);
104 0 : return false;
105 : }
106 0 : OwningNonNull<mozilla::dom::Touch>& slot = *slotPtr;
107 0 : if (temp.isObject()) {
108 : static_assert(IsRefcounted<mozilla::dom::Touch>::value, "We can only store refcounted classes.");{
109 0 : nsresult rv = UnwrapObject<prototypes::id::Touch, mozilla::dom::Touch>(&temp, slot);
110 0 : if (NS_FAILED(rv)) {
111 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of 'changedTouches' member of TouchEventInit", "Touch");
112 0 : return false;
113 : }
114 : }
115 : } else {
116 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of 'changedTouches' member of TouchEventInit");
117 0 : return false;
118 : }
119 0 : }
120 : } else {
121 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'changedTouches' member of TouchEventInit");
122 0 : return false;
123 : }
124 : } else {
125 : /* Array is already empty; nothing to do */
126 : }
127 0 : mIsAnyMemberPresent = true;
128 :
129 0 : if (!isNull) {
130 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->targetTouches_id, temp.ptr())) {
131 0 : return false;
132 : }
133 : }
134 0 : if (!isNull && !temp->isUndefined()) {
135 0 : if (temp.ref().isObject()) {
136 0 : JS::ForOfIterator iter(cx);
137 0 : if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
138 0 : return false;
139 : }
140 0 : if (!iter.valueIsIterable()) {
141 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'targetTouches' member of TouchEventInit");
142 0 : return false;
143 : }
144 0 : Sequence<OwningNonNull<mozilla::dom::Touch>> &arr = mTargetTouches;
145 0 : JS::Rooted<JS::Value> temp(cx);
146 : while (true) {
147 : bool done;
148 0 : if (!iter.next(&temp, &done)) {
149 0 : return false;
150 : }
151 0 : if (done) {
152 0 : break;
153 : }
154 0 : OwningNonNull<mozilla::dom::Touch>* slotPtr = arr.AppendElement(mozilla::fallible);
155 0 : if (!slotPtr) {
156 0 : JS_ReportOutOfMemory(cx);
157 0 : return false;
158 : }
159 0 : OwningNonNull<mozilla::dom::Touch>& slot = *slotPtr;
160 0 : if (temp.isObject()) {
161 : static_assert(IsRefcounted<mozilla::dom::Touch>::value, "We can only store refcounted classes.");{
162 0 : nsresult rv = UnwrapObject<prototypes::id::Touch, mozilla::dom::Touch>(&temp, slot);
163 0 : if (NS_FAILED(rv)) {
164 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of 'targetTouches' member of TouchEventInit", "Touch");
165 0 : return false;
166 : }
167 : }
168 : } else {
169 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of 'targetTouches' member of TouchEventInit");
170 0 : return false;
171 : }
172 0 : }
173 : } else {
174 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'targetTouches' member of TouchEventInit");
175 0 : return false;
176 : }
177 : } else {
178 : /* Array is already empty; nothing to do */
179 : }
180 0 : mIsAnyMemberPresent = true;
181 :
182 0 : if (!isNull) {
183 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->touches_id, temp.ptr())) {
184 0 : return false;
185 : }
186 : }
187 0 : if (!isNull && !temp->isUndefined()) {
188 0 : if (temp.ref().isObject()) {
189 0 : JS::ForOfIterator iter(cx);
190 0 : if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
191 0 : return false;
192 : }
193 0 : if (!iter.valueIsIterable()) {
194 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'touches' member of TouchEventInit");
195 0 : return false;
196 : }
197 0 : Sequence<OwningNonNull<mozilla::dom::Touch>> &arr = mTouches;
198 0 : JS::Rooted<JS::Value> temp(cx);
199 : while (true) {
200 : bool done;
201 0 : if (!iter.next(&temp, &done)) {
202 0 : return false;
203 : }
204 0 : if (done) {
205 0 : break;
206 : }
207 0 : OwningNonNull<mozilla::dom::Touch>* slotPtr = arr.AppendElement(mozilla::fallible);
208 0 : if (!slotPtr) {
209 0 : JS_ReportOutOfMemory(cx);
210 0 : return false;
211 : }
212 0 : OwningNonNull<mozilla::dom::Touch>& slot = *slotPtr;
213 0 : if (temp.isObject()) {
214 : static_assert(IsRefcounted<mozilla::dom::Touch>::value, "We can only store refcounted classes.");{
215 0 : nsresult rv = UnwrapObject<prototypes::id::Touch, mozilla::dom::Touch>(&temp, slot);
216 0 : if (NS_FAILED(rv)) {
217 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of 'touches' member of TouchEventInit", "Touch");
218 0 : return false;
219 : }
220 : }
221 : } else {
222 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of 'touches' member of TouchEventInit");
223 0 : return false;
224 : }
225 0 : }
226 : } else {
227 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'touches' member of TouchEventInit");
228 0 : return false;
229 : }
230 : } else {
231 : /* Array is already empty; nothing to do */
232 : }
233 0 : mIsAnyMemberPresent = true;
234 0 : return true;
235 : }
236 :
237 : bool
238 0 : TouchEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
239 : {
240 0 : TouchEventInitAtoms* atomsCache = GetAtomCache<TouchEventInitAtoms>(cx);
241 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
242 0 : return false;
243 : }
244 :
245 : // Per spec, we define the parent's members first
246 0 : if (!EventModifierInit::ToObjectInternal(cx, rval)) {
247 0 : return false;
248 : }
249 0 : JS::Rooted<JSObject*> obj(cx, &rval.toObject());
250 :
251 : do {
252 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
253 0 : JS::Rooted<JS::Value> temp(cx);
254 0 : Sequence<OwningNonNull<mozilla::dom::Touch>> const & currentValue = mChangedTouches;
255 :
256 0 : uint32_t length = currentValue.Length();
257 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
258 0 : if (!returnArray) {
259 0 : return false;
260 : }
261 : // Scope for 'tmp'
262 : {
263 0 : JS::Rooted<JS::Value> tmp(cx);
264 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
265 : // Control block to let us common up the JS_DefineElement calls when there
266 : // are different ways to succeed at wrapping the object.
267 : do {
268 0 : if (!GetOrCreateDOMReflector(cx, currentValue[sequenceIdx0], &tmp)) {
269 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
270 0 : return false;
271 : }
272 0 : break;
273 : } while (0);
274 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
275 : JSPROP_ENUMERATE)) {
276 0 : return false;
277 : }
278 : }
279 : }
280 0 : temp.setObject(*returnArray);
281 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->changedTouches_id, temp, JSPROP_ENUMERATE)) {
282 0 : return false;
283 : }
284 0 : break;
285 : } while(0);
286 :
287 : do {
288 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
289 0 : JS::Rooted<JS::Value> temp(cx);
290 0 : Sequence<OwningNonNull<mozilla::dom::Touch>> const & currentValue = mTargetTouches;
291 :
292 0 : uint32_t length = currentValue.Length();
293 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
294 0 : if (!returnArray) {
295 0 : return false;
296 : }
297 : // Scope for 'tmp'
298 : {
299 0 : JS::Rooted<JS::Value> tmp(cx);
300 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
301 : // Control block to let us common up the JS_DefineElement calls when there
302 : // are different ways to succeed at wrapping the object.
303 : do {
304 0 : if (!GetOrCreateDOMReflector(cx, currentValue[sequenceIdx0], &tmp)) {
305 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
306 0 : return false;
307 : }
308 0 : break;
309 : } while (0);
310 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
311 : JSPROP_ENUMERATE)) {
312 0 : return false;
313 : }
314 : }
315 : }
316 0 : temp.setObject(*returnArray);
317 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->targetTouches_id, temp, JSPROP_ENUMERATE)) {
318 0 : return false;
319 : }
320 0 : break;
321 : } while(0);
322 :
323 : do {
324 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
325 0 : JS::Rooted<JS::Value> temp(cx);
326 0 : Sequence<OwningNonNull<mozilla::dom::Touch>> const & currentValue = mTouches;
327 :
328 0 : uint32_t length = currentValue.Length();
329 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
330 0 : if (!returnArray) {
331 0 : return false;
332 : }
333 : // Scope for 'tmp'
334 : {
335 0 : JS::Rooted<JS::Value> tmp(cx);
336 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
337 : // Control block to let us common up the JS_DefineElement calls when there
338 : // are different ways to succeed at wrapping the object.
339 : do {
340 0 : if (!GetOrCreateDOMReflector(cx, currentValue[sequenceIdx0], &tmp)) {
341 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
342 0 : return false;
343 : }
344 0 : break;
345 : } while (0);
346 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
347 : JSPROP_ENUMERATE)) {
348 0 : return false;
349 : }
350 : }
351 : }
352 0 : temp.setObject(*returnArray);
353 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->touches_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 : TouchEventInit::TraceDictionary(JSTracer* trc)
364 : {
365 0 : EventModifierInit::TraceDictionary(trc);
366 0 : }
367 :
368 : TouchEventInit&
369 0 : TouchEventInit::operator=(const TouchEventInit& aOther)
370 : {
371 0 : EventModifierInit::operator=(aOther);
372 0 : mChangedTouches = aOther.mChangedTouches;
373 0 : mTargetTouches = aOther.mTargetTouches;
374 0 : mTouches = aOther.mTouches;
375 0 : return *this;
376 : }
377 :
378 : namespace binding_detail {
379 : } // namespace binding_detail
380 :
381 :
382 : namespace TouchEventBinding {
383 :
384 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<UIEventBinding::NativeType>::value,
385 : "Can't inherit from an interface with a different ownership model.");
386 :
387 : static bool
388 0 : get_touches(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
389 : {
390 0 : auto result(StrongOrRawPtr<mozilla::dom::TouchList>(self->Touches()));
391 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
392 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
393 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
394 0 : return false;
395 : }
396 0 : return true;
397 : }
398 :
399 : static const JSJitInfo touches_getterinfo = {
400 : { (JSJitGetterOp)get_touches },
401 : { prototypes::id::TouchEvent },
402 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
403 : JSJitInfo::Getter,
404 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
405 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
406 : false, /* isInfallible. False in setters. */
407 : false, /* isMovable. Not relevant for setters. */
408 : false, /* isEliminatable. Not relevant for setters. */
409 : false, /* isAlwaysInSlot. Only relevant for getters. */
410 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
411 : false, /* isTypedMethod. Only relevant for methods. */
412 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
413 : };
414 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
415 : static_assert(0 < 1, "There is no slot for us");
416 :
417 : static bool
418 0 : get_targetTouches(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
419 : {
420 0 : auto result(StrongOrRawPtr<mozilla::dom::TouchList>(self->TargetTouches()));
421 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
422 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
423 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
424 0 : return false;
425 : }
426 0 : return true;
427 : }
428 :
429 : static const JSJitInfo targetTouches_getterinfo = {
430 : { (JSJitGetterOp)get_targetTouches },
431 : { prototypes::id::TouchEvent },
432 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
433 : JSJitInfo::Getter,
434 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
435 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
436 : false, /* 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_changedTouches(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
449 : {
450 0 : auto result(StrongOrRawPtr<mozilla::dom::TouchList>(self->ChangedTouches()));
451 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
452 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
453 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
454 0 : return false;
455 : }
456 0 : return true;
457 : }
458 :
459 : static const JSJitInfo changedTouches_getterinfo = {
460 : { (JSJitGetterOp)get_changedTouches },
461 : { prototypes::id::TouchEvent },
462 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
463 : JSJitInfo::Getter,
464 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
465 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
466 : false, /* isInfallible. False in setters. */
467 : false, /* isMovable. Not relevant for setters. */
468 : false, /* isEliminatable. Not relevant for setters. */
469 : false, /* isAlwaysInSlot. Only relevant for getters. */
470 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
471 : false, /* isTypedMethod. Only relevant for methods. */
472 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
473 : };
474 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
475 : static_assert(0 < 1, "There is no slot for us");
476 :
477 : static bool
478 0 : get_altKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
479 : {
480 0 : bool result(self->AltKey());
481 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
482 0 : args.rval().setBoolean(result);
483 0 : return true;
484 : }
485 :
486 : static const JSJitInfo altKey_getterinfo = {
487 : { (JSJitGetterOp)get_altKey },
488 : { prototypes::id::TouchEvent },
489 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
490 : JSJitInfo::Getter,
491 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
492 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
493 : true, /* isInfallible. False in setters. */
494 : false, /* isMovable. Not relevant for setters. */
495 : false, /* isEliminatable. Not relevant for setters. */
496 : false, /* isAlwaysInSlot. Only relevant for getters. */
497 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
498 : false, /* isTypedMethod. Only relevant for methods. */
499 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
500 : };
501 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
502 : static_assert(0 < 1, "There is no slot for us");
503 :
504 : static bool
505 0 : get_metaKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
506 : {
507 0 : bool result(self->MetaKey());
508 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
509 0 : args.rval().setBoolean(result);
510 0 : return true;
511 : }
512 :
513 : static const JSJitInfo metaKey_getterinfo = {
514 : { (JSJitGetterOp)get_metaKey },
515 : { prototypes::id::TouchEvent },
516 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
517 : JSJitInfo::Getter,
518 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
519 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
520 : true, /* isInfallible. False in setters. */
521 : false, /* isMovable. Not relevant for setters. */
522 : false, /* isEliminatable. Not relevant for setters. */
523 : false, /* isAlwaysInSlot. Only relevant for getters. */
524 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
525 : false, /* isTypedMethod. Only relevant for methods. */
526 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
527 : };
528 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
529 : static_assert(0 < 1, "There is no slot for us");
530 :
531 : static bool
532 0 : get_ctrlKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
533 : {
534 0 : bool result(self->CtrlKey());
535 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
536 0 : args.rval().setBoolean(result);
537 0 : return true;
538 : }
539 :
540 : static const JSJitInfo ctrlKey_getterinfo = {
541 : { (JSJitGetterOp)get_ctrlKey },
542 : { prototypes::id::TouchEvent },
543 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
544 : JSJitInfo::Getter,
545 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
546 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
547 : true, /* isInfallible. False in setters. */
548 : false, /* isMovable. Not relevant for setters. */
549 : false, /* isEliminatable. Not relevant for setters. */
550 : false, /* isAlwaysInSlot. Only relevant for getters. */
551 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
552 : false, /* isTypedMethod. Only relevant for methods. */
553 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
554 : };
555 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
556 : static_assert(0 < 1, "There is no slot for us");
557 :
558 : static bool
559 0 : get_shiftKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
560 : {
561 0 : bool result(self->ShiftKey());
562 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
563 0 : args.rval().setBoolean(result);
564 0 : return true;
565 : }
566 :
567 : static const JSJitInfo shiftKey_getterinfo = {
568 : { (JSJitGetterOp)get_shiftKey },
569 : { prototypes::id::TouchEvent },
570 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
571 : JSJitInfo::Getter,
572 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
573 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
574 : true, /* isInfallible. False in setters. */
575 : false, /* isMovable. Not relevant for setters. */
576 : false, /* isEliminatable. Not relevant for setters. */
577 : false, /* isAlwaysInSlot. Only relevant for getters. */
578 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
579 : false, /* isTypedMethod. Only relevant for methods. */
580 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
581 : };
582 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
583 : static_assert(0 < 1, "There is no slot for us");
584 :
585 : static bool
586 0 : initTouchEvent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, const JSJitMethodCallArgs& args)
587 : {
588 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
589 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TouchEvent.initTouchEvent");
590 : }
591 0 : binding_detail::FakeString arg0;
592 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
593 0 : return false;
594 : }
595 : bool arg1;
596 0 : if (args.hasDefined(1)) {
597 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
598 0 : return false;
599 : }
600 : } else {
601 0 : arg1 = false;
602 : }
603 : bool arg2;
604 0 : if (args.hasDefined(2)) {
605 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
606 0 : return false;
607 : }
608 : } else {
609 0 : arg2 = false;
610 : }
611 : nsGlobalWindow* arg3;
612 0 : if (args.hasDefined(3)) {
613 0 : if (args[3].isObject()) {
614 : {
615 0 : nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindow>(args[3], arg3);
616 0 : if (NS_FAILED(rv)) {
617 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of TouchEvent.initTouchEvent", "Window");
618 0 : return false;
619 : }
620 : }
621 0 : } else if (args[3].isNullOrUndefined()) {
622 0 : arg3 = nullptr;
623 : } else {
624 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of TouchEvent.initTouchEvent");
625 0 : return false;
626 : }
627 : } else {
628 0 : arg3 = nullptr;
629 : }
630 : int32_t arg4;
631 0 : if (args.hasDefined(4)) {
632 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) {
633 0 : return false;
634 : }
635 : } else {
636 0 : arg4 = 0;
637 : }
638 : bool arg5;
639 0 : if (args.hasDefined(5)) {
640 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) {
641 0 : return false;
642 : }
643 : } else {
644 0 : arg5 = false;
645 : }
646 : bool arg6;
647 0 : if (args.hasDefined(6)) {
648 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[6], &arg6)) {
649 0 : return false;
650 : }
651 : } else {
652 0 : arg6 = false;
653 : }
654 : bool arg7;
655 0 : if (args.hasDefined(7)) {
656 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) {
657 0 : return false;
658 : }
659 : } else {
660 0 : arg7 = false;
661 : }
662 : bool arg8;
663 0 : if (args.hasDefined(8)) {
664 0 : if (!ValueToPrimitive<bool, eDefault>(cx, args[8], &arg8)) {
665 0 : return false;
666 : }
667 : } else {
668 0 : arg8 = false;
669 : }
670 : mozilla::dom::TouchList* arg9;
671 0 : if (args.hasDefined(9)) {
672 0 : if (args[9].isObject()) {
673 : {
674 0 : nsresult rv = UnwrapObject<prototypes::id::TouchList, mozilla::dom::TouchList>(args[9], arg9);
675 0 : if (NS_FAILED(rv)) {
676 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 10 of TouchEvent.initTouchEvent", "TouchList");
677 0 : return false;
678 : }
679 : }
680 0 : } else if (args[9].isNullOrUndefined()) {
681 0 : arg9 = nullptr;
682 : } else {
683 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 10 of TouchEvent.initTouchEvent");
684 0 : return false;
685 : }
686 : } else {
687 0 : arg9 = nullptr;
688 : }
689 : mozilla::dom::TouchList* arg10;
690 0 : if (args.hasDefined(10)) {
691 0 : if (args[10].isObject()) {
692 : {
693 0 : nsresult rv = UnwrapObject<prototypes::id::TouchList, mozilla::dom::TouchList>(args[10], arg10);
694 0 : if (NS_FAILED(rv)) {
695 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 11 of TouchEvent.initTouchEvent", "TouchList");
696 0 : return false;
697 : }
698 : }
699 0 : } else if (args[10].isNullOrUndefined()) {
700 0 : arg10 = nullptr;
701 : } else {
702 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 11 of TouchEvent.initTouchEvent");
703 0 : return false;
704 : }
705 : } else {
706 0 : arg10 = nullptr;
707 : }
708 : mozilla::dom::TouchList* arg11;
709 0 : if (args.hasDefined(11)) {
710 0 : if (args[11].isObject()) {
711 : {
712 0 : nsresult rv = UnwrapObject<prototypes::id::TouchList, mozilla::dom::TouchList>(args[11], arg11);
713 0 : if (NS_FAILED(rv)) {
714 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 12 of TouchEvent.initTouchEvent", "TouchList");
715 0 : return false;
716 : }
717 : }
718 0 : } else if (args[11].isNullOrUndefined()) {
719 0 : arg11 = nullptr;
720 : } else {
721 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 12 of TouchEvent.initTouchEvent");
722 0 : return false;
723 : }
724 : } else {
725 0 : arg11 = nullptr;
726 : }
727 0 : self->InitTouchEvent(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), arg4, arg5, arg6, arg7, arg8, Constify(arg9), Constify(arg10), Constify(arg11));
728 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
729 0 : args.rval().setUndefined();
730 0 : return true;
731 : }
732 :
733 : static const JSJitInfo initTouchEvent_methodinfo = {
734 : { (JSJitGetterOp)initTouchEvent },
735 : { prototypes::id::TouchEvent },
736 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
737 : JSJitInfo::Method,
738 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
739 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
740 : false, /* isInfallible. False in setters. */
741 : false, /* isMovable. Not relevant for setters. */
742 : false, /* isEliminatable. Not relevant for setters. */
743 : false, /* isAlwaysInSlot. Only relevant for getters. */
744 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
745 : false, /* isTypedMethod. Only relevant for methods. */
746 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
747 : };
748 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
749 : static_assert(0 < 1, "There is no slot for us");
750 :
751 : static bool
752 0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TouchEvent* self, JSJitGetterCallArgs args)
753 : {
754 0 : bool result(self->IsTrusted());
755 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
756 0 : args.rval().setBoolean(result);
757 0 : return true;
758 : }
759 :
760 : static const JSJitInfo isTrusted_getterinfo = {
761 : { (JSJitGetterOp)get_isTrusted },
762 : { prototypes::id::TouchEvent },
763 : { PrototypeTraits<prototypes::id::TouchEvent>::Depth },
764 : JSJitInfo::Getter,
765 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
766 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
767 : true, /* isInfallible. False in setters. */
768 : true, /* isMovable. Not relevant for setters. */
769 : true, /* isEliminatable. Not relevant for setters. */
770 : false, /* isAlwaysInSlot. Only relevant for getters. */
771 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
772 : false, /* isTypedMethod. Only relevant for methods. */
773 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
774 : };
775 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
776 : static_assert(0 < 1, "There is no slot for us");
777 :
778 : static bool
779 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
780 : {
781 0 : mozilla::dom::TouchEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TouchEvent>(obj);
782 : // We don't want to preserve if we don't have a wrapper, and we
783 : // obviously can't preserve if we're not initialized.
784 0 : if (self && self->GetWrapperPreserveColor()) {
785 0 : PreserveWrapper(self);
786 : }
787 0 : return true;
788 : }
789 :
790 : static void
791 0 : _finalize(js::FreeOp* fop, JSObject* obj)
792 : {
793 0 : mozilla::dom::TouchEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TouchEvent>(obj);
794 0 : if (self) {
795 0 : ClearWrapper(self, self, obj);
796 0 : AddForDeferredFinalization<mozilla::dom::TouchEvent>(self);
797 : }
798 0 : }
799 :
800 : static void
801 0 : _objectMoved(JSObject* obj, const JSObject* old)
802 : {
803 0 : mozilla::dom::TouchEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TouchEvent>(obj);
804 0 : if (self) {
805 0 : UpdateWrapper(self, self, obj, old);
806 : }
807 0 : }
808 :
809 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
810 : #if defined(__clang__)
811 : #pragma clang diagnostic push
812 : #pragma clang diagnostic ignored "-Wmissing-braces"
813 : #endif
814 : static const JSFunctionSpec sMethods_specs[] = {
815 : JS_FNSPEC("initTouchEvent", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initTouchEvent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
816 : JS_FS_END
817 : };
818 : #if defined(__clang__)
819 : #pragma clang diagnostic pop
820 : #endif
821 :
822 :
823 : // Can't be const because the pref-enabled boolean needs to be writable
824 : static Prefable<const JSFunctionSpec> sMethods[] = {
825 : { nullptr, &sMethods_specs[0] },
826 : { nullptr, nullptr }
827 : };
828 :
829 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
830 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
831 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
832 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
833 :
834 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
835 : #if defined(__clang__)
836 : #pragma clang diagnostic push
837 : #pragma clang diagnostic ignored "-Wmissing-braces"
838 : #endif
839 : static const JSPropertySpec sAttributes_specs[] = {
840 : { "touches", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &touches_getterinfo, nullptr, nullptr },
841 : { "targetTouches", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &targetTouches_getterinfo, nullptr, nullptr },
842 : { "changedTouches", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &changedTouches_getterinfo, nullptr, nullptr },
843 : { "altKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &altKey_getterinfo, nullptr, nullptr },
844 : { "metaKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &metaKey_getterinfo, nullptr, nullptr },
845 : { "ctrlKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ctrlKey_getterinfo, nullptr, nullptr },
846 : { "shiftKey", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &shiftKey_getterinfo, nullptr, nullptr },
847 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
848 : };
849 : #if defined(__clang__)
850 : #pragma clang diagnostic pop
851 : #endif
852 :
853 :
854 : // Can't be const because the pref-enabled boolean needs to be writable
855 : static Prefable<const JSPropertySpec> sAttributes[] = {
856 : { nullptr, &sAttributes_specs[0] },
857 : { nullptr, nullptr }
858 : };
859 :
860 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
861 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
862 : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
863 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
864 :
865 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
866 : #if defined(__clang__)
867 : #pragma clang diagnostic push
868 : #pragma clang diagnostic ignored "-Wmissing-braces"
869 : #endif
870 : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
871 : { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
872 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
873 : };
874 : #if defined(__clang__)
875 : #pragma clang diagnostic pop
876 : #endif
877 :
878 :
879 : // Can't be const because the pref-enabled boolean needs to be writable
880 : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
881 : { nullptr, &sUnforgeableAttributes_specs[0] },
882 : { nullptr, nullptr }
883 : };
884 :
885 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
886 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
887 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
888 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
889 :
890 :
891 : static uint16_t sNativeProperties_sortedPropertyIndices[9];
892 : static PropertyInfo sNativeProperties_propertyInfos[9];
893 :
894 : static const NativePropertiesN<3> sNativeProperties = {
895 : false, 0,
896 : false, 0,
897 : true, 0 /* sMethods */,
898 : true, 1 /* sAttributes */,
899 : false, 0,
900 : true, 2 /* sUnforgeableAttributes */,
901 : false, 0,
902 : -1,
903 : 9,
904 : sNativeProperties_sortedPropertyIndices,
905 : {
906 : { sMethods, &sNativeProperties_propertyInfos[0] },
907 : { sAttributes, &sNativeProperties_propertyInfos[1] },
908 : { sUnforgeableAttributes, &sNativeProperties_propertyInfos[8] }
909 : }
910 : };
911 : static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
912 : "We have a property info count that is oversized");
913 :
914 : static bool
915 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
916 : {
917 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
918 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
919 0 : if (!args.isConstructing()) {
920 : // XXXbz wish I could get the name from the callee instead of
921 : // Adding more relocations
922 0 : return ThrowConstructorWithoutNew(cx, "TouchEvent");
923 : }
924 :
925 0 : GlobalObject global(cx, obj);
926 0 : if (global.Failed()) {
927 0 : return false;
928 : }
929 :
930 0 : JS::Rooted<JSObject*> desiredProto(cx);
931 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
932 0 : return false;
933 : }
934 :
935 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
936 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TouchEvent");
937 : }
938 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
939 0 : binding_detail::FakeString arg0;
940 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
941 0 : return false;
942 : }
943 0 : binding_detail::FastTouchEventInit arg1;
944 0 : if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of TouchEvent.constructor", false)) {
945 0 : return false;
946 : }
947 0 : Maybe<JSAutoCompartment> ac;
948 0 : if (objIsXray) {
949 0 : obj = js::CheckedUnwrap(obj);
950 0 : if (!obj) {
951 0 : return false;
952 : }
953 0 : ac.emplace(cx, obj);
954 0 : if (!JS_WrapObject(cx, &desiredProto)) {
955 0 : return false;
956 : }
957 : }
958 0 : binding_detail::FastErrorResult rv;
959 0 : auto result(StrongOrRawPtr<mozilla::dom::TouchEvent>(mozilla::dom::TouchEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
960 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
961 0 : return false;
962 : }
963 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
964 : static_assert(!IsPointer<decltype(result)>::value,
965 : "NewObject implies that we need to keep the object alive with a strong reference.");
966 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
967 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
968 0 : return false;
969 : }
970 0 : return true;
971 : }
972 :
973 : static const js::ClassOps sInterfaceObjectClassOps = {
974 : nullptr, /* addProperty */
975 : nullptr, /* delProperty */
976 : nullptr, /* getProperty */
977 : nullptr, /* setProperty */
978 : nullptr, /* enumerate */
979 : nullptr, /* newEnumerate */
980 : nullptr, /* resolve */
981 : nullptr, /* mayResolve */
982 : nullptr, /* finalize */
983 : _constructor, /* call */
984 : nullptr, /* hasInstance */
985 : _constructor, /* construct */
986 : nullptr, /* trace */
987 : };
988 :
989 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
990 : {
991 : "Function",
992 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
993 : &sInterfaceObjectClassOps,
994 : JS_NULL_CLASS_SPEC,
995 : JS_NULL_CLASS_EXT,
996 : &sInterfaceObjectClassObjectOps
997 : },
998 : eInterface,
999 : true,
1000 : prototypes::id::TouchEvent,
1001 : PrototypeTraits<prototypes::id::TouchEvent>::Depth,
1002 : sNativePropertyHooks,
1003 : "function TouchEvent() {\n [native code]\n}",
1004 : UIEventBinding::GetConstructorObject
1005 : };
1006 :
1007 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1008 : {
1009 : "TouchEventPrototype",
1010 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
1011 : JS_NULL_CLASS_OPS,
1012 : JS_NULL_CLASS_SPEC,
1013 : JS_NULL_CLASS_EXT,
1014 : JS_NULL_OBJECT_OPS
1015 : },
1016 : eInterfacePrototype,
1017 : false,
1018 : prototypes::id::TouchEvent,
1019 : PrototypeTraits<prototypes::id::TouchEvent>::Depth,
1020 : sNativePropertyHooks,
1021 : "[object TouchEventPrototype]",
1022 : UIEventBinding::GetProtoObject
1023 : };
1024 :
1025 : bool
1026 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1027 : {
1028 0 : return mozilla::dom::TouchEvent::PrefEnabled(aCx, aObj);
1029 : }
1030 :
1031 : JSObject*
1032 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1033 : {
1034 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1035 : }
1036 :
1037 : static const js::ClassOps sClassOps = {
1038 : _addProperty, /* addProperty */
1039 : nullptr, /* delProperty */
1040 : nullptr, /* getProperty */
1041 : nullptr, /* setProperty */
1042 : nullptr, /* enumerate */
1043 : nullptr, /* newEnumerate */
1044 : nullptr, /* resolve */
1045 : nullptr, /* mayResolve */
1046 : _finalize, /* finalize */
1047 : nullptr, /* call */
1048 : nullptr, /* hasInstance */
1049 : nullptr, /* construct */
1050 : nullptr, /* trace */
1051 : };
1052 :
1053 : static const js::ClassExtension sClassExtension = {
1054 : nullptr, /* weakmapKeyDelegateOp */
1055 : _objectMoved /* objectMovedOp */
1056 : };
1057 :
1058 : static const DOMJSClass sClass = {
1059 : { "TouchEvent",
1060 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
1061 : &sClassOps,
1062 : JS_NULL_CLASS_SPEC,
1063 : &sClassExtension,
1064 : JS_NULL_OBJECT_OPS
1065 : },
1066 : { prototypes::id::Event, prototypes::id::UIEvent, prototypes::id::TouchEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1067 : IsBaseOf<nsISupports, mozilla::dom::TouchEvent >::value,
1068 : sNativePropertyHooks,
1069 : FindAssociatedGlobalForNative<mozilla::dom::TouchEvent>::Get,
1070 : GetProtoObjectHandle,
1071 : GetCCParticipant<mozilla::dom::TouchEvent>::Get()
1072 : };
1073 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1074 : "Must have the right minimal number of reserved slots.");
1075 : static_assert(1 >= 1,
1076 : "Must have enough reserved slots.");
1077 :
1078 : const JSClass*
1079 0 : GetJSClass()
1080 : {
1081 0 : return sClass.ToJSClass();
1082 : }
1083 :
1084 : bool
1085 0 : Wrap(JSContext* aCx, mozilla::dom::TouchEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1086 : {
1087 : MOZ_ASSERT(static_cast<mozilla::dom::TouchEvent*>(aObject) ==
1088 : reinterpret_cast<mozilla::dom::TouchEvent*>(aObject),
1089 : "Multiple inheritance for mozilla::dom::TouchEvent is broken.");
1090 : MOZ_ASSERT(static_cast<mozilla::dom::UIEvent*>(aObject) ==
1091 : reinterpret_cast<mozilla::dom::UIEvent*>(aObject),
1092 : "Multiple inheritance for mozilla::dom::UIEvent is broken.");
1093 : MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
1094 : reinterpret_cast<mozilla::dom::Event*>(aObject),
1095 : "Multiple inheritance for mozilla::dom::Event is broken.");
1096 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1097 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1098 0 : MOZ_ASSERT(!aCache->GetWrapper(),
1099 : "You should probably not be using Wrap() directly; use "
1100 : "GetOrCreateDOMReflector instead");
1101 :
1102 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1103 : "nsISupports must be on our primary inheritance chain");
1104 :
1105 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1106 0 : if (!global) {
1107 0 : return false;
1108 : }
1109 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
1110 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1111 :
1112 : // That might have ended up wrapping us already, due to the wonders
1113 : // of XBL. Check for that, and bail out as needed.
1114 0 : aReflector.set(aCache->GetWrapper());
1115 0 : if (aReflector) {
1116 : #ifdef DEBUG
1117 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1118 : #endif // DEBUG
1119 0 : return true;
1120 : }
1121 :
1122 0 : JSAutoCompartment ac(aCx, global);
1123 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1124 0 : if (!canonicalProto) {
1125 0 : return false;
1126 : }
1127 0 : JS::Rooted<JSObject*> proto(aCx);
1128 0 : if (aGivenProto) {
1129 0 : proto = aGivenProto;
1130 : // Unfortunately, while aGivenProto was in the compartment of aCx
1131 : // coming in, we changed compartments to that of "parent" so may need
1132 : // to wrap the proto here.
1133 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1134 0 : if (!JS_WrapObject(aCx, &proto)) {
1135 0 : return false;
1136 : }
1137 : }
1138 : } else {
1139 0 : proto = canonicalProto;
1140 : }
1141 :
1142 0 : BindingJSObjectCreator<mozilla::dom::TouchEvent> creator(aCx);
1143 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1144 0 : if (!aReflector) {
1145 0 : return false;
1146 : }
1147 :
1148 0 : aCache->SetWrapper(aReflector);
1149 :
1150 : // Important: do unforgeable property setup after we have handed
1151 : // over ownership of the C++ object to obj as needed, so that if
1152 : // we fail and it ends up GCed it won't have problems in the
1153 : // finalizer trying to drop its ownership of the C++ object.
1154 : JS::Rooted<JSObject*> unforgeableHolder(aCx,
1155 0 : &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
1156 0 : if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
1157 0 : aCache->ReleaseWrapper(aObject);
1158 0 : aCache->ClearWrapper();
1159 0 : return false;
1160 : }
1161 0 : creator.InitializationSucceeded();
1162 :
1163 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1164 : aCache->GetWrapperPreserveColor() == aReflector);
1165 : // If proto != canonicalProto, we have to preserve our wrapper;
1166 : // otherwise we won't be able to properly recreate it later, since
1167 : // we won't know what proto to use. Note that we don't check
1168 : // aGivenProto here, since it's entirely possible (and even
1169 : // somewhat common) to have a non-null aGivenProto which is the
1170 : // same as canonicalProto.
1171 0 : if (proto != canonicalProto) {
1172 0 : PreserveWrapper(aObject);
1173 : }
1174 :
1175 0 : return true;
1176 : }
1177 :
1178 : const NativePropertyHooks sNativePropertyHooks[] = { {
1179 : nullptr,
1180 : nullptr,
1181 : nullptr,
1182 : { sNativeProperties.Upcast(), nullptr },
1183 : prototypes::id::TouchEvent,
1184 : constructors::id::TouchEvent,
1185 : UIEventBinding::sNativePropertyHooks,
1186 : &DefaultXrayExpandoObjectClass
1187 : } };
1188 :
1189 : void
1190 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1191 : {
1192 0 : JS::Handle<JSObject*> parentProto(UIEventBinding::GetProtoObjectHandle(aCx));
1193 0 : if (!parentProto) {
1194 0 : return;
1195 : }
1196 :
1197 0 : JS::Handle<JSObject*> constructorProto(UIEventBinding::GetConstructorObjectHandle(aCx));
1198 0 : if (!constructorProto) {
1199 0 : return;
1200 : }
1201 :
1202 : static bool sIdsInited = false;
1203 0 : if (!sIdsInited && NS_IsMainThread()) {
1204 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1205 0 : return;
1206 : }
1207 0 : sIdsInited = true;
1208 : }
1209 :
1210 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TouchEvent);
1211 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TouchEvent);
1212 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1213 : &sPrototypeClass.mBase, protoCache,
1214 : constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1215 : interfaceCache,
1216 : sNativeProperties.Upcast(),
1217 : nullptr,
1218 : "TouchEvent", aDefineOnGlobal,
1219 : nullptr,
1220 0 : false);
1221 :
1222 0 : JS::Rooted<JSObject*> unforgeableHolder(aCx);
1223 : {
1224 0 : JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
1225 0 : unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
1226 0 : if (!unforgeableHolder) {
1227 0 : *protoCache = nullptr;
1228 0 : if (interfaceCache) {
1229 0 : *interfaceCache = nullptr;
1230 : }
1231 0 : return;
1232 : }
1233 : }
1234 :
1235 0 : if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
1236 0 : *protoCache = nullptr;
1237 0 : if (interfaceCache) {
1238 0 : *interfaceCache = nullptr;
1239 : }
1240 0 : return;
1241 : }
1242 :
1243 0 : if (*protoCache) {
1244 0 : js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
1245 0 : JS::ObjectValue(*unforgeableHolder));
1246 : }
1247 : }
1248 :
1249 : JS::Handle<JSObject*>
1250 0 : GetProtoObjectHandle(JSContext* aCx)
1251 : {
1252 : /* Get the interface prototype object for this class. This will create the
1253 : object as needed. */
1254 0 : bool aDefineOnGlobal = true;
1255 :
1256 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1257 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1258 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1259 0 : return nullptr;
1260 : }
1261 :
1262 : /* Check to see whether the interface objects are already installed */
1263 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1264 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::TouchEvent)) {
1265 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1266 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1267 : }
1268 :
1269 : /*
1270 : * The object might _still_ be null, but that's OK.
1271 : *
1272 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1273 : * traced by TraceProtoAndIfaceCache() and its contents are never
1274 : * changed after they have been set.
1275 : *
1276 : * Calling address() avoids the read read barrier that does gray
1277 : * unmarking, but it's not possible for the object to be gray here.
1278 : */
1279 :
1280 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::TouchEvent);
1281 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1282 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1283 : }
1284 :
1285 : JS::Handle<JSObject*>
1286 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1287 : {
1288 : /* Get the interface object for this class. This will create the object as
1289 : needed. */
1290 :
1291 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1292 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1293 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1294 0 : return nullptr;
1295 : }
1296 :
1297 : /* Check to see whether the interface objects are already installed */
1298 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1299 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::TouchEvent)) {
1300 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1301 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1302 : }
1303 :
1304 : /*
1305 : * The object might _still_ be null, but that's OK.
1306 : *
1307 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1308 : * traced by TraceProtoAndIfaceCache() and its contents are never
1309 : * changed after they have been set.
1310 : *
1311 : * Calling address() avoids the read read barrier that does gray
1312 : * unmarking, but it's not possible for the object to be gray here.
1313 : */
1314 :
1315 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::TouchEvent);
1316 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1317 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1318 : }
1319 :
1320 : JSObject*
1321 0 : GetConstructorObject(JSContext* aCx)
1322 : {
1323 0 : return GetConstructorObjectHandle(aCx);
1324 : }
1325 :
1326 : } // namespace TouchEventBinding
1327 :
1328 :
1329 :
1330 : } // namespace dom
1331 : } // namespace mozilla
|