Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SVGCircleElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SVGCircleElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "SVGCircleElementBinding.h"
4
#include "SVGGeometryElementBinding.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/SVGCircleElement.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 SVGCircleElement_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_cx(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGCircleElement* self, JSJitGetterCallArgs args)
28
0
{
29
0
  AUTO_PROFILER_LABEL_FAST("get SVGCircleElement.cx", DOM, cx);
30
0
31
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Cx()));
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 cx_getterinfo = {
41
  { (JSJitGetterOp)get_cx },
42
  { prototypes::id::SVGCircleElement },
43
  { PrototypeTraits<prototypes::id::SVGCircleElement>::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_cy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGCircleElement* self, JSJitGetterCallArgs args)
60
0
{
61
0
  AUTO_PROFILER_LABEL_FAST("get SVGCircleElement.cy", DOM, cx);
62
0
63
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Cy()));
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 cy_getterinfo = {
73
  { (JSJitGetterOp)get_cy },
74
  { prototypes::id::SVGCircleElement },
75
  { PrototypeTraits<prototypes::id::SVGCircleElement>::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_r(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGCircleElement* self, JSJitGetterCallArgs args)
92
0
{
93
0
  AUTO_PROFILER_LABEL_FAST("get SVGCircleElement.r", DOM, cx);
94
0
95
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->R()));
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 r_getterinfo = {
105
  { (JSJitGetterOp)get_r },
106
  { prototypes::id::SVGCircleElement },
107
  { PrototypeTraits<prototypes::id::SVGCircleElement>::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
static bool
123
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
124
0
{
125
0
  mozilla::dom::SVGCircleElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGCircleElement>(obj);
126
0
  // We don't want to preserve if we don't have a wrapper, and we
127
0
  // obviously can't preserve if we're not initialized.
128
0
  if (self && self->GetWrapperPreserveColor()) {
129
0
    PreserveWrapper(self);
130
0
  }
131
0
  return true;
132
0
}
133
134
static void
135
_finalize(js::FreeOp* fop, JSObject* obj)
136
0
{
137
0
  mozilla::dom::SVGCircleElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGCircleElement>(obj);
138
0
  if (self) {
139
0
    ClearWrapper(self, self, obj);
140
0
    AddForDeferredFinalization<mozilla::dom::SVGCircleElement>(self);
141
0
  }
142
0
}
143
144
static size_t
145
_objectMoved(JSObject* obj, JSObject* old)
146
0
{
147
0
  mozilla::dom::SVGCircleElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGCircleElement>(obj);
148
0
  if (self) {
149
0
    UpdateWrapper(self, self, obj, old);
150
0
  }
151
0
152
0
  return 0;
153
0
}
154
155
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
156
#if defined(__clang__)
157
#pragma clang diagnostic push
158
#pragma clang diagnostic ignored "-Wmissing-braces"
159
#endif
160
static const JSPropertySpec sAttributes_specs[] = {
161
  { "cx", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cx_getterinfo, nullptr, nullptr },
162
  { "cy", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &cy_getterinfo, nullptr, nullptr },
163
  { "r", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &r_getterinfo, nullptr, nullptr },
164
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
165
};
166
#if defined(__clang__)
167
#pragma clang diagnostic pop
168
#endif
169
170
171
static const Prefable<const JSPropertySpec> sAttributes[] = {
172
  { nullptr, &sAttributes_specs[0] },
173
  { nullptr, nullptr }
174
};
175
176
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
177
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
178
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
179
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
180
181
182
static uint16_t sNativeProperties_sortedPropertyIndices[3];
183
static PropertyInfo sNativeProperties_propertyInfos[3];
184
185
static const NativePropertiesN<1> sNativeProperties = {
186
  false, 0,
187
  false, 0,
188
  false, 0,
189
  true,  0 /* sAttributes */,
190
  false, 0,
191
  false, 0,
192
  false, 0,
193
  -1,
194
  3,
195
  sNativeProperties_sortedPropertyIndices,
196
  {
197
    { sAttributes, &sNativeProperties_propertyInfos[0] }
198
  }
199
};
200
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
201
    "We have a property info count that is oversized");
202
203
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
204
  {
205
    "Function",
206
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
207
    &sBoringInterfaceObjectClassClassOps,
208
    JS_NULL_CLASS_SPEC,
209
    JS_NULL_CLASS_EXT,
210
    &sInterfaceObjectClassObjectOps
211
  },
212
  eInterface,
213
  true,
214
  prototypes::id::SVGCircleElement,
215
  PrototypeTraits<prototypes::id::SVGCircleElement>::Depth,
216
  sNativePropertyHooks,
217
  "function SVGCircleElement() {\n    [native code]\n}",
218
  SVGGeometryElement_Binding::GetConstructorObject
219
};
220
221
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
222
  {
223
    "SVGCircleElementPrototype",
224
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
225
    JS_NULL_CLASS_OPS,
226
    JS_NULL_CLASS_SPEC,
227
    JS_NULL_CLASS_EXT,
228
    JS_NULL_OBJECT_OPS
229
  },
230
  eInterfacePrototype,
231
  false,
232
  prototypes::id::SVGCircleElement,
233
  PrototypeTraits<prototypes::id::SVGCircleElement>::Depth,
234
  sNativePropertyHooks,
235
  "[object SVGCircleElementPrototype]",
236
  SVGGeometryElement_Binding::GetProtoObject
237
};
238
239
static const js::ClassOps sClassOps = {
240
  _addProperty, /* addProperty */
241
  nullptr,               /* delProperty */
242
  nullptr,               /* enumerate */
243
  nullptr, /* newEnumerate */
244
  nullptr, /* resolve */
245
  nullptr, /* mayResolve */
246
  _finalize, /* finalize */
247
  nullptr, /* call */
248
  nullptr,               /* hasInstance */
249
  nullptr,               /* construct */
250
  nullptr, /* trace */
251
};
252
253
static const js::ClassExtension sClassExtension = {
254
  nullptr, /* weakmapKeyDelegateOp */
255
  _objectMoved /* objectMovedOp */
256
};
257
258
static const DOMJSClass sClass = {
259
  { "SVGCircleElement",
260
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
261
    &sClassOps,
262
    JS_NULL_CLASS_SPEC,
263
    &sClassExtension,
264
    JS_NULL_OBJECT_OPS
265
  },
266
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::SVGElement, prototypes::id::SVGGraphicsElement, prototypes::id::SVGGeometryElement, prototypes::id::SVGCircleElement, prototypes::id::_ID_Count },
267
  IsBaseOf<nsISupports, mozilla::dom::SVGCircleElement >::value,
268
  sNativePropertyHooks,
269
  FindAssociatedGlobalForNative<mozilla::dom::SVGCircleElement>::Get,
270
  GetProtoObjectHandle,
271
  GetCCParticipant<mozilla::dom::SVGCircleElement>::Get()
272
};
273
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
274
              "Must have the right minimal number of reserved slots.");
275
static_assert(1 >= 1,
276
              "Must have enough reserved slots.");
277
278
const JSClass*
279
GetJSClass()
280
0
{
281
0
  return sClass.ToJSClass();
282
0
}
283
284
bool
285
Wrap(JSContext* aCx, mozilla::dom::SVGCircleElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
286
0
{
287
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGCircleElement>::value,
288
0
                "Shouldn't have wrappercached things that are not refcounted.");
289
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGCircleElement*>(aObject) ==
290
0
             reinterpret_cast<mozilla::dom::SVGCircleElement*>(aObject),
291
0
             "Multiple inheritance for mozilla::dom::SVGCircleElement is broken.");
292
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGGeometryElement*>(aObject) ==
293
0
             reinterpret_cast<mozilla::dom::SVGGeometryElement*>(aObject),
294
0
             "Multiple inheritance for mozilla::dom::SVGGeometryElement is broken.");
295
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGGraphicsElement*>(aObject) ==
296
0
             reinterpret_cast<mozilla::dom::SVGGraphicsElement*>(aObject),
297
0
             "Multiple inheritance for mozilla::dom::SVGGraphicsElement is broken.");
298
0
  MOZ_ASSERT(static_cast<nsSVGElement*>(aObject) ==
299
0
             reinterpret_cast<nsSVGElement*>(aObject),
300
0
             "Multiple inheritance for nsSVGElement is broken.");
301
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
302
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
303
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
304
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
305
0
             reinterpret_cast<nsINode*>(aObject),
306
0
             "Multiple inheritance for nsINode is broken.");
307
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
308
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
309
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
310
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
311
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
312
0
  MOZ_ASSERT(!aCache->GetWrapper(),
313
0
             "You should probably not be using Wrap() directly; use "
314
0
             "GetOrCreateDOMReflector instead");
315
0
316
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
317
0
             "nsISupports must be on our primary inheritance chain");
318
0
319
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
320
0
  if (!global) {
321
0
    return false;
322
0
  }
323
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
324
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
325
0
326
0
  // That might have ended up wrapping us already, due to the wonders
327
0
  // of XBL.  Check for that, and bail out as needed.
328
0
  aReflector.set(aCache->GetWrapper());
329
0
  if (aReflector) {
330
#ifdef DEBUG
331
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
332
#endif // DEBUG
333
    return true;
334
0
  }
335
0
336
0
  JSAutoRealm ar(aCx, global);
337
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
338
0
  if (!canonicalProto) {
339
0
    return false;
340
0
  }
341
0
  JS::Rooted<JSObject*> proto(aCx);
342
0
  if (aGivenProto) {
343
0
    proto = aGivenProto;
344
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
345
0
    // coming in, we changed compartments to that of "parent" so may need
346
0
    // to wrap the proto here.
347
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
348
0
      if (!JS_WrapObject(aCx, &proto)) {
349
0
        return false;
350
0
      }
351
0
    }
352
0
  } else {
353
0
    proto = canonicalProto;
354
0
  }
355
0
356
0
  BindingJSObjectCreator<mozilla::dom::SVGCircleElement> creator(aCx);
357
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
358
0
  if (!aReflector) {
359
0
    return false;
360
0
  }
361
0
362
0
  aCache->SetWrapper(aReflector);
363
0
  creator.InitializationSucceeded();
364
0
365
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
366
0
             aCache->GetWrapperPreserveColor() == aReflector);
367
0
  // If proto != canonicalProto, we have to preserve our wrapper;
368
0
  // otherwise we won't be able to properly recreate it later, since
369
0
  // we won't know what proto to use.  Note that we don't check
370
0
  // aGivenProto here, since it's entirely possible (and even
371
0
  // somewhat common) to have a non-null aGivenProto which is the
372
0
  // same as canonicalProto.
373
0
  if (proto != canonicalProto) {
374
0
    PreserveWrapper(aObject);
375
0
  }
376
0
377
0
  return true;
378
0
}
379
380
const NativePropertyHooks sNativePropertyHooks[] = { {
381
  nullptr,
382
  nullptr,
383
  nullptr,
384
  { sNativeProperties.Upcast(), nullptr },
385
  prototypes::id::SVGCircleElement,
386
  constructors::id::SVGCircleElement,
387
  SVGGeometryElement_Binding::sNativePropertyHooks,
388
  &DefaultXrayExpandoObjectClass
389
} };
390
391
void
392
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
393
0
{
394
0
  JS::Handle<JSObject*> parentProto(SVGGeometryElement_Binding::GetProtoObjectHandle(aCx));
395
0
  if (!parentProto) {
396
0
    return;
397
0
  }
398
0
399
0
  JS::Handle<JSObject*> constructorProto(SVGGeometryElement_Binding::GetConstructorObjectHandle(aCx));
400
0
  if (!constructorProto) {
401
0
    return;
402
0
  }
403
0
404
0
  static bool sIdsInited = false;
405
0
  if (!sIdsInited && NS_IsMainThread()) {
406
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
407
0
      return;
408
0
    }
409
0
    sIdsInited = true;
410
0
  }
411
0
412
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGCircleElement);
413
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGCircleElement);
414
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
415
0
                              &sPrototypeClass.mBase, protoCache,
416
0
                              nullptr,
417
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
418
0
                              interfaceCache,
419
0
                              sNativeProperties.Upcast(),
420
0
                              nullptr,
421
0
                              "SVGCircleElement", aDefineOnGlobal,
422
0
                              nullptr,
423
0
                              false);
424
0
}
425
426
JSObject*
427
GetConstructorObject(JSContext* aCx)
428
0
{
429
0
  return GetConstructorObjectHandle(aCx);
430
0
}
431
432
} // namespace SVGCircleElement_Binding
433
434
435
436
} // namespace dom
437
} // namespace mozilla