Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SVGAnimatedRectBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SVGAnimatedRect.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "SVGAnimatedRectBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/NonRefcountedDOMObject.h"
9
#include "mozilla/dom/Nullable.h"
10
#include "mozilla/dom/SVGAnimatedRect.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 SVGAnimatedRect_Binding {
22
23
MOZ_CAN_RUN_SCRIPT static bool
24
get_baseVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedRect* self, JSJitGetterCallArgs args)
25
0
{
26
0
  AUTO_PROFILER_LABEL_FAST("get SVGAnimatedRect.baseVal", DOM, cx);
27
0
28
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGIRect>(self->GetBaseVal()));
29
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
30
0
  if (!result) {
31
0
    args.rval().setNull();
32
0
    return true;
33
0
  }
34
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
35
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
36
0
    return false;
37
0
  }
38
0
  return true;
39
0
}
40
41
static const JSJitInfo baseVal_getterinfo = {
42
  { (JSJitGetterOp)get_baseVal },
43
  { prototypes::id::SVGAnimatedRect },
44
  { PrototypeTraits<prototypes::id::SVGAnimatedRect>::Depth },
45
  JSJitInfo::Getter,
46
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
47
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
48
  false,  /* isInfallible. False in setters. */
49
  false,  /* isMovable.  Not relevant for setters. */
50
  false, /* isEliminatable.  Not relevant for setters. */
51
  false, /* isAlwaysInSlot.  Only relevant for getters. */
52
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
53
  false,  /* isTypedMethod.  Only relevant for methods. */
54
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
55
};
56
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
57
static_assert(0 < 1, "There is no slot for us");
58
59
MOZ_CAN_RUN_SCRIPT static bool
60
get_animVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedRect* self, JSJitGetterCallArgs args)
61
0
{
62
0
  AUTO_PROFILER_LABEL_FAST("get SVGAnimatedRect.animVal", DOM, cx);
63
0
64
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGIRect>(self->GetAnimVal()));
65
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
66
0
  if (!result) {
67
0
    args.rval().setNull();
68
0
    return true;
69
0
  }
70
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
71
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
72
0
    return false;
73
0
  }
74
0
  return true;
75
0
}
76
77
static const JSJitInfo animVal_getterinfo = {
78
  { (JSJitGetterOp)get_animVal },
79
  { prototypes::id::SVGAnimatedRect },
80
  { PrototypeTraits<prototypes::id::SVGAnimatedRect>::Depth },
81
  JSJitInfo::Getter,
82
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
83
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
84
  false,  /* isInfallible. False in setters. */
85
  false,  /* isMovable.  Not relevant for setters. */
86
  false, /* isEliminatable.  Not relevant for setters. */
87
  false, /* isAlwaysInSlot.  Only relevant for getters. */
88
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
89
  false,  /* isTypedMethod.  Only relevant for methods. */
90
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
91
};
92
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
93
static_assert(0 < 1, "There is no slot for us");
94
95
static bool
96
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
97
0
{
98
0
  mozilla::dom::SVGAnimatedRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedRect>(obj);
99
0
  // We don't want to preserve if we don't have a wrapper, and we
100
0
  // obviously can't preserve if we're not initialized.
101
0
  if (self && self->GetWrapperPreserveColor()) {
102
0
    PreserveWrapper(self);
103
0
  }
104
0
  return true;
105
0
}
106
107
static void
108
_finalize(js::FreeOp* fop, JSObject* obj)
109
0
{
110
0
  mozilla::dom::SVGAnimatedRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedRect>(obj);
111
0
  if (self) {
112
0
    ClearWrapper(self, self, obj);
113
0
    AddForDeferredFinalization<mozilla::dom::SVGAnimatedRect>(self);
114
0
  }
115
0
}
116
117
static size_t
118
_objectMoved(JSObject* obj, JSObject* old)
119
0
{
120
0
  mozilla::dom::SVGAnimatedRect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedRect>(obj);
121
0
  if (self) {
122
0
    UpdateWrapper(self, self, obj, old);
123
0
  }
124
0
125
0
  return 0;
126
0
}
127
128
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
129
#if defined(__clang__)
130
#pragma clang diagnostic push
131
#pragma clang diagnostic ignored "-Wmissing-braces"
132
#endif
133
static const JSPropertySpec sAttributes_specs[] = {
134
  { "baseVal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &baseVal_getterinfo, nullptr, nullptr },
135
  { "animVal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &animVal_getterinfo, nullptr, nullptr },
136
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
137
};
138
#if defined(__clang__)
139
#pragma clang diagnostic pop
140
#endif
141
142
143
static const Prefable<const JSPropertySpec> sAttributes[] = {
144
  { nullptr, &sAttributes_specs[0] },
145
  { nullptr, nullptr }
146
};
147
148
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
149
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
150
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
151
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
152
153
154
static uint16_t sNativeProperties_sortedPropertyIndices[2];
155
static PropertyInfo sNativeProperties_propertyInfos[2];
156
157
static const NativePropertiesN<1> sNativeProperties = {
158
  false, 0,
159
  false, 0,
160
  false, 0,
161
  true,  0 /* sAttributes */,
162
  false, 0,
163
  false, 0,
164
  false, 0,
165
  -1,
166
  2,
167
  sNativeProperties_sortedPropertyIndices,
168
  {
169
    { sAttributes, &sNativeProperties_propertyInfos[0] }
170
  }
171
};
172
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
173
    "We have a property info count that is oversized");
174
175
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
176
  {
177
    "Function",
178
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
179
    &sBoringInterfaceObjectClassClassOps,
180
    JS_NULL_CLASS_SPEC,
181
    JS_NULL_CLASS_EXT,
182
    &sInterfaceObjectClassObjectOps
183
  },
184
  eInterface,
185
  true,
186
  prototypes::id::SVGAnimatedRect,
187
  PrototypeTraits<prototypes::id::SVGAnimatedRect>::Depth,
188
  sNativePropertyHooks,
189
  "function SVGAnimatedRect() {\n    [native code]\n}",
190
  JS::GetRealmFunctionPrototype
191
};
192
193
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
194
  {
195
    "SVGAnimatedRectPrototype",
196
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
197
    JS_NULL_CLASS_OPS,
198
    JS_NULL_CLASS_SPEC,
199
    JS_NULL_CLASS_EXT,
200
    JS_NULL_OBJECT_OPS
201
  },
202
  eInterfacePrototype,
203
  false,
204
  prototypes::id::SVGAnimatedRect,
205
  PrototypeTraits<prototypes::id::SVGAnimatedRect>::Depth,
206
  sNativePropertyHooks,
207
  "[object SVGAnimatedRectPrototype]",
208
  JS::GetRealmObjectPrototype
209
};
210
211
static const js::ClassOps sClassOps = {
212
  _addProperty, /* addProperty */
213
  nullptr,               /* delProperty */
214
  nullptr,               /* enumerate */
215
  nullptr, /* newEnumerate */
216
  nullptr, /* resolve */
217
  nullptr, /* mayResolve */
218
  _finalize, /* finalize */
219
  nullptr, /* call */
220
  nullptr,               /* hasInstance */
221
  nullptr,               /* construct */
222
  nullptr, /* trace */
223
};
224
225
static const js::ClassExtension sClassExtension = {
226
  nullptr, /* weakmapKeyDelegateOp */
227
  _objectMoved /* objectMovedOp */
228
};
229
230
static const DOMJSClass sClass = {
231
  { "SVGAnimatedRect",
232
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
233
    &sClassOps,
234
    JS_NULL_CLASS_SPEC,
235
    &sClassExtension,
236
    JS_NULL_OBJECT_OPS
237
  },
238
  { prototypes::id::SVGAnimatedRect, 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 },
239
  IsBaseOf<nsISupports, mozilla::dom::SVGAnimatedRect >::value,
240
  sNativePropertyHooks,
241
  FindAssociatedGlobalForNative<mozilla::dom::SVGAnimatedRect>::Get,
242
  GetProtoObjectHandle,
243
  GetCCParticipant<mozilla::dom::SVGAnimatedRect>::Get()
244
};
245
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
246
              "Must have the right minimal number of reserved slots.");
247
static_assert(1 >= 1,
248
              "Must have enough reserved slots.");
249
250
const JSClass*
251
GetJSClass()
252
0
{
253
0
  return sClass.ToJSClass();
254
0
}
255
256
bool
257
Wrap(JSContext* aCx, mozilla::dom::SVGAnimatedRect* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
258
0
{
259
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGAnimatedRect>::value,
260
0
                "Shouldn't have wrappercached things that are not refcounted.");
261
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGAnimatedRect*>(aObject) ==
262
0
             reinterpret_cast<mozilla::dom::SVGAnimatedRect*>(aObject),
263
0
             "Multiple inheritance for mozilla::dom::SVGAnimatedRect is broken.");
264
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
265
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
266
0
  MOZ_ASSERT(!aCache->GetWrapper(),
267
0
             "You should probably not be using Wrap() directly; use "
268
0
             "GetOrCreateDOMReflector instead");
269
0
270
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
271
0
             "nsISupports must be on our primary inheritance chain");
272
0
273
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
274
0
  if (!global) {
275
0
    return false;
276
0
  }
277
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
278
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
279
0
280
0
  // That might have ended up wrapping us already, due to the wonders
281
0
  // of XBL.  Check for that, and bail out as needed.
282
0
  aReflector.set(aCache->GetWrapper());
283
0
  if (aReflector) {
284
#ifdef DEBUG
285
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
286
#endif // DEBUG
287
    return true;
288
0
  }
289
0
290
0
  JSAutoRealm ar(aCx, global);
291
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
292
0
  if (!canonicalProto) {
293
0
    return false;
294
0
  }
295
0
  JS::Rooted<JSObject*> proto(aCx);
296
0
  if (aGivenProto) {
297
0
    proto = aGivenProto;
298
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
299
0
    // coming in, we changed compartments to that of "parent" so may need
300
0
    // to wrap the proto here.
301
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
302
0
      if (!JS_WrapObject(aCx, &proto)) {
303
0
        return false;
304
0
      }
305
0
    }
306
0
  } else {
307
0
    proto = canonicalProto;
308
0
  }
309
0
310
0
  BindingJSObjectCreator<mozilla::dom::SVGAnimatedRect> creator(aCx);
311
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
312
0
  if (!aReflector) {
313
0
    return false;
314
0
  }
315
0
316
0
  aCache->SetWrapper(aReflector);
317
0
  creator.InitializationSucceeded();
318
0
319
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
320
0
             aCache->GetWrapperPreserveColor() == aReflector);
321
0
  // If proto != canonicalProto, we have to preserve our wrapper;
322
0
  // otherwise we won't be able to properly recreate it later, since
323
0
  // we won't know what proto to use.  Note that we don't check
324
0
  // aGivenProto here, since it's entirely possible (and even
325
0
  // somewhat common) to have a non-null aGivenProto which is the
326
0
  // same as canonicalProto.
327
0
  if (proto != canonicalProto) {
328
0
    PreserveWrapper(aObject);
329
0
  }
330
0
331
0
  return true;
332
0
}
333
334
const NativePropertyHooks sNativePropertyHooks[] = { {
335
  nullptr,
336
  nullptr,
337
  nullptr,
338
  { sNativeProperties.Upcast(), nullptr },
339
  prototypes::id::SVGAnimatedRect,
340
  constructors::id::SVGAnimatedRect,
341
  nullptr,
342
  &DefaultXrayExpandoObjectClass
343
} };
344
345
void
346
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
347
0
{
348
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
349
0
  if (!parentProto) {
350
0
    return;
351
0
  }
352
0
353
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
354
0
  if (!constructorProto) {
355
0
    return;
356
0
  }
357
0
358
0
  static bool sIdsInited = false;
359
0
  if (!sIdsInited && NS_IsMainThread()) {
360
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
361
0
      return;
362
0
    }
363
0
    sIdsInited = true;
364
0
  }
365
0
366
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGAnimatedRect);
367
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGAnimatedRect);
368
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
369
0
                              &sPrototypeClass.mBase, protoCache,
370
0
                              nullptr,
371
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
372
0
                              interfaceCache,
373
0
                              sNativeProperties.Upcast(),
374
0
                              nullptr,
375
0
                              "SVGAnimatedRect", aDefineOnGlobal,
376
0
                              nullptr,
377
0
                              false);
378
0
}
379
380
JSObject*
381
GetConstructorObject(JSContext* aCx)
382
0
{
383
0
  return GetConstructorObjectHandle(aCx);
384
0
}
385
386
} // namespace SVGAnimatedRect_Binding
387
388
389
390
} // namespace dom
391
} // namespace mozilla