Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/SVGGraphicsElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM SVGGraphicsElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "DOMSVGStringList.h"
5
#include "SVGElementBinding.h"
6
#include "SVGGraphicsElementBinding.h"
7
#include "WrapperFactory.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/PrimitiveConversions.h"
14
#include "mozilla/dom/SVGAnimatedTransformList.h"
15
#include "mozilla/dom/SVGGraphicsElement.h"
16
#include "mozilla/dom/SVGIRect.h"
17
#include "mozilla/dom/SVGMatrix.h"
18
#include "mozilla/dom/ScriptSettings.h"
19
#include "mozilla/dom/SimpleGlobalObject.h"
20
#include "mozilla/dom/XrayExpandoClass.h"
21
#include "nsSVGElement.h"
22
23
namespace mozilla {
24
namespace dom {
25
26
namespace binding_detail {}; // Just to make sure it's known as a namespace
27
using namespace mozilla::dom::binding_detail;
28
29
30
31
SVGBoundingBoxOptions::SVGBoundingBoxOptions()
32
0
{
33
0
  // Safe to pass a null context if we pass a null value
34
0
  Init(nullptr, JS::NullHandleValue);
35
0
}
36
37
38
39
bool
40
SVGBoundingBoxOptions::InitIds(JSContext* cx, SVGBoundingBoxOptionsAtoms* atomsCache)
41
0
{
42
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
43
0
44
0
  // Initialize these in reverse order so that any failure leaves the first one
45
0
  // uninitialized.
46
0
  if (!atomsCache->stroke_id.init(cx, "stroke") ||
47
0
      !atomsCache->markers_id.init(cx, "markers") ||
48
0
      !atomsCache->fill_id.init(cx, "fill") ||
49
0
      !atomsCache->clipped_id.init(cx, "clipped")) {
50
0
    return false;
51
0
  }
52
0
  return true;
53
0
}
54
55
bool
56
SVGBoundingBoxOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
57
0
{
58
0
  // Passing a null JSContext is OK only if we're initing from null,
59
0
  // Since in that case we will not have to do any property gets
60
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
61
0
  // checkers by static analysis tools
62
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
63
0
  SVGBoundingBoxOptionsAtoms* atomsCache = nullptr;
64
0
  if (cx) {
65
0
    atomsCache = GetAtomCache<SVGBoundingBoxOptionsAtoms>(cx);
66
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
67
0
      return false;
68
0
    }
69
0
  }
70
0
71
0
  if (!IsConvertibleToDictionary(val)) {
72
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
73
0
  }
74
0
75
0
  bool isNull = val.isNullOrUndefined();
76
0
  // We only need these if !isNull, in which case we have |cx|.
77
0
  Maybe<JS::Rooted<JSObject *> > object;
78
0
  Maybe<JS::Rooted<JS::Value> > temp;
79
0
  if (!isNull) {
80
0
    MOZ_ASSERT(cx);
81
0
    object.emplace(cx, &val.toObject());
82
0
    temp.emplace(cx);
83
0
  }
84
0
  if (!isNull) {
85
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->clipped_id, temp.ptr())) {
86
0
      return false;
87
0
    }
88
0
  }
89
0
  if (!isNull && !temp->isUndefined()) {
90
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mClipped)) {
91
0
      return false;
92
0
    }
93
0
  } else {
94
0
    mClipped = false;
95
0
  }
96
0
  mIsAnyMemberPresent = true;
97
0
98
0
  if (!isNull) {
99
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->fill_id, temp.ptr())) {
100
0
      return false;
101
0
    }
102
0
  }
103
0
  if (!isNull && !temp->isUndefined()) {
104
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFill)) {
105
0
      return false;
106
0
    }
107
0
  } else {
108
0
    mFill = true;
109
0
  }
110
0
  mIsAnyMemberPresent = true;
111
0
112
0
  if (!isNull) {
113
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->markers_id, temp.ptr())) {
114
0
      return false;
115
0
    }
116
0
  }
117
0
  if (!isNull && !temp->isUndefined()) {
118
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMarkers)) {
119
0
      return false;
120
0
    }
121
0
  } else {
122
0
    mMarkers = false;
123
0
  }
124
0
  mIsAnyMemberPresent = true;
125
0
126
0
  if (!isNull) {
127
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->stroke_id, temp.ptr())) {
128
0
      return false;
129
0
    }
130
0
  }
131
0
  if (!isNull && !temp->isUndefined()) {
132
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mStroke)) {
133
0
      return false;
134
0
    }
135
0
  } else {
136
0
    mStroke = false;
137
0
  }
138
0
  mIsAnyMemberPresent = true;
139
0
  return true;
140
0
}
141
142
bool
143
SVGBoundingBoxOptions::Init(const nsAString& aJSON)
144
0
{
145
0
  AutoJSAPI jsapi;
146
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
147
0
  if (!cleanGlobal) {
148
0
    return false;
149
0
  }
150
0
  if (!jsapi.Init(cleanGlobal)) {
151
0
    return false;
152
0
  }
153
0
  JSContext* cx = jsapi.cx();
154
0
  JS::Rooted<JS::Value> json(cx);
155
0
  bool ok = ParseJSON(cx, aJSON, &json);
156
0
  NS_ENSURE_TRUE(ok, false);
157
0
  return Init(cx, json);
158
0
}
159
160
bool
161
SVGBoundingBoxOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
162
0
{
163
0
  SVGBoundingBoxOptionsAtoms* atomsCache = GetAtomCache<SVGBoundingBoxOptionsAtoms>(cx);
164
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
165
0
    return false;
166
0
  }
167
0
168
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
169
0
  if (!obj) {
170
0
    return false;
171
0
  }
172
0
  rval.set(JS::ObjectValue(*obj));
173
0
174
0
  do {
175
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
176
0
    JS::Rooted<JS::Value> temp(cx);
177
0
    bool const & currentValue = mClipped;
178
0
    temp.setBoolean(currentValue);
179
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->clipped_id, temp, JSPROP_ENUMERATE)) {
180
0
      return false;
181
0
    }
182
0
    break;
183
0
  } while(false);
184
0
185
0
  do {
186
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
187
0
    JS::Rooted<JS::Value> temp(cx);
188
0
    bool const & currentValue = mFill;
189
0
    temp.setBoolean(currentValue);
190
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->fill_id, temp, JSPROP_ENUMERATE)) {
191
0
      return false;
192
0
    }
193
0
    break;
194
0
  } while(false);
195
0
196
0
  do {
197
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
198
0
    JS::Rooted<JS::Value> temp(cx);
199
0
    bool const & currentValue = mMarkers;
200
0
    temp.setBoolean(currentValue);
201
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->markers_id, temp, JSPROP_ENUMERATE)) {
202
0
      return false;
203
0
    }
204
0
    break;
205
0
  } while(false);
206
0
207
0
  do {
208
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
209
0
    JS::Rooted<JS::Value> temp(cx);
210
0
    bool const & currentValue = mStroke;
211
0
    temp.setBoolean(currentValue);
212
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->stroke_id, temp, JSPROP_ENUMERATE)) {
213
0
      return false;
214
0
    }
215
0
    break;
216
0
  } while(false);
217
0
218
0
  return true;
219
0
}
220
221
bool
222
SVGBoundingBoxOptions::ToJSON(nsAString& aJSON) const
223
0
{
224
0
  AutoJSAPI jsapi;
225
0
  jsapi.Init();
226
0
  JSContext *cx = jsapi.cx();
227
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
228
0
  // because we'll only be creating objects, in ways that have no
229
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
230
0
  // which likewise guarantees no side-effects for the sorts of
231
0
  // things we will pass it.
232
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
233
0
  JS::Rooted<JS::Value> val(cx);
234
0
  if (!ToObjectInternal(cx, &val)) {
235
0
    return false;
236
0
  }
237
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
238
0
  return StringifyToJSON(cx, obj, aJSON);
239
0
}
240
241
void
242
SVGBoundingBoxOptions::TraceDictionary(JSTracer* trc)
243
0
{
244
0
}
245
246
SVGBoundingBoxOptions&
247
SVGBoundingBoxOptions::operator=(const SVGBoundingBoxOptions& aOther)
248
0
{
249
0
  DictionaryBase::operator=(aOther);
250
0
  mClipped = aOther.mClipped;
251
0
  mFill = aOther.mFill;
252
0
  mMarkers = aOther.mMarkers;
253
0
  mStroke = aOther.mStroke;
254
0
  return *this;
255
0
}
256
257
namespace binding_detail {
258
} // namespace binding_detail
259
260
261
namespace SVGGraphicsElement_Binding {
262
263
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<SVGElement_Binding::NativeType>::value,
264
              "Can't inherit from an interface with a different ownership model.");
265
266
MOZ_CAN_RUN_SCRIPT static bool
267
get_transform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
268
0
{
269
0
  AUTO_PROFILER_LABEL_FAST("get SVGGraphicsElement.transform", DOM, cx);
270
0
271
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedTransformList>(self->Transform()));
272
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
273
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
274
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
275
0
    return false;
276
0
  }
277
0
  return true;
278
0
}
279
280
static const JSJitInfo transform_getterinfo = {
281
  { (JSJitGetterOp)get_transform },
282
  { prototypes::id::SVGGraphicsElement },
283
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
284
  JSJitInfo::Getter,
285
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
286
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
287
  false,  /* isInfallible. False in setters. */
288
  false,  /* isMovable.  Not relevant for setters. */
289
  false, /* isEliminatable.  Not relevant for setters. */
290
  false, /* isAlwaysInSlot.  Only relevant for getters. */
291
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
292
  false,  /* isTypedMethod.  Only relevant for methods. */
293
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
294
};
295
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
296
static_assert(0 < 1, "There is no slot for us");
297
298
MOZ_CAN_RUN_SCRIPT static bool
299
get_nearestViewportElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
300
0
{
301
0
  AUTO_PROFILER_LABEL_FAST("get SVGGraphicsElement.nearestViewportElement", DOM, cx);
302
0
303
0
  auto result(StrongOrRawPtr<nsSVGElement>(self->GetNearestViewportElement()));
304
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
305
0
  if (!result) {
306
0
    args.rval().setNull();
307
0
    return true;
308
0
  }
309
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
310
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
311
0
    return false;
312
0
  }
313
0
  return true;
314
0
}
315
316
static const JSJitInfo nearestViewportElement_getterinfo = {
317
  { (JSJitGetterOp)get_nearestViewportElement },
318
  { prototypes::id::SVGGraphicsElement },
319
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
320
  JSJitInfo::Getter,
321
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
322
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
323
  false,  /* isInfallible. False in setters. */
324
  false,  /* isMovable.  Not relevant for setters. */
325
  false, /* isEliminatable.  Not relevant for setters. */
326
  false, /* isAlwaysInSlot.  Only relevant for getters. */
327
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
328
  false,  /* isTypedMethod.  Only relevant for methods. */
329
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
330
};
331
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
332
static_assert(0 < 1, "There is no slot for us");
333
334
MOZ_CAN_RUN_SCRIPT static bool
335
get_farthestViewportElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
336
0
{
337
0
  AUTO_PROFILER_LABEL_FAST("get SVGGraphicsElement.farthestViewportElement", DOM, cx);
338
0
339
0
  auto result(StrongOrRawPtr<nsSVGElement>(self->GetFarthestViewportElement()));
340
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
341
0
  if (!result) {
342
0
    args.rval().setNull();
343
0
    return true;
344
0
  }
345
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
346
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
347
0
    return false;
348
0
  }
349
0
  return true;
350
0
}
351
352
static const JSJitInfo farthestViewportElement_getterinfo = {
353
  { (JSJitGetterOp)get_farthestViewportElement },
354
  { prototypes::id::SVGGraphicsElement },
355
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
356
  JSJitInfo::Getter,
357
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
358
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
359
  false,  /* isInfallible. False in setters. */
360
  false,  /* isMovable.  Not relevant for setters. */
361
  false, /* isEliminatable.  Not relevant for setters. */
362
  false, /* isAlwaysInSlot.  Only relevant for getters. */
363
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
364
  false,  /* isTypedMethod.  Only relevant for methods. */
365
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
366
};
367
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
368
static_assert(0 < 1, "There is no slot for us");
369
370
MOZ_CAN_RUN_SCRIPT static bool
371
getBBox(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
372
0
{
373
0
  AUTO_PROFILER_LABEL_FAST("SVGGraphicsElement.getBBox", DOM, cx);
374
0
375
0
  binding_detail::FastSVGBoundingBoxOptions arg0;
376
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of SVGGraphicsElement.getBBox", false)) {
377
0
    return false;
378
0
  }
379
0
  FastErrorResult rv;
380
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGIRect>(self->GetBBox(Constify(arg0), rv)));
381
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
382
0
    return false;
383
0
  }
384
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
385
0
  static_assert(!IsPointer<decltype(result)>::value,
386
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
387
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
388
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
389
0
    return false;
390
0
  }
391
0
  return true;
392
0
}
393
394
static const JSJitInfo getBBox_methodinfo = {
395
  { (JSJitGetterOp)getBBox },
396
  { prototypes::id::SVGGraphicsElement },
397
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
398
  JSJitInfo::Method,
399
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
400
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
401
  false,  /* isInfallible. False in setters. */
402
  false,  /* isMovable.  Not relevant for setters. */
403
  false, /* isEliminatable.  Not relevant for setters. */
404
  false, /* isAlwaysInSlot.  Only relevant for getters. */
405
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
406
  false,  /* isTypedMethod.  Only relevant for methods. */
407
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
408
};
409
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
410
static_assert(0 < 1, "There is no slot for us");
411
412
MOZ_CAN_RUN_SCRIPT static bool
413
getCTM(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
414
0
{
415
0
  AUTO_PROFILER_LABEL_FAST("SVGGraphicsElement.getCTM", DOM, cx);
416
0
417
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetCTM()));
418
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
419
0
  if (!result) {
420
0
    args.rval().setNull();
421
0
    return true;
422
0
  }
423
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
424
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
425
0
    return false;
426
0
  }
427
0
  return true;
428
0
}
429
430
static const JSJitInfo getCTM_methodinfo = {
431
  { (JSJitGetterOp)getCTM },
432
  { prototypes::id::SVGGraphicsElement },
433
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
434
  JSJitInfo::Method,
435
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
436
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
437
  false,  /* isInfallible. False in setters. */
438
  false,  /* isMovable.  Not relevant for setters. */
439
  false, /* isEliminatable.  Not relevant for setters. */
440
  false, /* isAlwaysInSlot.  Only relevant for getters. */
441
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
442
  false,  /* isTypedMethod.  Only relevant for methods. */
443
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
444
};
445
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
446
static_assert(0 < 1, "There is no slot for us");
447
448
MOZ_CAN_RUN_SCRIPT static bool
449
getScreenCTM(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
450
0
{
451
0
  AUTO_PROFILER_LABEL_FAST("SVGGraphicsElement.getScreenCTM", DOM, cx);
452
0
453
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetScreenCTM()));
454
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
455
0
  if (!result) {
456
0
    args.rval().setNull();
457
0
    return true;
458
0
  }
459
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
460
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
461
0
    return false;
462
0
  }
463
0
  return true;
464
0
}
465
466
static const JSJitInfo getScreenCTM_methodinfo = {
467
  { (JSJitGetterOp)getScreenCTM },
468
  { prototypes::id::SVGGraphicsElement },
469
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
470
  JSJitInfo::Method,
471
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
472
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
473
  false,  /* isInfallible. False in setters. */
474
  false,  /* isMovable.  Not relevant for setters. */
475
  false, /* isEliminatable.  Not relevant for setters. */
476
  false, /* isAlwaysInSlot.  Only relevant for getters. */
477
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
478
  false,  /* isTypedMethod.  Only relevant for methods. */
479
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
480
};
481
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
482
static_assert(0 < 1, "There is no slot for us");
483
484
MOZ_CAN_RUN_SCRIPT static bool
485
getTransformToElement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
486
0
{
487
0
  AUTO_PROFILER_LABEL_FAST("SVGGraphicsElement.getTransformToElement", DOM, cx);
488
0
489
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
490
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGGraphicsElement.getTransformToElement");
491
0
  }
492
0
  NonNull<mozilla::dom::SVGGraphicsElement> arg0;
493
0
  if (args[0].isObject()) {
494
0
    {
495
0
      nsresult rv = UnwrapObject<prototypes::id::SVGGraphicsElement, mozilla::dom::SVGGraphicsElement>(args[0], arg0);
496
0
      if (NS_FAILED(rv)) {
497
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGGraphicsElement.getTransformToElement", "SVGGraphicsElement");
498
0
        return false;
499
0
      }
500
0
    }
501
0
  } else {
502
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGGraphicsElement.getTransformToElement");
503
0
    return false;
504
0
  }
505
0
  FastErrorResult rv;
506
0
  auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetTransformToElement(MOZ_KnownLive(NonNullHelper(arg0)), rv)));
507
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
508
0
    return false;
509
0
  }
510
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
511
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
512
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
513
0
    return false;
514
0
  }
515
0
  return true;
516
0
}
517
518
static const JSJitInfo getTransformToElement_methodinfo = {
519
  { (JSJitGetterOp)getTransformToElement },
520
  { prototypes::id::SVGGraphicsElement },
521
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
522
  JSJitInfo::Method,
523
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
524
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
525
  false,  /* isInfallible. False in setters. */
526
  false,  /* isMovable.  Not relevant for setters. */
527
  false, /* isEliminatable.  Not relevant for setters. */
528
  false, /* isAlwaysInSlot.  Only relevant for getters. */
529
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
530
  false,  /* isTypedMethod.  Only relevant for methods. */
531
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
532
};
533
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
534
static_assert(0 < 1, "There is no slot for us");
535
536
MOZ_CAN_RUN_SCRIPT static bool
537
get_requiredFeatures(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
538
0
{
539
0
  AUTO_PROFILER_LABEL_FAST("get SVGGraphicsElement.requiredFeatures", DOM, cx);
540
0
541
0
  auto result(StrongOrRawPtr<mozilla::DOMSVGStringList>(self->RequiredFeatures()));
542
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
543
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
544
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
545
0
    return false;
546
0
  }
547
0
  return true;
548
0
}
549
550
static const JSJitInfo requiredFeatures_getterinfo = {
551
  { (JSJitGetterOp)get_requiredFeatures },
552
  { prototypes::id::SVGGraphicsElement },
553
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
554
  JSJitInfo::Getter,
555
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
556
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
557
  false,  /* isInfallible. False in setters. */
558
  false,  /* isMovable.  Not relevant for setters. */
559
  false, /* isEliminatable.  Not relevant for setters. */
560
  false, /* isAlwaysInSlot.  Only relevant for getters. */
561
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
562
  false,  /* isTypedMethod.  Only relevant for methods. */
563
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
564
};
565
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
566
static_assert(0 < 1, "There is no slot for us");
567
568
MOZ_CAN_RUN_SCRIPT static bool
569
get_requiredExtensions(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
570
0
{
571
0
  AUTO_PROFILER_LABEL_FAST("get SVGGraphicsElement.requiredExtensions", DOM, cx);
572
0
573
0
  auto result(StrongOrRawPtr<mozilla::DOMSVGStringList>(self->RequiredExtensions()));
574
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
575
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
576
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
577
0
    return false;
578
0
  }
579
0
  return true;
580
0
}
581
582
static const JSJitInfo requiredExtensions_getterinfo = {
583
  { (JSJitGetterOp)get_requiredExtensions },
584
  { prototypes::id::SVGGraphicsElement },
585
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
586
  JSJitInfo::Getter,
587
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
588
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
589
  false,  /* isInfallible. False in setters. */
590
  false,  /* isMovable.  Not relevant for setters. */
591
  false, /* isEliminatable.  Not relevant for setters. */
592
  false, /* isAlwaysInSlot.  Only relevant for getters. */
593
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
594
  false,  /* isTypedMethod.  Only relevant for methods. */
595
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
596
};
597
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
598
static_assert(0 < 1, "There is no slot for us");
599
600
MOZ_CAN_RUN_SCRIPT static bool
601
get_systemLanguage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, JSJitGetterCallArgs args)
602
0
{
603
0
  AUTO_PROFILER_LABEL_FAST("get SVGGraphicsElement.systemLanguage", DOM, cx);
604
0
605
0
  auto result(StrongOrRawPtr<mozilla::DOMSVGStringList>(self->SystemLanguage()));
606
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
607
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
608
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
609
0
    return false;
610
0
  }
611
0
  return true;
612
0
}
613
614
static const JSJitInfo systemLanguage_getterinfo = {
615
  { (JSJitGetterOp)get_systemLanguage },
616
  { prototypes::id::SVGGraphicsElement },
617
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
618
  JSJitInfo::Getter,
619
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
620
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
621
  false,  /* isInfallible. False in setters. */
622
  false,  /* isMovable.  Not relevant for setters. */
623
  false, /* isEliminatable.  Not relevant for setters. */
624
  false, /* isAlwaysInSlot.  Only relevant for getters. */
625
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
626
  false,  /* isTypedMethod.  Only relevant for methods. */
627
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
628
};
629
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
630
static_assert(0 < 1, "There is no slot for us");
631
632
MOZ_CAN_RUN_SCRIPT static bool
633
hasExtension(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGGraphicsElement* self, const JSJitMethodCallArgs& args)
634
0
{
635
0
  AUTO_PROFILER_LABEL_FAST("SVGGraphicsElement.hasExtension", DOM, cx);
636
0
637
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
638
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGGraphicsElement.hasExtension");
639
0
  }
640
0
  binding_detail::FakeString arg0;
641
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
642
0
    return false;
643
0
  }
644
0
  bool result(self->HasExtension(NonNullHelper(Constify(arg0))));
645
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
646
0
  args.rval().setBoolean(result);
647
0
  return true;
648
0
}
649
650
static const JSJitInfo hasExtension_methodinfo = {
651
  { (JSJitGetterOp)hasExtension },
652
  { prototypes::id::SVGGraphicsElement },
653
  { PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth },
654
  JSJitInfo::Method,
655
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
656
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
657
  false,  /* isInfallible. False in setters. */
658
  false,  /* isMovable.  Not relevant for setters. */
659
  false, /* isEliminatable.  Not relevant for setters. */
660
  false, /* isAlwaysInSlot.  Only relevant for getters. */
661
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
662
  false,  /* isTypedMethod.  Only relevant for methods. */
663
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
664
};
665
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
666
static_assert(0 < 1, "There is no slot for us");
667
668
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
669
#if defined(__clang__)
670
#pragma clang diagnostic push
671
#pragma clang diagnostic ignored "-Wmissing-braces"
672
#endif
673
static const JSFunctionSpec sMethods_specs[] = {
674
  JS_FNSPEC("getBBox", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getBBox_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
675
  JS_FNSPEC("getCTM", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getCTM_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
676
  JS_FNSPEC("getScreenCTM", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getScreenCTM_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
677
  JS_FNSPEC("getTransformToElement", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTransformToElement_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
678
  JS_FNSPEC("hasExtension", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasExtension_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
679
  JS_FS_END
680
};
681
#if defined(__clang__)
682
#pragma clang diagnostic pop
683
#endif
684
685
686
static const Prefable<const JSFunctionSpec> sMethods[] = {
687
  { nullptr, &sMethods_specs[0] },
688
  { nullptr, nullptr }
689
};
690
691
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
692
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
693
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
694
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
695
696
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
697
#if defined(__clang__)
698
#pragma clang diagnostic push
699
#pragma clang diagnostic ignored "-Wmissing-braces"
700
#endif
701
static const JSPropertySpec sAttributes_specs[] = {
702
  { "transform", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &transform_getterinfo, nullptr, nullptr },
703
  { "nearestViewportElement", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &nearestViewportElement_getterinfo, nullptr, nullptr },
704
  { "farthestViewportElement", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &farthestViewportElement_getterinfo, nullptr, nullptr },
705
  { "requiredFeatures", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &requiredFeatures_getterinfo, nullptr, nullptr },
706
  { "requiredExtensions", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &requiredExtensions_getterinfo, nullptr, nullptr },
707
  { "systemLanguage", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &systemLanguage_getterinfo, nullptr, nullptr },
708
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
709
};
710
#if defined(__clang__)
711
#pragma clang diagnostic pop
712
#endif
713
714
715
static const Prefable<const JSPropertySpec> sAttributes[] = {
716
  { nullptr, &sAttributes_specs[0] },
717
  { nullptr, nullptr }
718
};
719
720
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
721
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
722
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
723
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
724
725
726
static uint16_t sNativeProperties_sortedPropertyIndices[11];
727
static PropertyInfo sNativeProperties_propertyInfos[11];
728
729
static const NativePropertiesN<2> sNativeProperties = {
730
  false, 0,
731
  false, 0,
732
  true,  0 /* sMethods */,
733
  true,  1 /* sAttributes */,
734
  false, 0,
735
  false, 0,
736
  false, 0,
737
  -1,
738
  11,
739
  sNativeProperties_sortedPropertyIndices,
740
  {
741
    { sMethods, &sNativeProperties_propertyInfos[0] },
742
    { sAttributes, &sNativeProperties_propertyInfos[5] }
743
  }
744
};
745
static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
746
    "We have a property info count that is oversized");
747
748
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
749
  {
750
    "Function",
751
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
752
    &sBoringInterfaceObjectClassClassOps,
753
    JS_NULL_CLASS_SPEC,
754
    JS_NULL_CLASS_EXT,
755
    &sInterfaceObjectClassObjectOps
756
  },
757
  eInterface,
758
  true,
759
  prototypes::id::SVGGraphicsElement,
760
  PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth,
761
  sNativePropertyHooks,
762
  "function SVGGraphicsElement() {\n    [native code]\n}",
763
  SVGElement_Binding::GetConstructorObject
764
};
765
766
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
767
  {
768
    "SVGGraphicsElementPrototype",
769
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
770
    JS_NULL_CLASS_OPS,
771
    JS_NULL_CLASS_SPEC,
772
    JS_NULL_CLASS_EXT,
773
    JS_NULL_OBJECT_OPS
774
  },
775
  eInterfacePrototype,
776
  false,
777
  prototypes::id::SVGGraphicsElement,
778
  PrototypeTraits<prototypes::id::SVGGraphicsElement>::Depth,
779
  sNativePropertyHooks,
780
  "[object SVGGraphicsElementPrototype]",
781
  SVGElement_Binding::GetProtoObject
782
};
783
784
const NativePropertyHooks sNativePropertyHooks[] = { {
785
  nullptr,
786
  nullptr,
787
  nullptr,
788
  { sNativeProperties.Upcast(), nullptr },
789
  prototypes::id::SVGGraphicsElement,
790
  constructors::id::SVGGraphicsElement,
791
  SVGElement_Binding::sNativePropertyHooks,
792
  &DefaultXrayExpandoObjectClass
793
} };
794
795
void
796
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
797
0
{
798
0
  JS::Handle<JSObject*> parentProto(SVGElement_Binding::GetProtoObjectHandle(aCx));
799
0
  if (!parentProto) {
800
0
    return;
801
0
  }
802
0
803
0
  JS::Handle<JSObject*> constructorProto(SVGElement_Binding::GetConstructorObjectHandle(aCx));
804
0
  if (!constructorProto) {
805
0
    return;
806
0
  }
807
0
808
0
  static bool sIdsInited = false;
809
0
  if (!sIdsInited && NS_IsMainThread()) {
810
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
811
0
      return;
812
0
    }
813
0
    sIdsInited = true;
814
0
  }
815
0
816
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGGraphicsElement);
817
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGGraphicsElement);
818
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
819
0
                              &sPrototypeClass.mBase, protoCache,
820
0
                              nullptr,
821
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
822
0
                              interfaceCache,
823
0
                              sNativeProperties.Upcast(),
824
0
                              nullptr,
825
0
                              "SVGGraphicsElement", aDefineOnGlobal,
826
0
                              nullptr,
827
0
                              false);
828
0
}
829
830
JSObject*
831
GetProtoObject(JSContext* aCx)
832
0
{
833
0
  return GetProtoObjectHandle(aCx);
834
0
}
835
836
JSObject*
837
GetConstructorObject(JSContext* aCx)
838
0
{
839
0
  return GetConstructorObjectHandle(aCx);
840
0
}
841
842
} // namespace SVGGraphicsElement_Binding
843
844
845
846
} // namespace dom
847
} // namespace mozilla