Coverage Report

Created: 2018-09-25 14:53

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