Coverage Report

Created: 2018-09-25 14:53

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