Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/WebKitCSSMatrixBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM WebKitCSSMatrix.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "DOMMatrixBinding.h"
4
#include "WebKitCSSMatrixBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/PrimitiveConversions.h"
11
#include "mozilla/dom/WebKitCSSMatrix.h"
12
#include "mozilla/dom/XrayExpandoClass.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
namespace binding_detail {}; // Just to make sure it's known as a namespace
18
using namespace mozilla::dom::binding_detail;
19
20
21
namespace WebKitCSSMatrix_Binding {
22
23
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<DOMMatrix_Binding::NativeType>::value,
24
              "Can't inherit from an interface with a different ownership model.");
25
26
MOZ_CAN_RUN_SCRIPT static bool
27
setMatrixValue(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
28
0
{
29
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.setMatrixValue", DOM, cx);
30
0
31
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
32
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebKitCSSMatrix.setMatrixValue");
33
0
  }
34
0
  binding_detail::FakeString arg0;
35
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
36
0
    return false;
37
0
  }
38
0
  FastErrorResult rv;
39
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->SetMatrixValue(NonNullHelper(Constify(arg0)), rv)));
40
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
41
0
    return false;
42
0
  }
43
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
44
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
45
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
46
0
    return false;
47
0
  }
48
0
  return true;
49
0
}
50
51
static const JSJitInfo setMatrixValue_methodinfo = {
52
  { (JSJitGetterOp)setMatrixValue },
53
  { prototypes::id::WebKitCSSMatrix },
54
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
55
  JSJitInfo::Method,
56
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
57
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
58
  false,  /* isInfallible. False in setters. */
59
  false,  /* isMovable.  Not relevant for setters. */
60
  false, /* isEliminatable.  Not relevant for setters. */
61
  false, /* isAlwaysInSlot.  Only relevant for getters. */
62
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
63
  false,  /* isTypedMethod.  Only relevant for methods. */
64
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
65
};
66
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
67
static_assert(0 < 1, "There is no slot for us");
68
69
MOZ_CAN_RUN_SCRIPT static bool
70
multiply(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
71
0
{
72
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.multiply", DOM, cx);
73
0
74
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
75
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebKitCSSMatrix.multiply");
76
0
  }
77
0
  NonNull<mozilla::dom::WebKitCSSMatrix> arg0;
78
0
  if (args[0].isObject()) {
79
0
    {
80
0
      nsresult rv = UnwrapObject<prototypes::id::WebKitCSSMatrix, mozilla::dom::WebKitCSSMatrix>(args[0], arg0);
81
0
      if (NS_FAILED(rv)) {
82
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebKitCSSMatrix.multiply", "WebKitCSSMatrix");
83
0
        return false;
84
0
      }
85
0
    }
86
0
  } else {
87
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebKitCSSMatrix.multiply");
88
0
    return false;
89
0
  }
90
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->Multiply(MOZ_KnownLive(NonNullHelper(arg0)))));
91
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
92
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
93
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
94
0
    return false;
95
0
  }
96
0
  return true;
97
0
}
98
99
static const JSJitInfo multiply_methodinfo = {
100
  { (JSJitGetterOp)multiply },
101
  { prototypes::id::WebKitCSSMatrix },
102
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
103
  JSJitInfo::Method,
104
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
105
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
106
  false,  /* isInfallible. False in setters. */
107
  false,  /* isMovable.  Not relevant for setters. */
108
  false, /* isEliminatable.  Not relevant for setters. */
109
  false, /* isAlwaysInSlot.  Only relevant for getters. */
110
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
111
  false,  /* isTypedMethod.  Only relevant for methods. */
112
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
113
};
114
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
115
static_assert(0 < 1, "There is no slot for us");
116
117
MOZ_CAN_RUN_SCRIPT static bool
118
inverse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
119
0
{
120
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.inverse", DOM, cx);
121
0
122
0
  FastErrorResult rv;
123
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->Inverse(rv)));
124
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
125
0
    return false;
126
0
  }
127
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
128
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
129
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
130
0
    return false;
131
0
  }
132
0
  return true;
133
0
}
134
135
static const JSJitInfo inverse_methodinfo = {
136
  { (JSJitGetterOp)inverse },
137
  { prototypes::id::WebKitCSSMatrix },
138
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
139
  JSJitInfo::Method,
140
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
141
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
142
  false,  /* isInfallible. False in setters. */
143
  false,  /* isMovable.  Not relevant for setters. */
144
  false, /* isEliminatable.  Not relevant for setters. */
145
  false, /* isAlwaysInSlot.  Only relevant for getters. */
146
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
147
  false,  /* isTypedMethod.  Only relevant for methods. */
148
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
149
};
150
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
151
static_assert(0 < 1, "There is no slot for us");
152
153
MOZ_CAN_RUN_SCRIPT static bool
154
translate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
155
0
{
156
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.translate", DOM, cx);
157
0
158
0
  double arg0;
159
0
  if (args.hasDefined(0)) {
160
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
161
0
      return false;
162
0
    }
163
0
  } else {
164
0
    arg0 = 0.0;
165
0
  }
166
0
  double arg1;
167
0
  if (args.hasDefined(1)) {
168
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
169
0
      return false;
170
0
    }
171
0
  } else {
172
0
    arg1 = 0.0;
173
0
  }
174
0
  double arg2;
175
0
  if (args.hasDefined(2)) {
176
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
177
0
      return false;
178
0
    }
179
0
  } else {
180
0
    arg2 = 0.0;
181
0
  }
182
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->Translate(arg0, arg1, arg2)));
183
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
184
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
185
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
186
0
    return false;
187
0
  }
188
0
  return true;
189
0
}
190
191
static const JSJitInfo translate_methodinfo = {
192
  { (JSJitGetterOp)translate },
193
  { prototypes::id::WebKitCSSMatrix },
194
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
195
  JSJitInfo::Method,
196
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
197
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
198
  false,  /* isInfallible. False in setters. */
199
  false,  /* isMovable.  Not relevant for setters. */
200
  false, /* isEliminatable.  Not relevant for setters. */
201
  false, /* isAlwaysInSlot.  Only relevant for getters. */
202
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
203
  false,  /* isTypedMethod.  Only relevant for methods. */
204
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
205
};
206
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
207
static_assert(0 < 1, "There is no slot for us");
208
209
MOZ_CAN_RUN_SCRIPT static bool
210
scale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
211
0
{
212
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.scale", DOM, cx);
213
0
214
0
  double arg0;
215
0
  if (args.hasDefined(0)) {
216
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
217
0
      return false;
218
0
    }
219
0
  } else {
220
0
    arg0 = 1.0;
221
0
  }
222
0
  Optional<double> arg1;
223
0
  if (args.hasDefined(1)) {
224
0
    arg1.Construct();
225
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1.Value())) {
226
0
      return false;
227
0
    }
228
0
  }
229
0
  double arg2;
230
0
  if (args.hasDefined(2)) {
231
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
232
0
      return false;
233
0
    }
234
0
  } else {
235
0
    arg2 = 1.0;
236
0
  }
237
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->Scale(arg0, Constify(arg1), arg2)));
238
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
239
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
240
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
241
0
    return false;
242
0
  }
243
0
  return true;
244
0
}
245
246
static const JSJitInfo scale_methodinfo = {
247
  { (JSJitGetterOp)scale },
248
  { prototypes::id::WebKitCSSMatrix },
249
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
250
  JSJitInfo::Method,
251
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
252
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
253
  false,  /* isInfallible. False in setters. */
254
  false,  /* isMovable.  Not relevant for setters. */
255
  false, /* isEliminatable.  Not relevant for setters. */
256
  false, /* isAlwaysInSlot.  Only relevant for getters. */
257
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
258
  false,  /* isTypedMethod.  Only relevant for methods. */
259
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
260
};
261
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
262
static_assert(0 < 1, "There is no slot for us");
263
264
MOZ_CAN_RUN_SCRIPT static bool
265
rotate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
266
0
{
267
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.rotate", DOM, cx);
268
0
269
0
  double arg0;
270
0
  if (args.hasDefined(0)) {
271
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
272
0
      return false;
273
0
    }
274
0
  } else {
275
0
    arg0 = 0.0;
276
0
  }
277
0
  Optional<double> arg1;
278
0
  if (args.hasDefined(1)) {
279
0
    arg1.Construct();
280
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1.Value())) {
281
0
      return false;
282
0
    }
283
0
  }
284
0
  Optional<double> arg2;
285
0
  if (args.hasDefined(2)) {
286
0
    arg2.Construct();
287
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2.Value())) {
288
0
      return false;
289
0
    }
290
0
  }
291
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->Rotate(arg0, Constify(arg1), Constify(arg2))));
292
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
293
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
294
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
295
0
    return false;
296
0
  }
297
0
  return true;
298
0
}
299
300
static const JSJitInfo rotate_methodinfo = {
301
  { (JSJitGetterOp)rotate },
302
  { prototypes::id::WebKitCSSMatrix },
303
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
304
  JSJitInfo::Method,
305
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
306
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
307
  false,  /* isInfallible. False in setters. */
308
  false,  /* isMovable.  Not relevant for setters. */
309
  false, /* isEliminatable.  Not relevant for setters. */
310
  false, /* isAlwaysInSlot.  Only relevant for getters. */
311
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
312
  false,  /* isTypedMethod.  Only relevant for methods. */
313
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
314
};
315
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
316
static_assert(0 < 1, "There is no slot for us");
317
318
MOZ_CAN_RUN_SCRIPT static bool
319
rotateAxisAngle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
320
0
{
321
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.rotateAxisAngle", DOM, cx);
322
0
323
0
  double arg0;
324
0
  if (args.hasDefined(0)) {
325
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
326
0
      return false;
327
0
    }
328
0
  } else {
329
0
    arg0 = 0.0;
330
0
  }
331
0
  double arg1;
332
0
  if (args.hasDefined(1)) {
333
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
334
0
      return false;
335
0
    }
336
0
  } else {
337
0
    arg1 = 0.0;
338
0
  }
339
0
  double arg2;
340
0
  if (args.hasDefined(2)) {
341
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
342
0
      return false;
343
0
    }
344
0
  } else {
345
0
    arg2 = 0.0;
346
0
  }
347
0
  double arg3;
348
0
  if (args.hasDefined(3)) {
349
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
350
0
      return false;
351
0
    }
352
0
  } else {
353
0
    arg3 = 0.0;
354
0
  }
355
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->RotateAxisAngle(arg0, arg1, arg2, arg3)));
356
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
357
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
358
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
359
0
    return false;
360
0
  }
361
0
  return true;
362
0
}
363
364
static const JSJitInfo rotateAxisAngle_methodinfo = {
365
  { (JSJitGetterOp)rotateAxisAngle },
366
  { prototypes::id::WebKitCSSMatrix },
367
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
368
  JSJitInfo::Method,
369
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
370
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
371
  false,  /* isInfallible. False in setters. */
372
  false,  /* isMovable.  Not relevant for setters. */
373
  false, /* isEliminatable.  Not relevant for setters. */
374
  false, /* isAlwaysInSlot.  Only relevant for getters. */
375
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
376
  false,  /* isTypedMethod.  Only relevant for methods. */
377
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
378
};
379
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
380
static_assert(0 < 1, "There is no slot for us");
381
382
MOZ_CAN_RUN_SCRIPT static bool
383
skewX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
384
0
{
385
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.skewX", DOM, cx);
386
0
387
0
  double arg0;
388
0
  if (args.hasDefined(0)) {
389
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
390
0
      return false;
391
0
    }
392
0
  } else {
393
0
    arg0 = 0.0;
394
0
  }
395
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->SkewX(arg0)));
396
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
397
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
398
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
399
0
    return false;
400
0
  }
401
0
  return true;
402
0
}
403
404
static const JSJitInfo skewX_methodinfo = {
405
  { (JSJitGetterOp)skewX },
406
  { prototypes::id::WebKitCSSMatrix },
407
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
408
  JSJitInfo::Method,
409
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
410
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
411
  false,  /* isInfallible. False in setters. */
412
  false,  /* isMovable.  Not relevant for setters. */
413
  false, /* isEliminatable.  Not relevant for setters. */
414
  false, /* isAlwaysInSlot.  Only relevant for getters. */
415
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
416
  false,  /* isTypedMethod.  Only relevant for methods. */
417
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
418
};
419
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
420
static_assert(0 < 1, "There is no slot for us");
421
422
MOZ_CAN_RUN_SCRIPT static bool
423
skewY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WebKitCSSMatrix* self, const JSJitMethodCallArgs& args)
424
0
{
425
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix.skewY", DOM, cx);
426
0
427
0
  double arg0;
428
0
  if (args.hasDefined(0)) {
429
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
430
0
      return false;
431
0
    }
432
0
  } else {
433
0
    arg0 = 0.0;
434
0
  }
435
0
  auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(self->SkewY(arg0)));
436
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
437
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
438
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
439
0
    return false;
440
0
  }
441
0
  return true;
442
0
}
443
444
static const JSJitInfo skewY_methodinfo = {
445
  { (JSJitGetterOp)skewY },
446
  { prototypes::id::WebKitCSSMatrix },
447
  { PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth },
448
  JSJitInfo::Method,
449
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
450
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
451
  false,  /* isInfallible. False in setters. */
452
  false,  /* isMovable.  Not relevant for setters. */
453
  false, /* isEliminatable.  Not relevant for setters. */
454
  false, /* isAlwaysInSlot.  Only relevant for getters. */
455
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
456
  false,  /* isTypedMethod.  Only relevant for methods. */
457
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
458
};
459
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
460
static_assert(0 < 1, "There is no slot for us");
461
462
static bool
463
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
464
0
{
465
0
  mozilla::dom::WebKitCSSMatrix* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WebKitCSSMatrix>(obj);
466
0
  // We don't want to preserve if we don't have a wrapper, and we
467
0
  // obviously can't preserve if we're not initialized.
468
0
  if (self && self->GetWrapperPreserveColor()) {
469
0
    PreserveWrapper(self);
470
0
  }
471
0
  return true;
472
0
}
473
474
static void
475
_finalize(js::FreeOp* fop, JSObject* obj)
476
0
{
477
0
  mozilla::dom::WebKitCSSMatrix* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WebKitCSSMatrix>(obj);
478
0
  if (self) {
479
0
    ClearWrapper(self, self, obj);
480
0
    AddForDeferredFinalization<mozilla::dom::WebKitCSSMatrix>(self);
481
0
  }
482
0
}
483
484
static size_t
485
_objectMoved(JSObject* obj, JSObject* old)
486
0
{
487
0
  mozilla::dom::WebKitCSSMatrix* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WebKitCSSMatrix>(obj);
488
0
  if (self) {
489
0
    UpdateWrapper(self, self, obj, old);
490
0
  }
491
0
492
0
  return 0;
493
0
}
494
495
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
496
#if defined(__clang__)
497
#pragma clang diagnostic push
498
#pragma clang diagnostic ignored "-Wmissing-braces"
499
#endif
500
static const JSFunctionSpec sMethods_specs[] = {
501
  JS_FNSPEC("setMatrixValue", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setMatrixValue_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
502
  JS_FNSPEC("multiply", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&multiply_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
503
  JS_FNSPEC("inverse", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&inverse_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
504
  JS_FNSPEC("translate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&translate_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
505
  JS_FNSPEC("scale", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scale_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
506
  JS_FNSPEC("rotate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&rotate_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
507
  JS_FNSPEC("rotateAxisAngle", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&rotateAxisAngle_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
508
  JS_FNSPEC("skewX", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&skewX_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
509
  JS_FNSPEC("skewY", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&skewY_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
510
  JS_FS_END
511
};
512
#if defined(__clang__)
513
#pragma clang diagnostic pop
514
#endif
515
516
517
static const Prefable<const JSFunctionSpec> sMethods[] = {
518
  { nullptr, &sMethods_specs[0] },
519
  { nullptr, nullptr }
520
};
521
522
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
523
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
524
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
525
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
526
527
528
static uint16_t sNativeProperties_sortedPropertyIndices[9];
529
static PropertyInfo sNativeProperties_propertyInfos[9];
530
531
static const NativePropertiesN<1> sNativeProperties = {
532
  false, 0,
533
  false, 0,
534
  true,  0 /* sMethods */,
535
  false, 0,
536
  false, 0,
537
  false, 0,
538
  false, 0,
539
  -1,
540
  9,
541
  sNativeProperties_sortedPropertyIndices,
542
  {
543
    { sMethods, &sNativeProperties_propertyInfos[0] }
544
  }
545
};
546
static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
547
    "We have a property info count that is oversized");
548
549
static bool
550
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
551
0
{
552
0
  AUTO_PROFILER_LABEL_FAST("WebKitCSSMatrix constructor", DOM, cx);
553
0
554
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
555
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
556
0
  if (!args.isConstructing()) {
557
0
    // XXXbz wish I could get the name from the callee instead of
558
0
    // Adding more relocations
559
0
    return ThrowConstructorWithoutNew(cx, "WebKitCSSMatrix");
560
0
  }
561
0
562
0
  JS::Rooted<JSObject*> desiredProto(cx);
563
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
564
0
    return false;
565
0
  }
566
0
567
0
  unsigned argcount = std::min(args.length(), 1u);
568
0
  switch (argcount) {
569
0
    case 0: {
570
0
      GlobalObject global(cx, obj);
571
0
      if (global.Failed()) {
572
0
        return false;
573
0
      }
574
0
575
0
      bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
576
0
      Maybe<JSAutoRealm> ar;
577
0
      if (objIsXray) {
578
0
        obj = js::CheckedUnwrap(obj);
579
0
        if (!obj) {
580
0
          return false;
581
0
        }
582
0
        ar.emplace(cx, obj);
583
0
        if (!JS_WrapObject(cx, &desiredProto)) {
584
0
          return false;
585
0
        }
586
0
      }
587
0
      FastErrorResult rv;
588
0
      auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(mozilla::dom::WebKitCSSMatrix::Constructor(global, rv)));
589
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
590
0
        return false;
591
0
      }
592
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
593
0
      static_assert(!IsPointer<decltype(result)>::value,
594
0
                    "NewObject implies that we need to keep the object alive with a strong reference.");
595
0
      if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
596
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
597
0
        return false;
598
0
      }
599
0
      return true;
600
0
      break;
601
0
    }
602
0
    case 1: {
603
0
      if (args[0].isObject()) {
604
0
        do {
605
0
          NonNull<mozilla::dom::WebKitCSSMatrix> arg0;
606
0
          {
607
0
            nsresult rv = UnwrapObject<prototypes::id::WebKitCSSMatrix, mozilla::dom::WebKitCSSMatrix>(args[0], arg0);
608
0
            if (NS_FAILED(rv)) {
609
0
              break;
610
0
            }
611
0
          }
612
0
          GlobalObject global(cx, obj);
613
0
          if (global.Failed()) {
614
0
            return false;
615
0
          }
616
0
617
0
          bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
618
0
          Maybe<JSAutoRealm> ar;
619
0
          if (objIsXray) {
620
0
            obj = js::CheckedUnwrap(obj);
621
0
            if (!obj) {
622
0
              return false;
623
0
            }
624
0
            ar.emplace(cx, obj);
625
0
            if (!JS_WrapObject(cx, &desiredProto)) {
626
0
              return false;
627
0
            }
628
0
          }
629
0
          FastErrorResult rv;
630
0
          auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(mozilla::dom::WebKitCSSMatrix::Constructor(global, MOZ_KnownLive(NonNullHelper(arg0)), rv)));
631
0
          if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
632
0
            return false;
633
0
          }
634
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
635
0
          static_assert(!IsPointer<decltype(result)>::value,
636
0
                        "NewObject implies that we need to keep the object alive with a strong reference.");
637
0
          if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
638
0
            MOZ_ASSERT(JS_IsExceptionPending(cx));
639
0
            return false;
640
0
          }
641
0
          return true;
642
0
        } while (false);
643
0
      }
644
0
      GlobalObject global(cx, obj);
645
0
      if (global.Failed()) {
646
0
        return false;
647
0
      }
648
0
649
0
      bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
650
0
      binding_detail::FakeString arg0;
651
0
      if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
652
0
        return false;
653
0
      }
654
0
      Maybe<JSAutoRealm> ar;
655
0
      if (objIsXray) {
656
0
        obj = js::CheckedUnwrap(obj);
657
0
        if (!obj) {
658
0
          return false;
659
0
        }
660
0
        ar.emplace(cx, obj);
661
0
        if (!JS_WrapObject(cx, &desiredProto)) {
662
0
          return false;
663
0
        }
664
0
      }
665
0
      FastErrorResult rv;
666
0
      auto result(StrongOrRawPtr<mozilla::dom::WebKitCSSMatrix>(mozilla::dom::WebKitCSSMatrix::Constructor(global, NonNullHelper(Constify(arg0)), rv)));
667
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
668
0
        return false;
669
0
      }
670
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
671
0
      static_assert(!IsPointer<decltype(result)>::value,
672
0
                    "NewObject implies that we need to keep the object alive with a strong reference.");
673
0
      if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
674
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
675
0
        return false;
676
0
      }
677
0
      return true;
678
0
      break;
679
0
    }
680
0
    default: {
681
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebKitCSSMatrix");
682
0
      break;
683
0
    }
684
0
  }
685
0
  MOZ_CRASH("We have an always-returning default case");
686
0
  return false;
687
0
}
688
689
static const js::ClassOps sInterfaceObjectClassOps = {
690
    nullptr,               /* addProperty */
691
    nullptr,               /* delProperty */
692
    nullptr,               /* enumerate */
693
    nullptr,               /* newEnumerate */
694
    nullptr,               /* resolve */
695
    nullptr,               /* mayResolve */
696
    nullptr,               /* finalize */
697
    _constructor, /* call */
698
    nullptr,               /* hasInstance */
699
    _constructor, /* construct */
700
    nullptr,               /* trace */
701
};
702
703
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
704
  {
705
    "Function",
706
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
707
    &sInterfaceObjectClassOps,
708
    JS_NULL_CLASS_SPEC,
709
    JS_NULL_CLASS_EXT,
710
    &sInterfaceObjectClassObjectOps
711
  },
712
  eInterface,
713
  true,
714
  prototypes::id::WebKitCSSMatrix,
715
  PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth,
716
  sNativePropertyHooks,
717
  "function WebKitCSSMatrix() {\n    [native code]\n}",
718
  DOMMatrix_Binding::GetConstructorObject
719
};
720
721
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
722
  {
723
    "WebKitCSSMatrixPrototype",
724
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
725
    JS_NULL_CLASS_OPS,
726
    JS_NULL_CLASS_SPEC,
727
    JS_NULL_CLASS_EXT,
728
    JS_NULL_OBJECT_OPS
729
  },
730
  eInterfacePrototype,
731
  false,
732
  prototypes::id::WebKitCSSMatrix,
733
  PrototypeTraits<prototypes::id::WebKitCSSMatrix>::Depth,
734
  sNativePropertyHooks,
735
  "[object WebKitCSSMatrixPrototype]",
736
  DOMMatrix_Binding::GetProtoObject
737
};
738
739
bool
740
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
741
0
{
742
0
  return mozilla::dom::WebKitCSSMatrix::FeatureEnabled(aCx, aObj);
743
0
}
744
745
static const js::ClassOps sClassOps = {
746
  _addProperty, /* addProperty */
747
  nullptr,               /* delProperty */
748
  nullptr,               /* enumerate */
749
  nullptr, /* newEnumerate */
750
  nullptr, /* resolve */
751
  nullptr, /* mayResolve */
752
  _finalize, /* finalize */
753
  nullptr, /* call */
754
  nullptr,               /* hasInstance */
755
  nullptr,               /* construct */
756
  nullptr, /* trace */
757
};
758
759
static const js::ClassExtension sClassExtension = {
760
  nullptr, /* weakmapKeyDelegateOp */
761
  _objectMoved /* objectMovedOp */
762
};
763
764
static const DOMJSClass sClass = {
765
  { "WebKitCSSMatrix",
766
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
767
    &sClassOps,
768
    JS_NULL_CLASS_SPEC,
769
    &sClassExtension,
770
    JS_NULL_OBJECT_OPS
771
  },
772
  { prototypes::id::DOMMatrixReadOnly, prototypes::id::DOMMatrix, prototypes::id::WebKitCSSMatrix, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
773
  IsBaseOf<nsISupports, mozilla::dom::WebKitCSSMatrix >::value,
774
  sNativePropertyHooks,
775
  FindAssociatedGlobalForNative<mozilla::dom::WebKitCSSMatrix>::Get,
776
  GetProtoObjectHandle,
777
  GetCCParticipant<mozilla::dom::WebKitCSSMatrix>::Get()
778
};
779
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
780
              "Must have the right minimal number of reserved slots.");
781
static_assert(1 >= 1,
782
              "Must have enough reserved slots.");
783
784
const JSClass*
785
GetJSClass()
786
0
{
787
0
  return sClass.ToJSClass();
788
0
}
789
790
bool
791
Wrap(JSContext* aCx, mozilla::dom::WebKitCSSMatrix* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
792
0
{
793
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::WebKitCSSMatrix>::value,
794
0
                "Shouldn't have wrappercached things that are not refcounted.");
795
0
  MOZ_ASSERT(static_cast<mozilla::dom::WebKitCSSMatrix*>(aObject) ==
796
0
             reinterpret_cast<mozilla::dom::WebKitCSSMatrix*>(aObject),
797
0
             "Multiple inheritance for mozilla::dom::WebKitCSSMatrix is broken.");
798
0
  MOZ_ASSERT(static_cast<mozilla::dom::DOMMatrix*>(aObject) ==
799
0
             reinterpret_cast<mozilla::dom::DOMMatrix*>(aObject),
800
0
             "Multiple inheritance for mozilla::dom::DOMMatrix is broken.");
801
0
  MOZ_ASSERT(static_cast<mozilla::dom::DOMMatrixReadOnly*>(aObject) ==
802
0
             reinterpret_cast<mozilla::dom::DOMMatrixReadOnly*>(aObject),
803
0
             "Multiple inheritance for mozilla::dom::DOMMatrixReadOnly is broken.");
804
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
805
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
806
0
  MOZ_ASSERT(!aCache->GetWrapper(),
807
0
             "You should probably not be using Wrap() directly; use "
808
0
             "GetOrCreateDOMReflector instead");
809
0
810
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
811
0
             "nsISupports must be on our primary inheritance chain");
812
0
813
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
814
0
  if (!global) {
815
0
    return false;
816
0
  }
817
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
818
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
819
0
820
0
  // That might have ended up wrapping us already, due to the wonders
821
0
  // of XBL.  Check for that, and bail out as needed.
822
0
  aReflector.set(aCache->GetWrapper());
823
0
  if (aReflector) {
824
#ifdef DEBUG
825
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
826
#endif // DEBUG
827
    return true;
828
0
  }
829
0
830
0
  JSAutoRealm ar(aCx, global);
831
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
832
0
  if (!canonicalProto) {
833
0
    return false;
834
0
  }
835
0
  JS::Rooted<JSObject*> proto(aCx);
836
0
  if (aGivenProto) {
837
0
    proto = aGivenProto;
838
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
839
0
    // coming in, we changed compartments to that of "parent" so may need
840
0
    // to wrap the proto here.
841
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
842
0
      if (!JS_WrapObject(aCx, &proto)) {
843
0
        return false;
844
0
      }
845
0
    }
846
0
  } else {
847
0
    proto = canonicalProto;
848
0
  }
849
0
850
0
  BindingJSObjectCreator<mozilla::dom::WebKitCSSMatrix> creator(aCx);
851
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
852
0
  if (!aReflector) {
853
0
    return false;
854
0
  }
855
0
856
0
  aCache->SetWrapper(aReflector);
857
0
  creator.InitializationSucceeded();
858
0
859
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
860
0
             aCache->GetWrapperPreserveColor() == aReflector);
861
0
  // If proto != canonicalProto, we have to preserve our wrapper;
862
0
  // otherwise we won't be able to properly recreate it later, since
863
0
  // we won't know what proto to use.  Note that we don't check
864
0
  // aGivenProto here, since it's entirely possible (and even
865
0
  // somewhat common) to have a non-null aGivenProto which is the
866
0
  // same as canonicalProto.
867
0
  if (proto != canonicalProto) {
868
0
    PreserveWrapper(aObject);
869
0
  }
870
0
871
0
  return true;
872
0
}
873
874
const NativePropertyHooks sNativePropertyHooks[] = { {
875
  nullptr,
876
  nullptr,
877
  nullptr,
878
  { sNativeProperties.Upcast(), nullptr },
879
  prototypes::id::WebKitCSSMatrix,
880
  constructors::id::WebKitCSSMatrix,
881
  DOMMatrix_Binding::sNativePropertyHooks,
882
  &DefaultXrayExpandoObjectClass
883
} };
884
885
void
886
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
887
0
{
888
0
  JS::Handle<JSObject*> parentProto(DOMMatrix_Binding::GetProtoObjectHandle(aCx));
889
0
  if (!parentProto) {
890
0
    return;
891
0
  }
892
0
893
0
  JS::Handle<JSObject*> constructorProto(DOMMatrix_Binding::GetConstructorObjectHandle(aCx));
894
0
  if (!constructorProto) {
895
0
    return;
896
0
  }
897
0
898
0
  static bool sIdsInited = false;
899
0
  if (!sIdsInited && NS_IsMainThread()) {
900
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
901
0
      return;
902
0
    }
903
0
    sIdsInited = true;
904
0
  }
905
0
906
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebKitCSSMatrix);
907
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebKitCSSMatrix);
908
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
909
0
                              &sPrototypeClass.mBase, protoCache,
910
0
                              nullptr,
911
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
912
0
                              interfaceCache,
913
0
                              sNativeProperties.Upcast(),
914
0
                              nullptr,
915
0
                              "WebKitCSSMatrix", aDefineOnGlobal,
916
0
                              nullptr,
917
0
                              false);
918
0
}
919
920
JSObject*
921
GetConstructorObject(JSContext* aCx)
922
0
{
923
0
  return GetConstructorObjectHandle(aCx);
924
0
}
925
926
} // namespace WebKitCSSMatrix_Binding
927
928
929
930
} // namespace dom
931
} // namespace mozilla