Coverage Report

Created: 2018-09-25 14:53

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