Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/VRDisplayBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM VRDisplay.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "EventTargetBinding.h"
5
#include "VRDisplayBinding.h"
6
#include "WindowBinding.h"
7
#include "WrapperFactory.h"
8
#include "jsapi.h"
9
#include "jsfriendapi.h"
10
#include "mozilla/FloatingPoint.h"
11
#include "mozilla/OwningNonNull.h"
12
#include "mozilla/Preferences.h"
13
#include "mozilla/dom/BindingUtils.h"
14
#include "mozilla/dom/DOMJSClass.h"
15
#include "mozilla/dom/NonRefcountedDOMObject.h"
16
#include "mozilla/dom/Nullable.h"
17
#include "mozilla/dom/PrimitiveConversions.h"
18
#include "mozilla/dom/Promise.h"
19
#include "mozilla/dom/ScriptSettings.h"
20
#include "mozilla/dom/ToJSValue.h"
21
#include "mozilla/dom/TypedArray.h"
22
#include "mozilla/dom/VRDisplay.h"
23
#include "mozilla/dom/XrayExpandoClass.h"
24
#include "nsContentUtils.h"
25
26
namespace mozilla {
27
namespace dom {
28
29
namespace binding_detail {}; // Just to make sure it's known as a namespace
30
using namespace mozilla::dom::binding_detail;
31
32
33
namespace VREyeValues {
34
extern const EnumEntry strings[3] = {
35
  {"left", 4},
36
  {"right", 5},
37
  { nullptr, 0 }
38
};
39
} // namespace VREyeValues
40
41
bool
42
ToJSValue(JSContext* aCx, VREye aArgument, JS::MutableHandle<JS::Value> aValue)
43
0
{
44
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(VREyeValues::strings));
45
0
  JSString* resultStr =
46
0
    JS_NewStringCopyN(aCx, VREyeValues::strings[uint32_t(aArgument)].value,
47
0
                      VREyeValues::strings[uint32_t(aArgument)].length);
48
0
  if (!resultStr) {
49
0
    return false;
50
0
  }
51
0
  aValue.setString(resultStr);
52
0
  return true;
53
0
}
54
55
56
57
VRLayer::VRLayer()
58
0
{
59
0
  // Safe to pass a null context if we pass a null value
60
0
  Init(nullptr, JS::NullHandleValue);
61
0
}
62
63
64
65
bool
66
VRLayer::InitIds(JSContext* cx, VRLayerAtoms* atomsCache)
67
0
{
68
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
69
0
70
0
  // Initialize these in reverse order so that any failure leaves the first one
71
0
  // uninitialized.
72
0
  if (!atomsCache->source_id.init(cx, "source") ||
73
0
      !atomsCache->rightBounds_id.init(cx, "rightBounds") ||
74
0
      !atomsCache->leftBounds_id.init(cx, "leftBounds")) {
75
0
    return false;
76
0
  }
77
0
  return true;
78
0
}
79
80
bool
81
VRLayer::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
82
0
{
83
0
  // Passing a null JSContext is OK only if we're initing from null,
84
0
  // Since in that case we will not have to do any property gets
85
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
86
0
  // checkers by static analysis tools
87
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
88
0
  VRLayerAtoms* atomsCache = nullptr;
89
0
  if (cx) {
90
0
    atomsCache = GetAtomCache<VRLayerAtoms>(cx);
91
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
92
0
      return false;
93
0
    }
94
0
  }
95
0
96
0
  if (!IsConvertibleToDictionary(val)) {
97
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
98
0
  }
99
0
100
0
  bool isNull = val.isNullOrUndefined();
101
0
  // We only need these if !isNull, in which case we have |cx|.
102
0
  Maybe<JS::Rooted<JSObject *> > object;
103
0
  Maybe<JS::Rooted<JS::Value> > temp;
104
0
  if (!isNull) {
105
0
    MOZ_ASSERT(cx);
106
0
    object.emplace(cx, &val.toObject());
107
0
    temp.emplace(cx);
108
0
  }
109
0
  if (!isNull) {
110
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->leftBounds_id, temp.ptr())) {
111
0
      return false;
112
0
    }
113
0
  }
114
0
  if (!isNull && !temp->isUndefined()) {
115
0
    if (temp.ref().isObject()) {
116
0
      JS::ForOfIterator iter(cx);
117
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
118
0
        return false;
119
0
      }
120
0
      if (!iter.valueIsIterable()) {
121
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'leftBounds' member of VRLayer");
122
0
        return false;
123
0
      }
124
0
      Sequence<float> &arr = mLeftBounds;
125
0
      JS::Rooted<JS::Value> temp(cx);
126
0
      while (true) {
127
0
        bool done;
128
0
        if (!iter.next(&temp, &done)) {
129
0
          return false;
130
0
        }
131
0
        if (done) {
132
0
          break;
133
0
        }
134
0
        float* slotPtr = arr.AppendElement(mozilla::fallible);
135
0
        if (!slotPtr) {
136
0
          JS_ReportOutOfMemory(cx);
137
0
          return false;
138
0
        }
139
0
        float& slot = *slotPtr;
140
0
        if (!ValueToPrimitive<float, eDefault>(cx, temp, &slot)) {
141
0
          return false;
142
0
        } else if (!mozilla::IsFinite(slot)) {
143
0
          ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of 'leftBounds' member of VRLayer");
144
0
          return false;
145
0
        }
146
0
      }
147
0
    } else {
148
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'leftBounds' member of VRLayer");
149
0
      return false;
150
0
    }
151
0
  } else {
152
0
    /* Array is already empty; nothing to do */
153
0
  }
154
0
  mIsAnyMemberPresent = true;
155
0
156
0
  if (!isNull) {
157
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->rightBounds_id, temp.ptr())) {
158
0
      return false;
159
0
    }
160
0
  }
161
0
  if (!isNull && !temp->isUndefined()) {
162
0
    if (temp.ref().isObject()) {
163
0
      JS::ForOfIterator iter(cx);
164
0
      if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
165
0
        return false;
166
0
      }
167
0
      if (!iter.valueIsIterable()) {
168
0
        ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'rightBounds' member of VRLayer");
169
0
        return false;
170
0
      }
171
0
      Sequence<float> &arr = mRightBounds;
172
0
      JS::Rooted<JS::Value> temp(cx);
173
0
      while (true) {
174
0
        bool done;
175
0
        if (!iter.next(&temp, &done)) {
176
0
          return false;
177
0
        }
178
0
        if (done) {
179
0
          break;
180
0
        }
181
0
        float* slotPtr = arr.AppendElement(mozilla::fallible);
182
0
        if (!slotPtr) {
183
0
          JS_ReportOutOfMemory(cx);
184
0
          return false;
185
0
        }
186
0
        float& slot = *slotPtr;
187
0
        if (!ValueToPrimitive<float, eDefault>(cx, temp, &slot)) {
188
0
          return false;
189
0
        } else if (!mozilla::IsFinite(slot)) {
190
0
          ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of 'rightBounds' member of VRLayer");
191
0
          return false;
192
0
        }
193
0
      }
194
0
    } else {
195
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'rightBounds' member of VRLayer");
196
0
      return false;
197
0
    }
198
0
  } else {
199
0
    /* Array is already empty; nothing to do */
200
0
  }
201
0
  mIsAnyMemberPresent = true;
202
0
203
0
  if (!isNull) {
204
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->source_id, temp.ptr())) {
205
0
      return false;
206
0
    }
207
0
  }
208
0
  if (!isNull && !temp->isUndefined()) {
209
0
    if (temp.ref().isObject()) {
210
0
      static_assert(IsRefcounted<mozilla::dom::HTMLCanvasElement>::value, "We can only store refcounted classes.");{
211
0
        nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(temp.ptr(), mSource);
212
0
        if (NS_FAILED(rv)) {
213
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'source' member of VRLayer", "HTMLCanvasElement");
214
0
          return false;
215
0
        }
216
0
      }
217
0
    } else if (temp.ref().isNullOrUndefined()) {
218
0
      mSource = nullptr;
219
0
    } else {
220
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'source' member of VRLayer");
221
0
      return false;
222
0
    }
223
0
  } else {
224
0
    mSource = nullptr;
225
0
  }
226
0
  mIsAnyMemberPresent = true;
227
0
  return true;
228
0
}
229
230
bool
231
VRLayer::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
232
0
{
233
0
  VRLayerAtoms* atomsCache = GetAtomCache<VRLayerAtoms>(cx);
234
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
235
0
    return false;
236
0
  }
237
0
238
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
239
0
  if (!obj) {
240
0
    return false;
241
0
  }
242
0
  rval.set(JS::ObjectValue(*obj));
243
0
244
0
  do {
245
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
246
0
    JS::Rooted<JS::Value> temp(cx);
247
0
    Sequence<float> const & currentValue = mLeftBounds;
248
0
249
0
    uint32_t length = currentValue.Length();
250
0
    JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
251
0
    if (!returnArray) {
252
0
      return false;
253
0
    }
254
0
    // Scope for 'tmp'
255
0
    {
256
0
      JS::Rooted<JS::Value> tmp(cx);
257
0
      for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
258
0
        // Control block to let us common up the JS_DefineElement calls when there
259
0
        // are different ways to succeed at wrapping the object.
260
0
        do {
261
0
          tmp.set(JS_NumberValue(double(currentValue[sequenceIdx0])));
262
0
          break;
263
0
        } while (false);
264
0
        if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
265
0
                              JSPROP_ENUMERATE)) {
266
0
          return false;
267
0
        }
268
0
      }
269
0
    }
270
0
    temp.setObject(*returnArray);
271
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->leftBounds_id, temp, JSPROP_ENUMERATE)) {
272
0
      return false;
273
0
    }
274
0
    break;
275
0
  } while(false);
276
0
277
0
  do {
278
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
279
0
    JS::Rooted<JS::Value> temp(cx);
280
0
    Sequence<float> const & currentValue = mRightBounds;
281
0
282
0
    uint32_t length = currentValue.Length();
283
0
    JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
284
0
    if (!returnArray) {
285
0
      return false;
286
0
    }
287
0
    // Scope for 'tmp'
288
0
    {
289
0
      JS::Rooted<JS::Value> tmp(cx);
290
0
      for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
291
0
        // Control block to let us common up the JS_DefineElement calls when there
292
0
        // are different ways to succeed at wrapping the object.
293
0
        do {
294
0
          tmp.set(JS_NumberValue(double(currentValue[sequenceIdx0])));
295
0
          break;
296
0
        } while (false);
297
0
        if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
298
0
                              JSPROP_ENUMERATE)) {
299
0
          return false;
300
0
        }
301
0
      }
302
0
    }
303
0
    temp.setObject(*returnArray);
304
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->rightBounds_id, temp, JSPROP_ENUMERATE)) {
305
0
      return false;
306
0
    }
307
0
    break;
308
0
  } while(false);
309
0
310
0
  do {
311
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
312
0
    JS::Rooted<JS::Value> temp(cx);
313
0
    RefPtr<mozilla::dom::HTMLCanvasElement> const & currentValue = mSource;
314
0
    if (!currentValue) {
315
0
      temp.setNull();
316
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->source_id, temp, JSPROP_ENUMERATE)) {
317
0
        return false;
318
0
      }
319
0
      break;
320
0
    }
321
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
322
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
323
0
      return false;
324
0
    }
325
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->source_id, temp, JSPROP_ENUMERATE)) {
326
0
      return false;
327
0
    }
328
0
    break;
329
0
  } while(false);
330
0
331
0
  return true;
332
0
}
333
334
void
335
VRLayer::TraceDictionary(JSTracer* trc)
336
0
{
337
0
}
338
339
340
341
VRLayer&
342
VRLayer::operator=(const VRLayer& aOther)
343
0
{
344
0
  DictionaryBase::operator=(aOther);
345
0
  mLeftBounds = aOther.mLeftBounds;
346
0
  mRightBounds = aOther.mRightBounds;
347
0
  mSource = aOther.mSource;
348
0
  return *this;
349
0
}
350
351
namespace binding_detail {
352
} // namespace binding_detail
353
354
355
namespace VRDisplay_Binding {
356
357
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
358
              "Can't inherit from an interface with a different ownership model.");
359
360
MOZ_CAN_RUN_SCRIPT static bool
361
get_presentingGroups(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
362
0
{
363
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.presentingGroups", DOM, cx);
364
0
365
0
  uint32_t result(self->PresentingGroups());
366
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
367
0
  args.rval().setNumber(result);
368
0
  return true;
369
0
}
370
371
static const JSJitInfo presentingGroups_getterinfo = {
372
  { (JSJitGetterOp)get_presentingGroups },
373
  { prototypes::id::VRDisplay },
374
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
375
  JSJitInfo::Getter,
376
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
377
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
378
  true,  /* isInfallible. False in setters. */
379
  false,  /* isMovable.  Not relevant for setters. */
380
  false, /* isEliminatable.  Not relevant for setters. */
381
  false, /* isAlwaysInSlot.  Only relevant for getters. */
382
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
383
  false,  /* isTypedMethod.  Only relevant for methods. */
384
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
385
};
386
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
387
static_assert(0 < 1, "There is no slot for us");
388
389
MOZ_CAN_RUN_SCRIPT static bool
390
get_groupMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
391
0
{
392
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.groupMask", DOM, cx);
393
0
394
0
  uint32_t result(self->GroupMask());
395
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
396
0
  args.rval().setNumber(result);
397
0
  return true;
398
0
}
399
400
MOZ_CAN_RUN_SCRIPT static bool
401
set_groupMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitSetterCallArgs args)
402
0
{
403
0
  AUTO_PROFILER_LABEL_FAST("set VRDisplay.groupMask", DOM, cx);
404
0
405
0
  uint32_t arg0;
406
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
407
0
    return false;
408
0
  }
409
0
  self->SetGroupMask(arg0);
410
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
411
0
412
0
  return true;
413
0
}
414
415
static const JSJitInfo groupMask_getterinfo = {
416
  { (JSJitGetterOp)get_groupMask },
417
  { prototypes::id::VRDisplay },
418
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
419
  JSJitInfo::Getter,
420
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
421
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
422
  true,  /* isInfallible. False in setters. */
423
  false,  /* isMovable.  Not relevant for setters. */
424
  false, /* isEliminatable.  Not relevant for setters. */
425
  false, /* isAlwaysInSlot.  Only relevant for getters. */
426
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
427
  false,  /* isTypedMethod.  Only relevant for methods. */
428
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
429
};
430
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
431
static_assert(0 < 1, "There is no slot for us");
432
static const JSJitInfo groupMask_setterinfo = {
433
  { (JSJitGetterOp)set_groupMask },
434
  { prototypes::id::VRDisplay },
435
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
436
  JSJitInfo::Setter,
437
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
438
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
439
  false,  /* isInfallible. False in setters. */
440
  false,  /* isMovable.  Not relevant for setters. */
441
  false, /* isEliminatable.  Not relevant for setters. */
442
  false, /* isAlwaysInSlot.  Only relevant for getters. */
443
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
444
  false,  /* isTypedMethod.  Only relevant for methods. */
445
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
446
};
447
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
448
static_assert(0 < 1, "There is no slot for us");
449
450
MOZ_CAN_RUN_SCRIPT static bool
451
get_isConnected(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
452
0
{
453
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.isConnected", DOM, cx);
454
0
455
0
  bool result(self->IsConnected());
456
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
457
0
  args.rval().setBoolean(result);
458
0
  return true;
459
0
}
460
461
static const JSJitInfo isConnected_getterinfo = {
462
  { (JSJitGetterOp)get_isConnected },
463
  { prototypes::id::VRDisplay },
464
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
465
  JSJitInfo::Getter,
466
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
467
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
468
  true,  /* isInfallible. False in setters. */
469
  false,  /* isMovable.  Not relevant for setters. */
470
  false, /* isEliminatable.  Not relevant for setters. */
471
  false, /* isAlwaysInSlot.  Only relevant for getters. */
472
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
473
  false,  /* isTypedMethod.  Only relevant for methods. */
474
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
475
};
476
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
477
static_assert(0 < 1, "There is no slot for us");
478
479
MOZ_CAN_RUN_SCRIPT static bool
480
get_isPresenting(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
481
0
{
482
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.isPresenting", DOM, cx);
483
0
484
0
  bool result(self->IsPresenting());
485
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
486
0
  args.rval().setBoolean(result);
487
0
  return true;
488
0
}
489
490
static const JSJitInfo isPresenting_getterinfo = {
491
  { (JSJitGetterOp)get_isPresenting },
492
  { prototypes::id::VRDisplay },
493
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
494
  JSJitInfo::Getter,
495
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
496
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
497
  true,  /* isInfallible. False in setters. */
498
  false,  /* isMovable.  Not relevant for setters. */
499
  false, /* isEliminatable.  Not relevant for setters. */
500
  false, /* isAlwaysInSlot.  Only relevant for getters. */
501
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
502
  false,  /* isTypedMethod.  Only relevant for methods. */
503
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
504
};
505
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
506
static_assert(0 < 1, "There is no slot for us");
507
508
MOZ_CAN_RUN_SCRIPT static bool
509
get_capabilities(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
510
0
{
511
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.capabilities", DOM, cx);
512
0
513
0
  auto result(StrongOrRawPtr<mozilla::dom::VRDisplayCapabilities>(self->Capabilities()));
514
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
515
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
516
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
517
0
    return false;
518
0
  }
519
0
  return true;
520
0
}
521
522
static const JSJitInfo capabilities_getterinfo = {
523
  { (JSJitGetterOp)get_capabilities },
524
  { prototypes::id::VRDisplay },
525
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
526
  JSJitInfo::Getter,
527
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
528
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
529
  false,  /* isInfallible. False in setters. */
530
  true,  /* isMovable.  Not relevant for setters. */
531
  true, /* isEliminatable.  Not relevant for setters. */
532
  false, /* isAlwaysInSlot.  Only relevant for getters. */
533
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
534
  false,  /* isTypedMethod.  Only relevant for methods. */
535
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
536
};
537
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
538
static_assert(0 < 1, "There is no slot for us");
539
540
MOZ_CAN_RUN_SCRIPT static bool
541
get_stageParameters(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
542
0
{
543
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.stageParameters", DOM, cx);
544
0
545
0
  auto result(StrongOrRawPtr<mozilla::dom::VRStageParameters>(self->GetStageParameters()));
546
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
547
0
  if (!result) {
548
0
    args.rval().setNull();
549
0
    return true;
550
0
  }
551
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
552
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
553
0
    return false;
554
0
  }
555
0
  return true;
556
0
}
557
558
static const JSJitInfo stageParameters_getterinfo = {
559
  { (JSJitGetterOp)get_stageParameters },
560
  { prototypes::id::VRDisplay },
561
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
562
  JSJitInfo::Getter,
563
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
564
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
565
  false,  /* isInfallible. False in setters. */
566
  false,  /* isMovable.  Not relevant for setters. */
567
  false, /* isEliminatable.  Not relevant for setters. */
568
  false, /* isAlwaysInSlot.  Only relevant for getters. */
569
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
570
  false,  /* isTypedMethod.  Only relevant for methods. */
571
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
572
};
573
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
574
static_assert(0 < 1, "There is no slot for us");
575
576
MOZ_CAN_RUN_SCRIPT static bool
577
getEyeParameters(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
578
0
{
579
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.getEyeParameters", DOM, cx);
580
0
581
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
582
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.getEyeParameters");
583
0
  }
584
0
  VREye arg0;
585
0
  {
586
0
    int index;
587
0
    if (!FindEnumStringIndex<true>(cx, args[0], VREyeValues::strings, "VREye", "Argument 1 of VRDisplay.getEyeParameters", &index)) {
588
0
      return false;
589
0
    }
590
0
    MOZ_ASSERT(index >= 0);
591
0
    arg0 = static_cast<VREye>(index);
592
0
  }
593
0
  auto result(StrongOrRawPtr<mozilla::dom::VREyeParameters>(self->GetEyeParameters(arg0)));
594
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
595
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
596
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
597
0
    return false;
598
0
  }
599
0
  return true;
600
0
}
601
602
static const JSJitInfo getEyeParameters_methodinfo = {
603
  { (JSJitGetterOp)getEyeParameters },
604
  { prototypes::id::VRDisplay },
605
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
606
  JSJitInfo::Method,
607
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
608
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
609
  false,  /* isInfallible. False in setters. */
610
  false,  /* isMovable.  Not relevant for setters. */
611
  false, /* isEliminatable.  Not relevant for setters. */
612
  false, /* isAlwaysInSlot.  Only relevant for getters. */
613
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
614
  false,  /* isTypedMethod.  Only relevant for methods. */
615
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
616
};
617
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
618
static_assert(0 < 1, "There is no slot for us");
619
620
MOZ_CAN_RUN_SCRIPT static bool
621
get_displayId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
622
0
{
623
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.displayId", DOM, cx);
624
0
625
0
  uint32_t result(self->DisplayId());
626
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
627
0
  args.rval().setNumber(result);
628
0
  return true;
629
0
}
630
631
static const JSJitInfo displayId_getterinfo = {
632
  { (JSJitGetterOp)get_displayId },
633
  { prototypes::id::VRDisplay },
634
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
635
  JSJitInfo::Getter,
636
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
637
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
638
  true,  /* isInfallible. False in setters. */
639
  true,  /* isMovable.  Not relevant for setters. */
640
  true, /* isEliminatable.  Not relevant for setters. */
641
  false, /* isAlwaysInSlot.  Only relevant for getters. */
642
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
643
  false,  /* isTypedMethod.  Only relevant for methods. */
644
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
645
};
646
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
647
static_assert(0 < 1, "There is no slot for us");
648
649
MOZ_CAN_RUN_SCRIPT static bool
650
get_displayName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
651
0
{
652
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.displayName", DOM, cx);
653
0
654
0
  DOMString result;
655
0
  self->GetDisplayName(result);
656
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
657
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
658
0
    return false;
659
0
  }
660
0
  return true;
661
0
}
662
663
static const JSJitInfo displayName_getterinfo = {
664
  { (JSJitGetterOp)get_displayName },
665
  { prototypes::id::VRDisplay },
666
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
667
  JSJitInfo::Getter,
668
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
669
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
670
  false,  /* isInfallible. False in setters. */
671
  true,  /* isMovable.  Not relevant for setters. */
672
  true, /* isEliminatable.  Not relevant for setters. */
673
  false, /* isAlwaysInSlot.  Only relevant for getters. */
674
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
675
  false,  /* isTypedMethod.  Only relevant for methods. */
676
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
677
};
678
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
679
static_assert(0 < 1, "There is no slot for us");
680
681
MOZ_CAN_RUN_SCRIPT static bool
682
getFrameData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
683
0
{
684
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.getFrameData", DOM, cx);
685
0
686
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
687
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.getFrameData");
688
0
  }
689
0
  NonNull<mozilla::dom::VRFrameData> arg0;
690
0
  if (args[0].isObject()) {
691
0
    {
692
0
      nsresult rv = UnwrapObject<prototypes::id::VRFrameData, mozilla::dom::VRFrameData>(args[0], arg0);
693
0
      if (NS_FAILED(rv)) {
694
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of VRDisplay.getFrameData", "VRFrameData");
695
0
        return false;
696
0
      }
697
0
    }
698
0
  } else {
699
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of VRDisplay.getFrameData");
700
0
    return false;
701
0
  }
702
0
  bool result(self->GetFrameData(MOZ_KnownLive(NonNullHelper(arg0))));
703
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
704
0
  args.rval().setBoolean(result);
705
0
  return true;
706
0
}
707
708
static const JSJitInfo getFrameData_methodinfo = {
709
  { (JSJitGetterOp)getFrameData },
710
  { prototypes::id::VRDisplay },
711
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
712
  JSJitInfo::Method,
713
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
714
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
715
  false,  /* isInfallible. False in setters. */
716
  false,  /* isMovable.  Not relevant for setters. */
717
  false, /* isEliminatable.  Not relevant for setters. */
718
  false, /* isAlwaysInSlot.  Only relevant for getters. */
719
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
720
  false,  /* isTypedMethod.  Only relevant for methods. */
721
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
722
};
723
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
724
static_assert(0 < 1, "There is no slot for us");
725
726
MOZ_CAN_RUN_SCRIPT static bool
727
getPose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
728
0
{
729
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.getPose", DOM, cx);
730
0
731
0
  auto result(StrongOrRawPtr<mozilla::dom::VRPose>(self->GetPose()));
732
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
733
0
  static_assert(!IsPointer<decltype(result)>::value,
734
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
735
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
736
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
737
0
    return false;
738
0
  }
739
0
  return true;
740
0
}
741
742
static const JSJitInfo getPose_methodinfo = {
743
  { (JSJitGetterOp)getPose },
744
  { prototypes::id::VRDisplay },
745
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
746
  JSJitInfo::Method,
747
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
748
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
749
  false,  /* isInfallible. False in setters. */
750
  false,  /* isMovable.  Not relevant for setters. */
751
  false, /* isEliminatable.  Not relevant for setters. */
752
  false, /* isAlwaysInSlot.  Only relevant for getters. */
753
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
754
  false,  /* isTypedMethod.  Only relevant for methods. */
755
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
756
};
757
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
758
static_assert(0 < 1, "There is no slot for us");
759
760
MOZ_CAN_RUN_SCRIPT static bool
761
getSubmitFrameResult(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
762
0
{
763
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.getSubmitFrameResult", DOM, cx);
764
0
765
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
766
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.getSubmitFrameResult");
767
0
  }
768
0
  NonNull<mozilla::dom::VRSubmitFrameResult> arg0;
769
0
  if (args[0].isObject()) {
770
0
    {
771
0
      nsresult rv = UnwrapObject<prototypes::id::VRSubmitFrameResult, mozilla::dom::VRSubmitFrameResult>(args[0], arg0);
772
0
      if (NS_FAILED(rv)) {
773
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of VRDisplay.getSubmitFrameResult", "VRSubmitFrameResult");
774
0
        return false;
775
0
      }
776
0
    }
777
0
  } else {
778
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of VRDisplay.getSubmitFrameResult");
779
0
    return false;
780
0
  }
781
0
  bool result(self->GetSubmitFrameResult(MOZ_KnownLive(NonNullHelper(arg0))));
782
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
783
0
  args.rval().setBoolean(result);
784
0
  return true;
785
0
}
786
787
static const JSJitInfo getSubmitFrameResult_methodinfo = {
788
  { (JSJitGetterOp)getSubmitFrameResult },
789
  { prototypes::id::VRDisplay },
790
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
791
  JSJitInfo::Method,
792
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
793
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
794
  false,  /* isInfallible. False in setters. */
795
  false,  /* isMovable.  Not relevant for setters. */
796
  false, /* isEliminatable.  Not relevant for setters. */
797
  false, /* isAlwaysInSlot.  Only relevant for getters. */
798
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
799
  false,  /* isTypedMethod.  Only relevant for methods. */
800
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
801
};
802
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
803
static_assert(0 < 1, "There is no slot for us");
804
805
MOZ_CAN_RUN_SCRIPT static bool
806
resetPose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
807
0
{
808
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.resetPose", DOM, cx);
809
0
810
0
  self->ResetPose();
811
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
812
0
  args.rval().setUndefined();
813
0
  return true;
814
0
}
815
816
static const JSJitInfo resetPose_methodinfo = {
817
  { (JSJitGetterOp)resetPose },
818
  { prototypes::id::VRDisplay },
819
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
820
  JSJitInfo::Method,
821
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
822
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
823
  true,  /* isInfallible. False in setters. */
824
  false,  /* isMovable.  Not relevant for setters. */
825
  false, /* isEliminatable.  Not relevant for setters. */
826
  false, /* isAlwaysInSlot.  Only relevant for getters. */
827
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
828
  false,  /* isTypedMethod.  Only relevant for methods. */
829
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
830
};
831
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
832
static_assert(0 < 1, "There is no slot for us");
833
834
MOZ_CAN_RUN_SCRIPT static bool
835
get_depthNear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
836
0
{
837
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.depthNear", DOM, cx);
838
0
839
0
  double result(self->DepthNear());
840
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
841
0
  args.rval().set(JS_NumberValue(double(result)));
842
0
  return true;
843
0
}
844
845
MOZ_CAN_RUN_SCRIPT static bool
846
set_depthNear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitSetterCallArgs args)
847
0
{
848
0
  AUTO_PROFILER_LABEL_FAST("set VRDisplay.depthNear", DOM, cx);
849
0
850
0
  double arg0;
851
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
852
0
    return false;
853
0
  } else if (!mozilla::IsFinite(arg0)) {
854
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to VRDisplay.depthNear");
855
0
    return false;
856
0
  }
857
0
  self->SetDepthNear(arg0);
858
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
859
0
860
0
  return true;
861
0
}
862
863
static const JSJitInfo depthNear_getterinfo = {
864
  { (JSJitGetterOp)get_depthNear },
865
  { prototypes::id::VRDisplay },
866
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
867
  JSJitInfo::Getter,
868
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
869
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
870
  true,  /* isInfallible. False in setters. */
871
  false,  /* isMovable.  Not relevant for setters. */
872
  false, /* isEliminatable.  Not relevant for setters. */
873
  false, /* isAlwaysInSlot.  Only relevant for getters. */
874
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
875
  false,  /* isTypedMethod.  Only relevant for methods. */
876
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
877
};
878
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
879
static_assert(0 < 1, "There is no slot for us");
880
static const JSJitInfo depthNear_setterinfo = {
881
  { (JSJitGetterOp)set_depthNear },
882
  { prototypes::id::VRDisplay },
883
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
884
  JSJitInfo::Setter,
885
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
886
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
887
  false,  /* isInfallible. False in setters. */
888
  false,  /* isMovable.  Not relevant for setters. */
889
  false, /* isEliminatable.  Not relevant for setters. */
890
  false, /* isAlwaysInSlot.  Only relevant for getters. */
891
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
892
  false,  /* isTypedMethod.  Only relevant for methods. */
893
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
894
};
895
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
896
static_assert(0 < 1, "There is no slot for us");
897
898
MOZ_CAN_RUN_SCRIPT static bool
899
get_depthFar(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitGetterCallArgs args)
900
0
{
901
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplay.depthFar", DOM, cx);
902
0
903
0
  double result(self->DepthFar());
904
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
905
0
  args.rval().set(JS_NumberValue(double(result)));
906
0
  return true;
907
0
}
908
909
MOZ_CAN_RUN_SCRIPT static bool
910
set_depthFar(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, JSJitSetterCallArgs args)
911
0
{
912
0
  AUTO_PROFILER_LABEL_FAST("set VRDisplay.depthFar", DOM, cx);
913
0
914
0
  double arg0;
915
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
916
0
    return false;
917
0
  } else if (!mozilla::IsFinite(arg0)) {
918
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to VRDisplay.depthFar");
919
0
    return false;
920
0
  }
921
0
  self->SetDepthFar(arg0);
922
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
923
0
924
0
  return true;
925
0
}
926
927
static const JSJitInfo depthFar_getterinfo = {
928
  { (JSJitGetterOp)get_depthFar },
929
  { prototypes::id::VRDisplay },
930
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
931
  JSJitInfo::Getter,
932
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
933
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
934
  true,  /* isInfallible. False in setters. */
935
  false,  /* isMovable.  Not relevant for setters. */
936
  false, /* isEliminatable.  Not relevant for setters. */
937
  false, /* isAlwaysInSlot.  Only relevant for getters. */
938
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
939
  false,  /* isTypedMethod.  Only relevant for methods. */
940
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
941
};
942
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
943
static_assert(0 < 1, "There is no slot for us");
944
static const JSJitInfo depthFar_setterinfo = {
945
  { (JSJitGetterOp)set_depthFar },
946
  { prototypes::id::VRDisplay },
947
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
948
  JSJitInfo::Setter,
949
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
950
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
951
  false,  /* isInfallible. False in setters. */
952
  false,  /* isMovable.  Not relevant for setters. */
953
  false, /* isEliminatable.  Not relevant for setters. */
954
  false, /* isAlwaysInSlot.  Only relevant for getters. */
955
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
956
  false,  /* isTypedMethod.  Only relevant for methods. */
957
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
958
};
959
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
960
static_assert(0 < 1, "There is no slot for us");
961
962
MOZ_CAN_RUN_SCRIPT static bool
963
requestAnimationFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
964
0
{
965
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.requestAnimationFrame", DOM, cx);
966
0
967
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
968
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.requestAnimationFrame");
969
0
  }
970
0
  RootedCallback<OwningNonNull<binding_detail::FastFrameRequestCallback>> arg0(cx);
971
0
  if (args[0].isObject()) {
972
0
    if (JS::IsCallable(&args[0].toObject())) {
973
0
    { // scope for tempRoot and tempGlobalRoot if needed
974
0
      arg0 = new binding_detail::FastFrameRequestCallback(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
975
0
    }
976
0
    } else {
977
0
      ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of VRDisplay.requestAnimationFrame");
978
0
      return false;
979
0
    }
980
0
  } else {
981
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of VRDisplay.requestAnimationFrame");
982
0
    return false;
983
0
  }
984
0
  FastErrorResult rv;
985
0
  int32_t result(self->RequestAnimationFrame(NonNullHelper(arg0), rv));
986
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
987
0
    return false;
988
0
  }
989
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
990
0
  args.rval().setInt32(int32_t(result));
991
0
  return true;
992
0
}
993
994
static const JSJitInfo requestAnimationFrame_methodinfo = {
995
  { (JSJitGetterOp)requestAnimationFrame },
996
  { prototypes::id::VRDisplay },
997
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
998
  JSJitInfo::Method,
999
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1000
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
1001
  false,  /* isInfallible. False in setters. */
1002
  false,  /* isMovable.  Not relevant for setters. */
1003
  false, /* isEliminatable.  Not relevant for setters. */
1004
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1005
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1006
  false,  /* isTypedMethod.  Only relevant for methods. */
1007
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1008
};
1009
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1010
static_assert(0 < 1, "There is no slot for us");
1011
1012
MOZ_CAN_RUN_SCRIPT static bool
1013
cancelAnimationFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1014
0
{
1015
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.cancelAnimationFrame", DOM, cx);
1016
0
1017
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1018
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.cancelAnimationFrame");
1019
0
  }
1020
0
  int32_t arg0;
1021
0
  if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
1022
0
    return false;
1023
0
  }
1024
0
  FastErrorResult rv;
1025
0
  self->CancelAnimationFrame(arg0, rv);
1026
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1027
0
    return false;
1028
0
  }
1029
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1030
0
  args.rval().setUndefined();
1031
0
  return true;
1032
0
}
1033
1034
static const JSJitInfo cancelAnimationFrame_methodinfo = {
1035
  { (JSJitGetterOp)cancelAnimationFrame },
1036
  { prototypes::id::VRDisplay },
1037
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
1038
  JSJitInfo::Method,
1039
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1040
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1041
  false,  /* isInfallible. False in setters. */
1042
  false,  /* isMovable.  Not relevant for setters. */
1043
  false, /* isEliminatable.  Not relevant for setters. */
1044
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1045
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1046
  false,  /* isTypedMethod.  Only relevant for methods. */
1047
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1048
};
1049
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1050
static_assert(0 < 1, "There is no slot for us");
1051
1052
MOZ_CAN_RUN_SCRIPT static bool
1053
requestPresent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1054
0
{
1055
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.requestPresent", DOM, cx);
1056
0
1057
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1058
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VRDisplay.requestPresent");
1059
0
  }
1060
0
  binding_detail::AutoSequence<VRLayer> arg0;
1061
0
  if (args[0].isObject()) {
1062
0
    JS::ForOfIterator iter(cx);
1063
0
    if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
1064
0
      return false;
1065
0
    }
1066
0
    if (!iter.valueIsIterable()) {
1067
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of VRDisplay.requestPresent");
1068
0
      return false;
1069
0
    }
1070
0
    binding_detail::AutoSequence<VRLayer> &arr = arg0;
1071
0
    JS::Rooted<JS::Value> temp(cx);
1072
0
    while (true) {
1073
0
      bool done;
1074
0
      if (!iter.next(&temp, &done)) {
1075
0
        return false;
1076
0
      }
1077
0
      if (done) {
1078
0
        break;
1079
0
      }
1080
0
      VRLayer* slotPtr = arr.AppendElement(mozilla::fallible);
1081
0
      if (!slotPtr) {
1082
0
        JS_ReportOutOfMemory(cx);
1083
0
        return false;
1084
0
      }
1085
0
      VRLayer& slot = *slotPtr;
1086
0
      if (!slot.Init(cx, temp,  "Element of argument 1 of VRDisplay.requestPresent", false)) {
1087
0
        return false;
1088
0
      }
1089
0
    }
1090
0
  } else {
1091
0
    ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of VRDisplay.requestPresent");
1092
0
    return false;
1093
0
  }
1094
0
  FastErrorResult rv;
1095
0
  auto result(StrongOrRawPtr<Promise>(self->RequestPresent(Constify(arg0), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv)));
1096
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1097
0
    return false;
1098
0
  }
1099
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1100
0
  if (!ToJSValue(cx, result, args.rval())) {
1101
0
    return false;
1102
0
  }
1103
0
  return true;
1104
0
}
1105
1106
MOZ_CAN_RUN_SCRIPT static bool
1107
requestPresent_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1108
0
{
1109
0
  bool ok = requestPresent(cx, obj, self, args);
1110
0
  if (ok) {
1111
0
    return true;
1112
0
  }
1113
0
  return ConvertExceptionToPromise(cx, args.rval());
1114
0
}
1115
1116
static const JSJitInfo requestPresent_methodinfo = {
1117
  { (JSJitGetterOp)requestPresent_promiseWrapper },
1118
  { prototypes::id::VRDisplay },
1119
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
1120
  JSJitInfo::Method,
1121
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1122
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1123
  false,  /* isInfallible. False in setters. */
1124
  false,  /* isMovable.  Not relevant for setters. */
1125
  false, /* isEliminatable.  Not relevant for setters. */
1126
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1127
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1128
  false,  /* isTypedMethod.  Only relevant for methods. */
1129
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1130
};
1131
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1132
static_assert(0 < 1, "There is no slot for us");
1133
1134
MOZ_CAN_RUN_SCRIPT static bool
1135
exitPresent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1136
0
{
1137
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.exitPresent", DOM, cx);
1138
0
1139
0
  FastErrorResult rv;
1140
0
  auto result(StrongOrRawPtr<Promise>(self->ExitPresent(rv)));
1141
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1142
0
    return false;
1143
0
  }
1144
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1145
0
  if (!ToJSValue(cx, result, args.rval())) {
1146
0
    return false;
1147
0
  }
1148
0
  return true;
1149
0
}
1150
1151
MOZ_CAN_RUN_SCRIPT static bool
1152
exitPresent_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1153
0
{
1154
0
  bool ok = exitPresent(cx, obj, self, args);
1155
0
  if (ok) {
1156
0
    return true;
1157
0
  }
1158
0
  return ConvertExceptionToPromise(cx, args.rval());
1159
0
}
1160
1161
static const JSJitInfo exitPresent_methodinfo = {
1162
  { (JSJitGetterOp)exitPresent_promiseWrapper },
1163
  { prototypes::id::VRDisplay },
1164
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
1165
  JSJitInfo::Method,
1166
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1167
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1168
  false,  /* isInfallible. False in setters. */
1169
  false,  /* isMovable.  Not relevant for setters. */
1170
  false, /* isEliminatable.  Not relevant for setters. */
1171
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1172
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1173
  false,  /* isTypedMethod.  Only relevant for methods. */
1174
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1175
};
1176
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1177
static_assert(0 < 1, "There is no slot for us");
1178
1179
MOZ_CAN_RUN_SCRIPT static bool
1180
getLayers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1181
0
{
1182
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.getLayers", DOM, cx);
1183
0
1184
0
  nsTArray<VRLayer> result;
1185
0
  self->GetLayers(result);
1186
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1187
0
1188
0
  uint32_t length = result.Length();
1189
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1190
0
  if (!returnArray) {
1191
0
    return false;
1192
0
  }
1193
0
  // Scope for 'tmp'
1194
0
  {
1195
0
    JS::Rooted<JS::Value> tmp(cx);
1196
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1197
0
      // Control block to let us common up the JS_DefineElement calls when there
1198
0
      // are different ways to succeed at wrapping the object.
1199
0
      do {
1200
0
        if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
1201
0
          return false;
1202
0
        }
1203
0
        break;
1204
0
      } while (false);
1205
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1206
0
                            JSPROP_ENUMERATE)) {
1207
0
        return false;
1208
0
      }
1209
0
    }
1210
0
  }
1211
0
  args.rval().setObject(*returnArray);
1212
0
  return true;
1213
0
}
1214
1215
static const JSJitInfo getLayers_methodinfo = {
1216
  { (JSJitGetterOp)getLayers },
1217
  { prototypes::id::VRDisplay },
1218
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
1219
  JSJitInfo::Method,
1220
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1221
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1222
  false,  /* isInfallible. False in setters. */
1223
  false,  /* isMovable.  Not relevant for setters. */
1224
  false, /* isEliminatable.  Not relevant for setters. */
1225
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1226
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1227
  false,  /* isTypedMethod.  Only relevant for methods. */
1228
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1229
};
1230
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1231
static_assert(0 < 1, "There is no slot for us");
1232
1233
MOZ_CAN_RUN_SCRIPT static bool
1234
submitFrame(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplay* self, const JSJitMethodCallArgs& args)
1235
0
{
1236
0
  AUTO_PROFILER_LABEL_FAST("VRDisplay.submitFrame", DOM, cx);
1237
0
1238
0
  self->SubmitFrame();
1239
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1240
0
  args.rval().setUndefined();
1241
0
  return true;
1242
0
}
1243
1244
static const JSJitInfo submitFrame_methodinfo = {
1245
  { (JSJitGetterOp)submitFrame },
1246
  { prototypes::id::VRDisplay },
1247
  { PrototypeTraits<prototypes::id::VRDisplay>::Depth },
1248
  JSJitInfo::Method,
1249
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1250
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1251
  true,  /* isInfallible. False in setters. */
1252
  false,  /* isMovable.  Not relevant for setters. */
1253
  false, /* isEliminatable.  Not relevant for setters. */
1254
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1255
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1256
  false,  /* isTypedMethod.  Only relevant for methods. */
1257
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1258
};
1259
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1260
static_assert(0 < 1, "There is no slot for us");
1261
1262
static bool
1263
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1264
0
{
1265
0
  mozilla::dom::VRDisplay* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplay>(obj);
1266
0
  // We don't want to preserve if we don't have a wrapper, and we
1267
0
  // obviously can't preserve if we're not initialized.
1268
0
  if (self && self->GetWrapperPreserveColor()) {
1269
0
    PreserveWrapper(self);
1270
0
  }
1271
0
  return true;
1272
0
}
1273
1274
static void
1275
_finalize(js::FreeOp* fop, JSObject* obj)
1276
0
{
1277
0
  mozilla::dom::VRDisplay* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplay>(obj);
1278
0
  if (self) {
1279
0
    ClearWrapper(self, self, obj);
1280
0
    AddForDeferredFinalization<mozilla::dom::VRDisplay>(self);
1281
0
  }
1282
0
}
1283
1284
static size_t
1285
_objectMoved(JSObject* obj, JSObject* old)
1286
0
{
1287
0
  mozilla::dom::VRDisplay* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplay>(obj);
1288
0
  if (self) {
1289
0
    UpdateWrapper(self, self, obj, old);
1290
0
  }
1291
0
1292
0
  return 0;
1293
0
}
1294
1295
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1296
#if defined(__clang__)
1297
#pragma clang diagnostic push
1298
#pragma clang diagnostic ignored "-Wmissing-braces"
1299
#endif
1300
static const JSFunctionSpec sMethods_specs[] = {
1301
  JS_FNSPEC("getEyeParameters", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getEyeParameters_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1302
  JS_FNSPEC("getFrameData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFrameData_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1303
  JS_FNSPEC("getPose", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getPose_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1304
  JS_FS_END,
1305
  JS_FNSPEC("getSubmitFrameResult", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getSubmitFrameResult_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1306
  JS_FS_END,
1307
  JS_FNSPEC("resetPose", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&resetPose_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1308
  JS_FNSPEC("requestAnimationFrame", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&requestAnimationFrame_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1309
  JS_FNSPEC("cancelAnimationFrame", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&cancelAnimationFrame_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1310
  JS_FNSPEC("requestPresent", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&requestPresent_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1311
  JS_FNSPEC("exitPresent", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&exitPresent_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1312
  JS_FNSPEC("getLayers", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getLayers_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1313
  JS_FNSPEC("submitFrame", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&submitFrame_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1314
  JS_FS_END
1315
};
1316
#if defined(__clang__)
1317
#pragma clang diagnostic pop
1318
#endif
1319
1320
// Can't be const because the pref-enabled boolean needs to be writable
1321
static PrefableDisablers sMethods_disablers4 = {
1322
  true, false, 0, nullptr
1323
};
1324
1325
static const Prefable<const JSFunctionSpec> sMethods[] = {
1326
  { nullptr, &sMethods_specs[0] },
1327
  { &sMethods_disablers4, &sMethods_specs[4] },
1328
  { nullptr, &sMethods_specs[6] },
1329
  { nullptr, nullptr }
1330
};
1331
1332
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1333
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1334
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1335
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1336
1337
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1338
#if defined(__clang__)
1339
#pragma clang diagnostic push
1340
#pragma clang diagnostic ignored "-Wmissing-braces"
1341
#endif
1342
static const JSPropertySpec sAttributes_specs[] = {
1343
  { "isConnected", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isConnected_getterinfo, nullptr, nullptr },
1344
  { "isPresenting", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isPresenting_getterinfo, nullptr, nullptr },
1345
  { "capabilities", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &capabilities_getterinfo, nullptr, nullptr },
1346
  { "stageParameters", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &stageParameters_getterinfo, nullptr, nullptr },
1347
  { "displayId", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &displayId_getterinfo, nullptr, nullptr },
1348
  { "displayName", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &displayName_getterinfo, nullptr, nullptr },
1349
  { "depthNear", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &depthNear_getterinfo, GenericSetter<NormalThisPolicy>, &depthNear_setterinfo },
1350
  { "depthFar", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &depthFar_getterinfo, GenericSetter<NormalThisPolicy>, &depthFar_setterinfo },
1351
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1352
};
1353
#if defined(__clang__)
1354
#pragma clang diagnostic pop
1355
#endif
1356
1357
1358
static const Prefable<const JSPropertySpec> sAttributes[] = {
1359
  { nullptr, &sAttributes_specs[0] },
1360
  { nullptr, nullptr }
1361
};
1362
1363
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1364
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1365
static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1366
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1367
1368
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1369
#if defined(__clang__)
1370
#pragma clang diagnostic push
1371
#pragma clang diagnostic ignored "-Wmissing-braces"
1372
#endif
1373
static const JSPropertySpec sChromeAttributes_specs[] = {
1374
  { "presentingGroups", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &presentingGroups_getterinfo, nullptr, nullptr },
1375
  { "groupMask", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &groupMask_getterinfo, GenericSetter<NormalThisPolicy>, &groupMask_setterinfo },
1376
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1377
};
1378
#if defined(__clang__)
1379
#pragma clang diagnostic pop
1380
#endif
1381
1382
1383
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
1384
  { nullptr, &sChromeAttributes_specs[0] },
1385
  { nullptr, nullptr }
1386
};
1387
1388
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1389
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1390
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1391
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1392
1393
1394
static uint16_t sNativeProperties_sortedPropertyIndices[19];
1395
static PropertyInfo sNativeProperties_propertyInfos[19];
1396
1397
static const NativePropertiesN<2> sNativeProperties = {
1398
  false, 0,
1399
  false, 0,
1400
  true,  0 /* sMethods */,
1401
  true,  1 /* sAttributes */,
1402
  false, 0,
1403
  false, 0,
1404
  false, 0,
1405
  -1,
1406
  19,
1407
  sNativeProperties_sortedPropertyIndices,
1408
  {
1409
    { sMethods, &sNativeProperties_propertyInfos[0] },
1410
    { sAttributes, &sNativeProperties_propertyInfos[11] }
1411
  }
1412
};
1413
static_assert(19 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1414
    "We have a property info count that is oversized");
1415
1416
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2];
1417
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2];
1418
1419
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1420
  false, 0,
1421
  false, 0,
1422
  false, 0,
1423
  true,  0 /* sChromeAttributes */,
1424
  false, 0,
1425
  false, 0,
1426
  false, 0,
1427
  -1,
1428
  2,
1429
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1430
  {
1431
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
1432
  }
1433
};
1434
static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1435
    "We have a property info count that is oversized");
1436
1437
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1438
  {
1439
    "Function",
1440
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1441
    &sBoringInterfaceObjectClassClassOps,
1442
    JS_NULL_CLASS_SPEC,
1443
    JS_NULL_CLASS_EXT,
1444
    &sInterfaceObjectClassObjectOps
1445
  },
1446
  eInterface,
1447
  true,
1448
  prototypes::id::VRDisplay,
1449
  PrototypeTraits<prototypes::id::VRDisplay>::Depth,
1450
  sNativePropertyHooks,
1451
  "function VRDisplay() {\n    [native code]\n}",
1452
  EventTarget_Binding::GetConstructorObject
1453
};
1454
1455
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1456
  {
1457
    "VRDisplayPrototype",
1458
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1459
    JS_NULL_CLASS_OPS,
1460
    JS_NULL_CLASS_SPEC,
1461
    JS_NULL_CLASS_EXT,
1462
    JS_NULL_OBJECT_OPS
1463
  },
1464
  eInterfacePrototype,
1465
  false,
1466
  prototypes::id::VRDisplay,
1467
  PrototypeTraits<prototypes::id::VRDisplay>::Depth,
1468
  sNativePropertyHooks,
1469
  "[object VRDisplayPrototype]",
1470
  EventTarget_Binding::GetProtoObject
1471
};
1472
1473
bool
1474
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1475
0
{
1476
0
  static bool sPrefValue;
1477
0
  static bool sPrefCacheSetUp = false;
1478
0
  if (!sPrefCacheSetUp) {
1479
0
    sPrefCacheSetUp = true;
1480
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
1481
0
  }
1482
0
1483
0
  return sPrefValue;
1484
0
}
1485
1486
static const js::ClassOps sClassOps = {
1487
  _addProperty, /* addProperty */
1488
  nullptr,               /* delProperty */
1489
  nullptr,               /* enumerate */
1490
  nullptr, /* newEnumerate */
1491
  nullptr, /* resolve */
1492
  nullptr, /* mayResolve */
1493
  _finalize, /* finalize */
1494
  nullptr, /* call */
1495
  nullptr,               /* hasInstance */
1496
  nullptr,               /* construct */
1497
  nullptr, /* trace */
1498
};
1499
1500
static const js::ClassExtension sClassExtension = {
1501
  nullptr, /* weakmapKeyDelegateOp */
1502
  _objectMoved /* objectMovedOp */
1503
};
1504
1505
static const DOMJSClass sClass = {
1506
  { "VRDisplay",
1507
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1508
    &sClassOps,
1509
    JS_NULL_CLASS_SPEC,
1510
    &sClassExtension,
1511
    JS_NULL_OBJECT_OPS
1512
  },
1513
  { prototypes::id::EventTarget, prototypes::id::VRDisplay, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1514
  IsBaseOf<nsISupports, mozilla::dom::VRDisplay >::value,
1515
  sNativePropertyHooks,
1516
  FindAssociatedGlobalForNative<mozilla::dom::VRDisplay>::Get,
1517
  GetProtoObjectHandle,
1518
  GetCCParticipant<mozilla::dom::VRDisplay>::Get()
1519
};
1520
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1521
              "Must have the right minimal number of reserved slots.");
1522
static_assert(1 >= 1,
1523
              "Must have enough reserved slots.");
1524
1525
const JSClass*
1526
GetJSClass()
1527
0
{
1528
0
  return sClass.ToJSClass();
1529
0
}
1530
1531
bool
1532
Wrap(JSContext* aCx, mozilla::dom::VRDisplay* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1533
0
{
1534
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRDisplay>::value,
1535
0
                "Shouldn't have wrappercached things that are not refcounted.");
1536
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRDisplay*>(aObject) ==
1537
0
             reinterpret_cast<mozilla::dom::VRDisplay*>(aObject),
1538
0
             "Multiple inheritance for mozilla::dom::VRDisplay is broken.");
1539
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1540
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1541
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1542
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1543
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1544
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1545
0
             "You should probably not be using Wrap() directly; use "
1546
0
             "GetOrCreateDOMReflector instead");
1547
0
1548
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1549
0
             "nsISupports must be on our primary inheritance chain");
1550
0
1551
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1552
0
  if (!global) {
1553
0
    return false;
1554
0
  }
1555
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1556
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1557
0
1558
0
  // That might have ended up wrapping us already, due to the wonders
1559
0
  // of XBL.  Check for that, and bail out as needed.
1560
0
  aReflector.set(aCache->GetWrapper());
1561
0
  if (aReflector) {
1562
#ifdef DEBUG
1563
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1564
#endif // DEBUG
1565
    return true;
1566
0
  }
1567
0
1568
0
  JSAutoRealm ar(aCx, global);
1569
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1570
0
  if (!canonicalProto) {
1571
0
    return false;
1572
0
  }
1573
0
  JS::Rooted<JSObject*> proto(aCx);
1574
0
  if (aGivenProto) {
1575
0
    proto = aGivenProto;
1576
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1577
0
    // coming in, we changed compartments to that of "parent" so may need
1578
0
    // to wrap the proto here.
1579
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1580
0
      if (!JS_WrapObject(aCx, &proto)) {
1581
0
        return false;
1582
0
      }
1583
0
    }
1584
0
  } else {
1585
0
    proto = canonicalProto;
1586
0
  }
1587
0
1588
0
  BindingJSObjectCreator<mozilla::dom::VRDisplay> creator(aCx);
1589
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1590
0
  if (!aReflector) {
1591
0
    return false;
1592
0
  }
1593
0
1594
0
  aCache->SetWrapper(aReflector);
1595
0
  creator.InitializationSucceeded();
1596
0
1597
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1598
0
             aCache->GetWrapperPreserveColor() == aReflector);
1599
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1600
0
  // otherwise we won't be able to properly recreate it later, since
1601
0
  // we won't know what proto to use.  Note that we don't check
1602
0
  // aGivenProto here, since it's entirely possible (and even
1603
0
  // somewhat common) to have a non-null aGivenProto which is the
1604
0
  // same as canonicalProto.
1605
0
  if (proto != canonicalProto) {
1606
0
    PreserveWrapper(aObject);
1607
0
  }
1608
0
1609
0
  return true;
1610
0
}
1611
1612
const NativePropertyHooks sNativePropertyHooks[] = { {
1613
  nullptr,
1614
  nullptr,
1615
  nullptr,
1616
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1617
  prototypes::id::VRDisplay,
1618
  constructors::id::VRDisplay,
1619
  EventTarget_Binding::sNativePropertyHooks,
1620
  &DefaultXrayExpandoObjectClass
1621
} };
1622
1623
void
1624
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1625
0
{
1626
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
1627
0
  if (!parentProto) {
1628
0
    return;
1629
0
  }
1630
0
1631
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
1632
0
  if (!constructorProto) {
1633
0
    return;
1634
0
  }
1635
0
1636
0
  static bool sIdsInited = false;
1637
0
  if (!sIdsInited && NS_IsMainThread()) {
1638
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1639
0
      return;
1640
0
    }
1641
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1642
0
      return;
1643
0
    }
1644
0
    sIdsInited = true;
1645
0
  }
1646
0
1647
0
  static bool sPrefCachesInited = false;
1648
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
1649
0
    sPrefCachesInited = true;
1650
0
    Preferences::AddBoolVarCache(&sMethods[1].disablers->enabled, "dom.vr.test.enabled");
1651
0
  }
1652
0
1653
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRDisplay);
1654
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRDisplay);
1655
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1656
0
                              &sPrototypeClass.mBase, protoCache,
1657
0
                              nullptr,
1658
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1659
0
                              interfaceCache,
1660
0
                              sNativeProperties.Upcast(),
1661
0
                              sChromeOnlyNativeProperties.Upcast(),
1662
0
                              "VRDisplay", aDefineOnGlobal,
1663
0
                              nullptr,
1664
0
                              false);
1665
0
}
1666
1667
JSObject*
1668
GetConstructorObject(JSContext* aCx)
1669
0
{
1670
0
  return GetConstructorObjectHandle(aCx);
1671
0
}
1672
1673
} // namespace VRDisplay_Binding
1674
1675
1676
1677
namespace VRDisplayCapabilities_Binding {
1678
1679
MOZ_CAN_RUN_SCRIPT static bool
1680
get_hasPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
1681
0
{
1682
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplayCapabilities.hasPosition", DOM, cx);
1683
0
1684
0
  bool result(self->HasPosition());
1685
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1686
0
  args.rval().setBoolean(result);
1687
0
  return true;
1688
0
}
1689
1690
static const JSJitInfo hasPosition_getterinfo = {
1691
  { (JSJitGetterOp)get_hasPosition },
1692
  { prototypes::id::VRDisplayCapabilities },
1693
  { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
1694
  JSJitInfo::Getter,
1695
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1696
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1697
  true,  /* isInfallible. False in setters. */
1698
  false,  /* isMovable.  Not relevant for setters. */
1699
  false, /* isEliminatable.  Not relevant for setters. */
1700
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1701
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1702
  false,  /* isTypedMethod.  Only relevant for methods. */
1703
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1704
};
1705
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1706
static_assert(0 < 1, "There is no slot for us");
1707
1708
MOZ_CAN_RUN_SCRIPT static bool
1709
get_hasOrientation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
1710
0
{
1711
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplayCapabilities.hasOrientation", DOM, cx);
1712
0
1713
0
  bool result(self->HasOrientation());
1714
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1715
0
  args.rval().setBoolean(result);
1716
0
  return true;
1717
0
}
1718
1719
static const JSJitInfo hasOrientation_getterinfo = {
1720
  { (JSJitGetterOp)get_hasOrientation },
1721
  { prototypes::id::VRDisplayCapabilities },
1722
  { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
1723
  JSJitInfo::Getter,
1724
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1725
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1726
  true,  /* isInfallible. False in setters. */
1727
  false,  /* isMovable.  Not relevant for setters. */
1728
  false, /* isEliminatable.  Not relevant for setters. */
1729
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1730
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1731
  false,  /* isTypedMethod.  Only relevant for methods. */
1732
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1733
};
1734
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1735
static_assert(0 < 1, "There is no slot for us");
1736
1737
MOZ_CAN_RUN_SCRIPT static bool
1738
get_hasExternalDisplay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
1739
0
{
1740
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplayCapabilities.hasExternalDisplay", DOM, cx);
1741
0
1742
0
  bool result(self->HasExternalDisplay());
1743
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1744
0
  args.rval().setBoolean(result);
1745
0
  return true;
1746
0
}
1747
1748
static const JSJitInfo hasExternalDisplay_getterinfo = {
1749
  { (JSJitGetterOp)get_hasExternalDisplay },
1750
  { prototypes::id::VRDisplayCapabilities },
1751
  { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
1752
  JSJitInfo::Getter,
1753
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1754
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1755
  true,  /* isInfallible. False in setters. */
1756
  false,  /* isMovable.  Not relevant for setters. */
1757
  false, /* isEliminatable.  Not relevant for setters. */
1758
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1759
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1760
  false,  /* isTypedMethod.  Only relevant for methods. */
1761
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1762
};
1763
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1764
static_assert(0 < 1, "There is no slot for us");
1765
1766
MOZ_CAN_RUN_SCRIPT static bool
1767
get_canPresent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
1768
0
{
1769
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplayCapabilities.canPresent", DOM, cx);
1770
0
1771
0
  bool result(self->CanPresent());
1772
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1773
0
  args.rval().setBoolean(result);
1774
0
  return true;
1775
0
}
1776
1777
static const JSJitInfo canPresent_getterinfo = {
1778
  { (JSJitGetterOp)get_canPresent },
1779
  { prototypes::id::VRDisplayCapabilities },
1780
  { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
1781
  JSJitInfo::Getter,
1782
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1783
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1784
  true,  /* isInfallible. False in setters. */
1785
  false,  /* isMovable.  Not relevant for setters. */
1786
  false, /* isEliminatable.  Not relevant for setters. */
1787
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1788
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1789
  false,  /* isTypedMethod.  Only relevant for methods. */
1790
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1791
};
1792
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1793
static_assert(0 < 1, "There is no slot for us");
1794
1795
MOZ_CAN_RUN_SCRIPT static bool
1796
get_maxLayers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRDisplayCapabilities* self, JSJitGetterCallArgs args)
1797
0
{
1798
0
  AUTO_PROFILER_LABEL_FAST("get VRDisplayCapabilities.maxLayers", DOM, cx);
1799
0
1800
0
  uint32_t result(self->MaxLayers());
1801
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1802
0
  args.rval().setNumber(result);
1803
0
  return true;
1804
0
}
1805
1806
static const JSJitInfo maxLayers_getterinfo = {
1807
  { (JSJitGetterOp)get_maxLayers },
1808
  { prototypes::id::VRDisplayCapabilities },
1809
  { PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth },
1810
  JSJitInfo::Getter,
1811
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1812
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1813
  true,  /* isInfallible. False in setters. */
1814
  false,  /* isMovable.  Not relevant for setters. */
1815
  false, /* isEliminatable.  Not relevant for setters. */
1816
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1817
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1818
  false,  /* isTypedMethod.  Only relevant for methods. */
1819
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1820
};
1821
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1822
static_assert(0 < 1, "There is no slot for us");
1823
1824
static bool
1825
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1826
0
{
1827
0
  mozilla::dom::VRDisplayCapabilities* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplayCapabilities>(obj);
1828
0
  // We don't want to preserve if we don't have a wrapper, and we
1829
0
  // obviously can't preserve if we're not initialized.
1830
0
  if (self && self->GetWrapperPreserveColor()) {
1831
0
    PreserveWrapper(self);
1832
0
  }
1833
0
  return true;
1834
0
}
1835
1836
static void
1837
_finalize(js::FreeOp* fop, JSObject* obj)
1838
0
{
1839
0
  mozilla::dom::VRDisplayCapabilities* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplayCapabilities>(obj);
1840
0
  if (self) {
1841
0
    ClearWrapper(self, self, obj);
1842
0
    AddForDeferredFinalization<mozilla::dom::VRDisplayCapabilities>(self);
1843
0
  }
1844
0
}
1845
1846
static size_t
1847
_objectMoved(JSObject* obj, JSObject* old)
1848
0
{
1849
0
  mozilla::dom::VRDisplayCapabilities* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRDisplayCapabilities>(obj);
1850
0
  if (self) {
1851
0
    UpdateWrapper(self, self, obj, old);
1852
0
  }
1853
0
1854
0
  return 0;
1855
0
}
1856
1857
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1858
#if defined(__clang__)
1859
#pragma clang diagnostic push
1860
#pragma clang diagnostic ignored "-Wmissing-braces"
1861
#endif
1862
static const JSPropertySpec sAttributes_specs[] = {
1863
  { "hasPosition", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hasPosition_getterinfo, nullptr, nullptr },
1864
  { "hasOrientation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hasOrientation_getterinfo, nullptr, nullptr },
1865
  { "hasExternalDisplay", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hasExternalDisplay_getterinfo, nullptr, nullptr },
1866
  { "canPresent", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &canPresent_getterinfo, nullptr, nullptr },
1867
  { "maxLayers", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &maxLayers_getterinfo, nullptr, nullptr },
1868
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1869
};
1870
#if defined(__clang__)
1871
#pragma clang diagnostic pop
1872
#endif
1873
1874
1875
static const Prefable<const JSPropertySpec> sAttributes[] = {
1876
  { nullptr, &sAttributes_specs[0] },
1877
  { nullptr, nullptr }
1878
};
1879
1880
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1881
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1882
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1883
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1884
1885
1886
static uint16_t sNativeProperties_sortedPropertyIndices[5];
1887
static PropertyInfo sNativeProperties_propertyInfos[5];
1888
1889
static const NativePropertiesN<1> sNativeProperties = {
1890
  false, 0,
1891
  false, 0,
1892
  false, 0,
1893
  true,  0 /* sAttributes */,
1894
  false, 0,
1895
  false, 0,
1896
  false, 0,
1897
  -1,
1898
  5,
1899
  sNativeProperties_sortedPropertyIndices,
1900
  {
1901
    { sAttributes, &sNativeProperties_propertyInfos[0] }
1902
  }
1903
};
1904
static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1905
    "We have a property info count that is oversized");
1906
1907
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1908
  {
1909
    "Function",
1910
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1911
    &sBoringInterfaceObjectClassClassOps,
1912
    JS_NULL_CLASS_SPEC,
1913
    JS_NULL_CLASS_EXT,
1914
    &sInterfaceObjectClassObjectOps
1915
  },
1916
  eInterface,
1917
  true,
1918
  prototypes::id::VRDisplayCapabilities,
1919
  PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth,
1920
  sNativePropertyHooks,
1921
  "function VRDisplayCapabilities() {\n    [native code]\n}",
1922
  JS::GetRealmFunctionPrototype
1923
};
1924
1925
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1926
  {
1927
    "VRDisplayCapabilitiesPrototype",
1928
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1929
    JS_NULL_CLASS_OPS,
1930
    JS_NULL_CLASS_SPEC,
1931
    JS_NULL_CLASS_EXT,
1932
    JS_NULL_OBJECT_OPS
1933
  },
1934
  eInterfacePrototype,
1935
  false,
1936
  prototypes::id::VRDisplayCapabilities,
1937
  PrototypeTraits<prototypes::id::VRDisplayCapabilities>::Depth,
1938
  sNativePropertyHooks,
1939
  "[object VRDisplayCapabilitiesPrototype]",
1940
  JS::GetRealmObjectPrototype
1941
};
1942
1943
bool
1944
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1945
0
{
1946
0
  static bool sPrefValue;
1947
0
  static bool sPrefCacheSetUp = false;
1948
0
  if (!sPrefCacheSetUp) {
1949
0
    sPrefCacheSetUp = true;
1950
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
1951
0
  }
1952
0
1953
0
  return sPrefValue;
1954
0
}
1955
1956
static const js::ClassOps sClassOps = {
1957
  _addProperty, /* addProperty */
1958
  nullptr,               /* delProperty */
1959
  nullptr,               /* enumerate */
1960
  nullptr, /* newEnumerate */
1961
  nullptr, /* resolve */
1962
  nullptr, /* mayResolve */
1963
  _finalize, /* finalize */
1964
  nullptr, /* call */
1965
  nullptr,               /* hasInstance */
1966
  nullptr,               /* construct */
1967
  nullptr, /* trace */
1968
};
1969
1970
static const js::ClassExtension sClassExtension = {
1971
  nullptr, /* weakmapKeyDelegateOp */
1972
  _objectMoved /* objectMovedOp */
1973
};
1974
1975
static const DOMJSClass sClass = {
1976
  { "VRDisplayCapabilities",
1977
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1978
    &sClassOps,
1979
    JS_NULL_CLASS_SPEC,
1980
    &sClassExtension,
1981
    JS_NULL_OBJECT_OPS
1982
  },
1983
  { prototypes::id::VRDisplayCapabilities, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1984
  IsBaseOf<nsISupports, mozilla::dom::VRDisplayCapabilities >::value,
1985
  sNativePropertyHooks,
1986
  FindAssociatedGlobalForNative<mozilla::dom::VRDisplayCapabilities>::Get,
1987
  GetProtoObjectHandle,
1988
  GetCCParticipant<mozilla::dom::VRDisplayCapabilities>::Get()
1989
};
1990
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1991
              "Must have the right minimal number of reserved slots.");
1992
static_assert(1 >= 1,
1993
              "Must have enough reserved slots.");
1994
1995
const JSClass*
1996
GetJSClass()
1997
0
{
1998
0
  return sClass.ToJSClass();
1999
0
}
2000
2001
bool
2002
Wrap(JSContext* aCx, mozilla::dom::VRDisplayCapabilities* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2003
0
{
2004
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRDisplayCapabilities>::value,
2005
0
                "Shouldn't have wrappercached things that are not refcounted.");
2006
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRDisplayCapabilities*>(aObject) ==
2007
0
             reinterpret_cast<mozilla::dom::VRDisplayCapabilities*>(aObject),
2008
0
             "Multiple inheritance for mozilla::dom::VRDisplayCapabilities is broken.");
2009
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2010
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2011
0
  MOZ_ASSERT(!aCache->GetWrapper(),
2012
0
             "You should probably not be using Wrap() directly; use "
2013
0
             "GetOrCreateDOMReflector instead");
2014
0
2015
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2016
0
             "nsISupports must be on our primary inheritance chain");
2017
0
2018
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2019
0
  if (!global) {
2020
0
    return false;
2021
0
  }
2022
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
2023
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
2024
0
2025
0
  // That might have ended up wrapping us already, due to the wonders
2026
0
  // of XBL.  Check for that, and bail out as needed.
2027
0
  aReflector.set(aCache->GetWrapper());
2028
0
  if (aReflector) {
2029
#ifdef DEBUG
2030
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2031
#endif // DEBUG
2032
    return true;
2033
0
  }
2034
0
2035
0
  JSAutoRealm ar(aCx, global);
2036
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2037
0
  if (!canonicalProto) {
2038
0
    return false;
2039
0
  }
2040
0
  JS::Rooted<JSObject*> proto(aCx);
2041
0
  if (aGivenProto) {
2042
0
    proto = aGivenProto;
2043
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2044
0
    // coming in, we changed compartments to that of "parent" so may need
2045
0
    // to wrap the proto here.
2046
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2047
0
      if (!JS_WrapObject(aCx, &proto)) {
2048
0
        return false;
2049
0
      }
2050
0
    }
2051
0
  } else {
2052
0
    proto = canonicalProto;
2053
0
  }
2054
0
2055
0
  BindingJSObjectCreator<mozilla::dom::VRDisplayCapabilities> creator(aCx);
2056
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
2057
0
  if (!aReflector) {
2058
0
    return false;
2059
0
  }
2060
0
2061
0
  aCache->SetWrapper(aReflector);
2062
0
  creator.InitializationSucceeded();
2063
0
2064
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2065
0
             aCache->GetWrapperPreserveColor() == aReflector);
2066
0
  // If proto != canonicalProto, we have to preserve our wrapper;
2067
0
  // otherwise we won't be able to properly recreate it later, since
2068
0
  // we won't know what proto to use.  Note that we don't check
2069
0
  // aGivenProto here, since it's entirely possible (and even
2070
0
  // somewhat common) to have a non-null aGivenProto which is the
2071
0
  // same as canonicalProto.
2072
0
  if (proto != canonicalProto) {
2073
0
    PreserveWrapper(aObject);
2074
0
  }
2075
0
2076
0
  return true;
2077
0
}
2078
2079
const NativePropertyHooks sNativePropertyHooks[] = { {
2080
  nullptr,
2081
  nullptr,
2082
  nullptr,
2083
  { sNativeProperties.Upcast(), nullptr },
2084
  prototypes::id::VRDisplayCapabilities,
2085
  constructors::id::VRDisplayCapabilities,
2086
  nullptr,
2087
  &DefaultXrayExpandoObjectClass
2088
} };
2089
2090
void
2091
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2092
0
{
2093
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
2094
0
  if (!parentProto) {
2095
0
    return;
2096
0
  }
2097
0
2098
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
2099
0
  if (!constructorProto) {
2100
0
    return;
2101
0
  }
2102
0
2103
0
  static bool sIdsInited = false;
2104
0
  if (!sIdsInited && NS_IsMainThread()) {
2105
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
2106
0
      return;
2107
0
    }
2108
0
    sIdsInited = true;
2109
0
  }
2110
0
2111
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRDisplayCapabilities);
2112
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRDisplayCapabilities);
2113
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2114
0
                              &sPrototypeClass.mBase, protoCache,
2115
0
                              nullptr,
2116
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2117
0
                              interfaceCache,
2118
0
                              sNativeProperties.Upcast(),
2119
0
                              nullptr,
2120
0
                              "VRDisplayCapabilities", aDefineOnGlobal,
2121
0
                              nullptr,
2122
0
                              false);
2123
0
}
2124
2125
JSObject*
2126
GetConstructorObject(JSContext* aCx)
2127
0
{
2128
0
  return GetConstructorObjectHandle(aCx);
2129
0
}
2130
2131
} // namespace VRDisplayCapabilities_Binding
2132
2133
2134
2135
namespace VREyeParameters_Binding {
2136
2137
MOZ_CAN_RUN_SCRIPT static bool
2138
get_offset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
2139
0
{
2140
0
  AUTO_PROFILER_LABEL_FAST("get VREyeParameters.offset", DOM, cx);
2141
0
2142
0
  FastErrorResult rv;
2143
0
  JS::Rooted<JSObject*> result(cx);
2144
0
  self->GetOffset(cx, &result, rv);
2145
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2146
0
    return false;
2147
0
  }
2148
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2149
0
  JS::ExposeObjectToActiveJS(result);
2150
0
  args.rval().setObject(*result);
2151
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
2152
0
    return false;
2153
0
  }
2154
0
  return true;
2155
0
}
2156
2157
static const JSJitInfo offset_getterinfo = {
2158
  { (JSJitGetterOp)get_offset },
2159
  { prototypes::id::VREyeParameters },
2160
  { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
2161
  JSJitInfo::Getter,
2162
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2163
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2164
  false,  /* isInfallible. False in setters. */
2165
  false,  /* isMovable.  Not relevant for setters. */
2166
  false, /* isEliminatable.  Not relevant for setters. */
2167
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2168
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2169
  false,  /* isTypedMethod.  Only relevant for methods. */
2170
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2171
};
2172
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2173
static_assert(0 < 1, "There is no slot for us");
2174
2175
MOZ_CAN_RUN_SCRIPT static bool
2176
get_fieldOfView(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
2177
0
{
2178
0
  AUTO_PROFILER_LABEL_FAST("get VREyeParameters.fieldOfView", DOM, cx);
2179
0
2180
0
  auto result(StrongOrRawPtr<mozilla::dom::VRFieldOfView>(self->FieldOfView()));
2181
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2182
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
2183
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
2184
0
    return false;
2185
0
  }
2186
0
  return true;
2187
0
}
2188
2189
static const JSJitInfo fieldOfView_getterinfo = {
2190
  { (JSJitGetterOp)get_fieldOfView },
2191
  { prototypes::id::VREyeParameters },
2192
  { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
2193
  JSJitInfo::Getter,
2194
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2195
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2196
  false,  /* isInfallible. False in setters. */
2197
  true,  /* isMovable.  Not relevant for setters. */
2198
  true, /* isEliminatable.  Not relevant for setters. */
2199
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2200
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2201
  false,  /* isTypedMethod.  Only relevant for methods. */
2202
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2203
};
2204
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2205
static_assert(0 < 1, "There is no slot for us");
2206
2207
MOZ_CAN_RUN_SCRIPT static bool
2208
get_renderWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
2209
0
{
2210
0
  AUTO_PROFILER_LABEL_FAST("get VREyeParameters.renderWidth", DOM, cx);
2211
0
2212
0
  uint32_t result(self->RenderWidth());
2213
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2214
0
  args.rval().setNumber(result);
2215
0
  return true;
2216
0
}
2217
2218
static const JSJitInfo renderWidth_getterinfo = {
2219
  { (JSJitGetterOp)get_renderWidth },
2220
  { prototypes::id::VREyeParameters },
2221
  { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
2222
  JSJitInfo::Getter,
2223
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2224
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2225
  true,  /* isInfallible. False in setters. */
2226
  true,  /* isMovable.  Not relevant for setters. */
2227
  true, /* isEliminatable.  Not relevant for setters. */
2228
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2229
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2230
  false,  /* isTypedMethod.  Only relevant for methods. */
2231
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2232
};
2233
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2234
static_assert(0 < 1, "There is no slot for us");
2235
2236
MOZ_CAN_RUN_SCRIPT static bool
2237
get_renderHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VREyeParameters* self, JSJitGetterCallArgs args)
2238
0
{
2239
0
  AUTO_PROFILER_LABEL_FAST("get VREyeParameters.renderHeight", DOM, cx);
2240
0
2241
0
  uint32_t result(self->RenderHeight());
2242
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2243
0
  args.rval().setNumber(result);
2244
0
  return true;
2245
0
}
2246
2247
static const JSJitInfo renderHeight_getterinfo = {
2248
  { (JSJitGetterOp)get_renderHeight },
2249
  { prototypes::id::VREyeParameters },
2250
  { PrototypeTraits<prototypes::id::VREyeParameters>::Depth },
2251
  JSJitInfo::Getter,
2252
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
2253
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2254
  true,  /* isInfallible. False in setters. */
2255
  true,  /* isMovable.  Not relevant for setters. */
2256
  true, /* isEliminatable.  Not relevant for setters. */
2257
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2258
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2259
  false,  /* isTypedMethod.  Only relevant for methods. */
2260
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2261
};
2262
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2263
static_assert(0 < 1, "There is no slot for us");
2264
2265
static bool
2266
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
2267
0
{
2268
0
  mozilla::dom::VREyeParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VREyeParameters>(obj);
2269
0
  // We don't want to preserve if we don't have a wrapper, and we
2270
0
  // obviously can't preserve if we're not initialized.
2271
0
  if (self && self->GetWrapperPreserveColor()) {
2272
0
    PreserveWrapper(self);
2273
0
  }
2274
0
  return true;
2275
0
}
2276
2277
static void
2278
_finalize(js::FreeOp* fop, JSObject* obj)
2279
0
{
2280
0
  mozilla::dom::VREyeParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VREyeParameters>(obj);
2281
0
  if (self) {
2282
0
    ClearWrapper(self, self, obj);
2283
0
    AddForDeferredFinalization<mozilla::dom::VREyeParameters>(self);
2284
0
  }
2285
0
}
2286
2287
static size_t
2288
_objectMoved(JSObject* obj, JSObject* old)
2289
0
{
2290
0
  mozilla::dom::VREyeParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VREyeParameters>(obj);
2291
0
  if (self) {
2292
0
    UpdateWrapper(self, self, obj, old);
2293
0
  }
2294
0
2295
0
  return 0;
2296
0
}
2297
2298
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2299
#if defined(__clang__)
2300
#pragma clang diagnostic push
2301
#pragma clang diagnostic ignored "-Wmissing-braces"
2302
#endif
2303
static const JSPropertySpec sAttributes_specs[] = {
2304
  { "offset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &offset_getterinfo, nullptr, nullptr },
2305
  { "fieldOfView", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fieldOfView_getterinfo, nullptr, nullptr },
2306
  { "renderWidth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &renderWidth_getterinfo, nullptr, nullptr },
2307
  { "renderHeight", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &renderHeight_getterinfo, nullptr, nullptr },
2308
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
2309
};
2310
#if defined(__clang__)
2311
#pragma clang diagnostic pop
2312
#endif
2313
2314
2315
static const Prefable<const JSPropertySpec> sAttributes[] = {
2316
  { nullptr, &sAttributes_specs[0] },
2317
  { nullptr, nullptr }
2318
};
2319
2320
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2321
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2322
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2323
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2324
2325
2326
static uint16_t sNativeProperties_sortedPropertyIndices[4];
2327
static PropertyInfo sNativeProperties_propertyInfos[4];
2328
2329
static const NativePropertiesN<1> sNativeProperties = {
2330
  false, 0,
2331
  false, 0,
2332
  false, 0,
2333
  true,  0 /* sAttributes */,
2334
  false, 0,
2335
  false, 0,
2336
  false, 0,
2337
  -1,
2338
  4,
2339
  sNativeProperties_sortedPropertyIndices,
2340
  {
2341
    { sAttributes, &sNativeProperties_propertyInfos[0] }
2342
  }
2343
};
2344
static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
2345
    "We have a property info count that is oversized");
2346
2347
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2348
  {
2349
    "Function",
2350
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2351
    &sBoringInterfaceObjectClassClassOps,
2352
    JS_NULL_CLASS_SPEC,
2353
    JS_NULL_CLASS_EXT,
2354
    &sInterfaceObjectClassObjectOps
2355
  },
2356
  eInterface,
2357
  true,
2358
  prototypes::id::VREyeParameters,
2359
  PrototypeTraits<prototypes::id::VREyeParameters>::Depth,
2360
  sNativePropertyHooks,
2361
  "function VREyeParameters() {\n    [native code]\n}",
2362
  JS::GetRealmFunctionPrototype
2363
};
2364
2365
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2366
  {
2367
    "VREyeParametersPrototype",
2368
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2369
    JS_NULL_CLASS_OPS,
2370
    JS_NULL_CLASS_SPEC,
2371
    JS_NULL_CLASS_EXT,
2372
    JS_NULL_OBJECT_OPS
2373
  },
2374
  eInterfacePrototype,
2375
  false,
2376
  prototypes::id::VREyeParameters,
2377
  PrototypeTraits<prototypes::id::VREyeParameters>::Depth,
2378
  sNativePropertyHooks,
2379
  "[object VREyeParametersPrototype]",
2380
  JS::GetRealmObjectPrototype
2381
};
2382
2383
bool
2384
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
2385
0
{
2386
0
  static bool sPrefValue;
2387
0
  static bool sPrefCacheSetUp = false;
2388
0
  if (!sPrefCacheSetUp) {
2389
0
    sPrefCacheSetUp = true;
2390
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
2391
0
  }
2392
0
2393
0
  return sPrefValue;
2394
0
}
2395
2396
static const js::ClassOps sClassOps = {
2397
  _addProperty, /* addProperty */
2398
  nullptr,               /* delProperty */
2399
  nullptr,               /* enumerate */
2400
  nullptr, /* newEnumerate */
2401
  nullptr, /* resolve */
2402
  nullptr, /* mayResolve */
2403
  _finalize, /* finalize */
2404
  nullptr, /* call */
2405
  nullptr,               /* hasInstance */
2406
  nullptr,               /* construct */
2407
  nullptr, /* trace */
2408
};
2409
2410
static const js::ClassExtension sClassExtension = {
2411
  nullptr, /* weakmapKeyDelegateOp */
2412
  _objectMoved /* objectMovedOp */
2413
};
2414
2415
static const DOMJSClass sClass = {
2416
  { "VREyeParameters",
2417
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
2418
    &sClassOps,
2419
    JS_NULL_CLASS_SPEC,
2420
    &sClassExtension,
2421
    JS_NULL_OBJECT_OPS
2422
  },
2423
  { prototypes::id::VREyeParameters, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
2424
  IsBaseOf<nsISupports, mozilla::dom::VREyeParameters >::value,
2425
  sNativePropertyHooks,
2426
  FindAssociatedGlobalForNative<mozilla::dom::VREyeParameters>::Get,
2427
  GetProtoObjectHandle,
2428
  GetCCParticipant<mozilla::dom::VREyeParameters>::Get()
2429
};
2430
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
2431
              "Must have the right minimal number of reserved slots.");
2432
static_assert(1 >= 1,
2433
              "Must have enough reserved slots.");
2434
2435
const JSClass*
2436
GetJSClass()
2437
0
{
2438
0
  return sClass.ToJSClass();
2439
0
}
2440
2441
bool
2442
Wrap(JSContext* aCx, mozilla::dom::VREyeParameters* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2443
0
{
2444
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VREyeParameters>::value,
2445
0
                "Shouldn't have wrappercached things that are not refcounted.");
2446
0
  MOZ_ASSERT(static_cast<mozilla::dom::VREyeParameters*>(aObject) ==
2447
0
             reinterpret_cast<mozilla::dom::VREyeParameters*>(aObject),
2448
0
             "Multiple inheritance for mozilla::dom::VREyeParameters is broken.");
2449
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2450
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2451
0
  MOZ_ASSERT(!aCache->GetWrapper(),
2452
0
             "You should probably not be using Wrap() directly; use "
2453
0
             "GetOrCreateDOMReflector instead");
2454
0
2455
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2456
0
             "nsISupports must be on our primary inheritance chain");
2457
0
2458
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2459
0
  if (!global) {
2460
0
    return false;
2461
0
  }
2462
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
2463
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
2464
0
2465
0
  // That might have ended up wrapping us already, due to the wonders
2466
0
  // of XBL.  Check for that, and bail out as needed.
2467
0
  aReflector.set(aCache->GetWrapper());
2468
0
  if (aReflector) {
2469
#ifdef DEBUG
2470
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2471
#endif // DEBUG
2472
    return true;
2473
0
  }
2474
0
2475
0
  JSAutoRealm ar(aCx, global);
2476
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2477
0
  if (!canonicalProto) {
2478
0
    return false;
2479
0
  }
2480
0
  JS::Rooted<JSObject*> proto(aCx);
2481
0
  if (aGivenProto) {
2482
0
    proto = aGivenProto;
2483
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2484
0
    // coming in, we changed compartments to that of "parent" so may need
2485
0
    // to wrap the proto here.
2486
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2487
0
      if (!JS_WrapObject(aCx, &proto)) {
2488
0
        return false;
2489
0
      }
2490
0
    }
2491
0
  } else {
2492
0
    proto = canonicalProto;
2493
0
  }
2494
0
2495
0
  BindingJSObjectCreator<mozilla::dom::VREyeParameters> creator(aCx);
2496
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
2497
0
  if (!aReflector) {
2498
0
    return false;
2499
0
  }
2500
0
2501
0
  aCache->SetWrapper(aReflector);
2502
0
  creator.InitializationSucceeded();
2503
0
2504
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2505
0
             aCache->GetWrapperPreserveColor() == aReflector);
2506
0
  // If proto != canonicalProto, we have to preserve our wrapper;
2507
0
  // otherwise we won't be able to properly recreate it later, since
2508
0
  // we won't know what proto to use.  Note that we don't check
2509
0
  // aGivenProto here, since it's entirely possible (and even
2510
0
  // somewhat common) to have a non-null aGivenProto which is the
2511
0
  // same as canonicalProto.
2512
0
  if (proto != canonicalProto) {
2513
0
    PreserveWrapper(aObject);
2514
0
  }
2515
0
2516
0
  return true;
2517
0
}
2518
2519
const NativePropertyHooks sNativePropertyHooks[] = { {
2520
  nullptr,
2521
  nullptr,
2522
  nullptr,
2523
  { sNativeProperties.Upcast(), nullptr },
2524
  prototypes::id::VREyeParameters,
2525
  constructors::id::VREyeParameters,
2526
  nullptr,
2527
  &DefaultXrayExpandoObjectClass
2528
} };
2529
2530
void
2531
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2532
0
{
2533
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
2534
0
  if (!parentProto) {
2535
0
    return;
2536
0
  }
2537
0
2538
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
2539
0
  if (!constructorProto) {
2540
0
    return;
2541
0
  }
2542
0
2543
0
  static bool sIdsInited = false;
2544
0
  if (!sIdsInited && NS_IsMainThread()) {
2545
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
2546
0
      return;
2547
0
    }
2548
0
    sIdsInited = true;
2549
0
  }
2550
0
2551
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VREyeParameters);
2552
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VREyeParameters);
2553
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2554
0
                              &sPrototypeClass.mBase, protoCache,
2555
0
                              nullptr,
2556
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2557
0
                              interfaceCache,
2558
0
                              sNativeProperties.Upcast(),
2559
0
                              nullptr,
2560
0
                              "VREyeParameters", aDefineOnGlobal,
2561
0
                              nullptr,
2562
0
                              false);
2563
0
}
2564
2565
JSObject*
2566
GetConstructorObject(JSContext* aCx)
2567
0
{
2568
0
  return GetConstructorObjectHandle(aCx);
2569
0
}
2570
2571
} // namespace VREyeParameters_Binding
2572
2573
2574
2575
namespace VRFieldOfView_Binding {
2576
2577
MOZ_CAN_RUN_SCRIPT static bool
2578
get_upDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
2579
0
{
2580
0
  AUTO_PROFILER_LABEL_FAST("get VRFieldOfView.upDegrees", DOM, cx);
2581
0
2582
0
  double result(self->UpDegrees());
2583
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2584
0
  args.rval().set(JS_NumberValue(double(result)));
2585
0
  return true;
2586
0
}
2587
2588
static const JSJitInfo upDegrees_getterinfo = {
2589
  { (JSJitGetterOp)get_upDegrees },
2590
  { prototypes::id::VRFieldOfView },
2591
  { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
2592
  JSJitInfo::Getter,
2593
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2594
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2595
  true,  /* isInfallible. False in setters. */
2596
  false,  /* isMovable.  Not relevant for setters. */
2597
  false, /* isEliminatable.  Not relevant for setters. */
2598
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2599
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2600
  false,  /* isTypedMethod.  Only relevant for methods. */
2601
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2602
};
2603
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2604
static_assert(0 < 1, "There is no slot for us");
2605
2606
MOZ_CAN_RUN_SCRIPT static bool
2607
get_rightDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
2608
0
{
2609
0
  AUTO_PROFILER_LABEL_FAST("get VRFieldOfView.rightDegrees", DOM, cx);
2610
0
2611
0
  double result(self->RightDegrees());
2612
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2613
0
  args.rval().set(JS_NumberValue(double(result)));
2614
0
  return true;
2615
0
}
2616
2617
static const JSJitInfo rightDegrees_getterinfo = {
2618
  { (JSJitGetterOp)get_rightDegrees },
2619
  { prototypes::id::VRFieldOfView },
2620
  { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
2621
  JSJitInfo::Getter,
2622
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2623
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2624
  true,  /* isInfallible. False in setters. */
2625
  false,  /* isMovable.  Not relevant for setters. */
2626
  false, /* isEliminatable.  Not relevant for setters. */
2627
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2628
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2629
  false,  /* isTypedMethod.  Only relevant for methods. */
2630
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2631
};
2632
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2633
static_assert(0 < 1, "There is no slot for us");
2634
2635
MOZ_CAN_RUN_SCRIPT static bool
2636
get_downDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
2637
0
{
2638
0
  AUTO_PROFILER_LABEL_FAST("get VRFieldOfView.downDegrees", DOM, cx);
2639
0
2640
0
  double result(self->DownDegrees());
2641
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2642
0
  args.rval().set(JS_NumberValue(double(result)));
2643
0
  return true;
2644
0
}
2645
2646
static const JSJitInfo downDegrees_getterinfo = {
2647
  { (JSJitGetterOp)get_downDegrees },
2648
  { prototypes::id::VRFieldOfView },
2649
  { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
2650
  JSJitInfo::Getter,
2651
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2652
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2653
  true,  /* isInfallible. False in setters. */
2654
  false,  /* isMovable.  Not relevant for setters. */
2655
  false, /* isEliminatable.  Not relevant for setters. */
2656
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2657
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2658
  false,  /* isTypedMethod.  Only relevant for methods. */
2659
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2660
};
2661
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2662
static_assert(0 < 1, "There is no slot for us");
2663
2664
MOZ_CAN_RUN_SCRIPT static bool
2665
get_leftDegrees(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFieldOfView* self, JSJitGetterCallArgs args)
2666
0
{
2667
0
  AUTO_PROFILER_LABEL_FAST("get VRFieldOfView.leftDegrees", DOM, cx);
2668
0
2669
0
  double result(self->LeftDegrees());
2670
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2671
0
  args.rval().set(JS_NumberValue(double(result)));
2672
0
  return true;
2673
0
}
2674
2675
static const JSJitInfo leftDegrees_getterinfo = {
2676
  { (JSJitGetterOp)get_leftDegrees },
2677
  { prototypes::id::VRFieldOfView },
2678
  { PrototypeTraits<prototypes::id::VRFieldOfView>::Depth },
2679
  JSJitInfo::Getter,
2680
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2681
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2682
  true,  /* isInfallible. False in setters. */
2683
  false,  /* isMovable.  Not relevant for setters. */
2684
  false, /* isEliminatable.  Not relevant for setters. */
2685
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2686
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2687
  false,  /* isTypedMethod.  Only relevant for methods. */
2688
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2689
};
2690
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2691
static_assert(0 < 1, "There is no slot for us");
2692
2693
static bool
2694
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
2695
0
{
2696
0
  mozilla::dom::VRFieldOfView* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFieldOfView>(obj);
2697
0
  // We don't want to preserve if we don't have a wrapper, and we
2698
0
  // obviously can't preserve if we're not initialized.
2699
0
  if (self && self->GetWrapperPreserveColor()) {
2700
0
    PreserveWrapper(self);
2701
0
  }
2702
0
  return true;
2703
0
}
2704
2705
static void
2706
_finalize(js::FreeOp* fop, JSObject* obj)
2707
0
{
2708
0
  mozilla::dom::VRFieldOfView* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFieldOfView>(obj);
2709
0
  if (self) {
2710
0
    ClearWrapper(self, self, obj);
2711
0
    AddForDeferredFinalization<mozilla::dom::VRFieldOfView>(self);
2712
0
  }
2713
0
}
2714
2715
static size_t
2716
_objectMoved(JSObject* obj, JSObject* old)
2717
0
{
2718
0
  mozilla::dom::VRFieldOfView* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFieldOfView>(obj);
2719
0
  if (self) {
2720
0
    UpdateWrapper(self, self, obj, old);
2721
0
  }
2722
0
2723
0
  return 0;
2724
0
}
2725
2726
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
2727
#if defined(__clang__)
2728
#pragma clang diagnostic push
2729
#pragma clang diagnostic ignored "-Wmissing-braces"
2730
#endif
2731
static const JSPropertySpec sAttributes_specs[] = {
2732
  { "upDegrees", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &upDegrees_getterinfo, nullptr, nullptr },
2733
  { "rightDegrees", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rightDegrees_getterinfo, nullptr, nullptr },
2734
  { "downDegrees", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &downDegrees_getterinfo, nullptr, nullptr },
2735
  { "leftDegrees", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &leftDegrees_getterinfo, nullptr, nullptr },
2736
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
2737
};
2738
#if defined(__clang__)
2739
#pragma clang diagnostic pop
2740
#endif
2741
2742
2743
static const Prefable<const JSPropertySpec> sAttributes[] = {
2744
  { nullptr, &sAttributes_specs[0] },
2745
  { nullptr, nullptr }
2746
};
2747
2748
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
2749
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
2750
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
2751
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
2752
2753
2754
static uint16_t sNativeProperties_sortedPropertyIndices[4];
2755
static PropertyInfo sNativeProperties_propertyInfos[4];
2756
2757
static const NativePropertiesN<1> sNativeProperties = {
2758
  false, 0,
2759
  false, 0,
2760
  false, 0,
2761
  true,  0 /* sAttributes */,
2762
  false, 0,
2763
  false, 0,
2764
  false, 0,
2765
  -1,
2766
  4,
2767
  sNativeProperties_sortedPropertyIndices,
2768
  {
2769
    { sAttributes, &sNativeProperties_propertyInfos[0] }
2770
  }
2771
};
2772
static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
2773
    "We have a property info count that is oversized");
2774
2775
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
2776
  {
2777
    "Function",
2778
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
2779
    &sBoringInterfaceObjectClassClassOps,
2780
    JS_NULL_CLASS_SPEC,
2781
    JS_NULL_CLASS_EXT,
2782
    &sInterfaceObjectClassObjectOps
2783
  },
2784
  eInterface,
2785
  true,
2786
  prototypes::id::VRFieldOfView,
2787
  PrototypeTraits<prototypes::id::VRFieldOfView>::Depth,
2788
  sNativePropertyHooks,
2789
  "function VRFieldOfView() {\n    [native code]\n}",
2790
  JS::GetRealmFunctionPrototype
2791
};
2792
2793
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
2794
  {
2795
    "VRFieldOfViewPrototype",
2796
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
2797
    JS_NULL_CLASS_OPS,
2798
    JS_NULL_CLASS_SPEC,
2799
    JS_NULL_CLASS_EXT,
2800
    JS_NULL_OBJECT_OPS
2801
  },
2802
  eInterfacePrototype,
2803
  false,
2804
  prototypes::id::VRFieldOfView,
2805
  PrototypeTraits<prototypes::id::VRFieldOfView>::Depth,
2806
  sNativePropertyHooks,
2807
  "[object VRFieldOfViewPrototype]",
2808
  JS::GetRealmObjectPrototype
2809
};
2810
2811
bool
2812
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
2813
0
{
2814
0
  static bool sPrefValue;
2815
0
  static bool sPrefCacheSetUp = false;
2816
0
  if (!sPrefCacheSetUp) {
2817
0
    sPrefCacheSetUp = true;
2818
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
2819
0
  }
2820
0
2821
0
  return sPrefValue;
2822
0
}
2823
2824
static const js::ClassOps sClassOps = {
2825
  _addProperty, /* addProperty */
2826
  nullptr,               /* delProperty */
2827
  nullptr,               /* enumerate */
2828
  nullptr, /* newEnumerate */
2829
  nullptr, /* resolve */
2830
  nullptr, /* mayResolve */
2831
  _finalize, /* finalize */
2832
  nullptr, /* call */
2833
  nullptr,               /* hasInstance */
2834
  nullptr,               /* construct */
2835
  nullptr, /* trace */
2836
};
2837
2838
static const js::ClassExtension sClassExtension = {
2839
  nullptr, /* weakmapKeyDelegateOp */
2840
  _objectMoved /* objectMovedOp */
2841
};
2842
2843
static const DOMJSClass sClass = {
2844
  { "VRFieldOfView",
2845
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
2846
    &sClassOps,
2847
    JS_NULL_CLASS_SPEC,
2848
    &sClassExtension,
2849
    JS_NULL_OBJECT_OPS
2850
  },
2851
  { prototypes::id::VRFieldOfView, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
2852
  IsBaseOf<nsISupports, mozilla::dom::VRFieldOfView >::value,
2853
  sNativePropertyHooks,
2854
  FindAssociatedGlobalForNative<mozilla::dom::VRFieldOfView>::Get,
2855
  GetProtoObjectHandle,
2856
  GetCCParticipant<mozilla::dom::VRFieldOfView>::Get()
2857
};
2858
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
2859
              "Must have the right minimal number of reserved slots.");
2860
static_assert(1 >= 1,
2861
              "Must have enough reserved slots.");
2862
2863
const JSClass*
2864
GetJSClass()
2865
0
{
2866
0
  return sClass.ToJSClass();
2867
0
}
2868
2869
bool
2870
Wrap(JSContext* aCx, mozilla::dom::VRFieldOfView* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
2871
0
{
2872
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRFieldOfView>::value,
2873
0
                "Shouldn't have wrappercached things that are not refcounted.");
2874
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRFieldOfView*>(aObject) ==
2875
0
             reinterpret_cast<mozilla::dom::VRFieldOfView*>(aObject),
2876
0
             "Multiple inheritance for mozilla::dom::VRFieldOfView is broken.");
2877
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
2878
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
2879
0
  MOZ_ASSERT(!aCache->GetWrapper(),
2880
0
             "You should probably not be using Wrap() directly; use "
2881
0
             "GetOrCreateDOMReflector instead");
2882
0
2883
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
2884
0
             "nsISupports must be on our primary inheritance chain");
2885
0
2886
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
2887
0
  if (!global) {
2888
0
    return false;
2889
0
  }
2890
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
2891
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
2892
0
2893
0
  // That might have ended up wrapping us already, due to the wonders
2894
0
  // of XBL.  Check for that, and bail out as needed.
2895
0
  aReflector.set(aCache->GetWrapper());
2896
0
  if (aReflector) {
2897
#ifdef DEBUG
2898
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
2899
#endif // DEBUG
2900
    return true;
2901
0
  }
2902
0
2903
0
  JSAutoRealm ar(aCx, global);
2904
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
2905
0
  if (!canonicalProto) {
2906
0
    return false;
2907
0
  }
2908
0
  JS::Rooted<JSObject*> proto(aCx);
2909
0
  if (aGivenProto) {
2910
0
    proto = aGivenProto;
2911
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
2912
0
    // coming in, we changed compartments to that of "parent" so may need
2913
0
    // to wrap the proto here.
2914
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
2915
0
      if (!JS_WrapObject(aCx, &proto)) {
2916
0
        return false;
2917
0
      }
2918
0
    }
2919
0
  } else {
2920
0
    proto = canonicalProto;
2921
0
  }
2922
0
2923
0
  BindingJSObjectCreator<mozilla::dom::VRFieldOfView> creator(aCx);
2924
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
2925
0
  if (!aReflector) {
2926
0
    return false;
2927
0
  }
2928
0
2929
0
  aCache->SetWrapper(aReflector);
2930
0
  creator.InitializationSucceeded();
2931
0
2932
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
2933
0
             aCache->GetWrapperPreserveColor() == aReflector);
2934
0
  // If proto != canonicalProto, we have to preserve our wrapper;
2935
0
  // otherwise we won't be able to properly recreate it later, since
2936
0
  // we won't know what proto to use.  Note that we don't check
2937
0
  // aGivenProto here, since it's entirely possible (and even
2938
0
  // somewhat common) to have a non-null aGivenProto which is the
2939
0
  // same as canonicalProto.
2940
0
  if (proto != canonicalProto) {
2941
0
    PreserveWrapper(aObject);
2942
0
  }
2943
0
2944
0
  return true;
2945
0
}
2946
2947
const NativePropertyHooks sNativePropertyHooks[] = { {
2948
  nullptr,
2949
  nullptr,
2950
  nullptr,
2951
  { sNativeProperties.Upcast(), nullptr },
2952
  prototypes::id::VRFieldOfView,
2953
  constructors::id::VRFieldOfView,
2954
  nullptr,
2955
  &DefaultXrayExpandoObjectClass
2956
} };
2957
2958
void
2959
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
2960
0
{
2961
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
2962
0
  if (!parentProto) {
2963
0
    return;
2964
0
  }
2965
0
2966
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
2967
0
  if (!constructorProto) {
2968
0
    return;
2969
0
  }
2970
0
2971
0
  static bool sIdsInited = false;
2972
0
  if (!sIdsInited && NS_IsMainThread()) {
2973
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
2974
0
      return;
2975
0
    }
2976
0
    sIdsInited = true;
2977
0
  }
2978
0
2979
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRFieldOfView);
2980
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRFieldOfView);
2981
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
2982
0
                              &sPrototypeClass.mBase, protoCache,
2983
0
                              nullptr,
2984
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
2985
0
                              interfaceCache,
2986
0
                              sNativeProperties.Upcast(),
2987
0
                              nullptr,
2988
0
                              "VRFieldOfView", aDefineOnGlobal,
2989
0
                              nullptr,
2990
0
                              false);
2991
0
}
2992
2993
JSObject*
2994
GetConstructorObject(JSContext* aCx)
2995
0
{
2996
0
  return GetConstructorObjectHandle(aCx);
2997
0
}
2998
2999
} // namespace VRFieldOfView_Binding
3000
3001
3002
3003
namespace VRFrameData_Binding {
3004
3005
MOZ_CAN_RUN_SCRIPT static bool
3006
get_timestamp(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
3007
0
{
3008
0
  AUTO_PROFILER_LABEL_FAST("get VRFrameData.timestamp", DOM, cx);
3009
0
3010
0
  double result(self->Timestamp());
3011
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3012
0
  args.rval().set(JS_NumberValue(double(result)));
3013
0
  return true;
3014
0
}
3015
3016
static const JSJitInfo timestamp_getterinfo = {
3017
  { (JSJitGetterOp)get_timestamp },
3018
  { prototypes::id::VRFrameData },
3019
  { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
3020
  JSJitInfo::Getter,
3021
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3022
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
3023
  true,  /* isInfallible. False in setters. */
3024
  false,  /* isMovable.  Not relevant for setters. */
3025
  false, /* isEliminatable.  Not relevant for setters. */
3026
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3027
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3028
  false,  /* isTypedMethod.  Only relevant for methods. */
3029
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3030
};
3031
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3032
static_assert(0 < 1, "There is no slot for us");
3033
3034
MOZ_CAN_RUN_SCRIPT static bool
3035
get_leftProjectionMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
3036
0
{
3037
0
  AUTO_PROFILER_LABEL_FAST("get VRFrameData.leftProjectionMatrix", DOM, cx);
3038
0
3039
0
  FastErrorResult rv;
3040
0
  JS::Rooted<JSObject*> result(cx);
3041
0
  self->GetLeftProjectionMatrix(cx, &result, rv);
3042
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3043
0
    return false;
3044
0
  }
3045
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3046
0
  JS::ExposeObjectToActiveJS(result);
3047
0
  args.rval().setObject(*result);
3048
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
3049
0
    return false;
3050
0
  }
3051
0
  return true;
3052
0
}
3053
3054
static const JSJitInfo leftProjectionMatrix_getterinfo = {
3055
  { (JSJitGetterOp)get_leftProjectionMatrix },
3056
  { prototypes::id::VRFrameData },
3057
  { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
3058
  JSJitInfo::Getter,
3059
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3060
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3061
  false,  /* isInfallible. False in setters. */
3062
  false,  /* isMovable.  Not relevant for setters. */
3063
  false, /* isEliminatable.  Not relevant for setters. */
3064
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3065
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3066
  false,  /* isTypedMethod.  Only relevant for methods. */
3067
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3068
};
3069
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3070
static_assert(0 < 1, "There is no slot for us");
3071
3072
MOZ_CAN_RUN_SCRIPT static bool
3073
get_leftViewMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
3074
0
{
3075
0
  AUTO_PROFILER_LABEL_FAST("get VRFrameData.leftViewMatrix", DOM, cx);
3076
0
3077
0
  FastErrorResult rv;
3078
0
  JS::Rooted<JSObject*> result(cx);
3079
0
  self->GetLeftViewMatrix(cx, &result, rv);
3080
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3081
0
    return false;
3082
0
  }
3083
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3084
0
  JS::ExposeObjectToActiveJS(result);
3085
0
  args.rval().setObject(*result);
3086
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
3087
0
    return false;
3088
0
  }
3089
0
  return true;
3090
0
}
3091
3092
static const JSJitInfo leftViewMatrix_getterinfo = {
3093
  { (JSJitGetterOp)get_leftViewMatrix },
3094
  { prototypes::id::VRFrameData },
3095
  { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
3096
  JSJitInfo::Getter,
3097
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3098
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3099
  false,  /* isInfallible. False in setters. */
3100
  false,  /* isMovable.  Not relevant for setters. */
3101
  false, /* isEliminatable.  Not relevant for setters. */
3102
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3103
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3104
  false,  /* isTypedMethod.  Only relevant for methods. */
3105
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3106
};
3107
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3108
static_assert(0 < 1, "There is no slot for us");
3109
3110
MOZ_CAN_RUN_SCRIPT static bool
3111
get_rightProjectionMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
3112
0
{
3113
0
  AUTO_PROFILER_LABEL_FAST("get VRFrameData.rightProjectionMatrix", DOM, cx);
3114
0
3115
0
  FastErrorResult rv;
3116
0
  JS::Rooted<JSObject*> result(cx);
3117
0
  self->GetRightProjectionMatrix(cx, &result, rv);
3118
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3119
0
    return false;
3120
0
  }
3121
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3122
0
  JS::ExposeObjectToActiveJS(result);
3123
0
  args.rval().setObject(*result);
3124
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
3125
0
    return false;
3126
0
  }
3127
0
  return true;
3128
0
}
3129
3130
static const JSJitInfo rightProjectionMatrix_getterinfo = {
3131
  { (JSJitGetterOp)get_rightProjectionMatrix },
3132
  { prototypes::id::VRFrameData },
3133
  { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
3134
  JSJitInfo::Getter,
3135
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3136
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3137
  false,  /* isInfallible. False in setters. */
3138
  false,  /* isMovable.  Not relevant for setters. */
3139
  false, /* isEliminatable.  Not relevant for setters. */
3140
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3141
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3142
  false,  /* isTypedMethod.  Only relevant for methods. */
3143
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3144
};
3145
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3146
static_assert(0 < 1, "There is no slot for us");
3147
3148
MOZ_CAN_RUN_SCRIPT static bool
3149
get_rightViewMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
3150
0
{
3151
0
  AUTO_PROFILER_LABEL_FAST("get VRFrameData.rightViewMatrix", DOM, cx);
3152
0
3153
0
  FastErrorResult rv;
3154
0
  JS::Rooted<JSObject*> result(cx);
3155
0
  self->GetRightViewMatrix(cx, &result, rv);
3156
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3157
0
    return false;
3158
0
  }
3159
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3160
0
  JS::ExposeObjectToActiveJS(result);
3161
0
  args.rval().setObject(*result);
3162
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
3163
0
    return false;
3164
0
  }
3165
0
  return true;
3166
0
}
3167
3168
static const JSJitInfo rightViewMatrix_getterinfo = {
3169
  { (JSJitGetterOp)get_rightViewMatrix },
3170
  { prototypes::id::VRFrameData },
3171
  { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
3172
  JSJitInfo::Getter,
3173
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3174
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3175
  false,  /* isInfallible. False in setters. */
3176
  false,  /* isMovable.  Not relevant for setters. */
3177
  false, /* isEliminatable.  Not relevant for setters. */
3178
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3179
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3180
  false,  /* isTypedMethod.  Only relevant for methods. */
3181
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3182
};
3183
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3184
static_assert(0 < 1, "There is no slot for us");
3185
3186
MOZ_CAN_RUN_SCRIPT static bool
3187
get_pose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRFrameData* self, JSJitGetterCallArgs args)
3188
0
{
3189
0
  AUTO_PROFILER_LABEL_FAST("get VRFrameData.pose", DOM, cx);
3190
0
3191
0
  auto result(StrongOrRawPtr<mozilla::dom::VRPose>(self->Pose()));
3192
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3193
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3194
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3195
0
    return false;
3196
0
  }
3197
0
  return true;
3198
0
}
3199
3200
static const JSJitInfo pose_getterinfo = {
3201
  { (JSJitGetterOp)get_pose },
3202
  { prototypes::id::VRFrameData },
3203
  { PrototypeTraits<prototypes::id::VRFrameData>::Depth },
3204
  JSJitInfo::Getter,
3205
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
3206
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3207
  false,  /* isInfallible. False in setters. */
3208
  true,  /* isMovable.  Not relevant for setters. */
3209
  true, /* isEliminatable.  Not relevant for setters. */
3210
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3211
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3212
  false,  /* isTypedMethod.  Only relevant for methods. */
3213
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3214
};
3215
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3216
static_assert(0 < 1, "There is no slot for us");
3217
3218
static bool
3219
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
3220
0
{
3221
0
  mozilla::dom::VRFrameData* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFrameData>(obj);
3222
0
  // We don't want to preserve if we don't have a wrapper, and we
3223
0
  // obviously can't preserve if we're not initialized.
3224
0
  if (self && self->GetWrapperPreserveColor()) {
3225
0
    PreserveWrapper(self);
3226
0
  }
3227
0
  return true;
3228
0
}
3229
3230
static void
3231
_finalize(js::FreeOp* fop, JSObject* obj)
3232
0
{
3233
0
  mozilla::dom::VRFrameData* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFrameData>(obj);
3234
0
  if (self) {
3235
0
    ClearWrapper(self, self, obj);
3236
0
    AddForDeferredFinalization<mozilla::dom::VRFrameData>(self);
3237
0
  }
3238
0
}
3239
3240
static size_t
3241
_objectMoved(JSObject* obj, JSObject* old)
3242
0
{
3243
0
  mozilla::dom::VRFrameData* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRFrameData>(obj);
3244
0
  if (self) {
3245
0
    UpdateWrapper(self, self, obj, old);
3246
0
  }
3247
0
3248
0
  return 0;
3249
0
}
3250
3251
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3252
#if defined(__clang__)
3253
#pragma clang diagnostic push
3254
#pragma clang diagnostic ignored "-Wmissing-braces"
3255
#endif
3256
static const JSPropertySpec sAttributes_specs[] = {
3257
  { "timestamp", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &timestamp_getterinfo, nullptr, nullptr },
3258
  { "leftProjectionMatrix", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &leftProjectionMatrix_getterinfo, nullptr, nullptr },
3259
  { "leftViewMatrix", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &leftViewMatrix_getterinfo, nullptr, nullptr },
3260
  { "rightProjectionMatrix", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rightProjectionMatrix_getterinfo, nullptr, nullptr },
3261
  { "rightViewMatrix", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rightViewMatrix_getterinfo, nullptr, nullptr },
3262
  { "pose", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pose_getterinfo, nullptr, nullptr },
3263
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
3264
};
3265
#if defined(__clang__)
3266
#pragma clang diagnostic pop
3267
#endif
3268
3269
3270
static const Prefable<const JSPropertySpec> sAttributes[] = {
3271
  { nullptr, &sAttributes_specs[0] },
3272
  { nullptr, nullptr }
3273
};
3274
3275
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3276
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3277
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3278
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3279
3280
3281
static uint16_t sNativeProperties_sortedPropertyIndices[6];
3282
static PropertyInfo sNativeProperties_propertyInfos[6];
3283
3284
static const NativePropertiesN<1> sNativeProperties = {
3285
  false, 0,
3286
  false, 0,
3287
  false, 0,
3288
  true,  0 /* sAttributes */,
3289
  false, 0,
3290
  false, 0,
3291
  false, 0,
3292
  -1,
3293
  6,
3294
  sNativeProperties_sortedPropertyIndices,
3295
  {
3296
    { sAttributes, &sNativeProperties_propertyInfos[0] }
3297
  }
3298
};
3299
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
3300
    "We have a property info count that is oversized");
3301
3302
static bool
3303
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
3304
0
{
3305
0
  AUTO_PROFILER_LABEL_FAST("VRFrameData constructor", DOM, cx);
3306
0
3307
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
3308
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
3309
0
  if (!args.isConstructing()) {
3310
0
    // XXXbz wish I could get the name from the callee instead of
3311
0
    // Adding more relocations
3312
0
    return ThrowConstructorWithoutNew(cx, "VRFrameData");
3313
0
  }
3314
0
3315
0
  JS::Rooted<JSObject*> desiredProto(cx);
3316
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
3317
0
    return false;
3318
0
  }
3319
0
3320
0
  GlobalObject global(cx, obj);
3321
0
  if (global.Failed()) {
3322
0
    return false;
3323
0
  }
3324
0
3325
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
3326
0
  Maybe<JSAutoRealm> ar;
3327
0
  if (objIsXray) {
3328
0
    obj = js::CheckedUnwrap(obj);
3329
0
    if (!obj) {
3330
0
      return false;
3331
0
    }
3332
0
    ar.emplace(cx, obj);
3333
0
    if (!JS_WrapObject(cx, &desiredProto)) {
3334
0
      return false;
3335
0
    }
3336
0
  }
3337
0
  FastErrorResult rv;
3338
0
  auto result(StrongOrRawPtr<mozilla::dom::VRFrameData>(mozilla::dom::VRFrameData::Constructor(global, rv)));
3339
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3340
0
    return false;
3341
0
  }
3342
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3343
0
  static_assert(!IsPointer<decltype(result)>::value,
3344
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
3345
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
3346
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3347
0
    return false;
3348
0
  }
3349
0
  return true;
3350
0
}
3351
3352
static const js::ClassOps sInterfaceObjectClassOps = {
3353
    nullptr,               /* addProperty */
3354
    nullptr,               /* delProperty */
3355
    nullptr,               /* enumerate */
3356
    nullptr,               /* newEnumerate */
3357
    nullptr,               /* resolve */
3358
    nullptr,               /* mayResolve */
3359
    nullptr,               /* finalize */
3360
    _constructor, /* call */
3361
    nullptr,               /* hasInstance */
3362
    _constructor, /* construct */
3363
    nullptr,               /* trace */
3364
};
3365
3366
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
3367
  {
3368
    "Function",
3369
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
3370
    &sInterfaceObjectClassOps,
3371
    JS_NULL_CLASS_SPEC,
3372
    JS_NULL_CLASS_EXT,
3373
    &sInterfaceObjectClassObjectOps
3374
  },
3375
  eInterface,
3376
  true,
3377
  prototypes::id::VRFrameData,
3378
  PrototypeTraits<prototypes::id::VRFrameData>::Depth,
3379
  sNativePropertyHooks,
3380
  "function VRFrameData() {\n    [native code]\n}",
3381
  JS::GetRealmFunctionPrototype
3382
};
3383
3384
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3385
  {
3386
    "VRFrameDataPrototype",
3387
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3388
    JS_NULL_CLASS_OPS,
3389
    JS_NULL_CLASS_SPEC,
3390
    JS_NULL_CLASS_EXT,
3391
    JS_NULL_OBJECT_OPS
3392
  },
3393
  eInterfacePrototype,
3394
  false,
3395
  prototypes::id::VRFrameData,
3396
  PrototypeTraits<prototypes::id::VRFrameData>::Depth,
3397
  sNativePropertyHooks,
3398
  "[object VRFrameDataPrototype]",
3399
  JS::GetRealmObjectPrototype
3400
};
3401
3402
bool
3403
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
3404
0
{
3405
0
  static bool sPrefValue;
3406
0
  static bool sPrefCacheSetUp = false;
3407
0
  if (!sPrefCacheSetUp) {
3408
0
    sPrefCacheSetUp = true;
3409
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
3410
0
  }
3411
0
3412
0
  return sPrefValue;
3413
0
}
3414
3415
static const js::ClassOps sClassOps = {
3416
  _addProperty, /* addProperty */
3417
  nullptr,               /* delProperty */
3418
  nullptr,               /* enumerate */
3419
  nullptr, /* newEnumerate */
3420
  nullptr, /* resolve */
3421
  nullptr, /* mayResolve */
3422
  _finalize, /* finalize */
3423
  nullptr, /* call */
3424
  nullptr,               /* hasInstance */
3425
  nullptr,               /* construct */
3426
  nullptr, /* trace */
3427
};
3428
3429
static const js::ClassExtension sClassExtension = {
3430
  nullptr, /* weakmapKeyDelegateOp */
3431
  _objectMoved /* objectMovedOp */
3432
};
3433
3434
static const DOMJSClass sClass = {
3435
  { "VRFrameData",
3436
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
3437
    &sClassOps,
3438
    JS_NULL_CLASS_SPEC,
3439
    &sClassExtension,
3440
    JS_NULL_OBJECT_OPS
3441
  },
3442
  { prototypes::id::VRFrameData, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
3443
  IsBaseOf<nsISupports, mozilla::dom::VRFrameData >::value,
3444
  sNativePropertyHooks,
3445
  FindAssociatedGlobalForNative<mozilla::dom::VRFrameData>::Get,
3446
  GetProtoObjectHandle,
3447
  GetCCParticipant<mozilla::dom::VRFrameData>::Get()
3448
};
3449
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
3450
              "Must have the right minimal number of reserved slots.");
3451
static_assert(1 >= 1,
3452
              "Must have enough reserved slots.");
3453
3454
const JSClass*
3455
GetJSClass()
3456
0
{
3457
0
  return sClass.ToJSClass();
3458
0
}
3459
3460
bool
3461
Wrap(JSContext* aCx, mozilla::dom::VRFrameData* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
3462
0
{
3463
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRFrameData>::value,
3464
0
                "Shouldn't have wrappercached things that are not refcounted.");
3465
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRFrameData*>(aObject) ==
3466
0
             reinterpret_cast<mozilla::dom::VRFrameData*>(aObject),
3467
0
             "Multiple inheritance for mozilla::dom::VRFrameData is broken.");
3468
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
3469
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
3470
0
  MOZ_ASSERT(!aCache->GetWrapper(),
3471
0
             "You should probably not be using Wrap() directly; use "
3472
0
             "GetOrCreateDOMReflector instead");
3473
0
3474
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
3475
0
             "nsISupports must be on our primary inheritance chain");
3476
0
3477
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
3478
0
  if (!global) {
3479
0
    return false;
3480
0
  }
3481
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
3482
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
3483
0
3484
0
  // That might have ended up wrapping us already, due to the wonders
3485
0
  // of XBL.  Check for that, and bail out as needed.
3486
0
  aReflector.set(aCache->GetWrapper());
3487
0
  if (aReflector) {
3488
#ifdef DEBUG
3489
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
3490
#endif // DEBUG
3491
    return true;
3492
0
  }
3493
0
3494
0
  JSAutoRealm ar(aCx, global);
3495
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
3496
0
  if (!canonicalProto) {
3497
0
    return false;
3498
0
  }
3499
0
  JS::Rooted<JSObject*> proto(aCx);
3500
0
  if (aGivenProto) {
3501
0
    proto = aGivenProto;
3502
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
3503
0
    // coming in, we changed compartments to that of "parent" so may need
3504
0
    // to wrap the proto here.
3505
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
3506
0
      if (!JS_WrapObject(aCx, &proto)) {
3507
0
        return false;
3508
0
      }
3509
0
    }
3510
0
  } else {
3511
0
    proto = canonicalProto;
3512
0
  }
3513
0
3514
0
  BindingJSObjectCreator<mozilla::dom::VRFrameData> creator(aCx);
3515
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
3516
0
  if (!aReflector) {
3517
0
    return false;
3518
0
  }
3519
0
3520
0
  aCache->SetWrapper(aReflector);
3521
0
  creator.InitializationSucceeded();
3522
0
3523
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
3524
0
             aCache->GetWrapperPreserveColor() == aReflector);
3525
0
  // If proto != canonicalProto, we have to preserve our wrapper;
3526
0
  // otherwise we won't be able to properly recreate it later, since
3527
0
  // we won't know what proto to use.  Note that we don't check
3528
0
  // aGivenProto here, since it's entirely possible (and even
3529
0
  // somewhat common) to have a non-null aGivenProto which is the
3530
0
  // same as canonicalProto.
3531
0
  if (proto != canonicalProto) {
3532
0
    PreserveWrapper(aObject);
3533
0
  }
3534
0
3535
0
  return true;
3536
0
}
3537
3538
const NativePropertyHooks sNativePropertyHooks[] = { {
3539
  nullptr,
3540
  nullptr,
3541
  nullptr,
3542
  { sNativeProperties.Upcast(), nullptr },
3543
  prototypes::id::VRFrameData,
3544
  constructors::id::VRFrameData,
3545
  nullptr,
3546
  &DefaultXrayExpandoObjectClass
3547
} };
3548
3549
void
3550
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
3551
0
{
3552
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
3553
0
  if (!parentProto) {
3554
0
    return;
3555
0
  }
3556
0
3557
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
3558
0
  if (!constructorProto) {
3559
0
    return;
3560
0
  }
3561
0
3562
0
  static bool sIdsInited = false;
3563
0
  if (!sIdsInited && NS_IsMainThread()) {
3564
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
3565
0
      return;
3566
0
    }
3567
0
    sIdsInited = true;
3568
0
  }
3569
0
3570
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRFrameData);
3571
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRFrameData);
3572
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
3573
0
                              &sPrototypeClass.mBase, protoCache,
3574
0
                              nullptr,
3575
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
3576
0
                              interfaceCache,
3577
0
                              sNativeProperties.Upcast(),
3578
0
                              nullptr,
3579
0
                              "VRFrameData", aDefineOnGlobal,
3580
0
                              nullptr,
3581
0
                              false);
3582
0
}
3583
3584
JSObject*
3585
GetConstructorObject(JSContext* aCx)
3586
0
{
3587
0
  return GetConstructorObjectHandle(aCx);
3588
0
}
3589
3590
} // namespace VRFrameData_Binding
3591
3592
3593
3594
namespace VRPose_Binding {
3595
3596
MOZ_CAN_RUN_SCRIPT static bool
3597
get_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
3598
0
{
3599
0
  AUTO_PROFILER_LABEL_FAST("get VRPose.position", DOM, cx);
3600
0
3601
0
  FastErrorResult rv;
3602
0
  JS::Rooted<JSObject*> result(cx);
3603
0
  self->GetPosition(cx, &result, rv);
3604
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3605
0
    return false;
3606
0
  }
3607
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3608
0
  if (result) {
3609
0
                JS::ExposeObjectToActiveJS(result);
3610
0
              }
3611
0
              args.rval().setObjectOrNull(result);
3612
0
  if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3613
0
    return false;
3614
0
  }
3615
0
  return true;
3616
0
}
3617
3618
static const JSJitInfo position_getterinfo = {
3619
  { (JSJitGetterOp)get_position },
3620
  { prototypes::id::VRPose },
3621
  { PrototypeTraits<prototypes::id::VRPose>::Depth },
3622
  JSJitInfo::Getter,
3623
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3624
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3625
  false,  /* isInfallible. False in setters. */
3626
  false,  /* isMovable.  Not relevant for setters. */
3627
  false, /* isEliminatable.  Not relevant for setters. */
3628
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3629
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3630
  false,  /* isTypedMethod.  Only relevant for methods. */
3631
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3632
};
3633
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3634
static_assert(0 < 1, "There is no slot for us");
3635
3636
MOZ_CAN_RUN_SCRIPT static bool
3637
get_linearVelocity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
3638
0
{
3639
0
  AUTO_PROFILER_LABEL_FAST("get VRPose.linearVelocity", DOM, cx);
3640
0
3641
0
  FastErrorResult rv;
3642
0
  JS::Rooted<JSObject*> result(cx);
3643
0
  self->GetLinearVelocity(cx, &result, rv);
3644
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3645
0
    return false;
3646
0
  }
3647
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3648
0
  if (result) {
3649
0
                JS::ExposeObjectToActiveJS(result);
3650
0
              }
3651
0
              args.rval().setObjectOrNull(result);
3652
0
  if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3653
0
    return false;
3654
0
  }
3655
0
  return true;
3656
0
}
3657
3658
static const JSJitInfo linearVelocity_getterinfo = {
3659
  { (JSJitGetterOp)get_linearVelocity },
3660
  { prototypes::id::VRPose },
3661
  { PrototypeTraits<prototypes::id::VRPose>::Depth },
3662
  JSJitInfo::Getter,
3663
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3664
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3665
  false,  /* isInfallible. False in setters. */
3666
  false,  /* isMovable.  Not relevant for setters. */
3667
  false, /* isEliminatable.  Not relevant for setters. */
3668
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3669
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3670
  false,  /* isTypedMethod.  Only relevant for methods. */
3671
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3672
};
3673
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3674
static_assert(0 < 1, "There is no slot for us");
3675
3676
MOZ_CAN_RUN_SCRIPT static bool
3677
get_linearAcceleration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
3678
0
{
3679
0
  AUTO_PROFILER_LABEL_FAST("get VRPose.linearAcceleration", DOM, cx);
3680
0
3681
0
  FastErrorResult rv;
3682
0
  JS::Rooted<JSObject*> result(cx);
3683
0
  self->GetLinearAcceleration(cx, &result, rv);
3684
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3685
0
    return false;
3686
0
  }
3687
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3688
0
  if (result) {
3689
0
                JS::ExposeObjectToActiveJS(result);
3690
0
              }
3691
0
              args.rval().setObjectOrNull(result);
3692
0
  if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3693
0
    return false;
3694
0
  }
3695
0
  return true;
3696
0
}
3697
3698
static const JSJitInfo linearAcceleration_getterinfo = {
3699
  { (JSJitGetterOp)get_linearAcceleration },
3700
  { prototypes::id::VRPose },
3701
  { PrototypeTraits<prototypes::id::VRPose>::Depth },
3702
  JSJitInfo::Getter,
3703
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3704
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3705
  false,  /* isInfallible. False in setters. */
3706
  false,  /* isMovable.  Not relevant for setters. */
3707
  false, /* isEliminatable.  Not relevant for setters. */
3708
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3709
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3710
  false,  /* isTypedMethod.  Only relevant for methods. */
3711
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3712
};
3713
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3714
static_assert(0 < 1, "There is no slot for us");
3715
3716
MOZ_CAN_RUN_SCRIPT static bool
3717
get_orientation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
3718
0
{
3719
0
  AUTO_PROFILER_LABEL_FAST("get VRPose.orientation", DOM, cx);
3720
0
3721
0
  FastErrorResult rv;
3722
0
  JS::Rooted<JSObject*> result(cx);
3723
0
  self->GetOrientation(cx, &result, rv);
3724
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3725
0
    return false;
3726
0
  }
3727
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3728
0
  if (result) {
3729
0
                JS::ExposeObjectToActiveJS(result);
3730
0
              }
3731
0
              args.rval().setObjectOrNull(result);
3732
0
  if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3733
0
    return false;
3734
0
  }
3735
0
  return true;
3736
0
}
3737
3738
static const JSJitInfo orientation_getterinfo = {
3739
  { (JSJitGetterOp)get_orientation },
3740
  { prototypes::id::VRPose },
3741
  { PrototypeTraits<prototypes::id::VRPose>::Depth },
3742
  JSJitInfo::Getter,
3743
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3744
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3745
  false,  /* isInfallible. False in setters. */
3746
  false,  /* isMovable.  Not relevant for setters. */
3747
  false, /* isEliminatable.  Not relevant for setters. */
3748
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3749
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3750
  false,  /* isTypedMethod.  Only relevant for methods. */
3751
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3752
};
3753
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3754
static_assert(0 < 1, "There is no slot for us");
3755
3756
MOZ_CAN_RUN_SCRIPT static bool
3757
get_angularVelocity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
3758
0
{
3759
0
  AUTO_PROFILER_LABEL_FAST("get VRPose.angularVelocity", DOM, cx);
3760
0
3761
0
  FastErrorResult rv;
3762
0
  JS::Rooted<JSObject*> result(cx);
3763
0
  self->GetAngularVelocity(cx, &result, rv);
3764
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3765
0
    return false;
3766
0
  }
3767
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3768
0
  if (result) {
3769
0
                JS::ExposeObjectToActiveJS(result);
3770
0
              }
3771
0
              args.rval().setObjectOrNull(result);
3772
0
  if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3773
0
    return false;
3774
0
  }
3775
0
  return true;
3776
0
}
3777
3778
static const JSJitInfo angularVelocity_getterinfo = {
3779
  { (JSJitGetterOp)get_angularVelocity },
3780
  { prototypes::id::VRPose },
3781
  { PrototypeTraits<prototypes::id::VRPose>::Depth },
3782
  JSJitInfo::Getter,
3783
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3784
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3785
  false,  /* isInfallible. False in setters. */
3786
  false,  /* isMovable.  Not relevant for setters. */
3787
  false, /* isEliminatable.  Not relevant for setters. */
3788
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3789
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3790
  false,  /* isTypedMethod.  Only relevant for methods. */
3791
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3792
};
3793
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3794
static_assert(0 < 1, "There is no slot for us");
3795
3796
MOZ_CAN_RUN_SCRIPT static bool
3797
get_angularAcceleration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRPose* self, JSJitGetterCallArgs args)
3798
0
{
3799
0
  AUTO_PROFILER_LABEL_FAST("get VRPose.angularAcceleration", DOM, cx);
3800
0
3801
0
  FastErrorResult rv;
3802
0
  JS::Rooted<JSObject*> result(cx);
3803
0
  self->GetAngularAcceleration(cx, &result, rv);
3804
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3805
0
    return false;
3806
0
  }
3807
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3808
0
  if (result) {
3809
0
                JS::ExposeObjectToActiveJS(result);
3810
0
              }
3811
0
              args.rval().setObjectOrNull(result);
3812
0
  if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
3813
0
    return false;
3814
0
  }
3815
0
  return true;
3816
0
}
3817
3818
static const JSJitInfo angularAcceleration_getterinfo = {
3819
  { (JSJitGetterOp)get_angularAcceleration },
3820
  { prototypes::id::VRPose },
3821
  { PrototypeTraits<prototypes::id::VRPose>::Depth },
3822
  JSJitInfo::Getter,
3823
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
3824
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3825
  false,  /* isInfallible. False in setters. */
3826
  false,  /* isMovable.  Not relevant for setters. */
3827
  false, /* isEliminatable.  Not relevant for setters. */
3828
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3829
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3830
  false,  /* isTypedMethod.  Only relevant for methods. */
3831
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3832
};
3833
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3834
static_assert(0 < 1, "There is no slot for us");
3835
3836
static bool
3837
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
3838
0
{
3839
0
  mozilla::dom::VRPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRPose>(obj);
3840
0
  // We don't want to preserve if we don't have a wrapper, and we
3841
0
  // obviously can't preserve if we're not initialized.
3842
0
  if (self && self->GetWrapperPreserveColor()) {
3843
0
    PreserveWrapper(self);
3844
0
  }
3845
0
  return true;
3846
0
}
3847
3848
static void
3849
_finalize(js::FreeOp* fop, JSObject* obj)
3850
0
{
3851
0
  mozilla::dom::VRPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRPose>(obj);
3852
0
  if (self) {
3853
0
    ClearWrapper(self, self, obj);
3854
0
    AddForDeferredFinalization<mozilla::dom::VRPose>(self);
3855
0
  }
3856
0
}
3857
3858
static size_t
3859
_objectMoved(JSObject* obj, JSObject* old)
3860
0
{
3861
0
  mozilla::dom::VRPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRPose>(obj);
3862
0
  if (self) {
3863
0
    UpdateWrapper(self, self, obj, old);
3864
0
  }
3865
0
3866
0
  return 0;
3867
0
}
3868
3869
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
3870
#if defined(__clang__)
3871
#pragma clang diagnostic push
3872
#pragma clang diagnostic ignored "-Wmissing-braces"
3873
#endif
3874
static const JSPropertySpec sAttributes_specs[] = {
3875
  { "position", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &position_getterinfo, nullptr, nullptr },
3876
  { "linearVelocity", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &linearVelocity_getterinfo, nullptr, nullptr },
3877
  { "linearAcceleration", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &linearAcceleration_getterinfo, nullptr, nullptr },
3878
  { "orientation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &orientation_getterinfo, nullptr, nullptr },
3879
  { "angularVelocity", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &angularVelocity_getterinfo, nullptr, nullptr },
3880
  { "angularAcceleration", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &angularAcceleration_getterinfo, nullptr, nullptr },
3881
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
3882
};
3883
#if defined(__clang__)
3884
#pragma clang diagnostic pop
3885
#endif
3886
3887
3888
static const Prefable<const JSPropertySpec> sAttributes[] = {
3889
  { nullptr, &sAttributes_specs[0] },
3890
  { nullptr, nullptr }
3891
};
3892
3893
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
3894
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
3895
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
3896
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
3897
3898
3899
static uint16_t sNativeProperties_sortedPropertyIndices[6];
3900
static PropertyInfo sNativeProperties_propertyInfos[6];
3901
3902
static const NativePropertiesN<1> sNativeProperties = {
3903
  false, 0,
3904
  false, 0,
3905
  false, 0,
3906
  true,  0 /* sAttributes */,
3907
  false, 0,
3908
  false, 0,
3909
  false, 0,
3910
  -1,
3911
  6,
3912
  sNativeProperties_sortedPropertyIndices,
3913
  {
3914
    { sAttributes, &sNativeProperties_propertyInfos[0] }
3915
  }
3916
};
3917
static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
3918
    "We have a property info count that is oversized");
3919
3920
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
3921
  {
3922
    "Function",
3923
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
3924
    &sBoringInterfaceObjectClassClassOps,
3925
    JS_NULL_CLASS_SPEC,
3926
    JS_NULL_CLASS_EXT,
3927
    &sInterfaceObjectClassObjectOps
3928
  },
3929
  eInterface,
3930
  true,
3931
  prototypes::id::VRPose,
3932
  PrototypeTraits<prototypes::id::VRPose>::Depth,
3933
  sNativePropertyHooks,
3934
  "function VRPose() {\n    [native code]\n}",
3935
  JS::GetRealmFunctionPrototype
3936
};
3937
3938
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
3939
  {
3940
    "VRPosePrototype",
3941
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
3942
    JS_NULL_CLASS_OPS,
3943
    JS_NULL_CLASS_SPEC,
3944
    JS_NULL_CLASS_EXT,
3945
    JS_NULL_OBJECT_OPS
3946
  },
3947
  eInterfacePrototype,
3948
  false,
3949
  prototypes::id::VRPose,
3950
  PrototypeTraits<prototypes::id::VRPose>::Depth,
3951
  sNativePropertyHooks,
3952
  "[object VRPosePrototype]",
3953
  JS::GetRealmObjectPrototype
3954
};
3955
3956
bool
3957
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
3958
0
{
3959
0
  static bool sPrefValue;
3960
0
  static bool sPrefCacheSetUp = false;
3961
0
  if (!sPrefCacheSetUp) {
3962
0
    sPrefCacheSetUp = true;
3963
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
3964
0
  }
3965
0
3966
0
  return sPrefValue;
3967
0
}
3968
3969
static const js::ClassOps sClassOps = {
3970
  _addProperty, /* addProperty */
3971
  nullptr,               /* delProperty */
3972
  nullptr,               /* enumerate */
3973
  nullptr, /* newEnumerate */
3974
  nullptr, /* resolve */
3975
  nullptr, /* mayResolve */
3976
  _finalize, /* finalize */
3977
  nullptr, /* call */
3978
  nullptr,               /* hasInstance */
3979
  nullptr,               /* construct */
3980
  nullptr, /* trace */
3981
};
3982
3983
static const js::ClassExtension sClassExtension = {
3984
  nullptr, /* weakmapKeyDelegateOp */
3985
  _objectMoved /* objectMovedOp */
3986
};
3987
3988
static const DOMJSClass sClass = {
3989
  { "VRPose",
3990
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
3991
    &sClassOps,
3992
    JS_NULL_CLASS_SPEC,
3993
    &sClassExtension,
3994
    JS_NULL_OBJECT_OPS
3995
  },
3996
  { prototypes::id::VRPose, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
3997
  IsBaseOf<nsISupports, mozilla::dom::VRPose >::value,
3998
  sNativePropertyHooks,
3999
  FindAssociatedGlobalForNative<mozilla::dom::VRPose>::Get,
4000
  GetProtoObjectHandle,
4001
  GetCCParticipant<mozilla::dom::VRPose>::Get()
4002
};
4003
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
4004
              "Must have the right minimal number of reserved slots.");
4005
static_assert(1 >= 1,
4006
              "Must have enough reserved slots.");
4007
4008
const JSClass*
4009
GetJSClass()
4010
0
{
4011
0
  return sClass.ToJSClass();
4012
0
}
4013
4014
bool
4015
Wrap(JSContext* aCx, mozilla::dom::VRPose* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
4016
0
{
4017
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRPose>::value,
4018
0
                "Shouldn't have wrappercached things that are not refcounted.");
4019
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRPose*>(aObject) ==
4020
0
             reinterpret_cast<mozilla::dom::VRPose*>(aObject),
4021
0
             "Multiple inheritance for mozilla::dom::VRPose is broken.");
4022
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
4023
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
4024
0
  MOZ_ASSERT(!aCache->GetWrapper(),
4025
0
             "You should probably not be using Wrap() directly; use "
4026
0
             "GetOrCreateDOMReflector instead");
4027
0
4028
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
4029
0
             "nsISupports must be on our primary inheritance chain");
4030
0
4031
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
4032
0
  if (!global) {
4033
0
    return false;
4034
0
  }
4035
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
4036
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
4037
0
4038
0
  // That might have ended up wrapping us already, due to the wonders
4039
0
  // of XBL.  Check for that, and bail out as needed.
4040
0
  aReflector.set(aCache->GetWrapper());
4041
0
  if (aReflector) {
4042
#ifdef DEBUG
4043
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
4044
#endif // DEBUG
4045
    return true;
4046
0
  }
4047
0
4048
0
  JSAutoRealm ar(aCx, global);
4049
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
4050
0
  if (!canonicalProto) {
4051
0
    return false;
4052
0
  }
4053
0
  JS::Rooted<JSObject*> proto(aCx);
4054
0
  if (aGivenProto) {
4055
0
    proto = aGivenProto;
4056
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
4057
0
    // coming in, we changed compartments to that of "parent" so may need
4058
0
    // to wrap the proto here.
4059
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
4060
0
      if (!JS_WrapObject(aCx, &proto)) {
4061
0
        return false;
4062
0
      }
4063
0
    }
4064
0
  } else {
4065
0
    proto = canonicalProto;
4066
0
  }
4067
0
4068
0
  BindingJSObjectCreator<mozilla::dom::VRPose> creator(aCx);
4069
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
4070
0
  if (!aReflector) {
4071
0
    return false;
4072
0
  }
4073
0
4074
0
  aCache->SetWrapper(aReflector);
4075
0
  creator.InitializationSucceeded();
4076
0
4077
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
4078
0
             aCache->GetWrapperPreserveColor() == aReflector);
4079
0
  // If proto != canonicalProto, we have to preserve our wrapper;
4080
0
  // otherwise we won't be able to properly recreate it later, since
4081
0
  // we won't know what proto to use.  Note that we don't check
4082
0
  // aGivenProto here, since it's entirely possible (and even
4083
0
  // somewhat common) to have a non-null aGivenProto which is the
4084
0
  // same as canonicalProto.
4085
0
  if (proto != canonicalProto) {
4086
0
    PreserveWrapper(aObject);
4087
0
  }
4088
0
4089
0
  return true;
4090
0
}
4091
4092
const NativePropertyHooks sNativePropertyHooks[] = { {
4093
  nullptr,
4094
  nullptr,
4095
  nullptr,
4096
  { sNativeProperties.Upcast(), nullptr },
4097
  prototypes::id::VRPose,
4098
  constructors::id::VRPose,
4099
  nullptr,
4100
  &DefaultXrayExpandoObjectClass
4101
} };
4102
4103
void
4104
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
4105
0
{
4106
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
4107
0
  if (!parentProto) {
4108
0
    return;
4109
0
  }
4110
0
4111
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
4112
0
  if (!constructorProto) {
4113
0
    return;
4114
0
  }
4115
0
4116
0
  static bool sIdsInited = false;
4117
0
  if (!sIdsInited && NS_IsMainThread()) {
4118
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
4119
0
      return;
4120
0
    }
4121
0
    sIdsInited = true;
4122
0
  }
4123
0
4124
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRPose);
4125
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRPose);
4126
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
4127
0
                              &sPrototypeClass.mBase, protoCache,
4128
0
                              nullptr,
4129
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4130
0
                              interfaceCache,
4131
0
                              sNativeProperties.Upcast(),
4132
0
                              nullptr,
4133
0
                              "VRPose", aDefineOnGlobal,
4134
0
                              nullptr,
4135
0
                              false);
4136
0
}
4137
4138
JSObject*
4139
GetConstructorObject(JSContext* aCx)
4140
0
{
4141
0
  return GetConstructorObjectHandle(aCx);
4142
0
}
4143
4144
} // namespace VRPose_Binding
4145
4146
4147
4148
namespace VRStageParameters_Binding {
4149
4150
MOZ_CAN_RUN_SCRIPT static bool
4151
get_sittingToStandingTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRStageParameters* self, JSJitGetterCallArgs args)
4152
0
{
4153
0
  AUTO_PROFILER_LABEL_FAST("get VRStageParameters.sittingToStandingTransform", DOM, cx);
4154
0
4155
0
  FastErrorResult rv;
4156
0
  JS::Rooted<JSObject*> result(cx);
4157
0
  self->GetSittingToStandingTransform(cx, &result, rv);
4158
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4159
0
    return false;
4160
0
  }
4161
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4162
0
  JS::ExposeObjectToActiveJS(result);
4163
0
  args.rval().setObject(*result);
4164
0
  if (!MaybeWrapNonDOMObjectValue(cx, args.rval())) {
4165
0
    return false;
4166
0
  }
4167
0
  return true;
4168
0
}
4169
4170
static const JSJitInfo sittingToStandingTransform_getterinfo = {
4171
  { (JSJitGetterOp)get_sittingToStandingTransform },
4172
  { prototypes::id::VRStageParameters },
4173
  { PrototypeTraits<prototypes::id::VRStageParameters>::Depth },
4174
  JSJitInfo::Getter,
4175
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4176
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
4177
  false,  /* isInfallible. False in setters. */
4178
  false,  /* isMovable.  Not relevant for setters. */
4179
  false, /* isEliminatable.  Not relevant for setters. */
4180
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4181
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4182
  false,  /* isTypedMethod.  Only relevant for methods. */
4183
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4184
};
4185
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4186
static_assert(0 < 1, "There is no slot for us");
4187
4188
MOZ_CAN_RUN_SCRIPT static bool
4189
get_sizeX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRStageParameters* self, JSJitGetterCallArgs args)
4190
0
{
4191
0
  AUTO_PROFILER_LABEL_FAST("get VRStageParameters.sizeX", DOM, cx);
4192
0
4193
0
  float result(self->SizeX());
4194
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4195
0
  args.rval().set(JS_NumberValue(double(result)));
4196
0
  return true;
4197
0
}
4198
4199
static const JSJitInfo sizeX_getterinfo = {
4200
  { (JSJitGetterOp)get_sizeX },
4201
  { prototypes::id::VRStageParameters },
4202
  { PrototypeTraits<prototypes::id::VRStageParameters>::Depth },
4203
  JSJitInfo::Getter,
4204
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4205
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
4206
  true,  /* isInfallible. False in setters. */
4207
  false,  /* isMovable.  Not relevant for setters. */
4208
  false, /* isEliminatable.  Not relevant for setters. */
4209
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4210
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4211
  false,  /* isTypedMethod.  Only relevant for methods. */
4212
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4213
};
4214
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4215
static_assert(0 < 1, "There is no slot for us");
4216
4217
MOZ_CAN_RUN_SCRIPT static bool
4218
get_sizeZ(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRStageParameters* self, JSJitGetterCallArgs args)
4219
0
{
4220
0
  AUTO_PROFILER_LABEL_FAST("get VRStageParameters.sizeZ", DOM, cx);
4221
0
4222
0
  float result(self->SizeZ());
4223
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4224
0
  args.rval().set(JS_NumberValue(double(result)));
4225
0
  return true;
4226
0
}
4227
4228
static const JSJitInfo sizeZ_getterinfo = {
4229
  { (JSJitGetterOp)get_sizeZ },
4230
  { prototypes::id::VRStageParameters },
4231
  { PrototypeTraits<prototypes::id::VRStageParameters>::Depth },
4232
  JSJitInfo::Getter,
4233
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4234
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
4235
  true,  /* isInfallible. False in setters. */
4236
  false,  /* isMovable.  Not relevant for setters. */
4237
  false, /* isEliminatable.  Not relevant for setters. */
4238
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4239
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4240
  false,  /* isTypedMethod.  Only relevant for methods. */
4241
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4242
};
4243
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4244
static_assert(0 < 1, "There is no slot for us");
4245
4246
static bool
4247
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
4248
0
{
4249
0
  mozilla::dom::VRStageParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRStageParameters>(obj);
4250
0
  // We don't want to preserve if we don't have a wrapper, and we
4251
0
  // obviously can't preserve if we're not initialized.
4252
0
  if (self && self->GetWrapperPreserveColor()) {
4253
0
    PreserveWrapper(self);
4254
0
  }
4255
0
  return true;
4256
0
}
4257
4258
static void
4259
_finalize(js::FreeOp* fop, JSObject* obj)
4260
0
{
4261
0
  mozilla::dom::VRStageParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRStageParameters>(obj);
4262
0
  if (self) {
4263
0
    ClearWrapper(self, self, obj);
4264
0
    AddForDeferredFinalization<mozilla::dom::VRStageParameters>(self);
4265
0
  }
4266
0
}
4267
4268
static size_t
4269
_objectMoved(JSObject* obj, JSObject* old)
4270
0
{
4271
0
  mozilla::dom::VRStageParameters* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRStageParameters>(obj);
4272
0
  if (self) {
4273
0
    UpdateWrapper(self, self, obj, old);
4274
0
  }
4275
0
4276
0
  return 0;
4277
0
}
4278
4279
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4280
#if defined(__clang__)
4281
#pragma clang diagnostic push
4282
#pragma clang diagnostic ignored "-Wmissing-braces"
4283
#endif
4284
static const JSPropertySpec sAttributes_specs[] = {
4285
  { "sittingToStandingTransform", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sittingToStandingTransform_getterinfo, nullptr, nullptr },
4286
  { "sizeX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sizeX_getterinfo, nullptr, nullptr },
4287
  { "sizeZ", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sizeZ_getterinfo, nullptr, nullptr },
4288
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
4289
};
4290
#if defined(__clang__)
4291
#pragma clang diagnostic pop
4292
#endif
4293
4294
4295
static const Prefable<const JSPropertySpec> sAttributes[] = {
4296
  { nullptr, &sAttributes_specs[0] },
4297
  { nullptr, nullptr }
4298
};
4299
4300
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4301
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4302
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4303
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4304
4305
4306
static uint16_t sNativeProperties_sortedPropertyIndices[3];
4307
static PropertyInfo sNativeProperties_propertyInfos[3];
4308
4309
static const NativePropertiesN<1> sNativeProperties = {
4310
  false, 0,
4311
  false, 0,
4312
  false, 0,
4313
  true,  0 /* sAttributes */,
4314
  false, 0,
4315
  false, 0,
4316
  false, 0,
4317
  -1,
4318
  3,
4319
  sNativeProperties_sortedPropertyIndices,
4320
  {
4321
    { sAttributes, &sNativeProperties_propertyInfos[0] }
4322
  }
4323
};
4324
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
4325
    "We have a property info count that is oversized");
4326
4327
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
4328
  {
4329
    "Function",
4330
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
4331
    &sBoringInterfaceObjectClassClassOps,
4332
    JS_NULL_CLASS_SPEC,
4333
    JS_NULL_CLASS_EXT,
4334
    &sInterfaceObjectClassObjectOps
4335
  },
4336
  eInterface,
4337
  true,
4338
  prototypes::id::VRStageParameters,
4339
  PrototypeTraits<prototypes::id::VRStageParameters>::Depth,
4340
  sNativePropertyHooks,
4341
  "function VRStageParameters() {\n    [native code]\n}",
4342
  JS::GetRealmFunctionPrototype
4343
};
4344
4345
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
4346
  {
4347
    "VRStageParametersPrototype",
4348
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
4349
    JS_NULL_CLASS_OPS,
4350
    JS_NULL_CLASS_SPEC,
4351
    JS_NULL_CLASS_EXT,
4352
    JS_NULL_OBJECT_OPS
4353
  },
4354
  eInterfacePrototype,
4355
  false,
4356
  prototypes::id::VRStageParameters,
4357
  PrototypeTraits<prototypes::id::VRStageParameters>::Depth,
4358
  sNativePropertyHooks,
4359
  "[object VRStageParametersPrototype]",
4360
  JS::GetRealmObjectPrototype
4361
};
4362
4363
bool
4364
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
4365
0
{
4366
0
  static bool sPrefValue;
4367
0
  static bool sPrefCacheSetUp = false;
4368
0
  if (!sPrefCacheSetUp) {
4369
0
    sPrefCacheSetUp = true;
4370
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.enabled");
4371
0
  }
4372
0
4373
0
  return sPrefValue;
4374
0
}
4375
4376
static const js::ClassOps sClassOps = {
4377
  _addProperty, /* addProperty */
4378
  nullptr,               /* delProperty */
4379
  nullptr,               /* enumerate */
4380
  nullptr, /* newEnumerate */
4381
  nullptr, /* resolve */
4382
  nullptr, /* mayResolve */
4383
  _finalize, /* finalize */
4384
  nullptr, /* call */
4385
  nullptr,               /* hasInstance */
4386
  nullptr,               /* construct */
4387
  nullptr, /* trace */
4388
};
4389
4390
static const js::ClassExtension sClassExtension = {
4391
  nullptr, /* weakmapKeyDelegateOp */
4392
  _objectMoved /* objectMovedOp */
4393
};
4394
4395
static const DOMJSClass sClass = {
4396
  { "VRStageParameters",
4397
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
4398
    &sClassOps,
4399
    JS_NULL_CLASS_SPEC,
4400
    &sClassExtension,
4401
    JS_NULL_OBJECT_OPS
4402
  },
4403
  { prototypes::id::VRStageParameters, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
4404
  IsBaseOf<nsISupports, mozilla::dom::VRStageParameters >::value,
4405
  sNativePropertyHooks,
4406
  FindAssociatedGlobalForNative<mozilla::dom::VRStageParameters>::Get,
4407
  GetProtoObjectHandle,
4408
  GetCCParticipant<mozilla::dom::VRStageParameters>::Get()
4409
};
4410
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
4411
              "Must have the right minimal number of reserved slots.");
4412
static_assert(1 >= 1,
4413
              "Must have enough reserved slots.");
4414
4415
const JSClass*
4416
GetJSClass()
4417
0
{
4418
0
  return sClass.ToJSClass();
4419
0
}
4420
4421
bool
4422
Wrap(JSContext* aCx, mozilla::dom::VRStageParameters* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
4423
0
{
4424
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRStageParameters>::value,
4425
0
                "Shouldn't have wrappercached things that are not refcounted.");
4426
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRStageParameters*>(aObject) ==
4427
0
             reinterpret_cast<mozilla::dom::VRStageParameters*>(aObject),
4428
0
             "Multiple inheritance for mozilla::dom::VRStageParameters is broken.");
4429
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
4430
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
4431
0
  MOZ_ASSERT(!aCache->GetWrapper(),
4432
0
             "You should probably not be using Wrap() directly; use "
4433
0
             "GetOrCreateDOMReflector instead");
4434
0
4435
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
4436
0
             "nsISupports must be on our primary inheritance chain");
4437
0
4438
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
4439
0
  if (!global) {
4440
0
    return false;
4441
0
  }
4442
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
4443
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
4444
0
4445
0
  // That might have ended up wrapping us already, due to the wonders
4446
0
  // of XBL.  Check for that, and bail out as needed.
4447
0
  aReflector.set(aCache->GetWrapper());
4448
0
  if (aReflector) {
4449
#ifdef DEBUG
4450
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
4451
#endif // DEBUG
4452
    return true;
4453
0
  }
4454
0
4455
0
  JSAutoRealm ar(aCx, global);
4456
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
4457
0
  if (!canonicalProto) {
4458
0
    return false;
4459
0
  }
4460
0
  JS::Rooted<JSObject*> proto(aCx);
4461
0
  if (aGivenProto) {
4462
0
    proto = aGivenProto;
4463
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
4464
0
    // coming in, we changed compartments to that of "parent" so may need
4465
0
    // to wrap the proto here.
4466
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
4467
0
      if (!JS_WrapObject(aCx, &proto)) {
4468
0
        return false;
4469
0
      }
4470
0
    }
4471
0
  } else {
4472
0
    proto = canonicalProto;
4473
0
  }
4474
0
4475
0
  BindingJSObjectCreator<mozilla::dom::VRStageParameters> creator(aCx);
4476
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
4477
0
  if (!aReflector) {
4478
0
    return false;
4479
0
  }
4480
0
4481
0
  aCache->SetWrapper(aReflector);
4482
0
  creator.InitializationSucceeded();
4483
0
4484
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
4485
0
             aCache->GetWrapperPreserveColor() == aReflector);
4486
0
  // If proto != canonicalProto, we have to preserve our wrapper;
4487
0
  // otherwise we won't be able to properly recreate it later, since
4488
0
  // we won't know what proto to use.  Note that we don't check
4489
0
  // aGivenProto here, since it's entirely possible (and even
4490
0
  // somewhat common) to have a non-null aGivenProto which is the
4491
0
  // same as canonicalProto.
4492
0
  if (proto != canonicalProto) {
4493
0
    PreserveWrapper(aObject);
4494
0
  }
4495
0
4496
0
  return true;
4497
0
}
4498
4499
const NativePropertyHooks sNativePropertyHooks[] = { {
4500
  nullptr,
4501
  nullptr,
4502
  nullptr,
4503
  { sNativeProperties.Upcast(), nullptr },
4504
  prototypes::id::VRStageParameters,
4505
  constructors::id::VRStageParameters,
4506
  nullptr,
4507
  &DefaultXrayExpandoObjectClass
4508
} };
4509
4510
void
4511
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
4512
0
{
4513
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
4514
0
  if (!parentProto) {
4515
0
    return;
4516
0
  }
4517
0
4518
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
4519
0
  if (!constructorProto) {
4520
0
    return;
4521
0
  }
4522
0
4523
0
  static bool sIdsInited = false;
4524
0
  if (!sIdsInited && NS_IsMainThread()) {
4525
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
4526
0
      return;
4527
0
    }
4528
0
    sIdsInited = true;
4529
0
  }
4530
0
4531
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRStageParameters);
4532
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRStageParameters);
4533
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
4534
0
                              &sPrototypeClass.mBase, protoCache,
4535
0
                              nullptr,
4536
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4537
0
                              interfaceCache,
4538
0
                              sNativeProperties.Upcast(),
4539
0
                              nullptr,
4540
0
                              "VRStageParameters", aDefineOnGlobal,
4541
0
                              nullptr,
4542
0
                              false);
4543
0
}
4544
4545
JSObject*
4546
GetConstructorObject(JSContext* aCx)
4547
0
{
4548
0
  return GetConstructorObjectHandle(aCx);
4549
0
}
4550
4551
} // namespace VRStageParameters_Binding
4552
4553
4554
4555
namespace VRSubmitFrameResult_Binding {
4556
4557
MOZ_CAN_RUN_SCRIPT static bool
4558
get_frameNum(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRSubmitFrameResult* self, JSJitGetterCallArgs args)
4559
0
{
4560
0
  AUTO_PROFILER_LABEL_FAST("get VRSubmitFrameResult.frameNum", DOM, cx);
4561
0
4562
0
  uint32_t result(self->FrameNum());
4563
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4564
0
  args.rval().setNumber(result);
4565
0
  return true;
4566
0
}
4567
4568
static const JSJitInfo frameNum_getterinfo = {
4569
  { (JSJitGetterOp)get_frameNum },
4570
  { prototypes::id::VRSubmitFrameResult },
4571
  { PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth },
4572
  JSJitInfo::Getter,
4573
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4574
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
4575
  true,  /* isInfallible. False in setters. */
4576
  false,  /* isMovable.  Not relevant for setters. */
4577
  false, /* isEliminatable.  Not relevant for setters. */
4578
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4579
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4580
  false,  /* isTypedMethod.  Only relevant for methods. */
4581
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4582
};
4583
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4584
static_assert(0 < 1, "There is no slot for us");
4585
4586
MOZ_CAN_RUN_SCRIPT static bool
4587
get_base64Image(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::VRSubmitFrameResult* self, JSJitGetterCallArgs args)
4588
0
{
4589
0
  AUTO_PROFILER_LABEL_FAST("get VRSubmitFrameResult.base64Image", DOM, cx);
4590
0
4591
0
  DOMString result;
4592
0
  self->GetBase64Image(result);
4593
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4594
0
  if (!xpc::StringToJsval(cx, result, args.rval())) {
4595
0
    return false;
4596
0
  }
4597
0
  return true;
4598
0
}
4599
4600
static const JSJitInfo base64Image_getterinfo = {
4601
  { (JSJitGetterOp)get_base64Image },
4602
  { prototypes::id::VRSubmitFrameResult },
4603
  { PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth },
4604
  JSJitInfo::Getter,
4605
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4606
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
4607
  false,  /* isInfallible. False in setters. */
4608
  false,  /* isMovable.  Not relevant for setters. */
4609
  false, /* isEliminatable.  Not relevant for setters. */
4610
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4611
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4612
  false,  /* isTypedMethod.  Only relevant for methods. */
4613
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4614
};
4615
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4616
static_assert(0 < 1, "There is no slot for us");
4617
4618
static bool
4619
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
4620
0
{
4621
0
  mozilla::dom::VRSubmitFrameResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRSubmitFrameResult>(obj);
4622
0
  // We don't want to preserve if we don't have a wrapper, and we
4623
0
  // obviously can't preserve if we're not initialized.
4624
0
  if (self && self->GetWrapperPreserveColor()) {
4625
0
    PreserveWrapper(self);
4626
0
  }
4627
0
  return true;
4628
0
}
4629
4630
static void
4631
_finalize(js::FreeOp* fop, JSObject* obj)
4632
0
{
4633
0
  mozilla::dom::VRSubmitFrameResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRSubmitFrameResult>(obj);
4634
0
  if (self) {
4635
0
    ClearWrapper(self, self, obj);
4636
0
    AddForDeferredFinalization<mozilla::dom::VRSubmitFrameResult>(self);
4637
0
  }
4638
0
}
4639
4640
static size_t
4641
_objectMoved(JSObject* obj, JSObject* old)
4642
0
{
4643
0
  mozilla::dom::VRSubmitFrameResult* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::VRSubmitFrameResult>(obj);
4644
0
  if (self) {
4645
0
    UpdateWrapper(self, self, obj, old);
4646
0
  }
4647
0
4648
0
  return 0;
4649
0
}
4650
4651
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
4652
#if defined(__clang__)
4653
#pragma clang diagnostic push
4654
#pragma clang diagnostic ignored "-Wmissing-braces"
4655
#endif
4656
static const JSPropertySpec sAttributes_specs[] = {
4657
  { "frameNum", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &frameNum_getterinfo, nullptr, nullptr },
4658
  { "base64Image", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &base64Image_getterinfo, nullptr, nullptr },
4659
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
4660
};
4661
#if defined(__clang__)
4662
#pragma clang diagnostic pop
4663
#endif
4664
4665
4666
static const Prefable<const JSPropertySpec> sAttributes[] = {
4667
  { nullptr, &sAttributes_specs[0] },
4668
  { nullptr, nullptr }
4669
};
4670
4671
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
4672
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
4673
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
4674
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
4675
4676
4677
static uint16_t sNativeProperties_sortedPropertyIndices[2];
4678
static PropertyInfo sNativeProperties_propertyInfos[2];
4679
4680
static const NativePropertiesN<1> sNativeProperties = {
4681
  false, 0,
4682
  false, 0,
4683
  false, 0,
4684
  true,  0 /* sAttributes */,
4685
  false, 0,
4686
  false, 0,
4687
  false, 0,
4688
  -1,
4689
  2,
4690
  sNativeProperties_sortedPropertyIndices,
4691
  {
4692
    { sAttributes, &sNativeProperties_propertyInfos[0] }
4693
  }
4694
};
4695
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
4696
    "We have a property info count that is oversized");
4697
4698
static bool
4699
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
4700
0
{
4701
0
  AUTO_PROFILER_LABEL_FAST("VRSubmitFrameResult constructor", DOM, cx);
4702
0
4703
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
4704
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
4705
0
  if (!args.isConstructing()) {
4706
0
    // XXXbz wish I could get the name from the callee instead of
4707
0
    // Adding more relocations
4708
0
    return ThrowConstructorWithoutNew(cx, "VRSubmitFrameResult");
4709
0
  }
4710
0
4711
0
  JS::Rooted<JSObject*> desiredProto(cx);
4712
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
4713
0
    return false;
4714
0
  }
4715
0
4716
0
  GlobalObject global(cx, obj);
4717
0
  if (global.Failed()) {
4718
0
    return false;
4719
0
  }
4720
0
4721
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
4722
0
  Maybe<JSAutoRealm> ar;
4723
0
  if (objIsXray) {
4724
0
    obj = js::CheckedUnwrap(obj);
4725
0
    if (!obj) {
4726
0
      return false;
4727
0
    }
4728
0
    ar.emplace(cx, obj);
4729
0
    if (!JS_WrapObject(cx, &desiredProto)) {
4730
0
      return false;
4731
0
    }
4732
0
  }
4733
0
  FastErrorResult rv;
4734
0
  auto result(StrongOrRawPtr<mozilla::dom::VRSubmitFrameResult>(mozilla::dom::VRSubmitFrameResult::Constructor(global, rv)));
4735
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4736
0
    return false;
4737
0
  }
4738
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4739
0
  static_assert(!IsPointer<decltype(result)>::value,
4740
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
4741
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
4742
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
4743
0
    return false;
4744
0
  }
4745
0
  return true;
4746
0
}
4747
4748
static const js::ClassOps sInterfaceObjectClassOps = {
4749
    nullptr,               /* addProperty */
4750
    nullptr,               /* delProperty */
4751
    nullptr,               /* enumerate */
4752
    nullptr,               /* newEnumerate */
4753
    nullptr,               /* resolve */
4754
    nullptr,               /* mayResolve */
4755
    nullptr,               /* finalize */
4756
    _constructor, /* call */
4757
    nullptr,               /* hasInstance */
4758
    _constructor, /* construct */
4759
    nullptr,               /* trace */
4760
};
4761
4762
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
4763
  {
4764
    "Function",
4765
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
4766
    &sInterfaceObjectClassOps,
4767
    JS_NULL_CLASS_SPEC,
4768
    JS_NULL_CLASS_EXT,
4769
    &sInterfaceObjectClassObjectOps
4770
  },
4771
  eInterface,
4772
  true,
4773
  prototypes::id::VRSubmitFrameResult,
4774
  PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth,
4775
  sNativePropertyHooks,
4776
  "function VRSubmitFrameResult() {\n    [native code]\n}",
4777
  JS::GetRealmFunctionPrototype
4778
};
4779
4780
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
4781
  {
4782
    "VRSubmitFrameResultPrototype",
4783
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
4784
    JS_NULL_CLASS_OPS,
4785
    JS_NULL_CLASS_SPEC,
4786
    JS_NULL_CLASS_EXT,
4787
    JS_NULL_OBJECT_OPS
4788
  },
4789
  eInterfacePrototype,
4790
  false,
4791
  prototypes::id::VRSubmitFrameResult,
4792
  PrototypeTraits<prototypes::id::VRSubmitFrameResult>::Depth,
4793
  sNativePropertyHooks,
4794
  "[object VRSubmitFrameResultPrototype]",
4795
  JS::GetRealmObjectPrototype
4796
};
4797
4798
bool
4799
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
4800
0
{
4801
0
  static bool sPrefValue;
4802
0
  static bool sPrefCacheSetUp = false;
4803
0
  if (!sPrefCacheSetUp) {
4804
0
    sPrefCacheSetUp = true;
4805
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.vr.test.enabled");
4806
0
  }
4807
0
4808
0
  return sPrefValue;
4809
0
}
4810
4811
static const js::ClassOps sClassOps = {
4812
  _addProperty, /* addProperty */
4813
  nullptr,               /* delProperty */
4814
  nullptr,               /* enumerate */
4815
  nullptr, /* newEnumerate */
4816
  nullptr, /* resolve */
4817
  nullptr, /* mayResolve */
4818
  _finalize, /* finalize */
4819
  nullptr, /* call */
4820
  nullptr,               /* hasInstance */
4821
  nullptr,               /* construct */
4822
  nullptr, /* trace */
4823
};
4824
4825
static const js::ClassExtension sClassExtension = {
4826
  nullptr, /* weakmapKeyDelegateOp */
4827
  _objectMoved /* objectMovedOp */
4828
};
4829
4830
static const DOMJSClass sClass = {
4831
  { "VRSubmitFrameResult",
4832
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
4833
    &sClassOps,
4834
    JS_NULL_CLASS_SPEC,
4835
    &sClassExtension,
4836
    JS_NULL_OBJECT_OPS
4837
  },
4838
  { prototypes::id::VRSubmitFrameResult, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
4839
  IsBaseOf<nsISupports, mozilla::dom::VRSubmitFrameResult >::value,
4840
  sNativePropertyHooks,
4841
  FindAssociatedGlobalForNative<mozilla::dom::VRSubmitFrameResult>::Get,
4842
  GetProtoObjectHandle,
4843
  GetCCParticipant<mozilla::dom::VRSubmitFrameResult>::Get()
4844
};
4845
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
4846
              "Must have the right minimal number of reserved slots.");
4847
static_assert(1 >= 1,
4848
              "Must have enough reserved slots.");
4849
4850
const JSClass*
4851
GetJSClass()
4852
0
{
4853
0
  return sClass.ToJSClass();
4854
0
}
4855
4856
bool
4857
Wrap(JSContext* aCx, mozilla::dom::VRSubmitFrameResult* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
4858
0
{
4859
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::VRSubmitFrameResult>::value,
4860
0
                "Shouldn't have wrappercached things that are not refcounted.");
4861
0
  MOZ_ASSERT(static_cast<mozilla::dom::VRSubmitFrameResult*>(aObject) ==
4862
0
             reinterpret_cast<mozilla::dom::VRSubmitFrameResult*>(aObject),
4863
0
             "Multiple inheritance for mozilla::dom::VRSubmitFrameResult is broken.");
4864
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
4865
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
4866
0
  MOZ_ASSERT(!aCache->GetWrapper(),
4867
0
             "You should probably not be using Wrap() directly; use "
4868
0
             "GetOrCreateDOMReflector instead");
4869
0
4870
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
4871
0
             "nsISupports must be on our primary inheritance chain");
4872
0
4873
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
4874
0
  if (!global) {
4875
0
    return false;
4876
0
  }
4877
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
4878
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
4879
0
4880
0
  // That might have ended up wrapping us already, due to the wonders
4881
0
  // of XBL.  Check for that, and bail out as needed.
4882
0
  aReflector.set(aCache->GetWrapper());
4883
0
  if (aReflector) {
4884
#ifdef DEBUG
4885
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
4886
#endif // DEBUG
4887
    return true;
4888
0
  }
4889
0
4890
0
  JSAutoRealm ar(aCx, global);
4891
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
4892
0
  if (!canonicalProto) {
4893
0
    return false;
4894
0
  }
4895
0
  JS::Rooted<JSObject*> proto(aCx);
4896
0
  if (aGivenProto) {
4897
0
    proto = aGivenProto;
4898
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
4899
0
    // coming in, we changed compartments to that of "parent" so may need
4900
0
    // to wrap the proto here.
4901
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
4902
0
      if (!JS_WrapObject(aCx, &proto)) {
4903
0
        return false;
4904
0
      }
4905
0
    }
4906
0
  } else {
4907
0
    proto = canonicalProto;
4908
0
  }
4909
0
4910
0
  BindingJSObjectCreator<mozilla::dom::VRSubmitFrameResult> creator(aCx);
4911
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
4912
0
  if (!aReflector) {
4913
0
    return false;
4914
0
  }
4915
0
4916
0
  aCache->SetWrapper(aReflector);
4917
0
  creator.InitializationSucceeded();
4918
0
4919
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
4920
0
             aCache->GetWrapperPreserveColor() == aReflector);
4921
0
  // If proto != canonicalProto, we have to preserve our wrapper;
4922
0
  // otherwise we won't be able to properly recreate it later, since
4923
0
  // we won't know what proto to use.  Note that we don't check
4924
0
  // aGivenProto here, since it's entirely possible (and even
4925
0
  // somewhat common) to have a non-null aGivenProto which is the
4926
0
  // same as canonicalProto.
4927
0
  if (proto != canonicalProto) {
4928
0
    PreserveWrapper(aObject);
4929
0
  }
4930
0
4931
0
  return true;
4932
0
}
4933
4934
const NativePropertyHooks sNativePropertyHooks[] = { {
4935
  nullptr,
4936
  nullptr,
4937
  nullptr,
4938
  { sNativeProperties.Upcast(), nullptr },
4939
  prototypes::id::VRSubmitFrameResult,
4940
  constructors::id::VRSubmitFrameResult,
4941
  nullptr,
4942
  &DefaultXrayExpandoObjectClass
4943
} };
4944
4945
void
4946
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
4947
0
{
4948
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
4949
0
  if (!parentProto) {
4950
0
    return;
4951
0
  }
4952
0
4953
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
4954
0
  if (!constructorProto) {
4955
0
    return;
4956
0
  }
4957
0
4958
0
  static bool sIdsInited = false;
4959
0
  if (!sIdsInited && NS_IsMainThread()) {
4960
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
4961
0
      return;
4962
0
    }
4963
0
    sIdsInited = true;
4964
0
  }
4965
0
4966
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VRSubmitFrameResult);
4967
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VRSubmitFrameResult);
4968
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
4969
0
                              &sPrototypeClass.mBase, protoCache,
4970
0
                              nullptr,
4971
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
4972
0
                              interfaceCache,
4973
0
                              sNativeProperties.Upcast(),
4974
0
                              nullptr,
4975
0
                              "VRSubmitFrameResult", aDefineOnGlobal,
4976
0
                              nullptr,
4977
0
                              false);
4978
0
}
4979
4980
JSObject*
4981
GetConstructorObject(JSContext* aCx)
4982
0
{
4983
0
  return GetConstructorObjectHandle(aCx);
4984
0
}
4985
4986
} // namespace VRSubmitFrameResult_Binding
4987
4988
4989
4990
} // namespace dom
4991
} // namespace mozilla