Coverage Report

Created: 2018-09-25 14:53

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