Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SVGImageElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SVGImageElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "SVGAnimatedPreserveAspectRatio.h"
4
#include "SVGGraphicsElementBinding.h"
5
#include "SVGImageElementBinding.h"
6
#include "WrapperFactory.h"
7
#include "imgINotificationObserver.h"
8
#include "imgIRequest.h"
9
#include "mozilla/OwningNonNull.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/CustomElementRegistry.h"
12
#include "mozilla/dom/DOMJSClass.h"
13
#include "mozilla/dom/DocGroup.h"
14
#include "mozilla/dom/NonRefcountedDOMObject.h"
15
#include "mozilla/dom/Nullable.h"
16
#include "mozilla/dom/PrimitiveConversions.h"
17
#include "mozilla/dom/SVGAnimatedLength.h"
18
#include "mozilla/dom/SVGAnimatedString.h"
19
#include "mozilla/dom/SVGImageElement.h"
20
#include "mozilla/dom/XrayExpandoClass.h"
21
#include "nsContentUtils.h"
22
#include "nsIURI.h"
23
24
namespace mozilla {
25
namespace dom {
26
27
namespace binding_detail {}; // Just to make sure it's known as a namespace
28
using namespace mozilla::dom::binding_detail;
29
30
31
namespace SVGImageElement_Binding {
32
33
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<SVGGraphicsElement_Binding::NativeType>::value,
34
              "Can't inherit from an interface with a different ownership model.");
35
36
MOZ_CAN_RUN_SCRIPT static bool
37
get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
38
0
{
39
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.x", DOM, cx);
40
0
41
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->X()));
42
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
43
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
44
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
45
0
    return false;
46
0
  }
47
0
  return true;
48
0
}
49
50
static const JSJitInfo x_getterinfo = {
51
  { (JSJitGetterOp)get_x },
52
  { prototypes::id::SVGImageElement },
53
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
54
  JSJitInfo::Getter,
55
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
56
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
57
  false,  /* isInfallible. False in setters. */
58
  true,  /* isMovable.  Not relevant for setters. */
59
  true, /* isEliminatable.  Not relevant for setters. */
60
  false, /* isAlwaysInSlot.  Only relevant for getters. */
61
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
62
  false,  /* isTypedMethod.  Only relevant for methods. */
63
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
64
};
65
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
66
static_assert(0 < 1, "There is no slot for us");
67
68
MOZ_CAN_RUN_SCRIPT static bool
69
get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
70
0
{
71
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.y", DOM, cx);
72
0
73
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Y()));
74
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
75
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
76
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
77
0
    return false;
78
0
  }
79
0
  return true;
80
0
}
81
82
static const JSJitInfo y_getterinfo = {
83
  { (JSJitGetterOp)get_y },
84
  { prototypes::id::SVGImageElement },
85
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
86
  JSJitInfo::Getter,
87
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
88
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
89
  false,  /* isInfallible. False in setters. */
90
  true,  /* isMovable.  Not relevant for setters. */
91
  true, /* isEliminatable.  Not relevant for setters. */
92
  false, /* isAlwaysInSlot.  Only relevant for getters. */
93
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
94
  false,  /* isTypedMethod.  Only relevant for methods. */
95
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
96
};
97
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
98
static_assert(0 < 1, "There is no slot for us");
99
100
MOZ_CAN_RUN_SCRIPT static bool
101
get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
102
0
{
103
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.width", DOM, cx);
104
0
105
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Width()));
106
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
107
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
108
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
109
0
    return false;
110
0
  }
111
0
  return true;
112
0
}
113
114
static const JSJitInfo width_getterinfo = {
115
  { (JSJitGetterOp)get_width },
116
  { prototypes::id::SVGImageElement },
117
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
118
  JSJitInfo::Getter,
119
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
120
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
121
  false,  /* isInfallible. False in setters. */
122
  true,  /* isMovable.  Not relevant for setters. */
123
  true, /* isEliminatable.  Not relevant for setters. */
124
  false, /* isAlwaysInSlot.  Only relevant for getters. */
125
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
126
  false,  /* isTypedMethod.  Only relevant for methods. */
127
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
128
};
129
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
130
static_assert(0 < 1, "There is no slot for us");
131
132
MOZ_CAN_RUN_SCRIPT static bool
133
get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
134
0
{
135
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.height", DOM, cx);
136
0
137
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Height()));
138
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
139
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
140
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
141
0
    return false;
142
0
  }
143
0
  return true;
144
0
}
145
146
static const JSJitInfo height_getterinfo = {
147
  { (JSJitGetterOp)get_height },
148
  { prototypes::id::SVGImageElement },
149
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
150
  JSJitInfo::Getter,
151
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
152
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
153
  false,  /* isInfallible. False in setters. */
154
  true,  /* isMovable.  Not relevant for setters. */
155
  true, /* isEliminatable.  Not relevant for setters. */
156
  false, /* isAlwaysInSlot.  Only relevant for getters. */
157
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
158
  false,  /* isTypedMethod.  Only relevant for methods. */
159
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
160
};
161
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
162
static_assert(0 < 1, "There is no slot for us");
163
164
MOZ_CAN_RUN_SCRIPT static bool
165
get_preserveAspectRatio(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
166
0
{
167
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.preserveAspectRatio", DOM, cx);
168
0
169
0
  auto result(StrongOrRawPtr<mozilla::dom::DOMSVGAnimatedPreserveAspectRatio>(self->PreserveAspectRatio()));
170
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
171
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
172
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
173
0
    return false;
174
0
  }
175
0
  return true;
176
0
}
177
178
static const JSJitInfo preserveAspectRatio_getterinfo = {
179
  { (JSJitGetterOp)get_preserveAspectRatio },
180
  { prototypes::id::SVGImageElement },
181
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
182
  JSJitInfo::Getter,
183
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
184
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
185
  false,  /* isInfallible. False in setters. */
186
  true,  /* isMovable.  Not relevant for setters. */
187
  true, /* isEliminatable.  Not relevant for setters. */
188
  false, /* isAlwaysInSlot.  Only relevant for getters. */
189
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
190
  false,  /* isTypedMethod.  Only relevant for methods. */
191
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
192
};
193
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
194
static_assert(0 < 1, "There is no slot for us");
195
196
MOZ_CAN_RUN_SCRIPT static bool
197
get_decoding(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
198
0
{
199
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.decoding", DOM, cx);
200
0
201
0
  DOMString result;
202
0
  self->GetDecoding(result);
203
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
204
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
205
0
    return false;
206
0
  }
207
0
  return true;
208
0
}
209
210
MOZ_CAN_RUN_SCRIPT static bool
211
set_decoding(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitSetterCallArgs args)
212
0
{
213
0
  AUTO_PROFILER_LABEL_FAST("set SVGImageElement.decoding", DOM, cx);
214
0
215
0
  binding_detail::FakeString arg0;
216
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
217
0
    return false;
218
0
  }
219
0
  Maybe<AutoCEReaction> ceReaction;
220
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
221
0
    DocGroup* docGroup = self->GetDocGroup();
222
0
    if (docGroup) {
223
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
224
0
    }
225
0
  }
226
0
  FastErrorResult rv;
227
0
  self->SetDecoding(NonNullHelper(Constify(arg0)), rv);
228
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
229
0
    return false;
230
0
  }
231
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
232
0
233
0
  return true;
234
0
}
235
236
static const JSJitInfo decoding_getterinfo = {
237
  { (JSJitGetterOp)get_decoding },
238
  { prototypes::id::SVGImageElement },
239
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
240
  JSJitInfo::Getter,
241
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
242
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
243
  false,  /* isInfallible. False in setters. */
244
  false,  /* isMovable.  Not relevant for setters. */
245
  false, /* isEliminatable.  Not relevant for setters. */
246
  false, /* isAlwaysInSlot.  Only relevant for getters. */
247
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
248
  false,  /* isTypedMethod.  Only relevant for methods. */
249
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
250
};
251
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
252
static_assert(0 < 1, "There is no slot for us");
253
static const JSJitInfo decoding_setterinfo = {
254
  { (JSJitGetterOp)set_decoding },
255
  { prototypes::id::SVGImageElement },
256
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
257
  JSJitInfo::Setter,
258
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
259
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
260
  false,  /* isInfallible. False in setters. */
261
  false,  /* isMovable.  Not relevant for setters. */
262
  false, /* isEliminatable.  Not relevant for setters. */
263
  false, /* isAlwaysInSlot.  Only relevant for getters. */
264
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
265
  false,  /* isTypedMethod.  Only relevant for methods. */
266
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
267
};
268
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
269
static_assert(0 < 1, "There is no slot for us");
270
271
MOZ_CAN_RUN_SCRIPT static bool
272
get_loadingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
273
0
{
274
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.loadingEnabled", DOM, cx);
275
0
276
0
  bool result(self->LoadingEnabled());
277
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
278
0
  args.rval().setBoolean(result);
279
0
  return true;
280
0
}
281
282
MOZ_CAN_RUN_SCRIPT static bool
283
set_loadingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitSetterCallArgs args)
284
0
{
285
0
  AUTO_PROFILER_LABEL_FAST("set SVGImageElement.loadingEnabled", DOM, cx);
286
0
287
0
  bool arg0;
288
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
289
0
    return false;
290
0
  }
291
0
  self->SetLoadingEnabled(arg0);
292
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
293
0
294
0
  return true;
295
0
}
296
297
static const JSJitInfo loadingEnabled_getterinfo = {
298
  { (JSJitGetterOp)get_loadingEnabled },
299
  { prototypes::id::SVGImageElement },
300
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
301
  JSJitInfo::Getter,
302
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
303
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
304
  true,  /* isInfallible. False in setters. */
305
  false,  /* isMovable.  Not relevant for setters. */
306
  false, /* isEliminatable.  Not relevant for setters. */
307
  false, /* isAlwaysInSlot.  Only relevant for getters. */
308
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
309
  false,  /* isTypedMethod.  Only relevant for methods. */
310
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
311
};
312
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
313
static_assert(0 < 1, "There is no slot for us");
314
static const JSJitInfo loadingEnabled_setterinfo = {
315
  { (JSJitGetterOp)set_loadingEnabled },
316
  { prototypes::id::SVGImageElement },
317
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
318
  JSJitInfo::Setter,
319
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
320
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
321
  false,  /* isInfallible. False in setters. */
322
  false,  /* isMovable.  Not relevant for setters. */
323
  false, /* isEliminatable.  Not relevant for setters. */
324
  false, /* isAlwaysInSlot.  Only relevant for getters. */
325
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
326
  false,  /* isTypedMethod.  Only relevant for methods. */
327
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
328
};
329
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
330
static_assert(0 < 1, "There is no slot for us");
331
332
MOZ_CAN_RUN_SCRIPT static bool
333
get_imageBlockingStatus(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
334
0
{
335
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.imageBlockingStatus", DOM, cx);
336
0
337
0
  int16_t result(self->ImageBlockingStatus());
338
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
339
0
  args.rval().setInt32(int32_t(result));
340
0
  return true;
341
0
}
342
343
static const JSJitInfo imageBlockingStatus_getterinfo = {
344
  { (JSJitGetterOp)get_imageBlockingStatus },
345
  { prototypes::id::SVGImageElement },
346
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
347
  JSJitInfo::Getter,
348
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
349
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
350
  true,  /* isInfallible. False in setters. */
351
  false,  /* isMovable.  Not relevant for setters. */
352
  false, /* isEliminatable.  Not relevant for setters. */
353
  false, /* isAlwaysInSlot.  Only relevant for getters. */
354
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
355
  false,  /* isTypedMethod.  Only relevant for methods. */
356
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
357
};
358
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
359
static_assert(0 < 1, "There is no slot for us");
360
361
MOZ_CAN_RUN_SCRIPT static bool
362
addObserver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, const JSJitMethodCallArgs& args)
363
0
{
364
0
  AUTO_PROFILER_LABEL_FAST("SVGImageElement.addObserver", DOM, cx);
365
0
366
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
367
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGImageElement.addObserver");
368
0
  }
369
0
  imgINotificationObserver* arg0;
370
0
  RefPtr<imgINotificationObserver> arg0_holder;
371
0
  if (args[0].isObject()) {
372
0
    JS::Rooted<JSObject*> source(cx, &args[0].toObject());
373
0
    if (NS_FAILED(UnwrapArg<imgINotificationObserver>(cx, source, getter_AddRefs(arg0_holder)))) {
374
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGImageElement.addObserver", "imgINotificationObserver");
375
0
      return false;
376
0
    }
377
0
    MOZ_ASSERT(arg0_holder);
378
0
    arg0 = arg0_holder;
379
0
  } else {
380
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGImageElement.addObserver");
381
0
    return false;
382
0
  }
383
0
  self->AddObserver(MOZ_KnownLive(NonNullHelper(arg0)));
384
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
385
0
  args.rval().setUndefined();
386
0
  return true;
387
0
}
388
389
static const JSJitInfo addObserver_methodinfo = {
390
  { (JSJitGetterOp)addObserver },
391
  { prototypes::id::SVGImageElement },
392
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
393
  JSJitInfo::Method,
394
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
395
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
396
  false,  /* isInfallible. False in setters. */
397
  false,  /* isMovable.  Not relevant for setters. */
398
  false, /* isEliminatable.  Not relevant for setters. */
399
  false, /* isAlwaysInSlot.  Only relevant for getters. */
400
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
401
  false,  /* isTypedMethod.  Only relevant for methods. */
402
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
403
};
404
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
405
static_assert(0 < 1, "There is no slot for us");
406
407
MOZ_CAN_RUN_SCRIPT static bool
408
removeObserver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, const JSJitMethodCallArgs& args)
409
0
{
410
0
  AUTO_PROFILER_LABEL_FAST("SVGImageElement.removeObserver", DOM, cx);
411
0
412
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
413
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGImageElement.removeObserver");
414
0
  }
415
0
  imgINotificationObserver* arg0;
416
0
  RefPtr<imgINotificationObserver> arg0_holder;
417
0
  if (args[0].isObject()) {
418
0
    JS::Rooted<JSObject*> source(cx, &args[0].toObject());
419
0
    if (NS_FAILED(UnwrapArg<imgINotificationObserver>(cx, source, getter_AddRefs(arg0_holder)))) {
420
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGImageElement.removeObserver", "imgINotificationObserver");
421
0
      return false;
422
0
    }
423
0
    MOZ_ASSERT(arg0_holder);
424
0
    arg0 = arg0_holder;
425
0
  } else {
426
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGImageElement.removeObserver");
427
0
    return false;
428
0
  }
429
0
  self->RemoveObserver(MOZ_KnownLive(NonNullHelper(arg0)));
430
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
431
0
  args.rval().setUndefined();
432
0
  return true;
433
0
}
434
435
static const JSJitInfo removeObserver_methodinfo = {
436
  { (JSJitGetterOp)removeObserver },
437
  { prototypes::id::SVGImageElement },
438
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
439
  JSJitInfo::Method,
440
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
441
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
442
  false,  /* isInfallible. False in setters. */
443
  false,  /* isMovable.  Not relevant for setters. */
444
  false, /* isEliminatable.  Not relevant for setters. */
445
  false, /* isAlwaysInSlot.  Only relevant for getters. */
446
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
447
  false,  /* isTypedMethod.  Only relevant for methods. */
448
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
449
};
450
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
451
static_assert(0 < 1, "There is no slot for us");
452
453
MOZ_CAN_RUN_SCRIPT static bool
454
getRequest(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, const JSJitMethodCallArgs& args)
455
0
{
456
0
  AUTO_PROFILER_LABEL_FAST("SVGImageElement.getRequest", DOM, cx);
457
0
458
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
459
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGImageElement.getRequest");
460
0
  }
461
0
  int32_t arg0;
462
0
  if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
463
0
    return false;
464
0
  }
465
0
  FastErrorResult rv;
466
0
  auto result(StrongOrRawPtr<imgIRequest>(self->GetRequest(arg0, rv)));
467
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
468
0
    return false;
469
0
  }
470
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
471
0
  if (!result) {
472
0
    args.rval().setNull();
473
0
    return true;
474
0
  }
475
0
  if (!WrapObject(cx, result, &NS_GET_IID(imgIRequest), args.rval())) {
476
0
    return false;
477
0
  }
478
0
  return true;
479
0
}
480
481
static const JSJitInfo getRequest_methodinfo = {
482
  { (JSJitGetterOp)getRequest },
483
  { prototypes::id::SVGImageElement },
484
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
485
  JSJitInfo::Method,
486
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
487
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
488
  false,  /* isInfallible. False in setters. */
489
  false,  /* isMovable.  Not relevant for setters. */
490
  false, /* isEliminatable.  Not relevant for setters. */
491
  false, /* isAlwaysInSlot.  Only relevant for getters. */
492
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
493
  false,  /* isTypedMethod.  Only relevant for methods. */
494
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
495
};
496
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
497
static_assert(0 < 1, "There is no slot for us");
498
499
MOZ_CAN_RUN_SCRIPT static bool
500
getRequestType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, const JSJitMethodCallArgs& args)
501
0
{
502
0
  AUTO_PROFILER_LABEL_FAST("SVGImageElement.getRequestType", DOM, cx);
503
0
504
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
505
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGImageElement.getRequestType");
506
0
  }
507
0
  imgIRequest* arg0;
508
0
  RefPtr<imgIRequest> arg0_holder;
509
0
  if (args[0].isObject()) {
510
0
    JS::Rooted<JSObject*> source(cx, &args[0].toObject());
511
0
    if (NS_FAILED(UnwrapArg<imgIRequest>(cx, source, getter_AddRefs(arg0_holder)))) {
512
0
      ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGImageElement.getRequestType", "imgIRequest");
513
0
      return false;
514
0
    }
515
0
    MOZ_ASSERT(arg0_holder);
516
0
    arg0 = arg0_holder;
517
0
  } else {
518
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGImageElement.getRequestType");
519
0
    return false;
520
0
  }
521
0
  FastErrorResult rv;
522
0
  int32_t result(self->GetRequestType(MOZ_KnownLive(NonNullHelper(arg0)), rv));
523
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
524
0
    return false;
525
0
  }
526
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
527
0
  args.rval().setInt32(int32_t(result));
528
0
  return true;
529
0
}
530
531
static const JSJitInfo getRequestType_methodinfo = {
532
  { (JSJitGetterOp)getRequestType },
533
  { prototypes::id::SVGImageElement },
534
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
535
  JSJitInfo::Method,
536
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
537
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
538
  false,  /* isInfallible. False in setters. */
539
  false,  /* isMovable.  Not relevant for setters. */
540
  false, /* isEliminatable.  Not relevant for setters. */
541
  false, /* isAlwaysInSlot.  Only relevant for getters. */
542
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
543
  false,  /* isTypedMethod.  Only relevant for methods. */
544
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
545
};
546
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
547
static_assert(0 < 1, "There is no slot for us");
548
549
MOZ_CAN_RUN_SCRIPT static bool
550
get_currentURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
551
0
{
552
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.currentURI", DOM, cx);
553
0
554
0
  FastErrorResult rv;
555
0
  auto result(StrongOrRawPtr<nsIURI>(self->GetCurrentURI(rv)));
556
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
557
0
    return false;
558
0
  }
559
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
560
0
  if (!result) {
561
0
    args.rval().setNull();
562
0
    return true;
563
0
  }
564
0
  if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) {
565
0
    return false;
566
0
  }
567
0
  return true;
568
0
}
569
570
static const JSJitInfo currentURI_getterinfo = {
571
  { (JSJitGetterOp)get_currentURI },
572
  { prototypes::id::SVGImageElement },
573
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
574
  JSJitInfo::Getter,
575
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
576
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
577
  false,  /* isInfallible. False in setters. */
578
  false,  /* isMovable.  Not relevant for setters. */
579
  false, /* isEliminatable.  Not relevant for setters. */
580
  false, /* isAlwaysInSlot.  Only relevant for getters. */
581
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
582
  false,  /* isTypedMethod.  Only relevant for methods. */
583
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
584
};
585
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
586
static_assert(0 < 1, "There is no slot for us");
587
588
MOZ_CAN_RUN_SCRIPT static bool
589
get_currentRequestFinalURI(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
590
0
{
591
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.currentRequestFinalURI", DOM, cx);
592
0
593
0
  auto result(StrongOrRawPtr<nsIURI>(self->GetCurrentRequestFinalURI()));
594
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
595
0
  if (!result) {
596
0
    args.rval().setNull();
597
0
    return true;
598
0
  }
599
0
  if (!WrapObject(cx, result, &NS_GET_IID(nsIURI), args.rval())) {
600
0
    return false;
601
0
  }
602
0
  return true;
603
0
}
604
605
static const JSJitInfo currentRequestFinalURI_getterinfo = {
606
  { (JSJitGetterOp)get_currentRequestFinalURI },
607
  { prototypes::id::SVGImageElement },
608
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
609
  JSJitInfo::Getter,
610
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
611
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
612
  false,  /* isInfallible. False in setters. */
613
  false,  /* isMovable.  Not relevant for setters. */
614
  false, /* isEliminatable.  Not relevant for setters. */
615
  false, /* isAlwaysInSlot.  Only relevant for getters. */
616
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
617
  false,  /* isTypedMethod.  Only relevant for methods. */
618
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
619
};
620
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
621
static_assert(0 < 1, "There is no slot for us");
622
623
MOZ_CAN_RUN_SCRIPT static bool
624
forceReload(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, const JSJitMethodCallArgs& args)
625
0
{
626
0
  AUTO_PROFILER_LABEL_FAST("SVGImageElement.forceReload", DOM, cx);
627
0
628
0
  bool arg0;
629
0
  if (args.hasDefined(0)) {
630
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
631
0
      return false;
632
0
    }
633
0
  } else {
634
0
    arg0 = true;
635
0
  }
636
0
  FastErrorResult rv;
637
0
  self->ForceReload(arg0, rv);
638
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
639
0
    return false;
640
0
  }
641
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
642
0
  args.rval().setUndefined();
643
0
  return true;
644
0
}
645
646
static const JSJitInfo forceReload_methodinfo = {
647
  { (JSJitGetterOp)forceReload },
648
  { prototypes::id::SVGImageElement },
649
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
650
  JSJitInfo::Method,
651
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
652
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
653
  false,  /* isInfallible. False in setters. */
654
  false,  /* isMovable.  Not relevant for setters. */
655
  false, /* isEliminatable.  Not relevant for setters. */
656
  false, /* isAlwaysInSlot.  Only relevant for getters. */
657
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
658
  false,  /* isTypedMethod.  Only relevant for methods. */
659
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
660
};
661
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
662
static_assert(0 < 1, "There is no slot for us");
663
664
MOZ_CAN_RUN_SCRIPT static bool
665
forceImageState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, const JSJitMethodCallArgs& args)
666
0
{
667
0
  AUTO_PROFILER_LABEL_FAST("SVGImageElement.forceImageState", DOM, cx);
668
0
669
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
670
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGImageElement.forceImageState");
671
0
  }
672
0
  bool arg0;
673
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
674
0
    return false;
675
0
  }
676
0
  uint64_t arg1;
677
0
  if (!ValueToPrimitive<uint64_t, eDefault>(cx, args[1], &arg1)) {
678
0
    return false;
679
0
  }
680
0
  self->ForceImageState(arg0, arg1);
681
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
682
0
  args.rval().setUndefined();
683
0
  return true;
684
0
}
685
686
static const JSJitInfo forceImageState_methodinfo = {
687
  { (JSJitGetterOp)forceImageState },
688
  { prototypes::id::SVGImageElement },
689
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
690
  JSJitInfo::Method,
691
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
692
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
693
  false,  /* isInfallible. False in setters. */
694
  false,  /* isMovable.  Not relevant for setters. */
695
  false, /* isEliminatable.  Not relevant for setters. */
696
  false, /* isAlwaysInSlot.  Only relevant for getters. */
697
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
698
  false,  /* isTypedMethod.  Only relevant for methods. */
699
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
700
};
701
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
702
static_assert(0 < 1, "There is no slot for us");
703
704
MOZ_CAN_RUN_SCRIPT static bool
705
get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGImageElement* self, JSJitGetterCallArgs args)
706
0
{
707
0
  AUTO_PROFILER_LABEL_FAST("get SVGImageElement.href", DOM, cx);
708
0
709
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedString>(self->Href()));
710
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
711
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
712
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
713
0
    return false;
714
0
  }
715
0
  return true;
716
0
}
717
718
static const JSJitInfo href_getterinfo = {
719
  { (JSJitGetterOp)get_href },
720
  { prototypes::id::SVGImageElement },
721
  { PrototypeTraits<prototypes::id::SVGImageElement>::Depth },
722
  JSJitInfo::Getter,
723
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
724
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
725
  false,  /* isInfallible. False in setters. */
726
  true,  /* isMovable.  Not relevant for setters. */
727
  true, /* isEliminatable.  Not relevant for setters. */
728
  false, /* isAlwaysInSlot.  Only relevant for getters. */
729
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
730
  false,  /* isTypedMethod.  Only relevant for methods. */
731
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
732
};
733
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
734
static_assert(0 < 1, "There is no slot for us");
735
736
static bool
737
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
738
0
{
739
0
  mozilla::dom::SVGImageElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGImageElement>(obj);
740
0
  // We don't want to preserve if we don't have a wrapper, and we
741
0
  // obviously can't preserve if we're not initialized.
742
0
  if (self && self->GetWrapperPreserveColor()) {
743
0
    PreserveWrapper(self);
744
0
  }
745
0
  return true;
746
0
}
747
748
static void
749
_finalize(js::FreeOp* fop, JSObject* obj)
750
0
{
751
0
  mozilla::dom::SVGImageElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGImageElement>(obj);
752
0
  if (self) {
753
0
    ClearWrapper(self, self, obj);
754
0
    AddForDeferredFinalization<mozilla::dom::SVGImageElement>(self);
755
0
  }
756
0
}
757
758
static size_t
759
_objectMoved(JSObject* obj, JSObject* old)
760
0
{
761
0
  mozilla::dom::SVGImageElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGImageElement>(obj);
762
0
  if (self) {
763
0
    UpdateWrapper(self, self, obj, old);
764
0
  }
765
0
766
0
  return 0;
767
0
}
768
769
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
770
#if defined(__clang__)
771
#pragma clang diagnostic push
772
#pragma clang diagnostic ignored "-Wmissing-braces"
773
#endif
774
static const JSFunctionSpec sChromeMethods_specs[] = {
775
  JS_FNSPEC("addObserver", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addObserver_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
776
  JS_FNSPEC("removeObserver", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeObserver_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
777
  JS_FNSPEC("getRequest", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getRequest_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
778
  JS_FNSPEC("getRequestType", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getRequestType_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
779
  JS_FNSPEC("forceReload", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&forceReload_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
780
  JS_FNSPEC("forceImageState", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&forceImageState_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
781
  JS_FS_END
782
};
783
#if defined(__clang__)
784
#pragma clang diagnostic pop
785
#endif
786
787
788
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
789
  { nullptr, &sChromeMethods_specs[0] },
790
  { nullptr, nullptr }
791
};
792
793
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
794
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
795
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
796
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
797
798
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
799
#if defined(__clang__)
800
#pragma clang diagnostic push
801
#pragma clang diagnostic ignored "-Wmissing-braces"
802
#endif
803
static const JSPropertySpec sAttributes_specs[] = {
804
  { "x", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &x_getterinfo, nullptr, nullptr },
805
  { "y", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &y_getterinfo, nullptr, nullptr },
806
  { "width", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &width_getterinfo, nullptr, nullptr },
807
  { "height", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &height_getterinfo, nullptr, nullptr },
808
  { "preserveAspectRatio", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &preserveAspectRatio_getterinfo, nullptr, nullptr },
809
  { "decoding", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &decoding_getterinfo, GenericSetter<NormalThisPolicy>, &decoding_setterinfo },
810
  { "href", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &href_getterinfo, nullptr, nullptr },
811
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
812
};
813
#if defined(__clang__)
814
#pragma clang diagnostic pop
815
#endif
816
817
818
static const Prefable<const JSPropertySpec> sAttributes[] = {
819
  { nullptr, &sAttributes_specs[0] },
820
  { nullptr, nullptr }
821
};
822
823
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
824
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
825
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
826
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
827
828
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
829
#if defined(__clang__)
830
#pragma clang diagnostic push
831
#pragma clang diagnostic ignored "-Wmissing-braces"
832
#endif
833
static const JSPropertySpec sChromeAttributes_specs[] = {
834
  { "loadingEnabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &loadingEnabled_getterinfo, GenericSetter<NormalThisPolicy>, &loadingEnabled_setterinfo },
835
  { "imageBlockingStatus", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &imageBlockingStatus_getterinfo, nullptr, nullptr },
836
  { "currentURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &currentURI_getterinfo, nullptr, nullptr },
837
  { "currentRequestFinalURI", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &currentRequestFinalURI_getterinfo, nullptr, nullptr },
838
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
839
};
840
#if defined(__clang__)
841
#pragma clang diagnostic pop
842
#endif
843
844
845
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
846
  { nullptr, &sChromeAttributes_specs[0] },
847
  { nullptr, nullptr }
848
};
849
850
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
851
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
852
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
853
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
854
855
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
856
#if defined(__clang__)
857
#pragma clang diagnostic push
858
#pragma clang diagnostic ignored "-Wmissing-braces"
859
#endif
860
static const ConstantSpec sChromeConstants_specs[] = {
861
  { "UNKNOWN_REQUEST", JS::Int32Value(-1) },
862
  { "CURRENT_REQUEST", JS::Int32Value(0) },
863
  { "PENDING_REQUEST", JS::Int32Value(1) },
864
  { 0, JS::UndefinedValue() }
865
};
866
#if defined(__clang__)
867
#pragma clang diagnostic pop
868
#endif
869
870
871
static const Prefable<const ConstantSpec> sChromeConstants[] = {
872
  { nullptr, &sChromeConstants_specs[0] },
873
  { nullptr, nullptr }
874
};
875
876
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
877
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
878
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
879
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
880
881
882
static uint16_t sNativeProperties_sortedPropertyIndices[7];
883
static PropertyInfo sNativeProperties_propertyInfos[7];
884
885
static const NativePropertiesN<1> sNativeProperties = {
886
  false, 0,
887
  false, 0,
888
  false, 0,
889
  true,  0 /* sAttributes */,
890
  false, 0,
891
  false, 0,
892
  false, 0,
893
  -1,
894
  7,
895
  sNativeProperties_sortedPropertyIndices,
896
  {
897
    { sAttributes, &sNativeProperties_propertyInfos[0] }
898
  }
899
};
900
static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
901
    "We have a property info count that is oversized");
902
903
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[13];
904
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[13];
905
906
static const NativePropertiesN<3> sChromeOnlyNativeProperties = {
907
  false, 0,
908
  false, 0,
909
  true,  0 /* sChromeMethods */,
910
  true,  1 /* sChromeAttributes */,
911
  false, 0,
912
  false, 0,
913
  true,  2 /* sChromeConstants */,
914
  -1,
915
  13,
916
  sChromeOnlyNativeProperties_sortedPropertyIndices,
917
  {
918
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] },
919
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[6] },
920
    { sChromeConstants, &sChromeOnlyNativeProperties_propertyInfos[10] }
921
  }
922
};
923
static_assert(13 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
924
    "We have a property info count that is oversized");
925
926
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
927
  {
928
    "Function",
929
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
930
    &sBoringInterfaceObjectClassClassOps,
931
    JS_NULL_CLASS_SPEC,
932
    JS_NULL_CLASS_EXT,
933
    &sInterfaceObjectClassObjectOps
934
  },
935
  eInterface,
936
  true,
937
  prototypes::id::SVGImageElement,
938
  PrototypeTraits<prototypes::id::SVGImageElement>::Depth,
939
  sNativePropertyHooks,
940
  "function SVGImageElement() {\n    [native code]\n}",
941
  SVGGraphicsElement_Binding::GetConstructorObject
942
};
943
944
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
945
  {
946
    "SVGImageElementPrototype",
947
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
948
    JS_NULL_CLASS_OPS,
949
    JS_NULL_CLASS_SPEC,
950
    JS_NULL_CLASS_EXT,
951
    JS_NULL_OBJECT_OPS
952
  },
953
  eInterfacePrototype,
954
  false,
955
  prototypes::id::SVGImageElement,
956
  PrototypeTraits<prototypes::id::SVGImageElement>::Depth,
957
  sNativePropertyHooks,
958
  "[object SVGImageElementPrototype]",
959
  SVGGraphicsElement_Binding::GetProtoObject
960
};
961
962
static const js::ClassOps sClassOps = {
963
  _addProperty, /* addProperty */
964
  nullptr,               /* delProperty */
965
  nullptr,               /* enumerate */
966
  nullptr, /* newEnumerate */
967
  nullptr, /* resolve */
968
  nullptr, /* mayResolve */
969
  _finalize, /* finalize */
970
  nullptr, /* call */
971
  nullptr,               /* hasInstance */
972
  nullptr,               /* construct */
973
  nullptr, /* trace */
974
};
975
976
static const js::ClassExtension sClassExtension = {
977
  nullptr, /* weakmapKeyDelegateOp */
978
  _objectMoved /* objectMovedOp */
979
};
980
981
static const DOMJSClass sClass = {
982
  { "SVGImageElement",
983
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
984
    &sClassOps,
985
    JS_NULL_CLASS_SPEC,
986
    &sClassExtension,
987
    JS_NULL_OBJECT_OPS
988
  },
989
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::SVGElement, prototypes::id::SVGGraphicsElement, prototypes::id::SVGImageElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
990
  IsBaseOf<nsISupports, mozilla::dom::SVGImageElement >::value,
991
  sNativePropertyHooks,
992
  FindAssociatedGlobalForNative<mozilla::dom::SVGImageElement>::Get,
993
  GetProtoObjectHandle,
994
  GetCCParticipant<mozilla::dom::SVGImageElement>::Get()
995
};
996
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
997
              "Must have the right minimal number of reserved slots.");
998
static_assert(1 >= 1,
999
              "Must have enough reserved slots.");
1000
1001
const JSClass*
1002
GetJSClass()
1003
0
{
1004
0
  return sClass.ToJSClass();
1005
0
}
1006
1007
bool
1008
Wrap(JSContext* aCx, mozilla::dom::SVGImageElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1009
0
{
1010
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGImageElement>::value,
1011
0
                "Shouldn't have wrappercached things that are not refcounted.");
1012
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGImageElement*>(aObject) ==
1013
0
             reinterpret_cast<mozilla::dom::SVGImageElement*>(aObject),
1014
0
             "Multiple inheritance for mozilla::dom::SVGImageElement is broken.");
1015
0
  MOZ_ASSERT(static_cast<mozilla::dom::SVGGraphicsElement*>(aObject) ==
1016
0
             reinterpret_cast<mozilla::dom::SVGGraphicsElement*>(aObject),
1017
0
             "Multiple inheritance for mozilla::dom::SVGGraphicsElement is broken.");
1018
0
  MOZ_ASSERT(static_cast<nsSVGElement*>(aObject) ==
1019
0
             reinterpret_cast<nsSVGElement*>(aObject),
1020
0
             "Multiple inheritance for nsSVGElement is broken.");
1021
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
1022
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
1023
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
1024
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
1025
0
             reinterpret_cast<nsINode*>(aObject),
1026
0
             "Multiple inheritance for nsINode is broken.");
1027
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1028
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1029
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1030
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1031
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1032
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1033
0
             "You should probably not be using Wrap() directly; use "
1034
0
             "GetOrCreateDOMReflector instead");
1035
0
1036
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1037
0
             "nsISupports must be on our primary inheritance chain");
1038
0
1039
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1040
0
  if (!global) {
1041
0
    return false;
1042
0
  }
1043
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1044
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1045
0
1046
0
  // That might have ended up wrapping us already, due to the wonders
1047
0
  // of XBL.  Check for that, and bail out as needed.
1048
0
  aReflector.set(aCache->GetWrapper());
1049
0
  if (aReflector) {
1050
#ifdef DEBUG
1051
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1052
#endif // DEBUG
1053
    return true;
1054
0
  }
1055
0
1056
0
  JSAutoRealm ar(aCx, global);
1057
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1058
0
  if (!canonicalProto) {
1059
0
    return false;
1060
0
  }
1061
0
  JS::Rooted<JSObject*> proto(aCx);
1062
0
  if (aGivenProto) {
1063
0
    proto = aGivenProto;
1064
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1065
0
    // coming in, we changed compartments to that of "parent" so may need
1066
0
    // to wrap the proto here.
1067
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1068
0
      if (!JS_WrapObject(aCx, &proto)) {
1069
0
        return false;
1070
0
      }
1071
0
    }
1072
0
  } else {
1073
0
    proto = canonicalProto;
1074
0
  }
1075
0
1076
0
  BindingJSObjectCreator<mozilla::dom::SVGImageElement> creator(aCx);
1077
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1078
0
  if (!aReflector) {
1079
0
    return false;
1080
0
  }
1081
0
1082
0
  aCache->SetWrapper(aReflector);
1083
0
  creator.InitializationSucceeded();
1084
0
1085
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1086
0
             aCache->GetWrapperPreserveColor() == aReflector);
1087
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1088
0
  // otherwise we won't be able to properly recreate it later, since
1089
0
  // we won't know what proto to use.  Note that we don't check
1090
0
  // aGivenProto here, since it's entirely possible (and even
1091
0
  // somewhat common) to have a non-null aGivenProto which is the
1092
0
  // same as canonicalProto.
1093
0
  if (proto != canonicalProto) {
1094
0
    PreserveWrapper(aObject);
1095
0
  }
1096
0
1097
0
  return true;
1098
0
}
1099
1100
const NativePropertyHooks sNativePropertyHooks[] = { {
1101
  nullptr,
1102
  nullptr,
1103
  nullptr,
1104
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1105
  prototypes::id::SVGImageElement,
1106
  constructors::id::SVGImageElement,
1107
  SVGGraphicsElement_Binding::sNativePropertyHooks,
1108
  &DefaultXrayExpandoObjectClass
1109
} };
1110
1111
void
1112
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1113
0
{
1114
0
  JS::Handle<JSObject*> parentProto(SVGGraphicsElement_Binding::GetProtoObjectHandle(aCx));
1115
0
  if (!parentProto) {
1116
0
    return;
1117
0
  }
1118
0
1119
0
  JS::Handle<JSObject*> constructorProto(SVGGraphicsElement_Binding::GetConstructorObjectHandle(aCx));
1120
0
  if (!constructorProto) {
1121
0
    return;
1122
0
  }
1123
0
1124
0
  static bool sIdsInited = false;
1125
0
  if (!sIdsInited && NS_IsMainThread()) {
1126
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1127
0
      return;
1128
0
    }
1129
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1130
0
      return;
1131
0
    }
1132
0
    sIdsInited = true;
1133
0
  }
1134
0
1135
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGImageElement);
1136
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGImageElement);
1137
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1138
0
                              &sPrototypeClass.mBase, protoCache,
1139
0
                              nullptr,
1140
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1141
0
                              interfaceCache,
1142
0
                              sNativeProperties.Upcast(),
1143
0
                              sChromeOnlyNativeProperties.Upcast(),
1144
0
                              "SVGImageElement", aDefineOnGlobal,
1145
0
                              nullptr,
1146
0
                              false);
1147
0
}
1148
1149
JSObject*
1150
GetConstructorObject(JSContext* aCx)
1151
0
{
1152
0
  return GetConstructorObjectHandle(aCx);
1153
0
}
1154
1155
} // namespace SVGImageElement_Binding
1156
1157
1158
1159
} // namespace dom
1160
} // namespace mozilla