Coverage Report

Created: 2018-09-25 14:53

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