Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SVGRectBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SVGRect.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "SVGRectBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/FloatingPoint.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/PrimitiveConversions.h"
11
#include "mozilla/dom/SVGIRect.h"
12
#include "mozilla/dom/XrayExpandoClass.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
namespace binding_detail {}; // Just to make sure it's known as a namespace
18
using namespace mozilla::dom::binding_detail;
19
20
21
namespace SVGRect_Binding {
22
23
MOZ_CAN_RUN_SCRIPT static bool
24
get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
25
0
{
26
0
  AUTO_PROFILER_LABEL_FAST("get SVGRect.x", DOM, cx);
27
0
28
0
  float result(self->X());
29
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
30
0
  args.rval().set(JS_NumberValue(double(result)));
31
0
  return true;
32
0
}
33
34
MOZ_CAN_RUN_SCRIPT static bool
35
set_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
36
0
{
37
0
  AUTO_PROFILER_LABEL_FAST("set SVGRect.x", DOM, cx);
38
0
39
0
  float arg0;
40
0
  if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
41
0
    return false;
42
0
  } else if (!mozilla::IsFinite(arg0)) {
43
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.x");
44
0
    return false;
45
0
  }
46
0
  FastErrorResult rv;
47
0
  self->SetX(arg0, rv);
48
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
49
0
    return false;
50
0
  }
51
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
52
0
53
0
  return true;
54
0
}
55
56
static const JSJitInfo x_getterinfo = {
57
  { (JSJitGetterOp)get_x },
58
  { prototypes::id::SVGRect },
59
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
60
  JSJitInfo::Getter,
61
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
62
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
63
  true,  /* isInfallible. False in setters. */
64
  false,  /* isMovable.  Not relevant for setters. */
65
  false, /* isEliminatable.  Not relevant for setters. */
66
  false, /* isAlwaysInSlot.  Only relevant for getters. */
67
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
68
  false,  /* isTypedMethod.  Only relevant for methods. */
69
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
70
};
71
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
72
static_assert(0 < 1, "There is no slot for us");
73
static const JSJitInfo x_setterinfo = {
74
  { (JSJitGetterOp)set_x },
75
  { prototypes::id::SVGRect },
76
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
77
  JSJitInfo::Setter,
78
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
79
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
80
  false,  /* isInfallible. False in setters. */
81
  false,  /* isMovable.  Not relevant for setters. */
82
  false, /* isEliminatable.  Not relevant for setters. */
83
  false, /* isAlwaysInSlot.  Only relevant for getters. */
84
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
85
  false,  /* isTypedMethod.  Only relevant for methods. */
86
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
87
};
88
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
89
static_assert(0 < 1, "There is no slot for us");
90
91
MOZ_CAN_RUN_SCRIPT static bool
92
get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
93
0
{
94
0
  AUTO_PROFILER_LABEL_FAST("get SVGRect.y", DOM, cx);
95
0
96
0
  float result(self->Y());
97
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
98
0
  args.rval().set(JS_NumberValue(double(result)));
99
0
  return true;
100
0
}
101
102
MOZ_CAN_RUN_SCRIPT static bool
103
set_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
104
0
{
105
0
  AUTO_PROFILER_LABEL_FAST("set SVGRect.y", DOM, cx);
106
0
107
0
  float arg0;
108
0
  if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
109
0
    return false;
110
0
  } else if (!mozilla::IsFinite(arg0)) {
111
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.y");
112
0
    return false;
113
0
  }
114
0
  FastErrorResult rv;
115
0
  self->SetY(arg0, rv);
116
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
117
0
    return false;
118
0
  }
119
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
120
0
121
0
  return true;
122
0
}
123
124
static const JSJitInfo y_getterinfo = {
125
  { (JSJitGetterOp)get_y },
126
  { prototypes::id::SVGRect },
127
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
128
  JSJitInfo::Getter,
129
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
130
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
131
  true,  /* isInfallible. False in setters. */
132
  false,  /* isMovable.  Not relevant for setters. */
133
  false, /* isEliminatable.  Not relevant for setters. */
134
  false, /* isAlwaysInSlot.  Only relevant for getters. */
135
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
136
  false,  /* isTypedMethod.  Only relevant for methods. */
137
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
138
};
139
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
140
static_assert(0 < 1, "There is no slot for us");
141
static const JSJitInfo y_setterinfo = {
142
  { (JSJitGetterOp)set_y },
143
  { prototypes::id::SVGRect },
144
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
145
  JSJitInfo::Setter,
146
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
147
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
148
  false,  /* isInfallible. False in setters. */
149
  false,  /* isMovable.  Not relevant for setters. */
150
  false, /* isEliminatable.  Not relevant for setters. */
151
  false, /* isAlwaysInSlot.  Only relevant for getters. */
152
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
153
  false,  /* isTypedMethod.  Only relevant for methods. */
154
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
155
};
156
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
157
static_assert(0 < 1, "There is no slot for us");
158
159
MOZ_CAN_RUN_SCRIPT static bool
160
get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
161
0
{
162
0
  AUTO_PROFILER_LABEL_FAST("get SVGRect.width", DOM, cx);
163
0
164
0
  float result(self->Width());
165
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
166
0
  args.rval().set(JS_NumberValue(double(result)));
167
0
  return true;
168
0
}
169
170
MOZ_CAN_RUN_SCRIPT static bool
171
set_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
172
0
{
173
0
  AUTO_PROFILER_LABEL_FAST("set SVGRect.width", DOM, cx);
174
0
175
0
  float arg0;
176
0
  if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
177
0
    return false;
178
0
  } else if (!mozilla::IsFinite(arg0)) {
179
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.width");
180
0
    return false;
181
0
  }
182
0
  FastErrorResult rv;
183
0
  self->SetWidth(arg0, rv);
184
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
185
0
    return false;
186
0
  }
187
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
188
0
189
0
  return true;
190
0
}
191
192
static const JSJitInfo width_getterinfo = {
193
  { (JSJitGetterOp)get_width },
194
  { prototypes::id::SVGRect },
195
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
196
  JSJitInfo::Getter,
197
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
198
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
199
  true,  /* isInfallible. False in setters. */
200
  false,  /* isMovable.  Not relevant for setters. */
201
  false, /* isEliminatable.  Not relevant for setters. */
202
  false, /* isAlwaysInSlot.  Only relevant for getters. */
203
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
204
  false,  /* isTypedMethod.  Only relevant for methods. */
205
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
206
};
207
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
208
static_assert(0 < 1, "There is no slot for us");
209
static const JSJitInfo width_setterinfo = {
210
  { (JSJitGetterOp)set_width },
211
  { prototypes::id::SVGRect },
212
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
213
  JSJitInfo::Setter,
214
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
215
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
216
  false,  /* isInfallible. False in setters. */
217
  false,  /* isMovable.  Not relevant for setters. */
218
  false, /* isEliminatable.  Not relevant for setters. */
219
  false, /* isAlwaysInSlot.  Only relevant for getters. */
220
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
221
  false,  /* isTypedMethod.  Only relevant for methods. */
222
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
223
};
224
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
225
static_assert(0 < 1, "There is no slot for us");
226
227
MOZ_CAN_RUN_SCRIPT static bool
228
get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitGetterCallArgs args)
229
0
{
230
0
  AUTO_PROFILER_LABEL_FAST("get SVGRect.height", DOM, cx);
231
0
232
0
  float result(self->Height());
233
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
234
0
  args.rval().set(JS_NumberValue(double(result)));
235
0
  return true;
236
0
}
237
238
MOZ_CAN_RUN_SCRIPT static bool
239
set_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGIRect* self, JSJitSetterCallArgs args)
240
0
{
241
0
  AUTO_PROFILER_LABEL_FAST("set SVGRect.height", DOM, cx);
242
0
243
0
  float arg0;
244
0
  if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
245
0
    return false;
246
0
  } else if (!mozilla::IsFinite(arg0)) {
247
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGRect.height");
248
0
    return false;
249
0
  }
250
0
  FastErrorResult rv;
251
0
  self->SetHeight(arg0, rv);
252
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
253
0
    return false;
254
0
  }
255
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
256
0
257
0
  return true;
258
0
}
259
260
static const JSJitInfo height_getterinfo = {
261
  { (JSJitGetterOp)get_height },
262
  { prototypes::id::SVGRect },
263
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
264
  JSJitInfo::Getter,
265
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
266
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
267
  true,  /* isInfallible. False in setters. */
268
  false,  /* isMovable.  Not relevant for setters. */
269
  false, /* isEliminatable.  Not relevant for setters. */
270
  false, /* isAlwaysInSlot.  Only relevant for getters. */
271
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
272
  false,  /* isTypedMethod.  Only relevant for methods. */
273
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
274
};
275
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
276
static_assert(0 < 1, "There is no slot for us");
277
static const JSJitInfo height_setterinfo = {
278
  { (JSJitGetterOp)set_height },
279
  { prototypes::id::SVGRect },
280
  { PrototypeTraits<prototypes::id::SVGRect>::Depth },
281
  JSJitInfo::Setter,
282
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
283
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
284
  false,  /* isInfallible. False in setters. */
285
  false,  /* isMovable.  Not relevant for setters. */
286
  false, /* isEliminatable.  Not relevant for setters. */
287
  false, /* isAlwaysInSlot.  Only relevant for getters. */
288
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
289
  false,  /* isTypedMethod.  Only relevant for methods. */
290
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
291
};
292
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
293
static_assert(0 < 1, "There is no slot for us");
294
295
static bool
296
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
297
0
{
298
0
  mozilla::dom::SVGIRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGIRect>(obj);
299
0
  // We don't want to preserve if we don't have a wrapper, and we
300
0
  // obviously can't preserve if we're not initialized.
301
0
  if (self && self->GetWrapperPreserveColor()) {
302
0
    PreserveWrapper(self);
303
0
  }
304
0
  return true;
305
0
}
306
307
static void
308
_finalize(js::FreeOp* fop, JSObject* obj)
309
0
{
310
0
  mozilla::dom::SVGIRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGIRect>(obj);
311
0
  if (self) {
312
0
    ClearWrapper(self, self, obj);
313
0
    AddForDeferredFinalization<mozilla::dom::SVGIRect>(self);
314
0
  }
315
0
}
316
317
static size_t
318
_objectMoved(JSObject* obj, JSObject* old)
319
0
{
320
0
  mozilla::dom::SVGIRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGIRect>(obj);
321
0
  if (self) {
322
0
    UpdateWrapper(self, self, obj, old);
323
0
  }
324
0
325
0
  return 0;
326
0
}
327
328
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
329
#if defined(__clang__)
330
#pragma clang diagnostic push
331
#pragma clang diagnostic ignored "-Wmissing-braces"
332
#endif
333
static const JSPropertySpec sAttributes_specs[] = {
334
  { "x", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &x_getterinfo, GenericSetter<NormalThisPolicy>, &x_setterinfo },
335
  { "y", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &y_getterinfo, GenericSetter<NormalThisPolicy>, &y_setterinfo },
336
  { "width", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &width_getterinfo, GenericSetter<NormalThisPolicy>, &width_setterinfo },
337
  { "height", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &height_getterinfo, GenericSetter<NormalThisPolicy>, &height_setterinfo },
338
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
339
};
340
#if defined(__clang__)
341
#pragma clang diagnostic pop
342
#endif
343
344
345
static const Prefable<const JSPropertySpec> sAttributes[] = {
346
  { nullptr, &sAttributes_specs[0] },
347
  { nullptr, nullptr }
348
};
349
350
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
351
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
352
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
353
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
354
355
356
static uint16_t sNativeProperties_sortedPropertyIndices[4];
357
static PropertyInfo sNativeProperties_propertyInfos[4];
358
359
static const NativePropertiesN<1> sNativeProperties = {
360
  false, 0,
361
  false, 0,
362
  false, 0,
363
  true,  0 /* sAttributes */,
364
  false, 0,
365
  false, 0,
366
  false, 0,
367
  -1,
368
  4,
369
  sNativeProperties_sortedPropertyIndices,
370
  {
371
    { sAttributes, &sNativeProperties_propertyInfos[0] }
372
  }
373
};
374
static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
375
    "We have a property info count that is oversized");
376
377
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
378
  {
379
    "Function",
380
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
381
    &sBoringInterfaceObjectClassClassOps,
382
    JS_NULL_CLASS_SPEC,
383
    JS_NULL_CLASS_EXT,
384
    &sInterfaceObjectClassObjectOps
385
  },
386
  eInterface,
387
  true,
388
  prototypes::id::SVGRect,
389
  PrototypeTraits<prototypes::id::SVGRect>::Depth,
390
  sNativePropertyHooks,
391
  "function SVGRect() {\n    [native code]\n}",
392
  JS::GetRealmFunctionPrototype
393
};
394
395
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
396
  {
397
    "SVGRectPrototype",
398
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
399
    JS_NULL_CLASS_OPS,
400
    JS_NULL_CLASS_SPEC,
401
    JS_NULL_CLASS_EXT,
402
    JS_NULL_OBJECT_OPS
403
  },
404
  eInterfacePrototype,
405
  false,
406
  prototypes::id::SVGRect,
407
  PrototypeTraits<prototypes::id::SVGRect>::Depth,
408
  sNativePropertyHooks,
409
  "[object SVGRectPrototype]",
410
  JS::GetRealmObjectPrototype
411
};
412
413
static const js::ClassOps sClassOps = {
414
  _addProperty, /* addProperty */
415
  nullptr,               /* delProperty */
416
  nullptr,               /* enumerate */
417
  nullptr, /* newEnumerate */
418
  nullptr, /* resolve */
419
  nullptr, /* mayResolve */
420
  _finalize, /* finalize */
421
  nullptr, /* call */
422
  nullptr,               /* hasInstance */
423
  nullptr,               /* construct */
424
  nullptr, /* trace */
425
};
426
427
static const js::ClassExtension sClassExtension = {
428
  nullptr, /* weakmapKeyDelegateOp */
429
  _objectMoved /* objectMovedOp */
430
};
431
432
static const DOMJSClass sClass = {
433
  { "SVGRect",
434
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
435
    &sClassOps,
436
    JS_NULL_CLASS_SPEC,
437
    &sClassExtension,
438
    JS_NULL_OBJECT_OPS
439
  },
440
  { prototypes::id::SVGRect, 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 },
441
  IsBaseOf<nsISupports, mozilla::dom::SVGIRect >::value,
442
  sNativePropertyHooks,
443
  FindAssociatedGlobalForNative<mozilla::dom::SVGIRect>::Get,
444
  GetProtoObjectHandle,
445
  GetCCParticipant<mozilla::dom::SVGIRect>::Get()
446
};
447
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
448
              "Must have the right minimal number of reserved slots.");
449
static_assert(1 >= 1,
450
              "Must have enough reserved slots.");
451
452
const JSClass*
453
GetJSClass()
454
0
{
455
0
  return sClass.ToJSClass();
456
0
}
457
458
bool
459
Wrap(JSContext* aCx, mozilla::dom::SVGIRect* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
460
0
{
461
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGIRect>::value,
462
0
                "Shouldn't have wrappercached things that are not refcounted.");
463
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGIRect*>(aObject) ==
464
0
             reinterpret_cast<mozilla::dom::SVGIRect*>(aObject),
465
0
             "Multiple inheritance for mozilla::dom::SVGIRect is broken.");
466
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
467
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
468
0
  MOZ_ASSERT(!aCache->GetWrapper(),
469
0
             "You should probably not be using Wrap() directly; use "
470
0
             "GetOrCreateDOMReflector instead");
471
0
472
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
473
0
             "nsISupports must be on our primary inheritance chain");
474
0
475
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
476
0
  if (!global) {
477
0
    return false;
478
0
  }
479
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
480
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
481
0
482
0
  // That might have ended up wrapping us already, due to the wonders
483
0
  // of XBL.  Check for that, and bail out as needed.
484
0
  aReflector.set(aCache->GetWrapper());
485
0
  if (aReflector) {
486
#ifdef DEBUG
487
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
488
#endif // DEBUG
489
    return true;
490
0
  }
491
0
492
0
  JSAutoRealm ar(aCx, global);
493
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
494
0
  if (!canonicalProto) {
495
0
    return false;
496
0
  }
497
0
  JS::Rooted<JSObject*> proto(aCx);
498
0
  if (aGivenProto) {
499
0
    proto = aGivenProto;
500
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
501
0
    // coming in, we changed compartments to that of "parent" so may need
502
0
    // to wrap the proto here.
503
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
504
0
      if (!JS_WrapObject(aCx, &proto)) {
505
0
        return false;
506
0
      }
507
0
    }
508
0
  } else {
509
0
    proto = canonicalProto;
510
0
  }
511
0
512
0
  BindingJSObjectCreator<mozilla::dom::SVGIRect> creator(aCx);
513
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
514
0
  if (!aReflector) {
515
0
    return false;
516
0
  }
517
0
518
0
  aCache->SetWrapper(aReflector);
519
0
  creator.InitializationSucceeded();
520
0
521
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
522
0
             aCache->GetWrapperPreserveColor() == aReflector);
523
0
  // If proto != canonicalProto, we have to preserve our wrapper;
524
0
  // otherwise we won't be able to properly recreate it later, since
525
0
  // we won't know what proto to use.  Note that we don't check
526
0
  // aGivenProto here, since it's entirely possible (and even
527
0
  // somewhat common) to have a non-null aGivenProto which is the
528
0
  // same as canonicalProto.
529
0
  if (proto != canonicalProto) {
530
0
    PreserveWrapper(aObject);
531
0
  }
532
0
533
0
  return true;
534
0
}
535
536
const NativePropertyHooks sNativePropertyHooks[] = { {
537
  nullptr,
538
  nullptr,
539
  nullptr,
540
  { sNativeProperties.Upcast(), nullptr },
541
  prototypes::id::SVGRect,
542
  constructors::id::SVGRect,
543
  nullptr,
544
  &DefaultXrayExpandoObjectClass
545
} };
546
547
void
548
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
549
0
{
550
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
551
0
  if (!parentProto) {
552
0
    return;
553
0
  }
554
0
555
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
556
0
  if (!constructorProto) {
557
0
    return;
558
0
  }
559
0
560
0
  static bool sIdsInited = false;
561
0
  if (!sIdsInited && NS_IsMainThread()) {
562
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
563
0
      return;
564
0
    }
565
0
    sIdsInited = true;
566
0
  }
567
0
568
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGRect);
569
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGRect);
570
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
571
0
                              &sPrototypeClass.mBase, protoCache,
572
0
                              nullptr,
573
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
574
0
                              interfaceCache,
575
0
                              sNativeProperties.Upcast(),
576
0
                              nullptr,
577
0
                              "SVGRect", aDefineOnGlobal,
578
0
                              nullptr,
579
0
                              false);
580
0
}
581
582
JSObject*
583
GetConstructorObject(JSContext* aCx)
584
0
{
585
0
  return GetConstructorObjectHandle(aCx);
586
0
}
587
588
} // namespace SVGRect_Binding
589
590
591
592
} // namespace dom
593
} // namespace mozilla