Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/CanvasRenderingContext2DBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM CanvasRenderingContext2D.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "CanvasPath.h"
5
#include "CanvasRenderingContext2DBinding.h"
6
#include "CanvasUtils.h"
7
#include "WrapperFactory.h"
8
#include "jsapi.h"
9
#include "mozilla/FloatingPoint.h"
10
#include "mozilla/OwningNonNull.h"
11
#include "mozilla/Preferences.h"
12
#include "mozilla/dom/BindingUtils.h"
13
#include "mozilla/dom/CanvasGradient.h"
14
#include "mozilla/dom/CanvasPattern.h"
15
#include "mozilla/dom/CanvasRenderingContext2D.h"
16
#include "mozilla/dom/DOMJSClass.h"
17
#include "mozilla/dom/Element.h"
18
#include "mozilla/dom/HTMLCanvasElement.h"
19
#include "mozilla/dom/HTMLImageElement.h"
20
#include "mozilla/dom/HTMLVideoElement.h"
21
#include "mozilla/dom/ImageBitmap.h"
22
#include "mozilla/dom/ImageData.h"
23
#include "mozilla/dom/NonRefcountedDOMObject.h"
24
#include "mozilla/dom/Nullable.h"
25
#include "mozilla/dom/PrimitiveConversions.h"
26
#include "mozilla/dom/SVGImageElement.h"
27
#include "mozilla/dom/SVGMatrix.h"
28
#include "mozilla/dom/ScriptSettings.h"
29
#include "mozilla/dom/SimpleGlobalObject.h"
30
#include "mozilla/dom/TextMetrics.h"
31
#include "mozilla/dom/UnionConversions.h"
32
#include "mozilla/dom/XrayExpandoClass.h"
33
#include "nsContentUtils.h"
34
#include "nsGlobalWindow.h"
35
#include "nsIDocument.h"
36
37
namespace mozilla {
38
namespace dom {
39
40
namespace binding_detail {}; // Just to make sure it's known as a namespace
41
using namespace mozilla::dom::binding_detail;
42
43
44
namespace CanvasWindingRuleValues {
45
extern const EnumEntry strings[3] = {
46
  {"nonzero", 7},
47
  {"evenodd", 7},
48
  { nullptr, 0 }
49
};
50
} // namespace CanvasWindingRuleValues
51
52
bool
53
ToJSValue(JSContext* aCx, CanvasWindingRule aArgument, JS::MutableHandle<JS::Value> aValue)
54
0
{
55
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(CanvasWindingRuleValues::strings));
56
0
  JSString* resultStr =
57
0
    JS_NewStringCopyN(aCx, CanvasWindingRuleValues::strings[uint32_t(aArgument)].value,
58
0
                      CanvasWindingRuleValues::strings[uint32_t(aArgument)].length);
59
0
  if (!resultStr) {
60
0
    return false;
61
0
  }
62
0
  aValue.setString(resultStr);
63
0
  return true;
64
0
}
65
66
67
void
68
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap& aUnion, const char* aName, uint32_t aFlags)
69
0
{
70
0
  if (aUnion.IsHTMLImageElement()) {
71
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLImageElement(), "mHTMLImageElement", aFlags);
72
0
  } else if (aUnion.IsSVGImageElement()) {
73
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsSVGImageElement(), "mSVGImageElement", aFlags);
74
0
  } else if (aUnion.IsHTMLCanvasElement()) {
75
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLCanvasElement(), "mHTMLCanvasElement", aFlags);
76
0
  } else if (aUnion.IsHTMLVideoElement()) {
77
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLVideoElement(), "mHTMLVideoElement", aFlags);
78
0
  } else if (aUnion.IsImageBitmap()) {
79
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsImageBitmap(), "mImageBitmap", aFlags);
80
0
  }
81
0
}
82
83
84
void
85
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningStringOrCanvasGradientOrCanvasPattern& aUnion, const char* aName, uint32_t aFlags)
86
0
{
87
0
  if (aUnion.IsCanvasGradient()) {
88
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCanvasGradient(), "mCanvasGradient", aFlags);
89
0
  } else if (aUnion.IsCanvasPattern()) {
90
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCanvasPattern(), "mCanvasPattern", aFlags);
91
0
  }
92
0
}
93
94
95
void
96
ImplCycleCollectionUnlink(OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap& aUnion)
97
0
{
98
0
  aUnion.Uninit();
99
0
}
100
101
102
void
103
ImplCycleCollectionUnlink(OwningStringOrCanvasGradientOrCanvasPattern& aUnion)
104
0
{
105
0
  aUnion.Uninit();
106
0
}
107
108
109
110
ContextAttributes2D::ContextAttributes2D()
111
0
{
112
0
  // Safe to pass a null context if we pass a null value
113
0
  Init(nullptr, JS::NullHandleValue);
114
0
}
115
116
117
118
bool
119
ContextAttributes2D::InitIds(JSContext* cx, ContextAttributes2DAtoms* atomsCache)
120
0
{
121
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
122
0
123
0
  // Initialize these in reverse order so that any failure leaves the first one
124
0
  // uninitialized.
125
0
  if (!atomsCache->willReadFrequently_id.init(cx, "willReadFrequently") ||
126
0
      !atomsCache->alpha_id.init(cx, "alpha")) {
127
0
    return false;
128
0
  }
129
0
  return true;
130
0
}
131
132
bool
133
ContextAttributes2D::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
134
0
{
135
0
  // Passing a null JSContext is OK only if we're initing from null,
136
0
  // Since in that case we will not have to do any property gets
137
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
138
0
  // checkers by static analysis tools
139
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
140
0
  ContextAttributes2DAtoms* atomsCache = nullptr;
141
0
  if (cx) {
142
0
    atomsCache = GetAtomCache<ContextAttributes2DAtoms>(cx);
143
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
144
0
      return false;
145
0
    }
146
0
  }
147
0
148
0
  if (!IsConvertibleToDictionary(val)) {
149
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
150
0
  }
151
0
152
0
  bool isNull = val.isNullOrUndefined();
153
0
  // We only need these if !isNull, in which case we have |cx|.
154
0
  Maybe<JS::Rooted<JSObject *> > object;
155
0
  Maybe<JS::Rooted<JS::Value> > temp;
156
0
  if (!isNull) {
157
0
    MOZ_ASSERT(cx);
158
0
    object.emplace(cx, &val.toObject());
159
0
    temp.emplace(cx);
160
0
  }
161
0
  if (!isNull) {
162
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->alpha_id, temp.ptr())) {
163
0
      return false;
164
0
    }
165
0
  }
166
0
  if (!isNull && !temp->isUndefined()) {
167
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAlpha)) {
168
0
      return false;
169
0
    }
170
0
  } else {
171
0
    mAlpha = true;
172
0
  }
173
0
  mIsAnyMemberPresent = true;
174
0
175
0
  if (!isNull) {
176
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->willReadFrequently_id, temp.ptr())) {
177
0
      return false;
178
0
    }
179
0
  }
180
0
  if (!isNull && !temp->isUndefined()) {
181
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mWillReadFrequently)) {
182
0
      return false;
183
0
    }
184
0
  } else {
185
0
    mWillReadFrequently = false;
186
0
  }
187
0
  mIsAnyMemberPresent = true;
188
0
  return true;
189
0
}
190
191
bool
192
ContextAttributes2D::Init(const nsAString& aJSON)
193
0
{
194
0
  AutoJSAPI jsapi;
195
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
196
0
  if (!cleanGlobal) {
197
0
    return false;
198
0
  }
199
0
  if (!jsapi.Init(cleanGlobal)) {
200
0
    return false;
201
0
  }
202
0
  JSContext* cx = jsapi.cx();
203
0
  JS::Rooted<JS::Value> json(cx);
204
0
  bool ok = ParseJSON(cx, aJSON, &json);
205
0
  NS_ENSURE_TRUE(ok, false);
206
0
  return Init(cx, json);
207
0
}
208
209
bool
210
ContextAttributes2D::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
211
0
{
212
0
  ContextAttributes2DAtoms* atomsCache = GetAtomCache<ContextAttributes2DAtoms>(cx);
213
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
214
0
    return false;
215
0
  }
216
0
217
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
218
0
  if (!obj) {
219
0
    return false;
220
0
  }
221
0
  rval.set(JS::ObjectValue(*obj));
222
0
223
0
  do {
224
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
225
0
    JS::Rooted<JS::Value> temp(cx);
226
0
    bool const & currentValue = mAlpha;
227
0
    temp.setBoolean(currentValue);
228
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->alpha_id, temp, JSPROP_ENUMERATE)) {
229
0
      return false;
230
0
    }
231
0
    break;
232
0
  } while(false);
233
0
234
0
  do {
235
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
236
0
    JS::Rooted<JS::Value> temp(cx);
237
0
    bool const & currentValue = mWillReadFrequently;
238
0
    temp.setBoolean(currentValue);
239
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->willReadFrequently_id, temp, JSPROP_ENUMERATE)) {
240
0
      return false;
241
0
    }
242
0
    break;
243
0
  } while(false);
244
0
245
0
  return true;
246
0
}
247
248
bool
249
ContextAttributes2D::ToJSON(nsAString& aJSON) const
250
0
{
251
0
  AutoJSAPI jsapi;
252
0
  jsapi.Init();
253
0
  JSContext *cx = jsapi.cx();
254
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
255
0
  // because we'll only be creating objects, in ways that have no
256
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
257
0
  // which likewise guarantees no side-effects for the sorts of
258
0
  // things we will pass it.
259
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
260
0
  JS::Rooted<JS::Value> val(cx);
261
0
  if (!ToObjectInternal(cx, &val)) {
262
0
    return false;
263
0
  }
264
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
265
0
  return StringifyToJSON(cx, obj, aJSON);
266
0
}
267
268
void
269
ContextAttributes2D::TraceDictionary(JSTracer* trc)
270
0
{
271
0
}
272
273
ContextAttributes2D&
274
ContextAttributes2D::operator=(const ContextAttributes2D& aOther)
275
0
{
276
0
  DictionaryBase::operator=(aOther);
277
0
  mAlpha = aOther.mAlpha;
278
0
  mWillReadFrequently = aOther.mWillReadFrequently;
279
0
  return *this;
280
0
}
281
282
namespace binding_detail {
283
} // namespace binding_detail
284
285
286
bool
287
HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
288
0
{
289
0
  switch (mType) {
290
0
    case eUninitialized: {
291
0
      return false;
292
0
      break;
293
0
    }
294
0
    case eHTMLImageElement: {
295
0
      if (!GetOrCreateDOMReflector(cx, mValue.mHTMLImageElement.Value(), rval)) {
296
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
297
0
        return false;
298
0
      }
299
0
      return true;
300
0
      break;
301
0
    }
302
0
    case eSVGImageElement: {
303
0
      if (!GetOrCreateDOMReflector(cx, mValue.mSVGImageElement.Value(), rval)) {
304
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
305
0
        return false;
306
0
      }
307
0
      return true;
308
0
      break;
309
0
    }
310
0
    case eHTMLCanvasElement: {
311
0
      if (!GetOrCreateDOMReflector(cx, mValue.mHTMLCanvasElement.Value(), rval)) {
312
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
313
0
        return false;
314
0
      }
315
0
      return true;
316
0
      break;
317
0
    }
318
0
    case eHTMLVideoElement: {
319
0
      if (!GetOrCreateDOMReflector(cx, mValue.mHTMLVideoElement.Value(), rval)) {
320
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
321
0
        return false;
322
0
      }
323
0
      return true;
324
0
      break;
325
0
    }
326
0
    case eImageBitmap: {
327
0
      if (!GetOrCreateDOMReflector(cx, mValue.mImageBitmap.Value(), rval)) {
328
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
329
0
        return false;
330
0
      }
331
0
      return true;
332
0
      break;
333
0
    }
334
0
    default: {
335
0
      return false;
336
0
      break;
337
0
    }
338
0
  }
339
0
340
0
  return false;
341
0
}
342
343
344
OwningNonNull<mozilla::dom::HTMLImageElement>&
345
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsHTMLImageElement()
346
0
{
347
0
  if (mType == eHTMLImageElement) {
348
0
    return mValue.mHTMLImageElement.Value();
349
0
  }
350
0
  MOZ_ASSERT(mType == eUninitialized);
351
0
  mType = eHTMLImageElement;
352
0
  return mValue.mHTMLImageElement.SetValue();
353
0
}
354
355
OwningNonNull<mozilla::dom::HTMLImageElement>&
356
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsHTMLImageElement()
357
0
{
358
0
  if (mType == eHTMLImageElement) {
359
0
    return mValue.mHTMLImageElement.Value();
360
0
  }
361
0
  Uninit();
362
0
  mType = eHTMLImageElement;
363
0
  return mValue.mHTMLImageElement.SetValue();
364
0
}
365
366
bool
367
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToHTMLImageElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
368
0
{
369
0
  tryNext = false;
370
0
  { // scope for memberSlot
371
0
    OwningNonNull<mozilla::dom::HTMLImageElement>& memberSlot = RawSetAsHTMLImageElement();
372
0
    static_assert(IsRefcounted<mozilla::dom::HTMLImageElement>::value, "We can only store refcounted classes.");{
373
0
      nsresult rv = UnwrapObject<prototypes::id::HTMLImageElement, mozilla::dom::HTMLImageElement>(value, memberSlot);
374
0
      if (NS_FAILED(rv)) {
375
0
        DestroyHTMLImageElement();
376
0
        tryNext = true;
377
0
        return true;
378
0
      }
379
0
    }
380
0
  }
381
0
  return true;
382
0
}
383
384
void
385
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyHTMLImageElement()
386
0
{
387
0
  MOZ_ASSERT(IsHTMLImageElement(), "Wrong type!");
388
0
  mValue.mHTMLImageElement.Destroy();
389
0
  mType = eUninitialized;
390
0
}
391
392
393
394
395
OwningNonNull<mozilla::dom::SVGImageElement>&
396
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsSVGImageElement()
397
0
{
398
0
  if (mType == eSVGImageElement) {
399
0
    return mValue.mSVGImageElement.Value();
400
0
  }
401
0
  MOZ_ASSERT(mType == eUninitialized);
402
0
  mType = eSVGImageElement;
403
0
  return mValue.mSVGImageElement.SetValue();
404
0
}
405
406
OwningNonNull<mozilla::dom::SVGImageElement>&
407
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsSVGImageElement()
408
0
{
409
0
  if (mType == eSVGImageElement) {
410
0
    return mValue.mSVGImageElement.Value();
411
0
  }
412
0
  Uninit();
413
0
  mType = eSVGImageElement;
414
0
  return mValue.mSVGImageElement.SetValue();
415
0
}
416
417
bool
418
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToSVGImageElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
419
0
{
420
0
  tryNext = false;
421
0
  { // scope for memberSlot
422
0
    OwningNonNull<mozilla::dom::SVGImageElement>& memberSlot = RawSetAsSVGImageElement();
423
0
    static_assert(IsRefcounted<mozilla::dom::SVGImageElement>::value, "We can only store refcounted classes.");{
424
0
      nsresult rv = UnwrapObject<prototypes::id::SVGImageElement, mozilla::dom::SVGImageElement>(value, memberSlot);
425
0
      if (NS_FAILED(rv)) {
426
0
        DestroySVGImageElement();
427
0
        tryNext = true;
428
0
        return true;
429
0
      }
430
0
    }
431
0
  }
432
0
  return true;
433
0
}
434
435
void
436
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroySVGImageElement()
437
0
{
438
0
  MOZ_ASSERT(IsSVGImageElement(), "Wrong type!");
439
0
  mValue.mSVGImageElement.Destroy();
440
0
  mType = eUninitialized;
441
0
}
442
443
444
445
446
OwningNonNull<mozilla::dom::HTMLCanvasElement>&
447
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsHTMLCanvasElement()
448
0
{
449
0
  if (mType == eHTMLCanvasElement) {
450
0
    return mValue.mHTMLCanvasElement.Value();
451
0
  }
452
0
  MOZ_ASSERT(mType == eUninitialized);
453
0
  mType = eHTMLCanvasElement;
454
0
  return mValue.mHTMLCanvasElement.SetValue();
455
0
}
456
457
OwningNonNull<mozilla::dom::HTMLCanvasElement>&
458
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsHTMLCanvasElement()
459
0
{
460
0
  if (mType == eHTMLCanvasElement) {
461
0
    return mValue.mHTMLCanvasElement.Value();
462
0
  }
463
0
  Uninit();
464
0
  mType = eHTMLCanvasElement;
465
0
  return mValue.mHTMLCanvasElement.SetValue();
466
0
}
467
468
bool
469
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToHTMLCanvasElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
470
0
{
471
0
  tryNext = false;
472
0
  { // scope for memberSlot
473
0
    OwningNonNull<mozilla::dom::HTMLCanvasElement>& memberSlot = RawSetAsHTMLCanvasElement();
474
0
    static_assert(IsRefcounted<mozilla::dom::HTMLCanvasElement>::value, "We can only store refcounted classes.");{
475
0
      nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(value, memberSlot);
476
0
      if (NS_FAILED(rv)) {
477
0
        DestroyHTMLCanvasElement();
478
0
        tryNext = true;
479
0
        return true;
480
0
      }
481
0
    }
482
0
  }
483
0
  return true;
484
0
}
485
486
void
487
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyHTMLCanvasElement()
488
0
{
489
0
  MOZ_ASSERT(IsHTMLCanvasElement(), "Wrong type!");
490
0
  mValue.mHTMLCanvasElement.Destroy();
491
0
  mType = eUninitialized;
492
0
}
493
494
495
496
497
OwningNonNull<mozilla::dom::HTMLVideoElement>&
498
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsHTMLVideoElement()
499
0
{
500
0
  if (mType == eHTMLVideoElement) {
501
0
    return mValue.mHTMLVideoElement.Value();
502
0
  }
503
0
  MOZ_ASSERT(mType == eUninitialized);
504
0
  mType = eHTMLVideoElement;
505
0
  return mValue.mHTMLVideoElement.SetValue();
506
0
}
507
508
OwningNonNull<mozilla::dom::HTMLVideoElement>&
509
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsHTMLVideoElement()
510
0
{
511
0
  if (mType == eHTMLVideoElement) {
512
0
    return mValue.mHTMLVideoElement.Value();
513
0
  }
514
0
  Uninit();
515
0
  mType = eHTMLVideoElement;
516
0
  return mValue.mHTMLVideoElement.SetValue();
517
0
}
518
519
bool
520
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToHTMLVideoElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
521
0
{
522
0
  tryNext = false;
523
0
  { // scope for memberSlot
524
0
    OwningNonNull<mozilla::dom::HTMLVideoElement>& memberSlot = RawSetAsHTMLVideoElement();
525
0
    static_assert(IsRefcounted<mozilla::dom::HTMLVideoElement>::value, "We can only store refcounted classes.");{
526
0
      nsresult rv = UnwrapObject<prototypes::id::HTMLVideoElement, mozilla::dom::HTMLVideoElement>(value, memberSlot);
527
0
      if (NS_FAILED(rv)) {
528
0
        DestroyHTMLVideoElement();
529
0
        tryNext = true;
530
0
        return true;
531
0
      }
532
0
    }
533
0
  }
534
0
  return true;
535
0
}
536
537
void
538
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyHTMLVideoElement()
539
0
{
540
0
  MOZ_ASSERT(IsHTMLVideoElement(), "Wrong type!");
541
0
  mValue.mHTMLVideoElement.Destroy();
542
0
  mType = eUninitialized;
543
0
}
544
545
546
547
548
OwningNonNull<mozilla::dom::ImageBitmap>&
549
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::RawSetAsImageBitmap()
550
0
{
551
0
  if (mType == eImageBitmap) {
552
0
    return mValue.mImageBitmap.Value();
553
0
  }
554
0
  MOZ_ASSERT(mType == eUninitialized);
555
0
  mType = eImageBitmap;
556
0
  return mValue.mImageBitmap.SetValue();
557
0
}
558
559
OwningNonNull<mozilla::dom::ImageBitmap>&
560
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::SetAsImageBitmap()
561
0
{
562
0
  if (mType == eImageBitmap) {
563
0
    return mValue.mImageBitmap.Value();
564
0
  }
565
0
  Uninit();
566
0
  mType = eImageBitmap;
567
0
  return mValue.mImageBitmap.SetValue();
568
0
}
569
570
bool
571
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TrySetToImageBitmap(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
572
0
{
573
0
  tryNext = false;
574
0
  { // scope for memberSlot
575
0
    OwningNonNull<mozilla::dom::ImageBitmap>& memberSlot = RawSetAsImageBitmap();
576
0
    static_assert(IsRefcounted<mozilla::dom::ImageBitmap>::value, "We can only store refcounted classes.");{
577
0
      nsresult rv = UnwrapObject<prototypes::id::ImageBitmap, mozilla::dom::ImageBitmap>(value, memberSlot);
578
0
      if (NS_FAILED(rv)) {
579
0
        DestroyImageBitmap();
580
0
        tryNext = true;
581
0
        return true;
582
0
      }
583
0
    }
584
0
  }
585
0
  return true;
586
0
}
587
588
void
589
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::DestroyImageBitmap()
590
0
{
591
0
  MOZ_ASSERT(IsImageBitmap(), "Wrong type!");
592
0
  mValue.mImageBitmap.Destroy();
593
0
  mType = eUninitialized;
594
0
}
595
596
597
598
599
void
600
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::Uninit()
601
{
602
  switch (mType) {
603
    case eUninitialized: {
604
      break;
605
    }
606
    case eHTMLImageElement: {
607
      DestroyHTMLImageElement();
608
      break;
609
    }
610
    case eSVGImageElement: {
611
      DestroySVGImageElement();
612
      break;
613
    }
614
    case eHTMLCanvasElement: {
615
      DestroyHTMLCanvasElement();
616
      break;
617
    }
618
    case eHTMLVideoElement: {
619
      DestroyHTMLVideoElement();
620
      break;
621
    }
622
    case eImageBitmap: {
623
      DestroyImageBitmap();
624
      break;
625
    }
626
  }
627
}
628
629
bool
630
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
631
0
{
632
0
  switch (mType) {
633
0
    case eUninitialized: {
634
0
      return false;
635
0
      break;
636
0
    }
637
0
    case eHTMLImageElement: {
638
0
      if (!GetOrCreateDOMReflector(cx, mValue.mHTMLImageElement.Value(), rval)) {
639
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
640
0
        return false;
641
0
      }
642
0
      return true;
643
0
      break;
644
0
    }
645
0
    case eSVGImageElement: {
646
0
      if (!GetOrCreateDOMReflector(cx, mValue.mSVGImageElement.Value(), rval)) {
647
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
648
0
        return false;
649
0
      }
650
0
      return true;
651
0
      break;
652
0
    }
653
0
    case eHTMLCanvasElement: {
654
0
      if (!GetOrCreateDOMReflector(cx, mValue.mHTMLCanvasElement.Value(), rval)) {
655
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
656
0
        return false;
657
0
      }
658
0
      return true;
659
0
      break;
660
0
    }
661
0
    case eHTMLVideoElement: {
662
0
      if (!GetOrCreateDOMReflector(cx, mValue.mHTMLVideoElement.Value(), rval)) {
663
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
664
0
        return false;
665
0
      }
666
0
      return true;
667
0
      break;
668
0
    }
669
0
    case eImageBitmap: {
670
0
      if (!GetOrCreateDOMReflector(cx, mValue.mImageBitmap.Value(), rval)) {
671
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
672
0
        return false;
673
0
      }
674
0
      return true;
675
0
      break;
676
0
    }
677
0
    default: {
678
0
      return false;
679
0
      break;
680
0
    }
681
0
  }
682
0
683
0
  return false;
684
0
}
685
686
void
687
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::TraceUnion(JSTracer* trc)
688
0
{
689
0
}
690
691
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap&
692
OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap::operator=(const OwningHTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap& aOther)
693
0
{
694
0
  switch (aOther.mType) {
695
0
    case eUninitialized: {
696
0
      MOZ_ASSERT(mType == eUninitialized,
697
0
                 "We need to destroy ourselves?");
698
0
      break;
699
0
    }
700
0
    case eHTMLImageElement: {
701
0
      SetAsHTMLImageElement() = aOther.GetAsHTMLImageElement();
702
0
      break;
703
0
    }
704
0
    case eSVGImageElement: {
705
0
      SetAsSVGImageElement() = aOther.GetAsSVGImageElement();
706
0
      break;
707
0
    }
708
0
    case eHTMLCanvasElement: {
709
0
      SetAsHTMLCanvasElement() = aOther.GetAsHTMLCanvasElement();
710
0
      break;
711
0
    }
712
0
    case eHTMLVideoElement: {
713
0
      SetAsHTMLVideoElement() = aOther.GetAsHTMLVideoElement();
714
0
      break;
715
0
    }
716
0
    case eImageBitmap: {
717
0
      SetAsImageBitmap() = aOther.GetAsImageBitmap();
718
0
      break;
719
0
    }
720
0
  }
721
0
  return *this;
722
0
}
723
724
725
726
HitRegionOptions::HitRegionOptions()
727
0
{
728
0
  // Safe to pass a null context if we pass a null value
729
0
  Init(nullptr, JS::NullHandleValue);
730
0
}
731
732
733
734
bool
735
HitRegionOptions::InitIds(JSContext* cx, HitRegionOptionsAtoms* atomsCache)
736
0
{
737
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
738
0
739
0
  // Initialize these in reverse order so that any failure leaves the first one
740
0
  // uninitialized.
741
0
  if (!atomsCache->path_id.init(cx, "path") ||
742
0
      !atomsCache->id_id.init(cx, "id") ||
743
0
      !atomsCache->control_id.init(cx, "control")) {
744
0
    return false;
745
0
  }
746
0
  return true;
747
0
}
748
749
bool
750
HitRegionOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
751
0
{
752
0
  // Passing a null JSContext is OK only if we're initing from null,
753
0
  // Since in that case we will not have to do any property gets
754
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
755
0
  // checkers by static analysis tools
756
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
757
0
  HitRegionOptionsAtoms* atomsCache = nullptr;
758
0
  if (cx) {
759
0
    atomsCache = GetAtomCache<HitRegionOptionsAtoms>(cx);
760
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
761
0
      return false;
762
0
    }
763
0
  }
764
0
765
0
  if (!IsConvertibleToDictionary(val)) {
766
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
767
0
  }
768
0
769
0
  bool isNull = val.isNullOrUndefined();
770
0
  // We only need these if !isNull, in which case we have |cx|.
771
0
  Maybe<JS::Rooted<JSObject *> > object;
772
0
  Maybe<JS::Rooted<JS::Value> > temp;
773
0
  if (!isNull) {
774
0
    MOZ_ASSERT(cx);
775
0
    object.emplace(cx, &val.toObject());
776
0
    temp.emplace(cx);
777
0
  }
778
0
  if (!isNull) {
779
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->control_id, temp.ptr())) {
780
0
      return false;
781
0
    }
782
0
  }
783
0
  if (!isNull && !temp->isUndefined()) {
784
0
    if (temp.ref().isObject()) {
785
0
      static_assert(IsRefcounted<mozilla::dom::Element>::value, "We can only store refcounted classes.");{
786
0
        nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(temp.ptr(), mControl);
787
0
        if (NS_FAILED(rv)) {
788
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'control' member of HitRegionOptions", "Element");
789
0
          return false;
790
0
        }
791
0
      }
792
0
    } else if (temp.ref().isNullOrUndefined()) {
793
0
      mControl = nullptr;
794
0
    } else {
795
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'control' member of HitRegionOptions");
796
0
      return false;
797
0
    }
798
0
  } else {
799
0
    mControl = nullptr;
800
0
  }
801
0
  mIsAnyMemberPresent = true;
802
0
803
0
  if (!isNull) {
804
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->id_id, temp.ptr())) {
805
0
      return false;
806
0
    }
807
0
  }
808
0
  if (!isNull && !temp->isUndefined()) {
809
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mId)) {
810
0
      return false;
811
0
    }
812
0
  } else {
813
0
    static const char16_t data[] = { 0 };
814
0
    mId.Rebind(data, ArrayLength(data) - 1);
815
0
  }
816
0
  mIsAnyMemberPresent = true;
817
0
818
0
  if (!isNull) {
819
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->path_id, temp.ptr())) {
820
0
      return false;
821
0
    }
822
0
  }
823
0
  if (!isNull && !temp->isUndefined()) {
824
0
    if (temp.ref().isObject()) {
825
0
      static_assert(IsRefcounted<mozilla::dom::CanvasPath>::value, "We can only store refcounted classes.");{
826
0
        nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(temp.ptr(), mPath);
827
0
        if (NS_FAILED(rv)) {
828
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'path' member of HitRegionOptions", "Path2D");
829
0
          return false;
830
0
        }
831
0
      }
832
0
    } else if (temp.ref().isNullOrUndefined()) {
833
0
      mPath = nullptr;
834
0
    } else {
835
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'path' member of HitRegionOptions");
836
0
      return false;
837
0
    }
838
0
  } else {
839
0
    mPath = nullptr;
840
0
  }
841
0
  mIsAnyMemberPresent = true;
842
0
  return true;
843
0
}
844
845
bool
846
HitRegionOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
847
0
{
848
0
  HitRegionOptionsAtoms* atomsCache = GetAtomCache<HitRegionOptionsAtoms>(cx);
849
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
850
0
    return false;
851
0
  }
852
0
853
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
854
0
  if (!obj) {
855
0
    return false;
856
0
  }
857
0
  rval.set(JS::ObjectValue(*obj));
858
0
859
0
  do {
860
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
861
0
    JS::Rooted<JS::Value> temp(cx);
862
0
    RefPtr<mozilla::dom::Element> const & currentValue = mControl;
863
0
    if (!currentValue) {
864
0
      temp.setNull();
865
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->control_id, temp, JSPROP_ENUMERATE)) {
866
0
        return false;
867
0
      }
868
0
      break;
869
0
    }
870
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
871
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
872
0
      return false;
873
0
    }
874
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->control_id, temp, JSPROP_ENUMERATE)) {
875
0
      return false;
876
0
    }
877
0
    break;
878
0
  } while(false);
879
0
880
0
  do {
881
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
882
0
    JS::Rooted<JS::Value> temp(cx);
883
0
    nsString const & currentValue = mId;
884
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
885
0
      return false;
886
0
    }
887
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->id_id, temp, JSPROP_ENUMERATE)) {
888
0
      return false;
889
0
    }
890
0
    break;
891
0
  } while(false);
892
0
893
0
  do {
894
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
895
0
    JS::Rooted<JS::Value> temp(cx);
896
0
    RefPtr<mozilla::dom::CanvasPath> const & currentValue = mPath;
897
0
    if (!currentValue) {
898
0
      temp.setNull();
899
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->path_id, temp, JSPROP_ENUMERATE)) {
900
0
        return false;
901
0
      }
902
0
      break;
903
0
    }
904
0
    if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
905
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
906
0
      return false;
907
0
    }
908
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->path_id, temp, JSPROP_ENUMERATE)) {
909
0
      return false;
910
0
    }
911
0
    break;
912
0
  } while(false);
913
0
914
0
  return true;
915
0
}
916
917
void
918
HitRegionOptions::TraceDictionary(JSTracer* trc)
919
0
{
920
0
}
921
922
923
924
HitRegionOptions&
925
HitRegionOptions::operator=(const HitRegionOptions& aOther)
926
0
{
927
0
  DictionaryBase::operator=(aOther);
928
0
  mControl = aOther.mControl;
929
0
  mId = aOther.mId;
930
0
  mPath = aOther.mPath;
931
0
  return *this;
932
0
}
933
934
namespace binding_detail {
935
} // namespace binding_detail
936
937
938
bool
939
StringOrCanvasGradientOrCanvasPattern::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
940
0
{
941
0
  switch (mType) {
942
0
    case eUninitialized: {
943
0
      return false;
944
0
      break;
945
0
    }
946
0
    case eString: {
947
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
948
0
        return false;
949
0
      }
950
0
      return true;
951
0
      break;
952
0
    }
953
0
    case eCanvasGradient: {
954
0
      if (!GetOrCreateDOMReflector(cx, mValue.mCanvasGradient.Value(), rval)) {
955
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
956
0
        return false;
957
0
      }
958
0
      return true;
959
0
      break;
960
0
    }
961
0
    case eCanvasPattern: {
962
0
      if (!GetOrCreateDOMReflector(cx, mValue.mCanvasPattern.Value(), rval)) {
963
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
964
0
        return false;
965
0
      }
966
0
      return true;
967
0
      break;
968
0
    }
969
0
    default: {
970
0
      return false;
971
0
      break;
972
0
    }
973
0
  }
974
0
975
0
  return false;
976
0
}
977
978
979
nsString&
980
OwningStringOrCanvasGradientOrCanvasPattern::RawSetAsString()
981
0
{
982
0
  if (mType == eString) {
983
0
    return mValue.mString.Value();
984
0
  }
985
0
  MOZ_ASSERT(mType == eUninitialized);
986
0
  mType = eString;
987
0
  return mValue.mString.SetValue();
988
0
}
989
990
nsString&
991
OwningStringOrCanvasGradientOrCanvasPattern::SetAsString()
992
0
{
993
0
  if (mType == eString) {
994
0
    return mValue.mString.Value();
995
0
  }
996
0
  Uninit();
997
0
  mType = eString;
998
0
  return mValue.mString.SetValue();
999
0
}
1000
1001
bool
1002
OwningStringOrCanvasGradientOrCanvasPattern::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1003
0
{
1004
0
  tryNext = false;
1005
0
  { // scope for memberSlot
1006
0
    nsString& memberSlot = RawSetAsString();
1007
0
    if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
1008
0
      return false;
1009
0
    }
1010
0
  }
1011
0
  return true;
1012
0
}
1013
1014
1015
void
1016
OwningStringOrCanvasGradientOrCanvasPattern::DestroyString()
1017
0
{
1018
0
  MOZ_ASSERT(IsString(), "Wrong type!");
1019
0
  mValue.mString.Destroy();
1020
0
  mType = eUninitialized;
1021
0
}
1022
1023
1024
1025
1026
OwningNonNull<mozilla::dom::CanvasGradient>&
1027
OwningStringOrCanvasGradientOrCanvasPattern::RawSetAsCanvasGradient()
1028
0
{
1029
0
  if (mType == eCanvasGradient) {
1030
0
    return mValue.mCanvasGradient.Value();
1031
0
  }
1032
0
  MOZ_ASSERT(mType == eUninitialized);
1033
0
  mType = eCanvasGradient;
1034
0
  return mValue.mCanvasGradient.SetValue();
1035
0
}
1036
1037
OwningNonNull<mozilla::dom::CanvasGradient>&
1038
OwningStringOrCanvasGradientOrCanvasPattern::SetAsCanvasGradient()
1039
0
{
1040
0
  if (mType == eCanvasGradient) {
1041
0
    return mValue.mCanvasGradient.Value();
1042
0
  }
1043
0
  Uninit();
1044
0
  mType = eCanvasGradient;
1045
0
  return mValue.mCanvasGradient.SetValue();
1046
0
}
1047
1048
bool
1049
OwningStringOrCanvasGradientOrCanvasPattern::TrySetToCanvasGradient(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1050
0
{
1051
0
  tryNext = false;
1052
0
  { // scope for memberSlot
1053
0
    OwningNonNull<mozilla::dom::CanvasGradient>& memberSlot = RawSetAsCanvasGradient();
1054
0
    static_assert(IsRefcounted<mozilla::dom::CanvasGradient>::value, "We can only store refcounted classes.");{
1055
0
      nsresult rv = UnwrapObject<prototypes::id::CanvasGradient, mozilla::dom::CanvasGradient>(value, memberSlot);
1056
0
      if (NS_FAILED(rv)) {
1057
0
        DestroyCanvasGradient();
1058
0
        tryNext = true;
1059
0
        return true;
1060
0
      }
1061
0
    }
1062
0
  }
1063
0
  return true;
1064
0
}
1065
1066
void
1067
OwningStringOrCanvasGradientOrCanvasPattern::DestroyCanvasGradient()
1068
0
{
1069
0
  MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
1070
0
  mValue.mCanvasGradient.Destroy();
1071
0
  mType = eUninitialized;
1072
0
}
1073
1074
1075
1076
1077
OwningNonNull<mozilla::dom::CanvasPattern>&
1078
OwningStringOrCanvasGradientOrCanvasPattern::RawSetAsCanvasPattern()
1079
0
{
1080
0
  if (mType == eCanvasPattern) {
1081
0
    return mValue.mCanvasPattern.Value();
1082
0
  }
1083
0
  MOZ_ASSERT(mType == eUninitialized);
1084
0
  mType = eCanvasPattern;
1085
0
  return mValue.mCanvasPattern.SetValue();
1086
0
}
1087
1088
OwningNonNull<mozilla::dom::CanvasPattern>&
1089
OwningStringOrCanvasGradientOrCanvasPattern::SetAsCanvasPattern()
1090
0
{
1091
0
  if (mType == eCanvasPattern) {
1092
0
    return mValue.mCanvasPattern.Value();
1093
0
  }
1094
0
  Uninit();
1095
0
  mType = eCanvasPattern;
1096
0
  return mValue.mCanvasPattern.SetValue();
1097
0
}
1098
1099
bool
1100
OwningStringOrCanvasGradientOrCanvasPattern::TrySetToCanvasPattern(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1101
0
{
1102
0
  tryNext = false;
1103
0
  { // scope for memberSlot
1104
0
    OwningNonNull<mozilla::dom::CanvasPattern>& memberSlot = RawSetAsCanvasPattern();
1105
0
    static_assert(IsRefcounted<mozilla::dom::CanvasPattern>::value, "We can only store refcounted classes.");{
1106
0
      nsresult rv = UnwrapObject<prototypes::id::CanvasPattern, mozilla::dom::CanvasPattern>(value, memberSlot);
1107
0
      if (NS_FAILED(rv)) {
1108
0
        DestroyCanvasPattern();
1109
0
        tryNext = true;
1110
0
        return true;
1111
0
      }
1112
0
    }
1113
0
  }
1114
0
  return true;
1115
0
}
1116
1117
void
1118
OwningStringOrCanvasGradientOrCanvasPattern::DestroyCanvasPattern()
1119
0
{
1120
0
  MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
1121
0
  mValue.mCanvasPattern.Destroy();
1122
0
  mType = eUninitialized;
1123
0
}
1124
1125
1126
1127
1128
void
1129
OwningStringOrCanvasGradientOrCanvasPattern::Uninit()
1130
{
1131
  switch (mType) {
1132
    case eUninitialized: {
1133
      break;
1134
    }
1135
    case eString: {
1136
      DestroyString();
1137
      break;
1138
    }
1139
    case eCanvasGradient: {
1140
      DestroyCanvasGradient();
1141
      break;
1142
    }
1143
    case eCanvasPattern: {
1144
      DestroyCanvasPattern();
1145
      break;
1146
    }
1147
  }
1148
}
1149
1150
bool
1151
OwningStringOrCanvasGradientOrCanvasPattern::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
1152
0
{
1153
0
  switch (mType) {
1154
0
    case eUninitialized: {
1155
0
      return false;
1156
0
      break;
1157
0
    }
1158
0
    case eString: {
1159
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
1160
0
        return false;
1161
0
      }
1162
0
      return true;
1163
0
      break;
1164
0
    }
1165
0
    case eCanvasGradient: {
1166
0
      if (!GetOrCreateDOMReflector(cx, mValue.mCanvasGradient.Value(), rval)) {
1167
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
1168
0
        return false;
1169
0
      }
1170
0
      return true;
1171
0
      break;
1172
0
    }
1173
0
    case eCanvasPattern: {
1174
0
      if (!GetOrCreateDOMReflector(cx, mValue.mCanvasPattern.Value(), rval)) {
1175
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
1176
0
        return false;
1177
0
      }
1178
0
      return true;
1179
0
      break;
1180
0
    }
1181
0
    default: {
1182
0
      return false;
1183
0
      break;
1184
0
    }
1185
0
  }
1186
0
1187
0
  return false;
1188
0
}
1189
1190
void
1191
OwningStringOrCanvasGradientOrCanvasPattern::TraceUnion(JSTracer* trc)
1192
0
{
1193
0
}
1194
1195
OwningStringOrCanvasGradientOrCanvasPattern&
1196
OwningStringOrCanvasGradientOrCanvasPattern::operator=(const OwningStringOrCanvasGradientOrCanvasPattern& aOther)
1197
0
{
1198
0
  switch (aOther.mType) {
1199
0
    case eUninitialized: {
1200
0
      MOZ_ASSERT(mType == eUninitialized,
1201
0
                 "We need to destroy ourselves?");
1202
0
      break;
1203
0
    }
1204
0
    case eString: {
1205
0
      SetAsString() = aOther.GetAsString();
1206
0
      break;
1207
0
    }
1208
0
    case eCanvasGradient: {
1209
0
      SetAsCanvasGradient() = aOther.GetAsCanvasGradient();
1210
0
      break;
1211
0
    }
1212
0
    case eCanvasPattern: {
1213
0
      SetAsCanvasPattern() = aOther.GetAsCanvasPattern();
1214
0
      break;
1215
0
    }
1216
0
  }
1217
0
  return *this;
1218
0
}
1219
1220
1221
namespace CanvasGradient_Binding {
1222
1223
MOZ_CAN_RUN_SCRIPT static bool
1224
addColorStop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasGradient* self, const JSJitMethodCallArgs& args)
1225
0
{
1226
0
  AUTO_PROFILER_LABEL_FAST("CanvasGradient.addColorStop", DOM, cx);
1227
0
1228
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
1229
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasGradient.addColorStop");
1230
0
  }
1231
0
  float arg0;
1232
0
  if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
1233
0
    return false;
1234
0
  } else if (!mozilla::IsFinite(arg0)) {
1235
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasGradient.addColorStop");
1236
0
    return false;
1237
0
  }
1238
0
  binding_detail::FakeString arg1;
1239
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
1240
0
    return false;
1241
0
  }
1242
0
  FastErrorResult rv;
1243
0
  self->AddColorStop(arg0, NonNullHelper(Constify(arg1)), rv);
1244
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1245
0
    return false;
1246
0
  }
1247
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1248
0
  args.rval().setUndefined();
1249
0
  return true;
1250
0
}
1251
1252
static const JSJitInfo addColorStop_methodinfo = {
1253
  { (JSJitGetterOp)addColorStop },
1254
  { prototypes::id::CanvasGradient },
1255
  { PrototypeTraits<prototypes::id::CanvasGradient>::Depth },
1256
  JSJitInfo::Method,
1257
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1258
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1259
  false,  /* isInfallible. False in setters. */
1260
  false,  /* isMovable.  Not relevant for setters. */
1261
  false, /* isEliminatable.  Not relevant for setters. */
1262
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1263
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1264
  false,  /* isTypedMethod.  Only relevant for methods. */
1265
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1266
};
1267
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1268
static_assert(0 < 1, "There is no slot for us");
1269
1270
static bool
1271
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1272
0
{
1273
0
  mozilla::dom::CanvasGradient* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasGradient>(obj);
1274
0
  // We don't want to preserve if we don't have a wrapper, and we
1275
0
  // obviously can't preserve if we're not initialized.
1276
0
  if (self && self->GetWrapperPreserveColor()) {
1277
0
    PreserveWrapper(self);
1278
0
  }
1279
0
  return true;
1280
0
}
1281
1282
static void
1283
_finalize(js::FreeOp* fop, JSObject* obj)
1284
0
{
1285
0
  mozilla::dom::CanvasGradient* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasGradient>(obj);
1286
0
  if (self) {
1287
0
    ClearWrapper(self, self, obj);
1288
0
    AddForDeferredFinalization<mozilla::dom::CanvasGradient>(self);
1289
0
  }
1290
0
}
1291
1292
static size_t
1293
_objectMoved(JSObject* obj, JSObject* old)
1294
0
{
1295
0
  mozilla::dom::CanvasGradient* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasGradient>(obj);
1296
0
  if (self) {
1297
0
    UpdateWrapper(self, self, obj, old);
1298
0
  }
1299
0
1300
0
  return 0;
1301
0
}
1302
1303
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1304
#if defined(__clang__)
1305
#pragma clang diagnostic push
1306
#pragma clang diagnostic ignored "-Wmissing-braces"
1307
#endif
1308
static const JSFunctionSpec sMethods_specs[] = {
1309
  JS_FNSPEC("addColorStop", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addColorStop_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1310
  JS_FS_END
1311
};
1312
#if defined(__clang__)
1313
#pragma clang diagnostic pop
1314
#endif
1315
1316
1317
static const Prefable<const JSFunctionSpec> sMethods[] = {
1318
  { nullptr, &sMethods_specs[0] },
1319
  { nullptr, nullptr }
1320
};
1321
1322
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1323
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1324
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1325
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1326
1327
1328
static uint16_t sNativeProperties_sortedPropertyIndices[1];
1329
static PropertyInfo sNativeProperties_propertyInfos[1];
1330
1331
static const NativePropertiesN<1> sNativeProperties = {
1332
  false, 0,
1333
  false, 0,
1334
  true,  0 /* sMethods */,
1335
  false, 0,
1336
  false, 0,
1337
  false, 0,
1338
  false, 0,
1339
  -1,
1340
  1,
1341
  sNativeProperties_sortedPropertyIndices,
1342
  {
1343
    { sMethods, &sNativeProperties_propertyInfos[0] }
1344
  }
1345
};
1346
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1347
    "We have a property info count that is oversized");
1348
1349
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1350
  {
1351
    "Function",
1352
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1353
    &sBoringInterfaceObjectClassClassOps,
1354
    JS_NULL_CLASS_SPEC,
1355
    JS_NULL_CLASS_EXT,
1356
    &sInterfaceObjectClassObjectOps
1357
  },
1358
  eInterface,
1359
  true,
1360
  prototypes::id::CanvasGradient,
1361
  PrototypeTraits<prototypes::id::CanvasGradient>::Depth,
1362
  sNativePropertyHooks,
1363
  "function CanvasGradient() {\n    [native code]\n}",
1364
  JS::GetRealmFunctionPrototype
1365
};
1366
1367
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1368
  {
1369
    "CanvasGradientPrototype",
1370
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1371
    JS_NULL_CLASS_OPS,
1372
    JS_NULL_CLASS_SPEC,
1373
    JS_NULL_CLASS_EXT,
1374
    JS_NULL_OBJECT_OPS
1375
  },
1376
  eInterfacePrototype,
1377
  false,
1378
  prototypes::id::CanvasGradient,
1379
  PrototypeTraits<prototypes::id::CanvasGradient>::Depth,
1380
  sNativePropertyHooks,
1381
  "[object CanvasGradientPrototype]",
1382
  JS::GetRealmObjectPrototype
1383
};
1384
1385
static const js::ClassOps sClassOps = {
1386
  _addProperty, /* addProperty */
1387
  nullptr,               /* delProperty */
1388
  nullptr,               /* enumerate */
1389
  nullptr, /* newEnumerate */
1390
  nullptr, /* resolve */
1391
  nullptr, /* mayResolve */
1392
  _finalize, /* finalize */
1393
  nullptr, /* call */
1394
  nullptr,               /* hasInstance */
1395
  nullptr,               /* construct */
1396
  nullptr, /* trace */
1397
};
1398
1399
static const js::ClassExtension sClassExtension = {
1400
  nullptr, /* weakmapKeyDelegateOp */
1401
  _objectMoved /* objectMovedOp */
1402
};
1403
1404
static const DOMJSClass sClass = {
1405
  { "CanvasGradient",
1406
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1407
    &sClassOps,
1408
    JS_NULL_CLASS_SPEC,
1409
    &sClassExtension,
1410
    JS_NULL_OBJECT_OPS
1411
  },
1412
  { prototypes::id::CanvasGradient, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1413
  IsBaseOf<nsISupports, mozilla::dom::CanvasGradient >::value,
1414
  sNativePropertyHooks,
1415
  FindAssociatedGlobalForNative<mozilla::dom::CanvasGradient>::Get,
1416
  GetProtoObjectHandle,
1417
  GetCCParticipant<mozilla::dom::CanvasGradient>::Get()
1418
};
1419
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1420
              "Must have the right minimal number of reserved slots.");
1421
static_assert(1 >= 1,
1422
              "Must have enough reserved slots.");
1423
1424
const JSClass*
1425
GetJSClass()
1426
0
{
1427
0
  return sClass.ToJSClass();
1428
0
}
1429
1430
bool
1431
Wrap(JSContext* aCx, mozilla::dom::CanvasGradient* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1432
0
{
1433
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CanvasGradient>::value,
1434
0
                "Shouldn't have wrappercached things that are not refcounted.");
1435
0
  MOZ_ASSERT(static_cast<mozilla::dom::CanvasGradient*>(aObject) ==
1436
0
             reinterpret_cast<mozilla::dom::CanvasGradient*>(aObject),
1437
0
             "Multiple inheritance for mozilla::dom::CanvasGradient is broken.");
1438
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1439
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1440
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1441
0
             "You should probably not be using Wrap() directly; use "
1442
0
             "GetOrCreateDOMReflector instead");
1443
0
1444
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1445
0
             "nsISupports must be on our primary inheritance chain");
1446
0
1447
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1448
0
  if (!global) {
1449
0
    return false;
1450
0
  }
1451
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1452
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1453
0
1454
0
  // That might have ended up wrapping us already, due to the wonders
1455
0
  // of XBL.  Check for that, and bail out as needed.
1456
0
  aReflector.set(aCache->GetWrapper());
1457
0
  if (aReflector) {
1458
#ifdef DEBUG
1459
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1460
#endif // DEBUG
1461
    return true;
1462
0
  }
1463
0
1464
0
  JSAutoRealm ar(aCx, global);
1465
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1466
0
  if (!canonicalProto) {
1467
0
    return false;
1468
0
  }
1469
0
  JS::Rooted<JSObject*> proto(aCx);
1470
0
  if (aGivenProto) {
1471
0
    proto = aGivenProto;
1472
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1473
0
    // coming in, we changed compartments to that of "parent" so may need
1474
0
    // to wrap the proto here.
1475
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1476
0
      if (!JS_WrapObject(aCx, &proto)) {
1477
0
        return false;
1478
0
      }
1479
0
    }
1480
0
  } else {
1481
0
    proto = canonicalProto;
1482
0
  }
1483
0
1484
0
  BindingJSObjectCreator<mozilla::dom::CanvasGradient> creator(aCx);
1485
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1486
0
  if (!aReflector) {
1487
0
    return false;
1488
0
  }
1489
0
1490
0
  aCache->SetWrapper(aReflector);
1491
0
  creator.InitializationSucceeded();
1492
0
1493
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1494
0
             aCache->GetWrapperPreserveColor() == aReflector);
1495
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1496
0
  // otherwise we won't be able to properly recreate it later, since
1497
0
  // we won't know what proto to use.  Note that we don't check
1498
0
  // aGivenProto here, since it's entirely possible (and even
1499
0
  // somewhat common) to have a non-null aGivenProto which is the
1500
0
  // same as canonicalProto.
1501
0
  if (proto != canonicalProto) {
1502
0
    PreserveWrapper(aObject);
1503
0
  }
1504
0
1505
0
  return true;
1506
0
}
1507
1508
const NativePropertyHooks sNativePropertyHooks[] = { {
1509
  nullptr,
1510
  nullptr,
1511
  nullptr,
1512
  { sNativeProperties.Upcast(), nullptr },
1513
  prototypes::id::CanvasGradient,
1514
  constructors::id::CanvasGradient,
1515
  nullptr,
1516
  &DefaultXrayExpandoObjectClass
1517
} };
1518
1519
void
1520
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1521
0
{
1522
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1523
0
  if (!parentProto) {
1524
0
    return;
1525
0
  }
1526
0
1527
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1528
0
  if (!constructorProto) {
1529
0
    return;
1530
0
  }
1531
0
1532
0
  static bool sIdsInited = false;
1533
0
  if (!sIdsInited && NS_IsMainThread()) {
1534
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1535
0
      return;
1536
0
    }
1537
0
    sIdsInited = true;
1538
0
  }
1539
0
1540
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CanvasGradient);
1541
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CanvasGradient);
1542
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1543
0
                              &sPrototypeClass.mBase, protoCache,
1544
0
                              nullptr,
1545
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1546
0
                              interfaceCache,
1547
0
                              sNativeProperties.Upcast(),
1548
0
                              nullptr,
1549
0
                              "CanvasGradient", aDefineOnGlobal,
1550
0
                              nullptr,
1551
0
                              false);
1552
0
}
1553
1554
JSObject*
1555
GetConstructorObject(JSContext* aCx)
1556
0
{
1557
0
  return GetConstructorObjectHandle(aCx);
1558
0
}
1559
1560
} // namespace CanvasGradient_Binding
1561
1562
1563
1564
namespace CanvasPattern_Binding {
1565
1566
MOZ_CAN_RUN_SCRIPT static bool
1567
setTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPattern* self, const JSJitMethodCallArgs& args)
1568
0
{
1569
0
  AUTO_PROFILER_LABEL_FAST("CanvasPattern.setTransform", DOM, cx);
1570
0
1571
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
1572
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasPattern.setTransform");
1573
0
  }
1574
0
  NonNull<mozilla::dom::SVGMatrix> arg0;
1575
0
  if (args[0].isObject()) {
1576
0
    {
1577
0
      nsresult rv = UnwrapObject<prototypes::id::SVGMatrix, mozilla::dom::SVGMatrix>(args[0], arg0);
1578
0
      if (NS_FAILED(rv)) {
1579
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasPattern.setTransform", "SVGMatrix");
1580
0
        return false;
1581
0
      }
1582
0
    }
1583
0
  } else {
1584
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasPattern.setTransform");
1585
0
    return false;
1586
0
  }
1587
0
  self->SetTransform(MOZ_KnownLive(NonNullHelper(arg0)));
1588
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1589
0
  args.rval().setUndefined();
1590
0
  return true;
1591
0
}
1592
1593
static const JSJitInfo setTransform_methodinfo = {
1594
  { (JSJitGetterOp)setTransform },
1595
  { prototypes::id::CanvasPattern },
1596
  { PrototypeTraits<prototypes::id::CanvasPattern>::Depth },
1597
  JSJitInfo::Method,
1598
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1599
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1600
  false,  /* isInfallible. False in setters. */
1601
  false,  /* isMovable.  Not relevant for setters. */
1602
  false, /* isEliminatable.  Not relevant for setters. */
1603
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1604
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1605
  false,  /* isTypedMethod.  Only relevant for methods. */
1606
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1607
};
1608
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1609
static_assert(0 < 1, "There is no slot for us");
1610
1611
static bool
1612
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1613
0
{
1614
0
  mozilla::dom::CanvasPattern* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPattern>(obj);
1615
0
  // We don't want to preserve if we don't have a wrapper, and we
1616
0
  // obviously can't preserve if we're not initialized.
1617
0
  if (self && self->GetWrapperPreserveColor()) {
1618
0
    PreserveWrapper(self);
1619
0
  }
1620
0
  return true;
1621
0
}
1622
1623
static void
1624
_finalize(js::FreeOp* fop, JSObject* obj)
1625
0
{
1626
0
  mozilla::dom::CanvasPattern* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPattern>(obj);
1627
0
  if (self) {
1628
0
    ClearWrapper(self, self, obj);
1629
0
    AddForDeferredFinalization<mozilla::dom::CanvasPattern>(self);
1630
0
  }
1631
0
}
1632
1633
static size_t
1634
_objectMoved(JSObject* obj, JSObject* old)
1635
0
{
1636
0
  mozilla::dom::CanvasPattern* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPattern>(obj);
1637
0
  if (self) {
1638
0
    UpdateWrapper(self, self, obj, old);
1639
0
  }
1640
0
1641
0
  return 0;
1642
0
}
1643
1644
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1645
#if defined(__clang__)
1646
#pragma clang diagnostic push
1647
#pragma clang diagnostic ignored "-Wmissing-braces"
1648
#endif
1649
static const JSFunctionSpec sMethods_specs[] = {
1650
  JS_FNSPEC("setTransform", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setTransform_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1651
  JS_FS_END
1652
};
1653
#if defined(__clang__)
1654
#pragma clang diagnostic pop
1655
#endif
1656
1657
1658
static const Prefable<const JSFunctionSpec> sMethods[] = {
1659
  { nullptr, &sMethods_specs[0] },
1660
  { nullptr, nullptr }
1661
};
1662
1663
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1664
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1665
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1666
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1667
1668
1669
static uint16_t sNativeProperties_sortedPropertyIndices[1];
1670
static PropertyInfo sNativeProperties_propertyInfos[1];
1671
1672
static const NativePropertiesN<1> sNativeProperties = {
1673
  false, 0,
1674
  false, 0,
1675
  true,  0 /* sMethods */,
1676
  false, 0,
1677
  false, 0,
1678
  false, 0,
1679
  false, 0,
1680
  -1,
1681
  1,
1682
  sNativeProperties_sortedPropertyIndices,
1683
  {
1684
    { sMethods, &sNativeProperties_propertyInfos[0] }
1685
  }
1686
};
1687
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1688
    "We have a property info count that is oversized");
1689
1690
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1691
  {
1692
    "Function",
1693
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1694
    &sBoringInterfaceObjectClassClassOps,
1695
    JS_NULL_CLASS_SPEC,
1696
    JS_NULL_CLASS_EXT,
1697
    &sInterfaceObjectClassObjectOps
1698
  },
1699
  eInterface,
1700
  true,
1701
  prototypes::id::CanvasPattern,
1702
  PrototypeTraits<prototypes::id::CanvasPattern>::Depth,
1703
  sNativePropertyHooks,
1704
  "function CanvasPattern() {\n    [native code]\n}",
1705
  JS::GetRealmFunctionPrototype
1706
};
1707
1708
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1709
  {
1710
    "CanvasPatternPrototype",
1711
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1712
    JS_NULL_CLASS_OPS,
1713
    JS_NULL_CLASS_SPEC,
1714
    JS_NULL_CLASS_EXT,
1715
    JS_NULL_OBJECT_OPS
1716
  },
1717
  eInterfacePrototype,
1718
  false,
1719
  prototypes::id::CanvasPattern,
1720
  PrototypeTraits<prototypes::id::CanvasPattern>::Depth,
1721
  sNativePropertyHooks,
1722
  "[object CanvasPatternPrototype]",
1723
  JS::GetRealmObjectPrototype
1724
};
1725
1726
static const js::ClassOps sClassOps = {
1727
  _addProperty, /* addProperty */
1728
  nullptr,               /* delProperty */
1729
  nullptr,               /* enumerate */
1730
  nullptr, /* newEnumerate */
1731
  nullptr, /* resolve */
1732
  nullptr, /* mayResolve */
1733
  _finalize, /* finalize */
1734
  nullptr, /* call */
1735
  nullptr,               /* hasInstance */
1736
  nullptr,               /* construct */
1737
  nullptr, /* trace */
1738
};
1739
1740
static const js::ClassExtension sClassExtension = {
1741
  nullptr, /* weakmapKeyDelegateOp */
1742
  _objectMoved /* objectMovedOp */
1743
};
1744
1745
static const DOMJSClass sClass = {
1746
  { "CanvasPattern",
1747
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1748
    &sClassOps,
1749
    JS_NULL_CLASS_SPEC,
1750
    &sClassExtension,
1751
    JS_NULL_OBJECT_OPS
1752
  },
1753
  { prototypes::id::CanvasPattern, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1754
  IsBaseOf<nsISupports, mozilla::dom::CanvasPattern >::value,
1755
  sNativePropertyHooks,
1756
  FindAssociatedGlobalForNative<mozilla::dom::CanvasPattern>::Get,
1757
  GetProtoObjectHandle,
1758
  GetCCParticipant<mozilla::dom::CanvasPattern>::Get()
1759
};
1760
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1761
              "Must have the right minimal number of reserved slots.");
1762
static_assert(1 >= 1,
1763
              "Must have enough reserved slots.");
1764
1765
const JSClass*
1766
GetJSClass()
1767
0
{
1768
0
  return sClass.ToJSClass();
1769
0
}
1770
1771
bool
1772
Wrap(JSContext* aCx, mozilla::dom::CanvasPattern* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1773
0
{
1774
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CanvasPattern>::value,
1775
0
                "Shouldn't have wrappercached things that are not refcounted.");
1776
0
  MOZ_ASSERT(static_cast<mozilla::dom::CanvasPattern*>(aObject) ==
1777
0
             reinterpret_cast<mozilla::dom::CanvasPattern*>(aObject),
1778
0
             "Multiple inheritance for mozilla::dom::CanvasPattern is broken.");
1779
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1780
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1781
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1782
0
             "You should probably not be using Wrap() directly; use "
1783
0
             "GetOrCreateDOMReflector instead");
1784
0
1785
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1786
0
             "nsISupports must be on our primary inheritance chain");
1787
0
1788
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1789
0
  if (!global) {
1790
0
    return false;
1791
0
  }
1792
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1793
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1794
0
1795
0
  // That might have ended up wrapping us already, due to the wonders
1796
0
  // of XBL.  Check for that, and bail out as needed.
1797
0
  aReflector.set(aCache->GetWrapper());
1798
0
  if (aReflector) {
1799
#ifdef DEBUG
1800
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1801
#endif // DEBUG
1802
    return true;
1803
0
  }
1804
0
1805
0
  JSAutoRealm ar(aCx, global);
1806
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1807
0
  if (!canonicalProto) {
1808
0
    return false;
1809
0
  }
1810
0
  JS::Rooted<JSObject*> proto(aCx);
1811
0
  if (aGivenProto) {
1812
0
    proto = aGivenProto;
1813
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1814
0
    // coming in, we changed compartments to that of "parent" so may need
1815
0
    // to wrap the proto here.
1816
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1817
0
      if (!JS_WrapObject(aCx, &proto)) {
1818
0
        return false;
1819
0
      }
1820
0
    }
1821
0
  } else {
1822
0
    proto = canonicalProto;
1823
0
  }
1824
0
1825
0
  BindingJSObjectCreator<mozilla::dom::CanvasPattern> creator(aCx);
1826
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1827
0
  if (!aReflector) {
1828
0
    return false;
1829
0
  }
1830
0
1831
0
  aCache->SetWrapper(aReflector);
1832
0
  creator.InitializationSucceeded();
1833
0
1834
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1835
0
             aCache->GetWrapperPreserveColor() == aReflector);
1836
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1837
0
  // otherwise we won't be able to properly recreate it later, since
1838
0
  // we won't know what proto to use.  Note that we don't check
1839
0
  // aGivenProto here, since it's entirely possible (and even
1840
0
  // somewhat common) to have a non-null aGivenProto which is the
1841
0
  // same as canonicalProto.
1842
0
  if (proto != canonicalProto) {
1843
0
    PreserveWrapper(aObject);
1844
0
  }
1845
0
1846
0
  return true;
1847
0
}
1848
1849
const NativePropertyHooks sNativePropertyHooks[] = { {
1850
  nullptr,
1851
  nullptr,
1852
  nullptr,
1853
  { sNativeProperties.Upcast(), nullptr },
1854
  prototypes::id::CanvasPattern,
1855
  constructors::id::CanvasPattern,
1856
  nullptr,
1857
  &DefaultXrayExpandoObjectClass
1858
} };
1859
1860
void
1861
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1862
0
{
1863
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1864
0
  if (!parentProto) {
1865
0
    return;
1866
0
  }
1867
0
1868
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1869
0
  if (!constructorProto) {
1870
0
    return;
1871
0
  }
1872
0
1873
0
  static bool sIdsInited = false;
1874
0
  if (!sIdsInited && NS_IsMainThread()) {
1875
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1876
0
      return;
1877
0
    }
1878
0
    sIdsInited = true;
1879
0
  }
1880
0
1881
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CanvasPattern);
1882
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CanvasPattern);
1883
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1884
0
                              &sPrototypeClass.mBase, protoCache,
1885
0
                              nullptr,
1886
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1887
0
                              interfaceCache,
1888
0
                              sNativeProperties.Upcast(),
1889
0
                              nullptr,
1890
0
                              "CanvasPattern", aDefineOnGlobal,
1891
0
                              nullptr,
1892
0
                              false);
1893
0
}
1894
1895
JSObject*
1896
GetConstructorObject(JSContext* aCx)
1897
0
{
1898
0
  return GetConstructorObjectHandle(aCx);
1899
0
}
1900
1901
} // namespace CanvasPattern_Binding
1902
1903
1904
1905
namespace CanvasRenderingContext2D_Binding {
1906
1907
MOZ_CAN_RUN_SCRIPT static bool
1908
get_canvas(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
1909
0
{
1910
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.canvas", DOM, cx);
1911
0
1912
0
  auto result(StrongOrRawPtr<mozilla::dom::HTMLCanvasElement>(self->GetCanvas()));
1913
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1914
0
  if (!result) {
1915
0
    args.rval().setNull();
1916
0
    return true;
1917
0
  }
1918
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1919
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1920
0
    return false;
1921
0
  }
1922
0
  return true;
1923
0
}
1924
1925
static const JSJitInfo canvas_getterinfo = {
1926
  { (JSJitGetterOp)get_canvas },
1927
  { prototypes::id::CanvasRenderingContext2D },
1928
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
1929
  JSJitInfo::Getter,
1930
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1931
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1932
  false,  /* isInfallible. False in setters. */
1933
  false,  /* isMovable.  Not relevant for setters. */
1934
  false, /* isEliminatable.  Not relevant for setters. */
1935
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1936
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1937
  false,  /* isTypedMethod.  Only relevant for methods. */
1938
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1939
};
1940
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1941
static_assert(0 < 1, "There is no slot for us");
1942
1943
MOZ_CAN_RUN_SCRIPT static bool
1944
get_mozCurrentTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
1945
0
{
1946
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.mozCurrentTransform", DOM, cx);
1947
0
1948
0
  FastErrorResult rv;
1949
0
  JS::Rooted<JSObject*> result(cx);
1950
0
  self->GetMozCurrentTransform(cx, &result, rv);
1951
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1952
0
    return false;
1953
0
  }
1954
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1955
0
  JS::ExposeObjectToActiveJS(result);
1956
0
  args.rval().setObject(*result);
1957
0
  if (!MaybeWrapObjectValue(cx, args.rval())) {
1958
0
    return false;
1959
0
  }
1960
0
  return true;
1961
0
}
1962
1963
MOZ_CAN_RUN_SCRIPT static bool
1964
set_mozCurrentTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
1965
0
{
1966
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.mozCurrentTransform", DOM, cx);
1967
0
1968
0
  JS::Rooted<JSObject*> arg0(cx);
1969
0
  if (args[0].isObject()) {
1970
0
    arg0 = &args[0].toObject();
1971
0
  } else {
1972
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to CanvasRenderingContext2D.mozCurrentTransform");
1973
0
    return false;
1974
0
  }
1975
0
  FastErrorResult rv;
1976
0
  self->SetMozCurrentTransform(cx, arg0, rv);
1977
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1978
0
    return false;
1979
0
  }
1980
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1981
0
1982
0
  return true;
1983
0
}
1984
1985
static const JSJitInfo mozCurrentTransform_getterinfo = {
1986
  { (JSJitGetterOp)get_mozCurrentTransform },
1987
  { prototypes::id::CanvasRenderingContext2D },
1988
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
1989
  JSJitInfo::Getter,
1990
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1991
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1992
  false,  /* isInfallible. False in setters. */
1993
  false,  /* isMovable.  Not relevant for setters. */
1994
  false, /* isEliminatable.  Not relevant for setters. */
1995
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1996
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1997
  false,  /* isTypedMethod.  Only relevant for methods. */
1998
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1999
};
2000
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2001
static_assert(0 < 1, "There is no slot for us");
2002
static const JSJitInfo mozCurrentTransform_setterinfo = {
2003
  { (JSJitGetterOp)set_mozCurrentTransform },
2004
  { prototypes::id::CanvasRenderingContext2D },
2005
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2006
  JSJitInfo::Setter,
2007
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2008
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2009
  false,  /* isInfallible. False in setters. */
2010
  false,  /* isMovable.  Not relevant for setters. */
2011
  false, /* isEliminatable.  Not relevant for setters. */
2012
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2013
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2014
  false,  /* isTypedMethod.  Only relevant for methods. */
2015
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2016
};
2017
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2018
static_assert(0 < 1, "There is no slot for us");
2019
2020
MOZ_CAN_RUN_SCRIPT static bool
2021
get_mozCurrentTransformInverse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
2022
0
{
2023
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.mozCurrentTransformInverse", DOM, cx);
2024
0
2025
0
  FastErrorResult rv;
2026
0
  JS::Rooted<JSObject*> result(cx);
2027
0
  self->GetMozCurrentTransformInverse(cx, &result, rv);
2028
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2029
0
    return false;
2030
0
  }
2031
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2032
0
  JS::ExposeObjectToActiveJS(result);
2033
0
  args.rval().setObject(*result);
2034
0
  if (!MaybeWrapObjectValue(cx, args.rval())) {
2035
0
    return false;
2036
0
  }
2037
0
  return true;
2038
0
}
2039
2040
MOZ_CAN_RUN_SCRIPT static bool
2041
set_mozCurrentTransformInverse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
2042
0
{
2043
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.mozCurrentTransformInverse", DOM, cx);
2044
0
2045
0
  JS::Rooted<JSObject*> arg0(cx);
2046
0
  if (args[0].isObject()) {
2047
0
    arg0 = &args[0].toObject();
2048
0
  } else {
2049
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to CanvasRenderingContext2D.mozCurrentTransformInverse");
2050
0
    return false;
2051
0
  }
2052
0
  FastErrorResult rv;
2053
0
  self->SetMozCurrentTransformInverse(cx, arg0, rv);
2054
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2055
0
    return false;
2056
0
  }
2057
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2058
0
2059
0
  return true;
2060
0
}
2061
2062
static const JSJitInfo mozCurrentTransformInverse_getterinfo = {
2063
  { (JSJitGetterOp)get_mozCurrentTransformInverse },
2064
  { prototypes::id::CanvasRenderingContext2D },
2065
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2066
  JSJitInfo::Getter,
2067
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2068
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
2069
  false,  /* isInfallible. False in setters. */
2070
  false,  /* isMovable.  Not relevant for setters. */
2071
  false, /* isEliminatable.  Not relevant for setters. */
2072
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2073
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2074
  false,  /* isTypedMethod.  Only relevant for methods. */
2075
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2076
};
2077
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2078
static_assert(0 < 1, "There is no slot for us");
2079
static const JSJitInfo mozCurrentTransformInverse_setterinfo = {
2080
  { (JSJitGetterOp)set_mozCurrentTransformInverse },
2081
  { prototypes::id::CanvasRenderingContext2D },
2082
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2083
  JSJitInfo::Setter,
2084
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2085
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2086
  false,  /* isInfallible. False in setters. */
2087
  false,  /* isMovable.  Not relevant for setters. */
2088
  false, /* isEliminatable.  Not relevant for setters. */
2089
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2090
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2091
  false,  /* isTypedMethod.  Only relevant for methods. */
2092
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2093
};
2094
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2095
static_assert(0 < 1, "There is no slot for us");
2096
2097
MOZ_CAN_RUN_SCRIPT static bool
2098
get_mozTextStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
2099
0
{
2100
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.mozTextStyle", DOM, cx);
2101
0
2102
0
  DOMString result;
2103
0
  self->GetMozTextStyle(result);
2104
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2105
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2106
0
    return false;
2107
0
  }
2108
0
  return true;
2109
0
}
2110
2111
MOZ_CAN_RUN_SCRIPT static bool
2112
set_mozTextStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
2113
0
{
2114
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.mozTextStyle", DOM, cx);
2115
0
2116
0
  binding_detail::FakeString arg0;
2117
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
2118
0
    return false;
2119
0
  }
2120
0
  FastErrorResult rv;
2121
0
  self->SetMozTextStyle(NonNullHelper(Constify(arg0)), rv);
2122
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2123
0
    return false;
2124
0
  }
2125
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2126
0
2127
0
  return true;
2128
0
}
2129
2130
static const JSJitInfo mozTextStyle_getterinfo = {
2131
  { (JSJitGetterOp)get_mozTextStyle },
2132
  { prototypes::id::CanvasRenderingContext2D },
2133
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2134
  JSJitInfo::Getter,
2135
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2136
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2137
  false,  /* isInfallible. False in setters. */
2138
  false,  /* isMovable.  Not relevant for setters. */
2139
  false, /* isEliminatable.  Not relevant for setters. */
2140
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2141
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2142
  false,  /* isTypedMethod.  Only relevant for methods. */
2143
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2144
};
2145
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2146
static_assert(0 < 1, "There is no slot for us");
2147
static const JSJitInfo mozTextStyle_setterinfo = {
2148
  { (JSJitGetterOp)set_mozTextStyle },
2149
  { prototypes::id::CanvasRenderingContext2D },
2150
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2151
  JSJitInfo::Setter,
2152
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2153
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2154
  false,  /* isInfallible. False in setters. */
2155
  false,  /* isMovable.  Not relevant for setters. */
2156
  false, /* isEliminatable.  Not relevant for setters. */
2157
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2158
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2159
  false,  /* isTypedMethod.  Only relevant for methods. */
2160
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2161
};
2162
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2163
static_assert(0 < 1, "There is no slot for us");
2164
2165
MOZ_CAN_RUN_SCRIPT static bool
2166
get_mozImageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
2167
0
{
2168
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.mozImageSmoothingEnabled", DOM, cx);
2169
0
2170
0
  DeprecationWarning(cx, obj, nsIDocument::ePrefixedImageSmoothingEnabled);
2171
0
  bool result(self->ImageSmoothingEnabled());
2172
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2173
0
  args.rval().setBoolean(result);
2174
0
  return true;
2175
0
}
2176
2177
MOZ_CAN_RUN_SCRIPT static bool
2178
set_mozImageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
2179
0
{
2180
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.mozImageSmoothingEnabled", DOM, cx);
2181
0
2182
0
  DeprecationWarning(cx, obj, nsIDocument::ePrefixedImageSmoothingEnabled);
2183
0
  bool arg0;
2184
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
2185
0
    return false;
2186
0
  }
2187
0
  self->SetImageSmoothingEnabled(arg0);
2188
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2189
0
2190
0
  return true;
2191
0
}
2192
2193
static const JSJitInfo mozImageSmoothingEnabled_getterinfo = {
2194
  { (JSJitGetterOp)get_mozImageSmoothingEnabled },
2195
  { prototypes::id::CanvasRenderingContext2D },
2196
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2197
  JSJitInfo::Getter,
2198
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2199
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
2200
  true,  /* isInfallible. False in setters. */
2201
  false,  /* isMovable.  Not relevant for setters. */
2202
  false, /* isEliminatable.  Not relevant for setters. */
2203
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2204
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2205
  false,  /* isTypedMethod.  Only relevant for methods. */
2206
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2207
};
2208
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2209
static_assert(0 < 1, "There is no slot for us");
2210
static const JSJitInfo mozImageSmoothingEnabled_setterinfo = {
2211
  { (JSJitGetterOp)set_mozImageSmoothingEnabled },
2212
  { prototypes::id::CanvasRenderingContext2D },
2213
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2214
  JSJitInfo::Setter,
2215
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2216
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2217
  false,  /* isInfallible. False in setters. */
2218
  false,  /* isMovable.  Not relevant for setters. */
2219
  false, /* isEliminatable.  Not relevant for setters. */
2220
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2221
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2222
  false,  /* isTypedMethod.  Only relevant for methods. */
2223
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2224
};
2225
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2226
static_assert(0 < 1, "There is no slot for us");
2227
2228
MOZ_CAN_RUN_SCRIPT static bool
2229
drawWindow(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2230
0
{
2231
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.drawWindow", DOM, cx);
2232
0
2233
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
2234
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawWindow");
2235
0
  }
2236
0
  NonNull<nsGlobalWindowInner> arg0;
2237
0
  if (args[0].isObject()) {
2238
0
    {
2239
0
      nsresult rv = UnwrapObject<prototypes::id::Window, nsGlobalWindowInner>(args[0], arg0);
2240
0
      if (NS_FAILED(rv)) {
2241
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.drawWindow", "Window");
2242
0
        return false;
2243
0
      }
2244
0
    }
2245
0
  } else {
2246
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.drawWindow");
2247
0
    return false;
2248
0
  }
2249
0
  double arg1;
2250
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
2251
0
    return false;
2252
0
  } else if (!mozilla::IsFinite(arg1)) {
2253
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.drawWindow");
2254
0
    return false;
2255
0
  }
2256
0
  double arg2;
2257
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
2258
0
    return false;
2259
0
  } else if (!mozilla::IsFinite(arg2)) {
2260
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.drawWindow");
2261
0
    return false;
2262
0
  }
2263
0
  double arg3;
2264
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
2265
0
    return false;
2266
0
  } else if (!mozilla::IsFinite(arg3)) {
2267
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.drawWindow");
2268
0
    return false;
2269
0
  }
2270
0
  double arg4;
2271
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
2272
0
    return false;
2273
0
  } else if (!mozilla::IsFinite(arg4)) {
2274
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 5 of CanvasRenderingContext2D.drawWindow");
2275
0
    return false;
2276
0
  }
2277
0
  binding_detail::FakeString arg5;
2278
0
  if (!ConvertJSValueToString(cx, args[5], eStringify, eStringify, arg5)) {
2279
0
    return false;
2280
0
  }
2281
0
  uint32_t arg6;
2282
0
  if (args.hasDefined(6)) {
2283
0
    if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[6], &arg6)) {
2284
0
      return false;
2285
0
    }
2286
0
  } else {
2287
0
    arg6 = 0U;
2288
0
  }
2289
0
  FastErrorResult rv;
2290
0
  self->DrawWindow(MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, arg3, arg4, NonNullHelper(Constify(arg5)), arg6, rv);
2291
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2292
0
    return false;
2293
0
  }
2294
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2295
0
  args.rval().setUndefined();
2296
0
  return true;
2297
0
}
2298
2299
static const JSJitInfo drawWindow_methodinfo = {
2300
  { (JSJitGetterOp)drawWindow },
2301
  { prototypes::id::CanvasRenderingContext2D },
2302
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2303
  JSJitInfo::Method,
2304
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2305
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2306
  false,  /* isInfallible. False in setters. */
2307
  false,  /* isMovable.  Not relevant for setters. */
2308
  false, /* isEliminatable.  Not relevant for setters. */
2309
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2310
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2311
  false,  /* isTypedMethod.  Only relevant for methods. */
2312
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2313
};
2314
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2315
static_assert(0 < 1, "There is no slot for us");
2316
2317
MOZ_CAN_RUN_SCRIPT static bool
2318
demote(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2319
0
{
2320
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.demote", DOM, cx);
2321
0
2322
0
  self->Demote();
2323
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2324
0
  args.rval().setUndefined();
2325
0
  return true;
2326
0
}
2327
2328
static const JSJitInfo demote_methodinfo = {
2329
  { (JSJitGetterOp)demote },
2330
  { prototypes::id::CanvasRenderingContext2D },
2331
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2332
  JSJitInfo::Method,
2333
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2334
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2335
  true,  /* isInfallible. False in setters. */
2336
  false,  /* isMovable.  Not relevant for setters. */
2337
  false, /* isEliminatable.  Not relevant for setters. */
2338
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2339
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2340
  false,  /* isTypedMethod.  Only relevant for methods. */
2341
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2342
};
2343
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2344
static_assert(0 < 1, "There is no slot for us");
2345
2346
MOZ_CAN_RUN_SCRIPT static bool
2347
get_globalAlpha(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
2348
0
{
2349
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.globalAlpha", DOM, cx);
2350
0
2351
0
  double result(self->GlobalAlpha());
2352
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2353
0
  args.rval().set(JS_NumberValue(double(result)));
2354
0
  return true;
2355
0
}
2356
2357
MOZ_CAN_RUN_SCRIPT static bool
2358
set_globalAlpha(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
2359
0
{
2360
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.globalAlpha", DOM, cx);
2361
0
2362
0
  double arg0;
2363
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
2364
0
    return false;
2365
0
  }
2366
0
  self->SetGlobalAlpha(arg0);
2367
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2368
0
2369
0
  return true;
2370
0
}
2371
2372
static const JSJitInfo globalAlpha_getterinfo = {
2373
  { (JSJitGetterOp)get_globalAlpha },
2374
  { prototypes::id::CanvasRenderingContext2D },
2375
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2376
  JSJitInfo::Getter,
2377
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2378
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
2379
  true,  /* isInfallible. False in setters. */
2380
  false,  /* isMovable.  Not relevant for setters. */
2381
  false, /* isEliminatable.  Not relevant for setters. */
2382
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2383
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2384
  false,  /* isTypedMethod.  Only relevant for methods. */
2385
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2386
};
2387
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2388
static_assert(0 < 1, "There is no slot for us");
2389
static const JSJitInfo globalAlpha_setterinfo = {
2390
  { (JSJitGetterOp)set_globalAlpha },
2391
  { prototypes::id::CanvasRenderingContext2D },
2392
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2393
  JSJitInfo::Setter,
2394
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2395
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2396
  false,  /* isInfallible. False in setters. */
2397
  false,  /* isMovable.  Not relevant for setters. */
2398
  false, /* isEliminatable.  Not relevant for setters. */
2399
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2400
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2401
  false,  /* isTypedMethod.  Only relevant for methods. */
2402
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2403
};
2404
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2405
static_assert(0 < 1, "There is no slot for us");
2406
2407
MOZ_CAN_RUN_SCRIPT static bool
2408
get_globalCompositeOperation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
2409
0
{
2410
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.globalCompositeOperation", DOM, cx);
2411
0
2412
0
  FastErrorResult rv;
2413
0
  DOMString result;
2414
0
  self->GetGlobalCompositeOperation(result, rv);
2415
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2416
0
    return false;
2417
0
  }
2418
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2419
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
2420
0
    return false;
2421
0
  }
2422
0
  return true;
2423
0
}
2424
2425
MOZ_CAN_RUN_SCRIPT static bool
2426
set_globalCompositeOperation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
2427
0
{
2428
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.globalCompositeOperation", DOM, cx);
2429
0
2430
0
  binding_detail::FakeString arg0;
2431
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
2432
0
    return false;
2433
0
  }
2434
0
  FastErrorResult rv;
2435
0
  self->SetGlobalCompositeOperation(NonNullHelper(Constify(arg0)), rv);
2436
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2437
0
    return false;
2438
0
  }
2439
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2440
0
2441
0
  return true;
2442
0
}
2443
2444
static const JSJitInfo globalCompositeOperation_getterinfo = {
2445
  { (JSJitGetterOp)get_globalCompositeOperation },
2446
  { prototypes::id::CanvasRenderingContext2D },
2447
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2448
  JSJitInfo::Getter,
2449
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2450
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
2451
  false,  /* isInfallible. False in setters. */
2452
  false,  /* isMovable.  Not relevant for setters. */
2453
  false, /* isEliminatable.  Not relevant for setters. */
2454
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2455
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2456
  false,  /* isTypedMethod.  Only relevant for methods. */
2457
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2458
};
2459
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2460
static_assert(0 < 1, "There is no slot for us");
2461
static const JSJitInfo globalCompositeOperation_setterinfo = {
2462
  { (JSJitGetterOp)set_globalCompositeOperation },
2463
  { prototypes::id::CanvasRenderingContext2D },
2464
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2465
  JSJitInfo::Setter,
2466
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2467
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2468
  false,  /* isInfallible. False in setters. */
2469
  false,  /* isMovable.  Not relevant for setters. */
2470
  false, /* isEliminatable.  Not relevant for setters. */
2471
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2472
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2473
  false,  /* isTypedMethod.  Only relevant for methods. */
2474
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2475
};
2476
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2477
static_assert(0 < 1, "There is no slot for us");
2478
2479
MOZ_CAN_RUN_SCRIPT static bool
2480
drawImage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2481
0
{
2482
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.drawImage", DOM, cx);
2483
0
2484
0
  unsigned argcount = std::min(args.length(), 9u);
2485
0
  switch (argcount) {
2486
0
    case 3: {
2487
0
      bool foundNonFiniteFloat = false;
2488
0
      HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
2489
0
      HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
2490
0
      {
2491
0
        bool done = false, failed = false, tryNext;
2492
0
        if (args[0].isObject()) {
2493
0
          done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
2494
0
                 (failed = !arg0_holder.TrySetToSVGImageElement(cx, args[0], tryNext, false)) || !tryNext ||
2495
0
                 (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
2496
0
                 (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
2497
0
                 (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
2498
0
2499
0
        }
2500
0
        if (failed) {
2501
0
          return false;
2502
0
        }
2503
0
        if (!done) {
2504
0
          ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.drawImage", "HTMLImageElement, SVGImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
2505
0
          return false;
2506
0
        }
2507
0
      }
2508
0
      double arg1;
2509
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
2510
0
        return false;
2511
0
      } else if (!mozilla::IsFinite(arg1)) {
2512
0
        foundNonFiniteFloat = true;
2513
0
      }
2514
0
      double arg2;
2515
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
2516
0
        return false;
2517
0
      } else if (!mozilla::IsFinite(arg2)) {
2518
0
        foundNonFiniteFloat = true;
2519
0
      }
2520
0
      if (foundNonFiniteFloat) {
2521
0
        args.rval().setUndefined();
2522
0
        return true;
2523
0
      }
2524
0
      FastErrorResult rv;
2525
0
      self->DrawImage(Constify(arg0), arg1, arg2, rv);
2526
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2527
0
        return false;
2528
0
      }
2529
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2530
0
      args.rval().setUndefined();
2531
0
      return true;
2532
0
      break;
2533
0
    }
2534
0
    case 5: {
2535
0
      bool foundNonFiniteFloat = false;
2536
0
      HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
2537
0
      HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
2538
0
      {
2539
0
        bool done = false, failed = false, tryNext;
2540
0
        if (args[0].isObject()) {
2541
0
          done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
2542
0
                 (failed = !arg0_holder.TrySetToSVGImageElement(cx, args[0], tryNext, false)) || !tryNext ||
2543
0
                 (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
2544
0
                 (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
2545
0
                 (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
2546
0
2547
0
        }
2548
0
        if (failed) {
2549
0
          return false;
2550
0
        }
2551
0
        if (!done) {
2552
0
          ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.drawImage", "HTMLImageElement, SVGImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
2553
0
          return false;
2554
0
        }
2555
0
      }
2556
0
      double arg1;
2557
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
2558
0
        return false;
2559
0
      } else if (!mozilla::IsFinite(arg1)) {
2560
0
        foundNonFiniteFloat = true;
2561
0
      }
2562
0
      double arg2;
2563
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
2564
0
        return false;
2565
0
      } else if (!mozilla::IsFinite(arg2)) {
2566
0
        foundNonFiniteFloat = true;
2567
0
      }
2568
0
      double arg3;
2569
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
2570
0
        return false;
2571
0
      } else if (!mozilla::IsFinite(arg3)) {
2572
0
        foundNonFiniteFloat = true;
2573
0
      }
2574
0
      double arg4;
2575
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
2576
0
        return false;
2577
0
      } else if (!mozilla::IsFinite(arg4)) {
2578
0
        foundNonFiniteFloat = true;
2579
0
      }
2580
0
      if (foundNonFiniteFloat) {
2581
0
        args.rval().setUndefined();
2582
0
        return true;
2583
0
      }
2584
0
      FastErrorResult rv;
2585
0
      self->DrawImage(Constify(arg0), arg1, arg2, arg3, arg4, rv);
2586
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2587
0
        return false;
2588
0
      }
2589
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2590
0
      args.rval().setUndefined();
2591
0
      return true;
2592
0
      break;
2593
0
    }
2594
0
    case 9: {
2595
0
      bool foundNonFiniteFloat = false;
2596
0
      HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
2597
0
      HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
2598
0
      {
2599
0
        bool done = false, failed = false, tryNext;
2600
0
        if (args[0].isObject()) {
2601
0
          done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
2602
0
                 (failed = !arg0_holder.TrySetToSVGImageElement(cx, args[0], tryNext, false)) || !tryNext ||
2603
0
                 (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
2604
0
                 (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
2605
0
                 (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
2606
0
2607
0
        }
2608
0
        if (failed) {
2609
0
          return false;
2610
0
        }
2611
0
        if (!done) {
2612
0
          ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.drawImage", "HTMLImageElement, SVGImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
2613
0
          return false;
2614
0
        }
2615
0
      }
2616
0
      double arg1;
2617
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
2618
0
        return false;
2619
0
      } else if (!mozilla::IsFinite(arg1)) {
2620
0
        foundNonFiniteFloat = true;
2621
0
      }
2622
0
      double arg2;
2623
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
2624
0
        return false;
2625
0
      } else if (!mozilla::IsFinite(arg2)) {
2626
0
        foundNonFiniteFloat = true;
2627
0
      }
2628
0
      double arg3;
2629
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
2630
0
        return false;
2631
0
      } else if (!mozilla::IsFinite(arg3)) {
2632
0
        foundNonFiniteFloat = true;
2633
0
      }
2634
0
      double arg4;
2635
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
2636
0
        return false;
2637
0
      } else if (!mozilla::IsFinite(arg4)) {
2638
0
        foundNonFiniteFloat = true;
2639
0
      }
2640
0
      double arg5;
2641
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
2642
0
        return false;
2643
0
      } else if (!mozilla::IsFinite(arg5)) {
2644
0
        foundNonFiniteFloat = true;
2645
0
      }
2646
0
      double arg6;
2647
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
2648
0
        return false;
2649
0
      } else if (!mozilla::IsFinite(arg6)) {
2650
0
        foundNonFiniteFloat = true;
2651
0
      }
2652
0
      double arg7;
2653
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[7], &arg7)) {
2654
0
        return false;
2655
0
      } else if (!mozilla::IsFinite(arg7)) {
2656
0
        foundNonFiniteFloat = true;
2657
0
      }
2658
0
      double arg8;
2659
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[8], &arg8)) {
2660
0
        return false;
2661
0
      } else if (!mozilla::IsFinite(arg8)) {
2662
0
        foundNonFiniteFloat = true;
2663
0
      }
2664
0
      if (foundNonFiniteFloat) {
2665
0
        args.rval().setUndefined();
2666
0
        return true;
2667
0
      }
2668
0
      FastErrorResult rv;
2669
0
      self->DrawImage(Constify(arg0), arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, rv);
2670
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
2671
0
        return false;
2672
0
      }
2673
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2674
0
      args.rval().setUndefined();
2675
0
      return true;
2676
0
      break;
2677
0
    }
2678
0
    default: {
2679
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawImage");
2680
0
      break;
2681
0
    }
2682
0
  }
2683
0
  MOZ_CRASH("We have an always-returning default case");
2684
0
  return false;
2685
0
}
2686
2687
static const JSJitInfo drawImage_methodinfo = {
2688
  { (JSJitGetterOp)drawImage },
2689
  { prototypes::id::CanvasRenderingContext2D },
2690
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2691
  JSJitInfo::Method,
2692
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2693
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2694
  false,  /* isInfallible. False in setters. */
2695
  false,  /* isMovable.  Not relevant for setters. */
2696
  false, /* isEliminatable.  Not relevant for setters. */
2697
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2698
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2699
  false,  /* isTypedMethod.  Only relevant for methods. */
2700
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2701
};
2702
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2703
static_assert(0 < 1, "There is no slot for us");
2704
2705
MOZ_CAN_RUN_SCRIPT static bool
2706
beginPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2707
0
{
2708
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.beginPath", DOM, cx);
2709
0
2710
0
  self->BeginPath();
2711
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
2712
0
  args.rval().setUndefined();
2713
0
  return true;
2714
0
}
2715
2716
static const JSJitInfo beginPath_methodinfo = {
2717
  { (JSJitGetterOp)beginPath },
2718
  { prototypes::id::CanvasRenderingContext2D },
2719
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2720
  JSJitInfo::Method,
2721
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2722
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2723
  true,  /* isInfallible. False in setters. */
2724
  false,  /* isMovable.  Not relevant for setters. */
2725
  false, /* isEliminatable.  Not relevant for setters. */
2726
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2727
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2728
  false,  /* isTypedMethod.  Only relevant for methods. */
2729
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2730
};
2731
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2732
static_assert(0 < 1, "There is no slot for us");
2733
2734
MOZ_CAN_RUN_SCRIPT static bool
2735
fill(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2736
0
{
2737
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.fill", DOM, cx);
2738
0
2739
0
  unsigned argcount = std::min(args.length(), 2u);
2740
0
  switch (argcount) {
2741
0
    case 0: {
2742
0
      CanvasWindingRule arg0;
2743
0
      if (args.hasDefined(0)) {
2744
0
        {
2745
0
          int index;
2746
0
          if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.fill", &index)) {
2747
0
            return false;
2748
0
          }
2749
0
          MOZ_ASSERT(index >= 0);
2750
0
          arg0 = static_cast<CanvasWindingRule>(index);
2751
0
        }
2752
0
      } else {
2753
0
        arg0 = CanvasWindingRule::Nonzero;
2754
0
      }
2755
0
      self->Fill(arg0);
2756
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2757
0
      args.rval().setUndefined();
2758
0
      return true;
2759
0
      break;
2760
0
    }
2761
0
    case 1: {
2762
0
      if (args[0].isObject()) {
2763
0
        do {
2764
0
          NonNull<mozilla::dom::CanvasPath> arg0;
2765
0
          {
2766
0
            nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
2767
0
            if (NS_FAILED(rv)) {
2768
0
              break;
2769
0
            }
2770
0
          }
2771
0
          CanvasWindingRule arg1;
2772
0
          if (args.hasDefined(1)) {
2773
0
            {
2774
0
              int index;
2775
0
              if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.fill", &index)) {
2776
0
                return false;
2777
0
              }
2778
0
              MOZ_ASSERT(index >= 0);
2779
0
              arg1 = static_cast<CanvasWindingRule>(index);
2780
0
            }
2781
0
          } else {
2782
0
            arg1 = CanvasWindingRule::Nonzero;
2783
0
          }
2784
0
          self->Fill(MOZ_KnownLive(NonNullHelper(arg0)), arg1);
2785
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
2786
0
          args.rval().setUndefined();
2787
0
          return true;
2788
0
        } while (false);
2789
0
      }
2790
0
      CanvasWindingRule arg0;
2791
0
      if (args.hasDefined(0)) {
2792
0
        {
2793
0
          int index;
2794
0
          if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.fill", &index)) {
2795
0
            return false;
2796
0
          }
2797
0
          MOZ_ASSERT(index >= 0);
2798
0
          arg0 = static_cast<CanvasWindingRule>(index);
2799
0
        }
2800
0
      } else {
2801
0
        arg0 = CanvasWindingRule::Nonzero;
2802
0
      }
2803
0
      self->Fill(arg0);
2804
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2805
0
      args.rval().setUndefined();
2806
0
      return true;
2807
0
      break;
2808
0
    }
2809
0
    case 2: {
2810
0
      NonNull<mozilla::dom::CanvasPath> arg0;
2811
0
      if (args[0].isObject()) {
2812
0
        {
2813
0
          nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
2814
0
          if (NS_FAILED(rv)) {
2815
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.fill", "Path2D");
2816
0
            return false;
2817
0
          }
2818
0
        }
2819
0
      } else {
2820
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.fill");
2821
0
        return false;
2822
0
      }
2823
0
      CanvasWindingRule arg1;
2824
0
      if (args.hasDefined(1)) {
2825
0
        {
2826
0
          int index;
2827
0
          if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.fill", &index)) {
2828
0
            return false;
2829
0
          }
2830
0
          MOZ_ASSERT(index >= 0);
2831
0
          arg1 = static_cast<CanvasWindingRule>(index);
2832
0
        }
2833
0
      } else {
2834
0
        arg1 = CanvasWindingRule::Nonzero;
2835
0
      }
2836
0
      self->Fill(MOZ_KnownLive(NonNullHelper(arg0)), arg1);
2837
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2838
0
      args.rval().setUndefined();
2839
0
      return true;
2840
0
      break;
2841
0
    }
2842
0
    default: {
2843
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.fill");
2844
0
      break;
2845
0
    }
2846
0
  }
2847
0
  MOZ_CRASH("We have an always-returning default case");
2848
0
  return false;
2849
0
}
2850
2851
static const JSJitInfo fill_methodinfo = {
2852
  { (JSJitGetterOp)fill },
2853
  { prototypes::id::CanvasRenderingContext2D },
2854
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2855
  JSJitInfo::Method,
2856
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2857
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2858
  false,  /* isInfallible. False in setters. */
2859
  false,  /* isMovable.  Not relevant for setters. */
2860
  false, /* isEliminatable.  Not relevant for setters. */
2861
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2862
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2863
  false,  /* isTypedMethod.  Only relevant for methods. */
2864
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2865
};
2866
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2867
static_assert(0 < 1, "There is no slot for us");
2868
2869
MOZ_CAN_RUN_SCRIPT static bool
2870
stroke(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2871
0
{
2872
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.stroke", DOM, cx);
2873
0
2874
0
  unsigned argcount = std::min(args.length(), 1u);
2875
0
  switch (argcount) {
2876
0
    case 0: {
2877
0
      self->Stroke();
2878
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2879
0
      args.rval().setUndefined();
2880
0
      return true;
2881
0
      break;
2882
0
    }
2883
0
    case 1: {
2884
0
      NonNull<mozilla::dom::CanvasPath> arg0;
2885
0
      if (args[0].isObject()) {
2886
0
        {
2887
0
          nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
2888
0
          if (NS_FAILED(rv)) {
2889
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.stroke", "Path2D");
2890
0
            return false;
2891
0
          }
2892
0
        }
2893
0
      } else {
2894
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.stroke");
2895
0
        return false;
2896
0
      }
2897
0
      self->Stroke(MOZ_KnownLive(NonNullHelper(arg0)));
2898
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2899
0
      args.rval().setUndefined();
2900
0
      return true;
2901
0
      break;
2902
0
    }
2903
0
    default: {
2904
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.stroke");
2905
0
      break;
2906
0
    }
2907
0
  }
2908
0
  MOZ_CRASH("We have an always-returning default case");
2909
0
  return false;
2910
0
}
2911
2912
static const JSJitInfo stroke_methodinfo = {
2913
  { (JSJitGetterOp)stroke },
2914
  { prototypes::id::CanvasRenderingContext2D },
2915
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
2916
  JSJitInfo::Method,
2917
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
2918
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
2919
  false,  /* isInfallible. False in setters. */
2920
  false,  /* isMovable.  Not relevant for setters. */
2921
  false, /* isEliminatable.  Not relevant for setters. */
2922
  false, /* isAlwaysInSlot.  Only relevant for getters. */
2923
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
2924
  false,  /* isTypedMethod.  Only relevant for methods. */
2925
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
2926
};
2927
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
2928
static_assert(0 < 1, "There is no slot for us");
2929
2930
MOZ_CAN_RUN_SCRIPT static bool
2931
clip(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
2932
0
{
2933
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.clip", DOM, cx);
2934
0
2935
0
  unsigned argcount = std::min(args.length(), 2u);
2936
0
  switch (argcount) {
2937
0
    case 0: {
2938
0
      CanvasWindingRule arg0;
2939
0
      if (args.hasDefined(0)) {
2940
0
        {
2941
0
          int index;
2942
0
          if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.clip", &index)) {
2943
0
            return false;
2944
0
          }
2945
0
          MOZ_ASSERT(index >= 0);
2946
0
          arg0 = static_cast<CanvasWindingRule>(index);
2947
0
        }
2948
0
      } else {
2949
0
        arg0 = CanvasWindingRule::Nonzero;
2950
0
      }
2951
0
      self->Clip(arg0);
2952
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
2953
0
      args.rval().setUndefined();
2954
0
      return true;
2955
0
      break;
2956
0
    }
2957
0
    case 1: {
2958
0
      if (args[0].isObject()) {
2959
0
        do {
2960
0
          NonNull<mozilla::dom::CanvasPath> arg0;
2961
0
          {
2962
0
            nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
2963
0
            if (NS_FAILED(rv)) {
2964
0
              break;
2965
0
            }
2966
0
          }
2967
0
          CanvasWindingRule arg1;
2968
0
          if (args.hasDefined(1)) {
2969
0
            {
2970
0
              int index;
2971
0
              if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.clip", &index)) {
2972
0
                return false;
2973
0
              }
2974
0
              MOZ_ASSERT(index >= 0);
2975
0
              arg1 = static_cast<CanvasWindingRule>(index);
2976
0
            }
2977
0
          } else {
2978
0
            arg1 = CanvasWindingRule::Nonzero;
2979
0
          }
2980
0
          self->Clip(MOZ_KnownLive(NonNullHelper(arg0)), arg1);
2981
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
2982
0
          args.rval().setUndefined();
2983
0
          return true;
2984
0
        } while (false);
2985
0
      }
2986
0
      CanvasWindingRule arg0;
2987
0
      if (args.hasDefined(0)) {
2988
0
        {
2989
0
          int index;
2990
0
          if (!FindEnumStringIndex<true>(cx, args[0], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 1 of CanvasRenderingContext2D.clip", &index)) {
2991
0
            return false;
2992
0
          }
2993
0
          MOZ_ASSERT(index >= 0);
2994
0
          arg0 = static_cast<CanvasWindingRule>(index);
2995
0
        }
2996
0
      } else {
2997
0
        arg0 = CanvasWindingRule::Nonzero;
2998
0
      }
2999
0
      self->Clip(arg0);
3000
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3001
0
      args.rval().setUndefined();
3002
0
      return true;
3003
0
      break;
3004
0
    }
3005
0
    case 2: {
3006
0
      NonNull<mozilla::dom::CanvasPath> arg0;
3007
0
      if (args[0].isObject()) {
3008
0
        {
3009
0
          nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
3010
0
          if (NS_FAILED(rv)) {
3011
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.clip", "Path2D");
3012
0
            return false;
3013
0
          }
3014
0
        }
3015
0
      } else {
3016
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.clip");
3017
0
        return false;
3018
0
      }
3019
0
      CanvasWindingRule arg1;
3020
0
      if (args.hasDefined(1)) {
3021
0
        {
3022
0
          int index;
3023
0
          if (!FindEnumStringIndex<true>(cx, args[1], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 2 of CanvasRenderingContext2D.clip", &index)) {
3024
0
            return false;
3025
0
          }
3026
0
          MOZ_ASSERT(index >= 0);
3027
0
          arg1 = static_cast<CanvasWindingRule>(index);
3028
0
        }
3029
0
      } else {
3030
0
        arg1 = CanvasWindingRule::Nonzero;
3031
0
      }
3032
0
      self->Clip(MOZ_KnownLive(NonNullHelper(arg0)), arg1);
3033
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3034
0
      args.rval().setUndefined();
3035
0
      return true;
3036
0
      break;
3037
0
    }
3038
0
    default: {
3039
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.clip");
3040
0
      break;
3041
0
    }
3042
0
  }
3043
0
  MOZ_CRASH("We have an always-returning default case");
3044
0
  return false;
3045
0
}
3046
3047
static const JSJitInfo clip_methodinfo = {
3048
  { (JSJitGetterOp)clip },
3049
  { prototypes::id::CanvasRenderingContext2D },
3050
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3051
  JSJitInfo::Method,
3052
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3053
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3054
  false,  /* isInfallible. False in setters. */
3055
  false,  /* isMovable.  Not relevant for setters. */
3056
  false, /* isEliminatable.  Not relevant for setters. */
3057
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3058
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3059
  false,  /* isTypedMethod.  Only relevant for methods. */
3060
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3061
};
3062
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3063
static_assert(0 < 1, "There is no slot for us");
3064
3065
MOZ_CAN_RUN_SCRIPT static bool
3066
isPointInPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3067
0
{
3068
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.isPointInPath", DOM, cx);
3069
0
3070
0
  unsigned argcount = std::min(args.length(), 4u);
3071
0
  switch (argcount) {
3072
0
    case 2: {
3073
0
      double arg0;
3074
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
3075
0
        return false;
3076
0
      }
3077
0
      double arg1;
3078
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3079
0
        return false;
3080
0
      }
3081
0
      CanvasWindingRule arg2;
3082
0
      if (args.hasDefined(2)) {
3083
0
        {
3084
0
          int index;
3085
0
          if (!FindEnumStringIndex<true>(cx, args[2], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 3 of CanvasRenderingContext2D.isPointInPath", &index)) {
3086
0
            return false;
3087
0
          }
3088
0
          MOZ_ASSERT(index >= 0);
3089
0
          arg2 = static_cast<CanvasWindingRule>(index);
3090
0
        }
3091
0
      } else {
3092
0
        arg2 = CanvasWindingRule::Nonzero;
3093
0
      }
3094
0
      NonNull<nsIPrincipal> subjectPrincipal;
3095
0
      {
3096
0
        JS::Realm* realm = js::GetContextRealm(cx);
3097
0
        MOZ_ASSERT(realm);
3098
0
        JSPrincipals* principals = JS::GetRealmPrincipals(realm);
3099
0
        nsIPrincipal* principal = nsJSPrincipals::get(principals);
3100
0
3101
0
        subjectPrincipal = principal;
3102
0
      }
3103
0
      bool result(self->IsPointInPath(cx, arg0, arg1, arg2, subjectPrincipal));
3104
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3105
0
      args.rval().setBoolean(result);
3106
0
      return true;
3107
0
      break;
3108
0
    }
3109
0
    case 3: {
3110
0
      if (args[0].isObject()) {
3111
0
        do {
3112
0
          NonNull<mozilla::dom::CanvasPath> arg0;
3113
0
          {
3114
0
            nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
3115
0
            if (NS_FAILED(rv)) {
3116
0
              break;
3117
0
            }
3118
0
          }
3119
0
          double arg1;
3120
0
          if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3121
0
            return false;
3122
0
          }
3123
0
          double arg2;
3124
0
          if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
3125
0
            return false;
3126
0
          }
3127
0
          CanvasWindingRule arg3;
3128
0
          if (args.hasDefined(3)) {
3129
0
            {
3130
0
              int index;
3131
0
              if (!FindEnumStringIndex<true>(cx, args[3], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 4 of CanvasRenderingContext2D.isPointInPath", &index)) {
3132
0
                return false;
3133
0
              }
3134
0
              MOZ_ASSERT(index >= 0);
3135
0
              arg3 = static_cast<CanvasWindingRule>(index);
3136
0
            }
3137
0
          } else {
3138
0
            arg3 = CanvasWindingRule::Nonzero;
3139
0
          }
3140
0
          NonNull<nsIPrincipal> subjectPrincipal;
3141
0
          {
3142
0
            JS::Realm* realm = js::GetContextRealm(cx);
3143
0
            MOZ_ASSERT(realm);
3144
0
            JSPrincipals* principals = JS::GetRealmPrincipals(realm);
3145
0
            nsIPrincipal* principal = nsJSPrincipals::get(principals);
3146
0
3147
0
            subjectPrincipal = principal;
3148
0
          }
3149
0
          bool result(self->IsPointInPath(cx, MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, arg3, subjectPrincipal));
3150
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
3151
0
          args.rval().setBoolean(result);
3152
0
          return true;
3153
0
        } while (false);
3154
0
      }
3155
0
      double arg0;
3156
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
3157
0
        return false;
3158
0
      }
3159
0
      double arg1;
3160
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3161
0
        return false;
3162
0
      }
3163
0
      CanvasWindingRule arg2;
3164
0
      if (args.hasDefined(2)) {
3165
0
        {
3166
0
          int index;
3167
0
          if (!FindEnumStringIndex<true>(cx, args[2], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 3 of CanvasRenderingContext2D.isPointInPath", &index)) {
3168
0
            return false;
3169
0
          }
3170
0
          MOZ_ASSERT(index >= 0);
3171
0
          arg2 = static_cast<CanvasWindingRule>(index);
3172
0
        }
3173
0
      } else {
3174
0
        arg2 = CanvasWindingRule::Nonzero;
3175
0
      }
3176
0
      NonNull<nsIPrincipal> subjectPrincipal;
3177
0
      {
3178
0
        JS::Realm* realm = js::GetContextRealm(cx);
3179
0
        MOZ_ASSERT(realm);
3180
0
        JSPrincipals* principals = JS::GetRealmPrincipals(realm);
3181
0
        nsIPrincipal* principal = nsJSPrincipals::get(principals);
3182
0
3183
0
        subjectPrincipal = principal;
3184
0
      }
3185
0
      bool result(self->IsPointInPath(cx, arg0, arg1, arg2, subjectPrincipal));
3186
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3187
0
      args.rval().setBoolean(result);
3188
0
      return true;
3189
0
      break;
3190
0
    }
3191
0
    case 4: {
3192
0
      NonNull<mozilla::dom::CanvasPath> arg0;
3193
0
      if (args[0].isObject()) {
3194
0
        {
3195
0
          nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
3196
0
          if (NS_FAILED(rv)) {
3197
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.isPointInPath", "Path2D");
3198
0
            return false;
3199
0
          }
3200
0
        }
3201
0
      } else {
3202
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.isPointInPath");
3203
0
        return false;
3204
0
      }
3205
0
      double arg1;
3206
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3207
0
        return false;
3208
0
      }
3209
0
      double arg2;
3210
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
3211
0
        return false;
3212
0
      }
3213
0
      CanvasWindingRule arg3;
3214
0
      if (args.hasDefined(3)) {
3215
0
        {
3216
0
          int index;
3217
0
          if (!FindEnumStringIndex<true>(cx, args[3], CanvasWindingRuleValues::strings, "CanvasWindingRule", "Argument 4 of CanvasRenderingContext2D.isPointInPath", &index)) {
3218
0
            return false;
3219
0
          }
3220
0
          MOZ_ASSERT(index >= 0);
3221
0
          arg3 = static_cast<CanvasWindingRule>(index);
3222
0
        }
3223
0
      } else {
3224
0
        arg3 = CanvasWindingRule::Nonzero;
3225
0
      }
3226
0
      NonNull<nsIPrincipal> subjectPrincipal;
3227
0
      {
3228
0
        JS::Realm* realm = js::GetContextRealm(cx);
3229
0
        MOZ_ASSERT(realm);
3230
0
        JSPrincipals* principals = JS::GetRealmPrincipals(realm);
3231
0
        nsIPrincipal* principal = nsJSPrincipals::get(principals);
3232
0
3233
0
        subjectPrincipal = principal;
3234
0
      }
3235
0
      bool result(self->IsPointInPath(cx, MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, arg3, subjectPrincipal));
3236
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3237
0
      args.rval().setBoolean(result);
3238
0
      return true;
3239
0
      break;
3240
0
    }
3241
0
    default: {
3242
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.isPointInPath");
3243
0
      break;
3244
0
    }
3245
0
  }
3246
0
  MOZ_CRASH("We have an always-returning default case");
3247
0
  return false;
3248
0
}
3249
3250
static const JSJitInfo isPointInPath_methodinfo = {
3251
  { (JSJitGetterOp)isPointInPath },
3252
  { prototypes::id::CanvasRenderingContext2D },
3253
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3254
  JSJitInfo::Method,
3255
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3256
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
3257
  false,  /* isInfallible. False in setters. */
3258
  false,  /* isMovable.  Not relevant for setters. */
3259
  false, /* isEliminatable.  Not relevant for setters. */
3260
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3261
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3262
  false,  /* isTypedMethod.  Only relevant for methods. */
3263
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3264
};
3265
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3266
static_assert(0 < 1, "There is no slot for us");
3267
3268
MOZ_CAN_RUN_SCRIPT static bool
3269
isPointInStroke(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3270
0
{
3271
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.isPointInStroke", DOM, cx);
3272
0
3273
0
  unsigned argcount = std::min(args.length(), 3u);
3274
0
  switch (argcount) {
3275
0
    case 2: {
3276
0
      double arg0;
3277
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
3278
0
        return false;
3279
0
      } else if (!mozilla::IsFinite(arg0)) {
3280
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.isPointInStroke");
3281
0
        return false;
3282
0
      }
3283
0
      double arg1;
3284
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3285
0
        return false;
3286
0
      } else if (!mozilla::IsFinite(arg1)) {
3287
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.isPointInStroke");
3288
0
        return false;
3289
0
      }
3290
0
      NonNull<nsIPrincipal> subjectPrincipal;
3291
0
      {
3292
0
        JS::Realm* realm = js::GetContextRealm(cx);
3293
0
        MOZ_ASSERT(realm);
3294
0
        JSPrincipals* principals = JS::GetRealmPrincipals(realm);
3295
0
        nsIPrincipal* principal = nsJSPrincipals::get(principals);
3296
0
3297
0
        subjectPrincipal = principal;
3298
0
      }
3299
0
      bool result(self->IsPointInStroke(cx, arg0, arg1, subjectPrincipal));
3300
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3301
0
      args.rval().setBoolean(result);
3302
0
      return true;
3303
0
      break;
3304
0
    }
3305
0
    case 3: {
3306
0
      NonNull<mozilla::dom::CanvasPath> arg0;
3307
0
      if (args[0].isObject()) {
3308
0
        {
3309
0
          nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
3310
0
          if (NS_FAILED(rv)) {
3311
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.isPointInStroke", "Path2D");
3312
0
            return false;
3313
0
          }
3314
0
        }
3315
0
      } else {
3316
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.isPointInStroke");
3317
0
        return false;
3318
0
      }
3319
0
      double arg1;
3320
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3321
0
        return false;
3322
0
      }
3323
0
      double arg2;
3324
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
3325
0
        return false;
3326
0
      }
3327
0
      NonNull<nsIPrincipal> subjectPrincipal;
3328
0
      {
3329
0
        JS::Realm* realm = js::GetContextRealm(cx);
3330
0
        MOZ_ASSERT(realm);
3331
0
        JSPrincipals* principals = JS::GetRealmPrincipals(realm);
3332
0
        nsIPrincipal* principal = nsJSPrincipals::get(principals);
3333
0
3334
0
        subjectPrincipal = principal;
3335
0
      }
3336
0
      bool result(self->IsPointInStroke(cx, MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, subjectPrincipal));
3337
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3338
0
      args.rval().setBoolean(result);
3339
0
      return true;
3340
0
      break;
3341
0
    }
3342
0
    default: {
3343
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.isPointInStroke");
3344
0
      break;
3345
0
    }
3346
0
  }
3347
0
  MOZ_CRASH("We have an always-returning default case");
3348
0
  return false;
3349
0
}
3350
3351
static const JSJitInfo isPointInStroke_methodinfo = {
3352
  { (JSJitGetterOp)isPointInStroke },
3353
  { prototypes::id::CanvasRenderingContext2D },
3354
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3355
  JSJitInfo::Method,
3356
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3357
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
3358
  false,  /* isInfallible. False in setters. */
3359
  false,  /* isMovable.  Not relevant for setters. */
3360
  false, /* isEliminatable.  Not relevant for setters. */
3361
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3362
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3363
  false,  /* isTypedMethod.  Only relevant for methods. */
3364
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3365
};
3366
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3367
static_assert(0 < 1, "There is no slot for us");
3368
3369
MOZ_CAN_RUN_SCRIPT static bool
3370
get_strokeStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
3371
0
{
3372
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.strokeStyle", DOM, cx);
3373
0
3374
0
  OwningStringOrCanvasGradientOrCanvasPattern result;
3375
0
  self->GetStrokeStyle(result);
3376
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3377
0
  if (!result.ToJSVal(cx, obj, args.rval())) {
3378
0
    return false;
3379
0
  }
3380
0
  return true;
3381
0
}
3382
3383
MOZ_CAN_RUN_SCRIPT static bool
3384
set_strokeStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
3385
0
{
3386
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.strokeStyle", DOM, cx);
3387
0
3388
0
  StringOrCanvasGradientOrCanvasPattern arg0;
3389
0
  StringOrCanvasGradientOrCanvasPatternArgument arg0_holder(arg0);
3390
0
  {
3391
0
    bool done = false, failed = false, tryNext;
3392
0
    if (args[0].isObject()) {
3393
0
      done = (failed = !arg0_holder.TrySetToCanvasGradient(cx, args[0], tryNext, false)) || !tryNext ||
3394
0
             (failed = !arg0_holder.TrySetToCanvasPattern(cx, args[0], tryNext, false)) || !tryNext;
3395
0
3396
0
    }
3397
0
    if (!done) {
3398
0
      do {
3399
0
        done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
3400
0
        break;
3401
0
      } while (false);
3402
0
    }
3403
0
    if (failed) {
3404
0
      return false;
3405
0
    }
3406
0
    if (!done) {
3407
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to CanvasRenderingContext2D.strokeStyle", "CanvasGradient, CanvasPattern");
3408
0
      return false;
3409
0
    }
3410
0
  }
3411
0
  self->SetStrokeStyle(Constify(arg0));
3412
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3413
0
3414
0
  return true;
3415
0
}
3416
3417
static const JSJitInfo strokeStyle_getterinfo = {
3418
  { (JSJitGetterOp)get_strokeStyle },
3419
  { prototypes::id::CanvasRenderingContext2D },
3420
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3421
  JSJitInfo::Getter,
3422
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3423
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3424
  false,  /* isInfallible. False in setters. */
3425
  false,  /* isMovable.  Not relevant for setters. */
3426
  false, /* isEliminatable.  Not relevant for setters. */
3427
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3428
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3429
  false,  /* isTypedMethod.  Only relevant for methods. */
3430
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3431
};
3432
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3433
static_assert(0 < 1, "There is no slot for us");
3434
static const JSJitInfo strokeStyle_setterinfo = {
3435
  { (JSJitGetterOp)set_strokeStyle },
3436
  { prototypes::id::CanvasRenderingContext2D },
3437
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3438
  JSJitInfo::Setter,
3439
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3440
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3441
  false,  /* isInfallible. False in setters. */
3442
  false,  /* isMovable.  Not relevant for setters. */
3443
  false, /* isEliminatable.  Not relevant for setters. */
3444
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3445
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3446
  false,  /* isTypedMethod.  Only relevant for methods. */
3447
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3448
};
3449
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3450
static_assert(0 < 1, "There is no slot for us");
3451
3452
MOZ_CAN_RUN_SCRIPT static bool
3453
get_fillStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
3454
0
{
3455
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.fillStyle", DOM, cx);
3456
0
3457
0
  OwningStringOrCanvasGradientOrCanvasPattern result;
3458
0
  self->GetFillStyle(result);
3459
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3460
0
  if (!result.ToJSVal(cx, obj, args.rval())) {
3461
0
    return false;
3462
0
  }
3463
0
  return true;
3464
0
}
3465
3466
MOZ_CAN_RUN_SCRIPT static bool
3467
set_fillStyle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
3468
0
{
3469
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.fillStyle", DOM, cx);
3470
0
3471
0
  StringOrCanvasGradientOrCanvasPattern arg0;
3472
0
  StringOrCanvasGradientOrCanvasPatternArgument arg0_holder(arg0);
3473
0
  {
3474
0
    bool done = false, failed = false, tryNext;
3475
0
    if (args[0].isObject()) {
3476
0
      done = (failed = !arg0_holder.TrySetToCanvasGradient(cx, args[0], tryNext, false)) || !tryNext ||
3477
0
             (failed = !arg0_holder.TrySetToCanvasPattern(cx, args[0], tryNext, false)) || !tryNext;
3478
0
3479
0
    }
3480
0
    if (!done) {
3481
0
      do {
3482
0
        done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
3483
0
        break;
3484
0
      } while (false);
3485
0
    }
3486
0
    if (failed) {
3487
0
      return false;
3488
0
    }
3489
0
    if (!done) {
3490
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to CanvasRenderingContext2D.fillStyle", "CanvasGradient, CanvasPattern");
3491
0
      return false;
3492
0
    }
3493
0
  }
3494
0
  self->SetFillStyle(Constify(arg0));
3495
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3496
0
3497
0
  return true;
3498
0
}
3499
3500
static const JSJitInfo fillStyle_getterinfo = {
3501
  { (JSJitGetterOp)get_fillStyle },
3502
  { prototypes::id::CanvasRenderingContext2D },
3503
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3504
  JSJitInfo::Getter,
3505
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3506
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3507
  false,  /* isInfallible. False in setters. */
3508
  false,  /* isMovable.  Not relevant for setters. */
3509
  false, /* isEliminatable.  Not relevant for setters. */
3510
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3511
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3512
  false,  /* isTypedMethod.  Only relevant for methods. */
3513
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3514
};
3515
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3516
static_assert(0 < 1, "There is no slot for us");
3517
static const JSJitInfo fillStyle_setterinfo = {
3518
  { (JSJitGetterOp)set_fillStyle },
3519
  { prototypes::id::CanvasRenderingContext2D },
3520
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3521
  JSJitInfo::Setter,
3522
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3523
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3524
  false,  /* isInfallible. False in setters. */
3525
  false,  /* isMovable.  Not relevant for setters. */
3526
  false, /* isEliminatable.  Not relevant for setters. */
3527
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3528
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3529
  false,  /* isTypedMethod.  Only relevant for methods. */
3530
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3531
};
3532
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3533
static_assert(0 < 1, "There is no slot for us");
3534
3535
MOZ_CAN_RUN_SCRIPT static bool
3536
createLinearGradient(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3537
0
{
3538
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.createLinearGradient", DOM, cx);
3539
0
3540
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
3541
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createLinearGradient");
3542
0
  }
3543
0
  double arg0;
3544
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
3545
0
    return false;
3546
0
  } else if (!mozilla::IsFinite(arg0)) {
3547
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.createLinearGradient");
3548
0
    return false;
3549
0
  }
3550
0
  double arg1;
3551
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3552
0
    return false;
3553
0
  } else if (!mozilla::IsFinite(arg1)) {
3554
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.createLinearGradient");
3555
0
    return false;
3556
0
  }
3557
0
  double arg2;
3558
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
3559
0
    return false;
3560
0
  } else if (!mozilla::IsFinite(arg2)) {
3561
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.createLinearGradient");
3562
0
    return false;
3563
0
  }
3564
0
  double arg3;
3565
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
3566
0
    return false;
3567
0
  } else if (!mozilla::IsFinite(arg3)) {
3568
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.createLinearGradient");
3569
0
    return false;
3570
0
  }
3571
0
  auto result(StrongOrRawPtr<mozilla::dom::CanvasGradient>(self->CreateLinearGradient(arg0, arg1, arg2, arg3)));
3572
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3573
0
  static_assert(!IsPointer<decltype(result)>::value,
3574
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
3575
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3576
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3577
0
    return false;
3578
0
  }
3579
0
  return true;
3580
0
}
3581
3582
static const JSJitInfo createLinearGradient_methodinfo = {
3583
  { (JSJitGetterOp)createLinearGradient },
3584
  { prototypes::id::CanvasRenderingContext2D },
3585
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3586
  JSJitInfo::Method,
3587
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3588
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3589
  false,  /* isInfallible. False in setters. */
3590
  false,  /* isMovable.  Not relevant for setters. */
3591
  false, /* isEliminatable.  Not relevant for setters. */
3592
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3593
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3594
  false,  /* isTypedMethod.  Only relevant for methods. */
3595
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3596
};
3597
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3598
static_assert(0 < 1, "There is no slot for us");
3599
3600
MOZ_CAN_RUN_SCRIPT static bool
3601
createRadialGradient(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3602
0
{
3603
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.createRadialGradient", DOM, cx);
3604
0
3605
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
3606
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createRadialGradient");
3607
0
  }
3608
0
  double arg0;
3609
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
3610
0
    return false;
3611
0
  } else if (!mozilla::IsFinite(arg0)) {
3612
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.createRadialGradient");
3613
0
    return false;
3614
0
  }
3615
0
  double arg1;
3616
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3617
0
    return false;
3618
0
  } else if (!mozilla::IsFinite(arg1)) {
3619
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.createRadialGradient");
3620
0
    return false;
3621
0
  }
3622
0
  double arg2;
3623
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
3624
0
    return false;
3625
0
  } else if (!mozilla::IsFinite(arg2)) {
3626
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.createRadialGradient");
3627
0
    return false;
3628
0
  }
3629
0
  double arg3;
3630
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
3631
0
    return false;
3632
0
  } else if (!mozilla::IsFinite(arg3)) {
3633
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.createRadialGradient");
3634
0
    return false;
3635
0
  }
3636
0
  double arg4;
3637
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
3638
0
    return false;
3639
0
  } else if (!mozilla::IsFinite(arg4)) {
3640
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 5 of CanvasRenderingContext2D.createRadialGradient");
3641
0
    return false;
3642
0
  }
3643
0
  double arg5;
3644
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
3645
0
    return false;
3646
0
  } else if (!mozilla::IsFinite(arg5)) {
3647
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 6 of CanvasRenderingContext2D.createRadialGradient");
3648
0
    return false;
3649
0
  }
3650
0
  FastErrorResult rv;
3651
0
  auto result(StrongOrRawPtr<mozilla::dom::CanvasGradient>(self->CreateRadialGradient(arg0, arg1, arg2, arg3, arg4, arg5, rv)));
3652
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3653
0
    return false;
3654
0
  }
3655
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3656
0
  static_assert(!IsPointer<decltype(result)>::value,
3657
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
3658
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3659
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3660
0
    return false;
3661
0
  }
3662
0
  return true;
3663
0
}
3664
3665
static const JSJitInfo createRadialGradient_methodinfo = {
3666
  { (JSJitGetterOp)createRadialGradient },
3667
  { prototypes::id::CanvasRenderingContext2D },
3668
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3669
  JSJitInfo::Method,
3670
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3671
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
3672
  false,  /* isInfallible. False in setters. */
3673
  false,  /* isMovable.  Not relevant for setters. */
3674
  false, /* isEliminatable.  Not relevant for setters. */
3675
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3676
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3677
  false,  /* isTypedMethod.  Only relevant for methods. */
3678
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3679
};
3680
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3681
static_assert(0 < 1, "There is no slot for us");
3682
3683
MOZ_CAN_RUN_SCRIPT static bool
3684
createPattern(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3685
0
{
3686
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.createPattern", DOM, cx);
3687
0
3688
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
3689
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createPattern");
3690
0
  }
3691
0
  HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap arg0;
3692
0
  HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmapArgument arg0_holder(arg0);
3693
0
  {
3694
0
    bool done = false, failed = false, tryNext;
3695
0
    if (args[0].isObject()) {
3696
0
      done = (failed = !arg0_holder.TrySetToHTMLImageElement(cx, args[0], tryNext, false)) || !tryNext ||
3697
0
             (failed = !arg0_holder.TrySetToSVGImageElement(cx, args[0], tryNext, false)) || !tryNext ||
3698
0
             (failed = !arg0_holder.TrySetToHTMLCanvasElement(cx, args[0], tryNext, false)) || !tryNext ||
3699
0
             (failed = !arg0_holder.TrySetToHTMLVideoElement(cx, args[0], tryNext, false)) || !tryNext ||
3700
0
             (failed = !arg0_holder.TrySetToImageBitmap(cx, args[0], tryNext, false)) || !tryNext;
3701
0
3702
0
    }
3703
0
    if (failed) {
3704
0
      return false;
3705
0
    }
3706
0
    if (!done) {
3707
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of CanvasRenderingContext2D.createPattern", "HTMLImageElement, SVGImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap");
3708
0
      return false;
3709
0
    }
3710
0
  }
3711
0
  binding_detail::FakeString arg1;
3712
0
  if (!ConvertJSValueToString(cx, args[1], eEmpty, eStringify, arg1)) {
3713
0
    return false;
3714
0
  }
3715
0
  FastErrorResult rv;
3716
0
  auto result(StrongOrRawPtr<mozilla::dom::CanvasPattern>(self->CreatePattern(Constify(arg0), NonNullHelper(Constify(arg1)), rv)));
3717
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3718
0
    return false;
3719
0
  }
3720
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3721
0
  static_assert(!IsPointer<decltype(result)>::value,
3722
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
3723
0
  if (!result) {
3724
0
    args.rval().setNull();
3725
0
    return true;
3726
0
  }
3727
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
3728
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
3729
0
    return false;
3730
0
  }
3731
0
  return true;
3732
0
}
3733
3734
static const JSJitInfo createPattern_methodinfo = {
3735
  { (JSJitGetterOp)createPattern },
3736
  { prototypes::id::CanvasRenderingContext2D },
3737
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3738
  JSJitInfo::Method,
3739
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3740
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
3741
  false,  /* isInfallible. False in setters. */
3742
  false,  /* isMovable.  Not relevant for setters. */
3743
  false, /* isEliminatable.  Not relevant for setters. */
3744
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3745
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3746
  false,  /* isTypedMethod.  Only relevant for methods. */
3747
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3748
};
3749
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3750
static_assert(0 < 1, "There is no slot for us");
3751
3752
MOZ_CAN_RUN_SCRIPT static bool
3753
get_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
3754
0
{
3755
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.filter", DOM, cx);
3756
0
3757
0
  DOMString result;
3758
0
  self->GetFilter(result);
3759
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3760
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
3761
0
    return false;
3762
0
  }
3763
0
  return true;
3764
0
}
3765
3766
MOZ_CAN_RUN_SCRIPT static bool
3767
set_filter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
3768
0
{
3769
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.filter", DOM, cx);
3770
0
3771
0
  binding_detail::FakeString arg0;
3772
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3773
0
    return false;
3774
0
  }
3775
0
  FastErrorResult rv;
3776
0
  self->SetFilter(NonNullHelper(Constify(arg0)), rv);
3777
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3778
0
    return false;
3779
0
  }
3780
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3781
0
3782
0
  return true;
3783
0
}
3784
3785
static const JSJitInfo filter_getterinfo = {
3786
  { (JSJitGetterOp)get_filter },
3787
  { prototypes::id::CanvasRenderingContext2D },
3788
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3789
  JSJitInfo::Getter,
3790
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3791
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
3792
  false,  /* isInfallible. False in setters. */
3793
  false,  /* isMovable.  Not relevant for setters. */
3794
  false, /* isEliminatable.  Not relevant for setters. */
3795
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3796
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3797
  false,  /* isTypedMethod.  Only relevant for methods. */
3798
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3799
};
3800
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3801
static_assert(0 < 1, "There is no slot for us");
3802
static const JSJitInfo filter_setterinfo = {
3803
  { (JSJitGetterOp)set_filter },
3804
  { prototypes::id::CanvasRenderingContext2D },
3805
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3806
  JSJitInfo::Setter,
3807
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3808
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3809
  false,  /* isInfallible. False in setters. */
3810
  false,  /* isMovable.  Not relevant for setters. */
3811
  false, /* isEliminatable.  Not relevant for setters. */
3812
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3813
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3814
  false,  /* isTypedMethod.  Only relevant for methods. */
3815
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3816
};
3817
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3818
static_assert(0 < 1, "There is no slot for us");
3819
3820
MOZ_CAN_RUN_SCRIPT static bool
3821
addHitRegion(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3822
0
{
3823
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.addHitRegion", DOM, cx);
3824
0
3825
0
  binding_detail::FastHitRegionOptions arg0;
3826
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of CanvasRenderingContext2D.addHitRegion", false)) {
3827
0
    return false;
3828
0
  }
3829
0
  FastErrorResult rv;
3830
0
  self->AddHitRegion(Constify(arg0), rv);
3831
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3832
0
    return false;
3833
0
  }
3834
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3835
0
  args.rval().setUndefined();
3836
0
  return true;
3837
0
}
3838
3839
static const JSJitInfo addHitRegion_methodinfo = {
3840
  { (JSJitGetterOp)addHitRegion },
3841
  { prototypes::id::CanvasRenderingContext2D },
3842
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3843
  JSJitInfo::Method,
3844
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3845
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3846
  false,  /* isInfallible. False in setters. */
3847
  false,  /* isMovable.  Not relevant for setters. */
3848
  false, /* isEliminatable.  Not relevant for setters. */
3849
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3850
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3851
  false,  /* isTypedMethod.  Only relevant for methods. */
3852
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3853
};
3854
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3855
static_assert(0 < 1, "There is no slot for us");
3856
3857
MOZ_CAN_RUN_SCRIPT static bool
3858
removeHitRegion(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3859
0
{
3860
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.removeHitRegion", DOM, cx);
3861
0
3862
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
3863
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.removeHitRegion");
3864
0
  }
3865
0
  binding_detail::FakeString arg0;
3866
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
3867
0
    return false;
3868
0
  }
3869
0
  self->RemoveHitRegion(NonNullHelper(Constify(arg0)));
3870
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3871
0
  args.rval().setUndefined();
3872
0
  return true;
3873
0
}
3874
3875
static const JSJitInfo removeHitRegion_methodinfo = {
3876
  { (JSJitGetterOp)removeHitRegion },
3877
  { prototypes::id::CanvasRenderingContext2D },
3878
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3879
  JSJitInfo::Method,
3880
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3881
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3882
  false,  /* isInfallible. False in setters. */
3883
  false,  /* isMovable.  Not relevant for setters. */
3884
  false, /* isEliminatable.  Not relevant for setters. */
3885
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3886
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3887
  false,  /* isTypedMethod.  Only relevant for methods. */
3888
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3889
};
3890
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3891
static_assert(0 < 1, "There is no slot for us");
3892
3893
MOZ_CAN_RUN_SCRIPT static bool
3894
clearHitRegions(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3895
0
{
3896
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.clearHitRegions", DOM, cx);
3897
0
3898
0
  self->ClearHitRegions();
3899
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
3900
0
  args.rval().setUndefined();
3901
0
  return true;
3902
0
}
3903
3904
static const JSJitInfo clearHitRegions_methodinfo = {
3905
  { (JSJitGetterOp)clearHitRegions },
3906
  { prototypes::id::CanvasRenderingContext2D },
3907
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
3908
  JSJitInfo::Method,
3909
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
3910
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
3911
  true,  /* isInfallible. False in setters. */
3912
  false,  /* isMovable.  Not relevant for setters. */
3913
  false, /* isEliminatable.  Not relevant for setters. */
3914
  false, /* isAlwaysInSlot.  Only relevant for getters. */
3915
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
3916
  false,  /* isTypedMethod.  Only relevant for methods. */
3917
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
3918
};
3919
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
3920
static_assert(0 < 1, "There is no slot for us");
3921
3922
MOZ_CAN_RUN_SCRIPT static bool
3923
createImageData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
3924
0
{
3925
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.createImageData", DOM, cx);
3926
0
3927
0
  unsigned argcount = std::min(args.length(), 2u);
3928
0
  switch (argcount) {
3929
0
    case 1: {
3930
0
      NonNull<mozilla::dom::ImageData> arg0;
3931
0
      if (args[0].isObject()) {
3932
0
        {
3933
0
          nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[0], arg0);
3934
0
          if (NS_FAILED(rv)) {
3935
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.createImageData", "ImageData");
3936
0
            return false;
3937
0
          }
3938
0
        }
3939
0
      } else {
3940
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.createImageData");
3941
0
        return false;
3942
0
      }
3943
0
      FastErrorResult rv;
3944
0
      auto result(StrongOrRawPtr<mozilla::dom::ImageData>(self->CreateImageData(cx, MOZ_KnownLive(NonNullHelper(arg0)), rv)));
3945
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3946
0
        return false;
3947
0
      }
3948
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3949
0
      static_assert(!IsPointer<decltype(result)>::value,
3950
0
                    "NewObject implies that we need to keep the object alive with a strong reference.");
3951
0
      if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
3952
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
3953
0
        return false;
3954
0
      }
3955
0
      return true;
3956
0
      break;
3957
0
    }
3958
0
    case 2: {
3959
0
      double arg0;
3960
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
3961
0
        return false;
3962
0
      } else if (!mozilla::IsFinite(arg0)) {
3963
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.createImageData");
3964
0
        return false;
3965
0
      }
3966
0
      double arg1;
3967
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
3968
0
        return false;
3969
0
      } else if (!mozilla::IsFinite(arg1)) {
3970
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.createImageData");
3971
0
        return false;
3972
0
      }
3973
0
      FastErrorResult rv;
3974
0
      auto result(StrongOrRawPtr<mozilla::dom::ImageData>(self->CreateImageData(cx, arg0, arg1, rv)));
3975
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
3976
0
        return false;
3977
0
      }
3978
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
3979
0
      static_assert(!IsPointer<decltype(result)>::value,
3980
0
                    "NewObject implies that we need to keep the object alive with a strong reference.");
3981
0
      if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
3982
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
3983
0
        return false;
3984
0
      }
3985
0
      return true;
3986
0
      break;
3987
0
    }
3988
0
    default: {
3989
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.createImageData");
3990
0
      break;
3991
0
    }
3992
0
  }
3993
0
  MOZ_CRASH("We have an always-returning default case");
3994
0
  return false;
3995
0
}
3996
3997
static const JSJitInfo createImageData_methodinfo = {
3998
  { (JSJitGetterOp)createImageData },
3999
  { prototypes::id::CanvasRenderingContext2D },
4000
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4001
  JSJitInfo::Method,
4002
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4003
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
4004
  false,  /* isInfallible. False in setters. */
4005
  false,  /* isMovable.  Not relevant for setters. */
4006
  false, /* isEliminatable.  Not relevant for setters. */
4007
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4008
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4009
  false,  /* isTypedMethod.  Only relevant for methods. */
4010
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4011
};
4012
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4013
static_assert(0 < 1, "There is no slot for us");
4014
4015
MOZ_CAN_RUN_SCRIPT static bool
4016
getImageData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4017
0
{
4018
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.getImageData", DOM, cx);
4019
0
4020
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
4021
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.getImageData");
4022
0
  }
4023
0
  double arg0;
4024
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4025
0
    return false;
4026
0
  } else if (!mozilla::IsFinite(arg0)) {
4027
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of CanvasRenderingContext2D.getImageData");
4028
0
    return false;
4029
0
  }
4030
0
  double arg1;
4031
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4032
0
    return false;
4033
0
  } else if (!mozilla::IsFinite(arg1)) {
4034
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.getImageData");
4035
0
    return false;
4036
0
  }
4037
0
  double arg2;
4038
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
4039
0
    return false;
4040
0
  } else if (!mozilla::IsFinite(arg2)) {
4041
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.getImageData");
4042
0
    return false;
4043
0
  }
4044
0
  double arg3;
4045
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
4046
0
    return false;
4047
0
  } else if (!mozilla::IsFinite(arg3)) {
4048
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.getImageData");
4049
0
    return false;
4050
0
  }
4051
0
  FastErrorResult rv;
4052
0
  NonNull<nsIPrincipal> subjectPrincipal;
4053
0
  {
4054
0
    JS::Realm* realm = js::GetContextRealm(cx);
4055
0
    MOZ_ASSERT(realm);
4056
0
    JSPrincipals* principals = JS::GetRealmPrincipals(realm);
4057
0
    nsIPrincipal* principal = nsJSPrincipals::get(principals);
4058
0
4059
0
    subjectPrincipal = principal;
4060
0
  }
4061
0
  auto result(StrongOrRawPtr<mozilla::dom::ImageData>(self->GetImageData(cx, arg0, arg1, arg2, arg3, subjectPrincipal, rv)));
4062
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4063
0
    return false;
4064
0
  }
4065
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4066
0
  static_assert(!IsPointer<decltype(result)>::value,
4067
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
4068
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
4069
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
4070
0
    return false;
4071
0
  }
4072
0
  return true;
4073
0
}
4074
4075
static const JSJitInfo getImageData_methodinfo = {
4076
  { (JSJitGetterOp)getImageData },
4077
  { prototypes::id::CanvasRenderingContext2D },
4078
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4079
  JSJitInfo::Method,
4080
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4081
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
4082
  false,  /* isInfallible. False in setters. */
4083
  false,  /* isMovable.  Not relevant for setters. */
4084
  false, /* isEliminatable.  Not relevant for setters. */
4085
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4086
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4087
  false,  /* isTypedMethod.  Only relevant for methods. */
4088
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4089
};
4090
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4091
static_assert(0 < 1, "There is no slot for us");
4092
4093
MOZ_CAN_RUN_SCRIPT static bool
4094
putImageData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4095
0
{
4096
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.putImageData", DOM, cx);
4097
0
4098
0
  unsigned argcount = std::min(args.length(), 7u);
4099
0
  switch (argcount) {
4100
0
    case 3: {
4101
0
      NonNull<mozilla::dom::ImageData> arg0;
4102
0
      if (args[0].isObject()) {
4103
0
        {
4104
0
          nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[0], arg0);
4105
0
          if (NS_FAILED(rv)) {
4106
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.putImageData", "ImageData");
4107
0
            return false;
4108
0
          }
4109
0
        }
4110
0
      } else {
4111
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.putImageData");
4112
0
        return false;
4113
0
      }
4114
0
      double arg1;
4115
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4116
0
        return false;
4117
0
      } else if (!mozilla::IsFinite(arg1)) {
4118
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.putImageData");
4119
0
        return false;
4120
0
      }
4121
0
      double arg2;
4122
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
4123
0
        return false;
4124
0
      } else if (!mozilla::IsFinite(arg2)) {
4125
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.putImageData");
4126
0
        return false;
4127
0
      }
4128
0
      FastErrorResult rv;
4129
0
      self->PutImageData(MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, rv);
4130
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4131
0
        return false;
4132
0
      }
4133
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
4134
0
      args.rval().setUndefined();
4135
0
      return true;
4136
0
      break;
4137
0
    }
4138
0
    case 7: {
4139
0
      NonNull<mozilla::dom::ImageData> arg0;
4140
0
      if (args[0].isObject()) {
4141
0
        {
4142
0
          nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[0], arg0);
4143
0
          if (NS_FAILED(rv)) {
4144
0
            ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.putImageData", "ImageData");
4145
0
            return false;
4146
0
          }
4147
0
        }
4148
0
      } else {
4149
0
        ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.putImageData");
4150
0
        return false;
4151
0
      }
4152
0
      double arg1;
4153
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4154
0
        return false;
4155
0
      } else if (!mozilla::IsFinite(arg1)) {
4156
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of CanvasRenderingContext2D.putImageData");
4157
0
        return false;
4158
0
      }
4159
0
      double arg2;
4160
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
4161
0
        return false;
4162
0
      } else if (!mozilla::IsFinite(arg2)) {
4163
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of CanvasRenderingContext2D.putImageData");
4164
0
        return false;
4165
0
      }
4166
0
      double arg3;
4167
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
4168
0
        return false;
4169
0
      } else if (!mozilla::IsFinite(arg3)) {
4170
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 4 of CanvasRenderingContext2D.putImageData");
4171
0
        return false;
4172
0
      }
4173
0
      double arg4;
4174
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
4175
0
        return false;
4176
0
      } else if (!mozilla::IsFinite(arg4)) {
4177
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 5 of CanvasRenderingContext2D.putImageData");
4178
0
        return false;
4179
0
      }
4180
0
      double arg5;
4181
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
4182
0
        return false;
4183
0
      } else if (!mozilla::IsFinite(arg5)) {
4184
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 6 of CanvasRenderingContext2D.putImageData");
4185
0
        return false;
4186
0
      }
4187
0
      double arg6;
4188
0
      if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
4189
0
        return false;
4190
0
      } else if (!mozilla::IsFinite(arg6)) {
4191
0
        ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 7 of CanvasRenderingContext2D.putImageData");
4192
0
        return false;
4193
0
      }
4194
0
      FastErrorResult rv;
4195
0
      self->PutImageData(MOZ_KnownLive(NonNullHelper(arg0)), arg1, arg2, arg3, arg4, arg5, arg6, rv);
4196
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4197
0
        return false;
4198
0
      }
4199
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
4200
0
      args.rval().setUndefined();
4201
0
      return true;
4202
0
      break;
4203
0
    }
4204
0
    default: {
4205
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.putImageData");
4206
0
      break;
4207
0
    }
4208
0
  }
4209
0
  MOZ_CRASH("We have an always-returning default case");
4210
0
  return false;
4211
0
}
4212
4213
static const JSJitInfo putImageData_methodinfo = {
4214
  { (JSJitGetterOp)putImageData },
4215
  { prototypes::id::CanvasRenderingContext2D },
4216
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4217
  JSJitInfo::Method,
4218
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4219
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4220
  false,  /* isInfallible. False in setters. */
4221
  false,  /* isMovable.  Not relevant for setters. */
4222
  false, /* isEliminatable.  Not relevant for setters. */
4223
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4224
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4225
  false,  /* isTypedMethod.  Only relevant for methods. */
4226
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4227
};
4228
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4229
static_assert(0 < 1, "There is no slot for us");
4230
4231
MOZ_CAN_RUN_SCRIPT static bool
4232
get_imageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
4233
0
{
4234
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.imageSmoothingEnabled", DOM, cx);
4235
0
4236
0
  bool result(self->ImageSmoothingEnabled());
4237
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4238
0
  args.rval().setBoolean(result);
4239
0
  return true;
4240
0
}
4241
4242
MOZ_CAN_RUN_SCRIPT static bool
4243
set_imageSmoothingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
4244
0
{
4245
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.imageSmoothingEnabled", DOM, cx);
4246
0
4247
0
  bool arg0;
4248
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
4249
0
    return false;
4250
0
  }
4251
0
  self->SetImageSmoothingEnabled(arg0);
4252
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4253
0
4254
0
  return true;
4255
0
}
4256
4257
static const JSJitInfo imageSmoothingEnabled_getterinfo = {
4258
  { (JSJitGetterOp)get_imageSmoothingEnabled },
4259
  { prototypes::id::CanvasRenderingContext2D },
4260
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4261
  JSJitInfo::Getter,
4262
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4263
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
4264
  true,  /* isInfallible. False in setters. */
4265
  false,  /* isMovable.  Not relevant for setters. */
4266
  false, /* isEliminatable.  Not relevant for setters. */
4267
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4268
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4269
  false,  /* isTypedMethod.  Only relevant for methods. */
4270
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4271
};
4272
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4273
static_assert(0 < 1, "There is no slot for us");
4274
static const JSJitInfo imageSmoothingEnabled_setterinfo = {
4275
  { (JSJitGetterOp)set_imageSmoothingEnabled },
4276
  { prototypes::id::CanvasRenderingContext2D },
4277
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4278
  JSJitInfo::Setter,
4279
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4280
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4281
  false,  /* isInfallible. False in setters. */
4282
  false,  /* isMovable.  Not relevant for setters. */
4283
  false, /* isEliminatable.  Not relevant for setters. */
4284
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4285
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4286
  false,  /* isTypedMethod.  Only relevant for methods. */
4287
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4288
};
4289
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4290
static_assert(0 < 1, "There is no slot for us");
4291
4292
MOZ_CAN_RUN_SCRIPT static bool
4293
get_lineWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
4294
0
{
4295
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.lineWidth", DOM, cx);
4296
0
4297
0
  double result(self->LineWidth());
4298
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4299
0
  args.rval().set(JS_NumberValue(double(result)));
4300
0
  return true;
4301
0
}
4302
4303
MOZ_CAN_RUN_SCRIPT static bool
4304
set_lineWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
4305
0
{
4306
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.lineWidth", DOM, cx);
4307
0
4308
0
  bool foundNonFiniteFloat = false;
4309
0
  double arg0;
4310
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4311
0
    return false;
4312
0
  } else if (!mozilla::IsFinite(arg0)) {
4313
0
    foundNonFiniteFloat = true;
4314
0
  }
4315
0
  if (foundNonFiniteFloat) {
4316
0
    return true;
4317
0
  }
4318
0
  self->SetLineWidth(arg0);
4319
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4320
0
4321
0
  return true;
4322
0
}
4323
4324
static const JSJitInfo lineWidth_getterinfo = {
4325
  { (JSJitGetterOp)get_lineWidth },
4326
  { prototypes::id::CanvasRenderingContext2D },
4327
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4328
  JSJitInfo::Getter,
4329
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4330
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
4331
  true,  /* isInfallible. False in setters. */
4332
  false,  /* isMovable.  Not relevant for setters. */
4333
  false, /* isEliminatable.  Not relevant for setters. */
4334
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4335
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4336
  false,  /* isTypedMethod.  Only relevant for methods. */
4337
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4338
};
4339
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4340
static_assert(0 < 1, "There is no slot for us");
4341
static const JSJitInfo lineWidth_setterinfo = {
4342
  { (JSJitGetterOp)set_lineWidth },
4343
  { prototypes::id::CanvasRenderingContext2D },
4344
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4345
  JSJitInfo::Setter,
4346
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4347
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4348
  false,  /* isInfallible. False in setters. */
4349
  false,  /* isMovable.  Not relevant for setters. */
4350
  false, /* isEliminatable.  Not relevant for setters. */
4351
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4352
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4353
  false,  /* isTypedMethod.  Only relevant for methods. */
4354
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4355
};
4356
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4357
static_assert(0 < 1, "There is no slot for us");
4358
4359
MOZ_CAN_RUN_SCRIPT static bool
4360
get_lineCap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
4361
0
{
4362
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.lineCap", DOM, cx);
4363
0
4364
0
  DOMString result;
4365
0
  self->GetLineCap(result);
4366
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4367
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
4368
0
    return false;
4369
0
  }
4370
0
  return true;
4371
0
}
4372
4373
MOZ_CAN_RUN_SCRIPT static bool
4374
set_lineCap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
4375
0
{
4376
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.lineCap", DOM, cx);
4377
0
4378
0
  binding_detail::FakeString arg0;
4379
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4380
0
    return false;
4381
0
  }
4382
0
  self->SetLineCap(NonNullHelper(Constify(arg0)));
4383
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4384
0
4385
0
  return true;
4386
0
}
4387
4388
static const JSJitInfo lineCap_getterinfo = {
4389
  { (JSJitGetterOp)get_lineCap },
4390
  { prototypes::id::CanvasRenderingContext2D },
4391
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4392
  JSJitInfo::Getter,
4393
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4394
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
4395
  false,  /* isInfallible. False in setters. */
4396
  false,  /* isMovable.  Not relevant for setters. */
4397
  false, /* isEliminatable.  Not relevant for setters. */
4398
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4399
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4400
  false,  /* isTypedMethod.  Only relevant for methods. */
4401
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4402
};
4403
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4404
static_assert(0 < 1, "There is no slot for us");
4405
static const JSJitInfo lineCap_setterinfo = {
4406
  { (JSJitGetterOp)set_lineCap },
4407
  { prototypes::id::CanvasRenderingContext2D },
4408
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4409
  JSJitInfo::Setter,
4410
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4411
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4412
  false,  /* isInfallible. False in setters. */
4413
  false,  /* isMovable.  Not relevant for setters. */
4414
  false, /* isEliminatable.  Not relevant for setters. */
4415
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4416
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4417
  false,  /* isTypedMethod.  Only relevant for methods. */
4418
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4419
};
4420
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4421
static_assert(0 < 1, "There is no slot for us");
4422
4423
MOZ_CAN_RUN_SCRIPT static bool
4424
get_lineJoin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
4425
0
{
4426
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.lineJoin", DOM, cx);
4427
0
4428
0
  FastErrorResult rv;
4429
0
  DOMString result;
4430
0
  self->GetLineJoin(result, rv);
4431
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4432
0
    return false;
4433
0
  }
4434
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4435
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
4436
0
    return false;
4437
0
  }
4438
0
  return true;
4439
0
}
4440
4441
MOZ_CAN_RUN_SCRIPT static bool
4442
set_lineJoin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
4443
0
{
4444
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.lineJoin", DOM, cx);
4445
0
4446
0
  binding_detail::FakeString arg0;
4447
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
4448
0
    return false;
4449
0
  }
4450
0
  self->SetLineJoin(NonNullHelper(Constify(arg0)));
4451
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4452
0
4453
0
  return true;
4454
0
}
4455
4456
static const JSJitInfo lineJoin_getterinfo = {
4457
  { (JSJitGetterOp)get_lineJoin },
4458
  { prototypes::id::CanvasRenderingContext2D },
4459
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4460
  JSJitInfo::Getter,
4461
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4462
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
4463
  false,  /* isInfallible. False in setters. */
4464
  false,  /* isMovable.  Not relevant for setters. */
4465
  false, /* isEliminatable.  Not relevant for setters. */
4466
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4467
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4468
  false,  /* isTypedMethod.  Only relevant for methods. */
4469
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4470
};
4471
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4472
static_assert(0 < 1, "There is no slot for us");
4473
static const JSJitInfo lineJoin_setterinfo = {
4474
  { (JSJitGetterOp)set_lineJoin },
4475
  { prototypes::id::CanvasRenderingContext2D },
4476
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4477
  JSJitInfo::Setter,
4478
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4479
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4480
  false,  /* isInfallible. False in setters. */
4481
  false,  /* isMovable.  Not relevant for setters. */
4482
  false, /* isEliminatable.  Not relevant for setters. */
4483
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4484
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4485
  false,  /* isTypedMethod.  Only relevant for methods. */
4486
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4487
};
4488
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4489
static_assert(0 < 1, "There is no slot for us");
4490
4491
MOZ_CAN_RUN_SCRIPT static bool
4492
get_miterLimit(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
4493
0
{
4494
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.miterLimit", DOM, cx);
4495
0
4496
0
  double result(self->MiterLimit());
4497
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4498
0
  args.rval().set(JS_NumberValue(double(result)));
4499
0
  return true;
4500
0
}
4501
4502
MOZ_CAN_RUN_SCRIPT static bool
4503
set_miterLimit(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
4504
0
{
4505
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.miterLimit", DOM, cx);
4506
0
4507
0
  bool foundNonFiniteFloat = false;
4508
0
  double arg0;
4509
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4510
0
    return false;
4511
0
  } else if (!mozilla::IsFinite(arg0)) {
4512
0
    foundNonFiniteFloat = true;
4513
0
  }
4514
0
  if (foundNonFiniteFloat) {
4515
0
    return true;
4516
0
  }
4517
0
  self->SetMiterLimit(arg0);
4518
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4519
0
4520
0
  return true;
4521
0
}
4522
4523
static const JSJitInfo miterLimit_getterinfo = {
4524
  { (JSJitGetterOp)get_miterLimit },
4525
  { prototypes::id::CanvasRenderingContext2D },
4526
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4527
  JSJitInfo::Getter,
4528
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4529
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
4530
  true,  /* isInfallible. False in setters. */
4531
  false,  /* isMovable.  Not relevant for setters. */
4532
  false, /* isEliminatable.  Not relevant for setters. */
4533
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4534
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4535
  false,  /* isTypedMethod.  Only relevant for methods. */
4536
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4537
};
4538
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4539
static_assert(0 < 1, "There is no slot for us");
4540
static const JSJitInfo miterLimit_setterinfo = {
4541
  { (JSJitGetterOp)set_miterLimit },
4542
  { prototypes::id::CanvasRenderingContext2D },
4543
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4544
  JSJitInfo::Setter,
4545
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4546
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4547
  false,  /* isInfallible. False in setters. */
4548
  false,  /* isMovable.  Not relevant for setters. */
4549
  false, /* isEliminatable.  Not relevant for setters. */
4550
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4551
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4552
  false,  /* isTypedMethod.  Only relevant for methods. */
4553
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4554
};
4555
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4556
static_assert(0 < 1, "There is no slot for us");
4557
4558
MOZ_CAN_RUN_SCRIPT static bool
4559
setLineDash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4560
0
{
4561
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.setLineDash", DOM, cx);
4562
0
4563
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
4564
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.setLineDash");
4565
0
  }
4566
0
  bool foundNonFiniteFloat = false;
4567
0
  binding_detail::AutoSequence<double> arg0;
4568
0
  if (args[0].isObject()) {
4569
0
    JS::ForOfIterator iter(cx);
4570
0
    if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
4571
0
      return false;
4572
0
    }
4573
0
    if (!iter.valueIsIterable()) {
4574
0
      ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of CanvasRenderingContext2D.setLineDash");
4575
0
      return false;
4576
0
    }
4577
0
    binding_detail::AutoSequence<double> &arr = arg0;
4578
0
    JS::Rooted<JS::Value> temp(cx);
4579
0
    while (true) {
4580
0
      bool done;
4581
0
      if (!iter.next(&temp, &done)) {
4582
0
        return false;
4583
0
      }
4584
0
      if (done) {
4585
0
        break;
4586
0
      }
4587
0
      double* slotPtr = arr.AppendElement(mozilla::fallible);
4588
0
      if (!slotPtr) {
4589
0
        JS_ReportOutOfMemory(cx);
4590
0
        return false;
4591
0
      }
4592
0
      double& slot = *slotPtr;
4593
0
      if (!ValueToPrimitive<double, eDefault>(cx, temp, &slot)) {
4594
0
        return false;
4595
0
      } else if (!mozilla::IsFinite(slot)) {
4596
0
        foundNonFiniteFloat = true;
4597
0
      }
4598
0
    }
4599
0
  } else {
4600
0
    ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of CanvasRenderingContext2D.setLineDash");
4601
0
    return false;
4602
0
  }
4603
0
  if (foundNonFiniteFloat) {
4604
0
    args.rval().setUndefined();
4605
0
    return true;
4606
0
  }
4607
0
  FastErrorResult rv;
4608
0
  self->SetLineDash(Constify(arg0), rv);
4609
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
4610
0
    return false;
4611
0
  }
4612
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4613
0
  args.rval().setUndefined();
4614
0
  return true;
4615
0
}
4616
4617
static const JSJitInfo setLineDash_methodinfo = {
4618
  { (JSJitGetterOp)setLineDash },
4619
  { prototypes::id::CanvasRenderingContext2D },
4620
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4621
  JSJitInfo::Method,
4622
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4623
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4624
  false,  /* isInfallible. False in setters. */
4625
  false,  /* isMovable.  Not relevant for setters. */
4626
  false, /* isEliminatable.  Not relevant for setters. */
4627
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4628
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4629
  false,  /* isTypedMethod.  Only relevant for methods. */
4630
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4631
};
4632
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4633
static_assert(0 < 1, "There is no slot for us");
4634
4635
MOZ_CAN_RUN_SCRIPT static bool
4636
getLineDash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4637
0
{
4638
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.getLineDash", DOM, cx);
4639
0
4640
0
  nsTArray<double> result;
4641
0
  self->GetLineDash(result);
4642
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4643
0
4644
0
  uint32_t length = result.Length();
4645
0
  JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
4646
0
  if (!returnArray) {
4647
0
    return false;
4648
0
  }
4649
0
  // Scope for 'tmp'
4650
0
  {
4651
0
    JS::Rooted<JS::Value> tmp(cx);
4652
0
    for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
4653
0
      // Control block to let us common up the JS_DefineElement calls when there
4654
0
      // are different ways to succeed at wrapping the object.
4655
0
      do {
4656
0
        tmp.set(JS_NumberValue(double(result[sequenceIdx0])));
4657
0
        break;
4658
0
      } while (false);
4659
0
      if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
4660
0
                            JSPROP_ENUMERATE)) {
4661
0
        return false;
4662
0
      }
4663
0
    }
4664
0
  }
4665
0
  args.rval().setObject(*returnArray);
4666
0
  return true;
4667
0
}
4668
4669
static const JSJitInfo getLineDash_methodinfo = {
4670
  { (JSJitGetterOp)getLineDash },
4671
  { prototypes::id::CanvasRenderingContext2D },
4672
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4673
  JSJitInfo::Method,
4674
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4675
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
4676
  false,  /* isInfallible. False in setters. */
4677
  false,  /* isMovable.  Not relevant for setters. */
4678
  false, /* isEliminatable.  Not relevant for setters. */
4679
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4680
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4681
  false,  /* isTypedMethod.  Only relevant for methods. */
4682
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4683
};
4684
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4685
static_assert(0 < 1, "There is no slot for us");
4686
4687
MOZ_CAN_RUN_SCRIPT static bool
4688
get_lineDashOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
4689
0
{
4690
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.lineDashOffset", DOM, cx);
4691
0
4692
0
  double result(self->LineDashOffset());
4693
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4694
0
  args.rval().set(JS_NumberValue(double(result)));
4695
0
  return true;
4696
0
}
4697
4698
MOZ_CAN_RUN_SCRIPT static bool
4699
set_lineDashOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
4700
0
{
4701
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.lineDashOffset", DOM, cx);
4702
0
4703
0
  bool foundNonFiniteFloat = false;
4704
0
  double arg0;
4705
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4706
0
    return false;
4707
0
  } else if (!mozilla::IsFinite(arg0)) {
4708
0
    foundNonFiniteFloat = true;
4709
0
  }
4710
0
  if (foundNonFiniteFloat) {
4711
0
    return true;
4712
0
  }
4713
0
  self->SetLineDashOffset(arg0);
4714
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4715
0
4716
0
  return true;
4717
0
}
4718
4719
static const JSJitInfo lineDashOffset_getterinfo = {
4720
  { (JSJitGetterOp)get_lineDashOffset },
4721
  { prototypes::id::CanvasRenderingContext2D },
4722
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4723
  JSJitInfo::Getter,
4724
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4725
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
4726
  true,  /* isInfallible. False in setters. */
4727
  false,  /* isMovable.  Not relevant for setters. */
4728
  false, /* isEliminatable.  Not relevant for setters. */
4729
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4730
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4731
  false,  /* isTypedMethod.  Only relevant for methods. */
4732
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4733
};
4734
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4735
static_assert(0 < 1, "There is no slot for us");
4736
static const JSJitInfo lineDashOffset_setterinfo = {
4737
  { (JSJitGetterOp)set_lineDashOffset },
4738
  { prototypes::id::CanvasRenderingContext2D },
4739
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4740
  JSJitInfo::Setter,
4741
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4742
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4743
  false,  /* isInfallible. False in setters. */
4744
  false,  /* isMovable.  Not relevant for setters. */
4745
  false, /* isEliminatable.  Not relevant for setters. */
4746
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4747
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4748
  false,  /* isTypedMethod.  Only relevant for methods. */
4749
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4750
};
4751
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4752
static_assert(0 < 1, "There is no slot for us");
4753
4754
MOZ_CAN_RUN_SCRIPT static bool
4755
closePath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4756
0
{
4757
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.closePath", DOM, cx);
4758
0
4759
0
  self->ClosePath();
4760
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4761
0
  args.rval().setUndefined();
4762
0
  return true;
4763
0
}
4764
4765
static const JSJitInfo closePath_methodinfo = {
4766
  { (JSJitGetterOp)closePath },
4767
  { prototypes::id::CanvasRenderingContext2D },
4768
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4769
  JSJitInfo::Method,
4770
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4771
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4772
  true,  /* isInfallible. False in setters. */
4773
  false,  /* isMovable.  Not relevant for setters. */
4774
  false, /* isEliminatable.  Not relevant for setters. */
4775
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4776
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4777
  false,  /* isTypedMethod.  Only relevant for methods. */
4778
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4779
};
4780
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4781
static_assert(0 < 1, "There is no slot for us");
4782
4783
MOZ_CAN_RUN_SCRIPT static bool
4784
moveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4785
0
{
4786
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.moveTo", DOM, cx);
4787
0
4788
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
4789
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.moveTo");
4790
0
  }
4791
0
  bool foundNonFiniteFloat = false;
4792
0
  double arg0;
4793
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4794
0
    return false;
4795
0
  } else if (!mozilla::IsFinite(arg0)) {
4796
0
    foundNonFiniteFloat = true;
4797
0
  }
4798
0
  double arg1;
4799
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4800
0
    return false;
4801
0
  } else if (!mozilla::IsFinite(arg1)) {
4802
0
    foundNonFiniteFloat = true;
4803
0
  }
4804
0
  if (foundNonFiniteFloat) {
4805
0
    args.rval().setUndefined();
4806
0
    return true;
4807
0
  }
4808
0
  self->MoveTo(arg0, arg1);
4809
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4810
0
  args.rval().setUndefined();
4811
0
  return true;
4812
0
}
4813
4814
static const JSJitInfo moveTo_methodinfo = {
4815
  { (JSJitGetterOp)moveTo },
4816
  { prototypes::id::CanvasRenderingContext2D },
4817
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4818
  JSJitInfo::Method,
4819
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4820
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4821
  false,  /* isInfallible. False in setters. */
4822
  false,  /* isMovable.  Not relevant for setters. */
4823
  false, /* isEliminatable.  Not relevant for setters. */
4824
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4825
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4826
  false,  /* isTypedMethod.  Only relevant for methods. */
4827
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4828
};
4829
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4830
static_assert(0 < 1, "There is no slot for us");
4831
4832
MOZ_CAN_RUN_SCRIPT static bool
4833
lineTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4834
0
{
4835
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.lineTo", DOM, cx);
4836
0
4837
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
4838
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.lineTo");
4839
0
  }
4840
0
  bool foundNonFiniteFloat = false;
4841
0
  double arg0;
4842
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4843
0
    return false;
4844
0
  } else if (!mozilla::IsFinite(arg0)) {
4845
0
    foundNonFiniteFloat = true;
4846
0
  }
4847
0
  double arg1;
4848
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4849
0
    return false;
4850
0
  } else if (!mozilla::IsFinite(arg1)) {
4851
0
    foundNonFiniteFloat = true;
4852
0
  }
4853
0
  if (foundNonFiniteFloat) {
4854
0
    args.rval().setUndefined();
4855
0
    return true;
4856
0
  }
4857
0
  self->LineTo(arg0, arg1);
4858
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4859
0
  args.rval().setUndefined();
4860
0
  return true;
4861
0
}
4862
4863
static const JSJitInfo lineTo_methodinfo = {
4864
  { (JSJitGetterOp)lineTo },
4865
  { prototypes::id::CanvasRenderingContext2D },
4866
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4867
  JSJitInfo::Method,
4868
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4869
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4870
  false,  /* isInfallible. False in setters. */
4871
  false,  /* isMovable.  Not relevant for setters. */
4872
  false, /* isEliminatable.  Not relevant for setters. */
4873
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4874
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4875
  false,  /* isTypedMethod.  Only relevant for methods. */
4876
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4877
};
4878
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4879
static_assert(0 < 1, "There is no slot for us");
4880
4881
MOZ_CAN_RUN_SCRIPT static bool
4882
quadraticCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4883
0
{
4884
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.quadraticCurveTo", DOM, cx);
4885
0
4886
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
4887
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.quadraticCurveTo");
4888
0
  }
4889
0
  bool foundNonFiniteFloat = false;
4890
0
  double arg0;
4891
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4892
0
    return false;
4893
0
  } else if (!mozilla::IsFinite(arg0)) {
4894
0
    foundNonFiniteFloat = true;
4895
0
  }
4896
0
  double arg1;
4897
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4898
0
    return false;
4899
0
  } else if (!mozilla::IsFinite(arg1)) {
4900
0
    foundNonFiniteFloat = true;
4901
0
  }
4902
0
  double arg2;
4903
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
4904
0
    return false;
4905
0
  } else if (!mozilla::IsFinite(arg2)) {
4906
0
    foundNonFiniteFloat = true;
4907
0
  }
4908
0
  double arg3;
4909
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
4910
0
    return false;
4911
0
  } else if (!mozilla::IsFinite(arg3)) {
4912
0
    foundNonFiniteFloat = true;
4913
0
  }
4914
0
  if (foundNonFiniteFloat) {
4915
0
    args.rval().setUndefined();
4916
0
    return true;
4917
0
  }
4918
0
  self->QuadraticCurveTo(arg0, arg1, arg2, arg3);
4919
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4920
0
  args.rval().setUndefined();
4921
0
  return true;
4922
0
}
4923
4924
static const JSJitInfo quadraticCurveTo_methodinfo = {
4925
  { (JSJitGetterOp)quadraticCurveTo },
4926
  { prototypes::id::CanvasRenderingContext2D },
4927
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
4928
  JSJitInfo::Method,
4929
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
4930
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
4931
  false,  /* isInfallible. False in setters. */
4932
  false,  /* isMovable.  Not relevant for setters. */
4933
  false, /* isEliminatable.  Not relevant for setters. */
4934
  false, /* isAlwaysInSlot.  Only relevant for getters. */
4935
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
4936
  false,  /* isTypedMethod.  Only relevant for methods. */
4937
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
4938
};
4939
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
4940
static_assert(0 < 1, "There is no slot for us");
4941
4942
MOZ_CAN_RUN_SCRIPT static bool
4943
bezierCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
4944
0
{
4945
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.bezierCurveTo", DOM, cx);
4946
0
4947
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
4948
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.bezierCurveTo");
4949
0
  }
4950
0
  bool foundNonFiniteFloat = false;
4951
0
  double arg0;
4952
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
4953
0
    return false;
4954
0
  } else if (!mozilla::IsFinite(arg0)) {
4955
0
    foundNonFiniteFloat = true;
4956
0
  }
4957
0
  double arg1;
4958
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
4959
0
    return false;
4960
0
  } else if (!mozilla::IsFinite(arg1)) {
4961
0
    foundNonFiniteFloat = true;
4962
0
  }
4963
0
  double arg2;
4964
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
4965
0
    return false;
4966
0
  } else if (!mozilla::IsFinite(arg2)) {
4967
0
    foundNonFiniteFloat = true;
4968
0
  }
4969
0
  double arg3;
4970
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
4971
0
    return false;
4972
0
  } else if (!mozilla::IsFinite(arg3)) {
4973
0
    foundNonFiniteFloat = true;
4974
0
  }
4975
0
  double arg4;
4976
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
4977
0
    return false;
4978
0
  } else if (!mozilla::IsFinite(arg4)) {
4979
0
    foundNonFiniteFloat = true;
4980
0
  }
4981
0
  double arg5;
4982
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
4983
0
    return false;
4984
0
  } else if (!mozilla::IsFinite(arg5)) {
4985
0
    foundNonFiniteFloat = true;
4986
0
  }
4987
0
  if (foundNonFiniteFloat) {
4988
0
    args.rval().setUndefined();
4989
0
    return true;
4990
0
  }
4991
0
  self->BezierCurveTo(arg0, arg1, arg2, arg3, arg4, arg5);
4992
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
4993
0
  args.rval().setUndefined();
4994
0
  return true;
4995
0
}
4996
4997
static const JSJitInfo bezierCurveTo_methodinfo = {
4998
  { (JSJitGetterOp)bezierCurveTo },
4999
  { prototypes::id::CanvasRenderingContext2D },
5000
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5001
  JSJitInfo::Method,
5002
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5003
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5004
  false,  /* isInfallible. False in setters. */
5005
  false,  /* isMovable.  Not relevant for setters. */
5006
  false, /* isEliminatable.  Not relevant for setters. */
5007
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5008
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5009
  false,  /* isTypedMethod.  Only relevant for methods. */
5010
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5011
};
5012
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5013
static_assert(0 < 1, "There is no slot for us");
5014
5015
MOZ_CAN_RUN_SCRIPT static bool
5016
arcTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5017
0
{
5018
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.arcTo", DOM, cx);
5019
0
5020
0
  if (MOZ_UNLIKELY(args.length() < 5)) {
5021
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.arcTo");
5022
0
  }
5023
0
  bool foundNonFiniteFloat = false;
5024
0
  double arg0;
5025
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5026
0
    return false;
5027
0
  } else if (!mozilla::IsFinite(arg0)) {
5028
0
    foundNonFiniteFloat = true;
5029
0
  }
5030
0
  double arg1;
5031
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5032
0
    return false;
5033
0
  } else if (!mozilla::IsFinite(arg1)) {
5034
0
    foundNonFiniteFloat = true;
5035
0
  }
5036
0
  double arg2;
5037
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5038
0
    return false;
5039
0
  } else if (!mozilla::IsFinite(arg2)) {
5040
0
    foundNonFiniteFloat = true;
5041
0
  }
5042
0
  double arg3;
5043
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5044
0
    return false;
5045
0
  } else if (!mozilla::IsFinite(arg3)) {
5046
0
    foundNonFiniteFloat = true;
5047
0
  }
5048
0
  double arg4;
5049
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
5050
0
    return false;
5051
0
  } else if (!mozilla::IsFinite(arg4)) {
5052
0
    foundNonFiniteFloat = true;
5053
0
  }
5054
0
  if (foundNonFiniteFloat) {
5055
0
    args.rval().setUndefined();
5056
0
    return true;
5057
0
  }
5058
0
  FastErrorResult rv;
5059
0
  self->ArcTo(arg0, arg1, arg2, arg3, arg4, rv);
5060
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
5061
0
    return false;
5062
0
  }
5063
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5064
0
  args.rval().setUndefined();
5065
0
  return true;
5066
0
}
5067
5068
static const JSJitInfo arcTo_methodinfo = {
5069
  { (JSJitGetterOp)arcTo },
5070
  { prototypes::id::CanvasRenderingContext2D },
5071
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5072
  JSJitInfo::Method,
5073
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5074
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5075
  false,  /* isInfallible. False in setters. */
5076
  false,  /* isMovable.  Not relevant for setters. */
5077
  false, /* isEliminatable.  Not relevant for setters. */
5078
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5079
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5080
  false,  /* isTypedMethod.  Only relevant for methods. */
5081
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5082
};
5083
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5084
static_assert(0 < 1, "There is no slot for us");
5085
5086
MOZ_CAN_RUN_SCRIPT static bool
5087
rect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5088
0
{
5089
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.rect", DOM, cx);
5090
0
5091
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
5092
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.rect");
5093
0
  }
5094
0
  bool foundNonFiniteFloat = false;
5095
0
  double arg0;
5096
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5097
0
    return false;
5098
0
  } else if (!mozilla::IsFinite(arg0)) {
5099
0
    foundNonFiniteFloat = true;
5100
0
  }
5101
0
  double arg1;
5102
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5103
0
    return false;
5104
0
  } else if (!mozilla::IsFinite(arg1)) {
5105
0
    foundNonFiniteFloat = true;
5106
0
  }
5107
0
  double arg2;
5108
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5109
0
    return false;
5110
0
  } else if (!mozilla::IsFinite(arg2)) {
5111
0
    foundNonFiniteFloat = true;
5112
0
  }
5113
0
  double arg3;
5114
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5115
0
    return false;
5116
0
  } else if (!mozilla::IsFinite(arg3)) {
5117
0
    foundNonFiniteFloat = true;
5118
0
  }
5119
0
  if (foundNonFiniteFloat) {
5120
0
    args.rval().setUndefined();
5121
0
    return true;
5122
0
  }
5123
0
  self->Rect(arg0, arg1, arg2, arg3);
5124
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5125
0
  args.rval().setUndefined();
5126
0
  return true;
5127
0
}
5128
5129
static const JSJitInfo rect_methodinfo = {
5130
  { (JSJitGetterOp)rect },
5131
  { prototypes::id::CanvasRenderingContext2D },
5132
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5133
  JSJitInfo::Method,
5134
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5135
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5136
  false,  /* isInfallible. False in setters. */
5137
  false,  /* isMovable.  Not relevant for setters. */
5138
  false, /* isEliminatable.  Not relevant for setters. */
5139
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5140
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5141
  false,  /* isTypedMethod.  Only relevant for methods. */
5142
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5143
};
5144
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5145
static_assert(0 < 1, "There is no slot for us");
5146
5147
MOZ_CAN_RUN_SCRIPT static bool
5148
arc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5149
0
{
5150
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.arc", DOM, cx);
5151
0
5152
0
  if (MOZ_UNLIKELY(args.length() < 5)) {
5153
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.arc");
5154
0
  }
5155
0
  bool foundNonFiniteFloat = false;
5156
0
  double arg0;
5157
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5158
0
    return false;
5159
0
  } else if (!mozilla::IsFinite(arg0)) {
5160
0
    foundNonFiniteFloat = true;
5161
0
  }
5162
0
  double arg1;
5163
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5164
0
    return false;
5165
0
  } else if (!mozilla::IsFinite(arg1)) {
5166
0
    foundNonFiniteFloat = true;
5167
0
  }
5168
0
  double arg2;
5169
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5170
0
    return false;
5171
0
  } else if (!mozilla::IsFinite(arg2)) {
5172
0
    foundNonFiniteFloat = true;
5173
0
  }
5174
0
  double arg3;
5175
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5176
0
    return false;
5177
0
  } else if (!mozilla::IsFinite(arg3)) {
5178
0
    foundNonFiniteFloat = true;
5179
0
  }
5180
0
  double arg4;
5181
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
5182
0
    return false;
5183
0
  } else if (!mozilla::IsFinite(arg4)) {
5184
0
    foundNonFiniteFloat = true;
5185
0
  }
5186
0
  bool arg5;
5187
0
  if (args.hasDefined(5)) {
5188
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) {
5189
0
      return false;
5190
0
    }
5191
0
  } else {
5192
0
    arg5 = false;
5193
0
  }
5194
0
  if (foundNonFiniteFloat) {
5195
0
    args.rval().setUndefined();
5196
0
    return true;
5197
0
  }
5198
0
  FastErrorResult rv;
5199
0
  self->Arc(arg0, arg1, arg2, arg3, arg4, arg5, rv);
5200
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
5201
0
    return false;
5202
0
  }
5203
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5204
0
  args.rval().setUndefined();
5205
0
  return true;
5206
0
}
5207
5208
static const JSJitInfo arc_methodinfo = {
5209
  { (JSJitGetterOp)arc },
5210
  { prototypes::id::CanvasRenderingContext2D },
5211
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5212
  JSJitInfo::Method,
5213
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5214
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5215
  false,  /* isInfallible. False in setters. */
5216
  false,  /* isMovable.  Not relevant for setters. */
5217
  false, /* isEliminatable.  Not relevant for setters. */
5218
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5219
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5220
  false,  /* isTypedMethod.  Only relevant for methods. */
5221
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5222
};
5223
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5224
static_assert(0 < 1, "There is no slot for us");
5225
5226
MOZ_CAN_RUN_SCRIPT static bool
5227
ellipse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5228
0
{
5229
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.ellipse", DOM, cx);
5230
0
5231
0
  if (MOZ_UNLIKELY(args.length() < 7)) {
5232
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.ellipse");
5233
0
  }
5234
0
  bool foundNonFiniteFloat = false;
5235
0
  double arg0;
5236
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5237
0
    return false;
5238
0
  } else if (!mozilla::IsFinite(arg0)) {
5239
0
    foundNonFiniteFloat = true;
5240
0
  }
5241
0
  double arg1;
5242
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5243
0
    return false;
5244
0
  } else if (!mozilla::IsFinite(arg1)) {
5245
0
    foundNonFiniteFloat = true;
5246
0
  }
5247
0
  double arg2;
5248
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5249
0
    return false;
5250
0
  } else if (!mozilla::IsFinite(arg2)) {
5251
0
    foundNonFiniteFloat = true;
5252
0
  }
5253
0
  double arg3;
5254
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5255
0
    return false;
5256
0
  } else if (!mozilla::IsFinite(arg3)) {
5257
0
    foundNonFiniteFloat = true;
5258
0
  }
5259
0
  double arg4;
5260
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
5261
0
    return false;
5262
0
  } else if (!mozilla::IsFinite(arg4)) {
5263
0
    foundNonFiniteFloat = true;
5264
0
  }
5265
0
  double arg5;
5266
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
5267
0
    return false;
5268
0
  } else if (!mozilla::IsFinite(arg5)) {
5269
0
    foundNonFiniteFloat = true;
5270
0
  }
5271
0
  double arg6;
5272
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
5273
0
    return false;
5274
0
  } else if (!mozilla::IsFinite(arg6)) {
5275
0
    foundNonFiniteFloat = true;
5276
0
  }
5277
0
  bool arg7;
5278
0
  if (args.hasDefined(7)) {
5279
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) {
5280
0
      return false;
5281
0
    }
5282
0
  } else {
5283
0
    arg7 = false;
5284
0
  }
5285
0
  if (foundNonFiniteFloat) {
5286
0
    args.rval().setUndefined();
5287
0
    return true;
5288
0
  }
5289
0
  FastErrorResult rv;
5290
0
  self->Ellipse(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, rv);
5291
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
5292
0
    return false;
5293
0
  }
5294
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5295
0
  args.rval().setUndefined();
5296
0
  return true;
5297
0
}
5298
5299
static const JSJitInfo ellipse_methodinfo = {
5300
  { (JSJitGetterOp)ellipse },
5301
  { prototypes::id::CanvasRenderingContext2D },
5302
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5303
  JSJitInfo::Method,
5304
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5305
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5306
  false,  /* isInfallible. False in setters. */
5307
  false,  /* isMovable.  Not relevant for setters. */
5308
  false, /* isEliminatable.  Not relevant for setters. */
5309
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5310
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5311
  false,  /* isTypedMethod.  Only relevant for methods. */
5312
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5313
};
5314
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5315
static_assert(0 < 1, "There is no slot for us");
5316
5317
MOZ_CAN_RUN_SCRIPT static bool
5318
clearRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5319
0
{
5320
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.clearRect", DOM, cx);
5321
0
5322
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
5323
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.clearRect");
5324
0
  }
5325
0
  bool foundNonFiniteFloat = false;
5326
0
  double arg0;
5327
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5328
0
    return false;
5329
0
  } else if (!mozilla::IsFinite(arg0)) {
5330
0
    foundNonFiniteFloat = true;
5331
0
  }
5332
0
  double arg1;
5333
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5334
0
    return false;
5335
0
  } else if (!mozilla::IsFinite(arg1)) {
5336
0
    foundNonFiniteFloat = true;
5337
0
  }
5338
0
  double arg2;
5339
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5340
0
    return false;
5341
0
  } else if (!mozilla::IsFinite(arg2)) {
5342
0
    foundNonFiniteFloat = true;
5343
0
  }
5344
0
  double arg3;
5345
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5346
0
    return false;
5347
0
  } else if (!mozilla::IsFinite(arg3)) {
5348
0
    foundNonFiniteFloat = true;
5349
0
  }
5350
0
  if (foundNonFiniteFloat) {
5351
0
    args.rval().setUndefined();
5352
0
    return true;
5353
0
  }
5354
0
  self->ClearRect(arg0, arg1, arg2, arg3);
5355
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5356
0
  args.rval().setUndefined();
5357
0
  return true;
5358
0
}
5359
5360
static const JSJitInfo clearRect_methodinfo = {
5361
  { (JSJitGetterOp)clearRect },
5362
  { prototypes::id::CanvasRenderingContext2D },
5363
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5364
  JSJitInfo::Method,
5365
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5366
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5367
  false,  /* isInfallible. False in setters. */
5368
  false,  /* isMovable.  Not relevant for setters. */
5369
  false, /* isEliminatable.  Not relevant for setters. */
5370
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5371
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5372
  false,  /* isTypedMethod.  Only relevant for methods. */
5373
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5374
};
5375
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5376
static_assert(0 < 1, "There is no slot for us");
5377
5378
MOZ_CAN_RUN_SCRIPT static bool
5379
fillRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5380
0
{
5381
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.fillRect", DOM, cx);
5382
0
5383
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
5384
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.fillRect");
5385
0
  }
5386
0
  bool foundNonFiniteFloat = false;
5387
0
  double arg0;
5388
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5389
0
    return false;
5390
0
  } else if (!mozilla::IsFinite(arg0)) {
5391
0
    foundNonFiniteFloat = true;
5392
0
  }
5393
0
  double arg1;
5394
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5395
0
    return false;
5396
0
  } else if (!mozilla::IsFinite(arg1)) {
5397
0
    foundNonFiniteFloat = true;
5398
0
  }
5399
0
  double arg2;
5400
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5401
0
    return false;
5402
0
  } else if (!mozilla::IsFinite(arg2)) {
5403
0
    foundNonFiniteFloat = true;
5404
0
  }
5405
0
  double arg3;
5406
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5407
0
    return false;
5408
0
  } else if (!mozilla::IsFinite(arg3)) {
5409
0
    foundNonFiniteFloat = true;
5410
0
  }
5411
0
  if (foundNonFiniteFloat) {
5412
0
    args.rval().setUndefined();
5413
0
    return true;
5414
0
  }
5415
0
  self->FillRect(arg0, arg1, arg2, arg3);
5416
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5417
0
  args.rval().setUndefined();
5418
0
  return true;
5419
0
}
5420
5421
static const JSJitInfo fillRect_methodinfo = {
5422
  { (JSJitGetterOp)fillRect },
5423
  { prototypes::id::CanvasRenderingContext2D },
5424
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5425
  JSJitInfo::Method,
5426
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5427
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5428
  false,  /* isInfallible. False in setters. */
5429
  false,  /* isMovable.  Not relevant for setters. */
5430
  false, /* isEliminatable.  Not relevant for setters. */
5431
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5432
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5433
  false,  /* isTypedMethod.  Only relevant for methods. */
5434
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5435
};
5436
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5437
static_assert(0 < 1, "There is no slot for us");
5438
5439
MOZ_CAN_RUN_SCRIPT static bool
5440
strokeRect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5441
0
{
5442
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.strokeRect", DOM, cx);
5443
0
5444
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
5445
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.strokeRect");
5446
0
  }
5447
0
  bool foundNonFiniteFloat = false;
5448
0
  double arg0;
5449
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5450
0
    return false;
5451
0
  } else if (!mozilla::IsFinite(arg0)) {
5452
0
    foundNonFiniteFloat = true;
5453
0
  }
5454
0
  double arg1;
5455
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5456
0
    return false;
5457
0
  } else if (!mozilla::IsFinite(arg1)) {
5458
0
    foundNonFiniteFloat = true;
5459
0
  }
5460
0
  double arg2;
5461
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5462
0
    return false;
5463
0
  } else if (!mozilla::IsFinite(arg2)) {
5464
0
    foundNonFiniteFloat = true;
5465
0
  }
5466
0
  double arg3;
5467
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
5468
0
    return false;
5469
0
  } else if (!mozilla::IsFinite(arg3)) {
5470
0
    foundNonFiniteFloat = true;
5471
0
  }
5472
0
  if (foundNonFiniteFloat) {
5473
0
    args.rval().setUndefined();
5474
0
    return true;
5475
0
  }
5476
0
  self->StrokeRect(arg0, arg1, arg2, arg3);
5477
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5478
0
  args.rval().setUndefined();
5479
0
  return true;
5480
0
}
5481
5482
static const JSJitInfo strokeRect_methodinfo = {
5483
  { (JSJitGetterOp)strokeRect },
5484
  { prototypes::id::CanvasRenderingContext2D },
5485
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5486
  JSJitInfo::Method,
5487
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5488
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5489
  false,  /* isInfallible. False in setters. */
5490
  false,  /* isMovable.  Not relevant for setters. */
5491
  false, /* isEliminatable.  Not relevant for setters. */
5492
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5493
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5494
  false,  /* isTypedMethod.  Only relevant for methods. */
5495
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5496
};
5497
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5498
static_assert(0 < 1, "There is no slot for us");
5499
5500
MOZ_CAN_RUN_SCRIPT static bool
5501
get_shadowOffsetX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
5502
0
{
5503
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.shadowOffsetX", DOM, cx);
5504
0
5505
0
  double result(self->ShadowOffsetX());
5506
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5507
0
  args.rval().set(JS_NumberValue(double(result)));
5508
0
  return true;
5509
0
}
5510
5511
MOZ_CAN_RUN_SCRIPT static bool
5512
set_shadowOffsetX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
5513
0
{
5514
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.shadowOffsetX", DOM, cx);
5515
0
5516
0
  bool foundNonFiniteFloat = false;
5517
0
  double arg0;
5518
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5519
0
    return false;
5520
0
  } else if (!mozilla::IsFinite(arg0)) {
5521
0
    foundNonFiniteFloat = true;
5522
0
  }
5523
0
  if (foundNonFiniteFloat) {
5524
0
    return true;
5525
0
  }
5526
0
  self->SetShadowOffsetX(arg0);
5527
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5528
0
5529
0
  return true;
5530
0
}
5531
5532
static const JSJitInfo shadowOffsetX_getterinfo = {
5533
  { (JSJitGetterOp)get_shadowOffsetX },
5534
  { prototypes::id::CanvasRenderingContext2D },
5535
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5536
  JSJitInfo::Getter,
5537
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5538
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
5539
  true,  /* isInfallible. False in setters. */
5540
  false,  /* isMovable.  Not relevant for setters. */
5541
  false, /* isEliminatable.  Not relevant for setters. */
5542
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5543
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5544
  false,  /* isTypedMethod.  Only relevant for methods. */
5545
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5546
};
5547
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5548
static_assert(0 < 1, "There is no slot for us");
5549
static const JSJitInfo shadowOffsetX_setterinfo = {
5550
  { (JSJitGetterOp)set_shadowOffsetX },
5551
  { prototypes::id::CanvasRenderingContext2D },
5552
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5553
  JSJitInfo::Setter,
5554
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5555
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5556
  false,  /* isInfallible. False in setters. */
5557
  false,  /* isMovable.  Not relevant for setters. */
5558
  false, /* isEliminatable.  Not relevant for setters. */
5559
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5560
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5561
  false,  /* isTypedMethod.  Only relevant for methods. */
5562
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5563
};
5564
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5565
static_assert(0 < 1, "There is no slot for us");
5566
5567
MOZ_CAN_RUN_SCRIPT static bool
5568
get_shadowOffsetY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
5569
0
{
5570
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.shadowOffsetY", DOM, cx);
5571
0
5572
0
  double result(self->ShadowOffsetY());
5573
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5574
0
  args.rval().set(JS_NumberValue(double(result)));
5575
0
  return true;
5576
0
}
5577
5578
MOZ_CAN_RUN_SCRIPT static bool
5579
set_shadowOffsetY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
5580
0
{
5581
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.shadowOffsetY", DOM, cx);
5582
0
5583
0
  bool foundNonFiniteFloat = false;
5584
0
  double arg0;
5585
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5586
0
    return false;
5587
0
  } else if (!mozilla::IsFinite(arg0)) {
5588
0
    foundNonFiniteFloat = true;
5589
0
  }
5590
0
  if (foundNonFiniteFloat) {
5591
0
    return true;
5592
0
  }
5593
0
  self->SetShadowOffsetY(arg0);
5594
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5595
0
5596
0
  return true;
5597
0
}
5598
5599
static const JSJitInfo shadowOffsetY_getterinfo = {
5600
  { (JSJitGetterOp)get_shadowOffsetY },
5601
  { prototypes::id::CanvasRenderingContext2D },
5602
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5603
  JSJitInfo::Getter,
5604
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5605
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
5606
  true,  /* isInfallible. False in setters. */
5607
  false,  /* isMovable.  Not relevant for setters. */
5608
  false, /* isEliminatable.  Not relevant for setters. */
5609
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5610
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5611
  false,  /* isTypedMethod.  Only relevant for methods. */
5612
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5613
};
5614
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5615
static_assert(0 < 1, "There is no slot for us");
5616
static const JSJitInfo shadowOffsetY_setterinfo = {
5617
  { (JSJitGetterOp)set_shadowOffsetY },
5618
  { prototypes::id::CanvasRenderingContext2D },
5619
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5620
  JSJitInfo::Setter,
5621
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5622
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5623
  false,  /* isInfallible. False in setters. */
5624
  false,  /* isMovable.  Not relevant for setters. */
5625
  false, /* isEliminatable.  Not relevant for setters. */
5626
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5627
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5628
  false,  /* isTypedMethod.  Only relevant for methods. */
5629
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5630
};
5631
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5632
static_assert(0 < 1, "There is no slot for us");
5633
5634
MOZ_CAN_RUN_SCRIPT static bool
5635
get_shadowBlur(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
5636
0
{
5637
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.shadowBlur", DOM, cx);
5638
0
5639
0
  double result(self->ShadowBlur());
5640
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5641
0
  args.rval().set(JS_NumberValue(double(result)));
5642
0
  return true;
5643
0
}
5644
5645
MOZ_CAN_RUN_SCRIPT static bool
5646
set_shadowBlur(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
5647
0
{
5648
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.shadowBlur", DOM, cx);
5649
0
5650
0
  bool foundNonFiniteFloat = false;
5651
0
  double arg0;
5652
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
5653
0
    return false;
5654
0
  } else if (!mozilla::IsFinite(arg0)) {
5655
0
    foundNonFiniteFloat = true;
5656
0
  }
5657
0
  if (foundNonFiniteFloat) {
5658
0
    return true;
5659
0
  }
5660
0
  self->SetShadowBlur(arg0);
5661
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5662
0
5663
0
  return true;
5664
0
}
5665
5666
static const JSJitInfo shadowBlur_getterinfo = {
5667
  { (JSJitGetterOp)get_shadowBlur },
5668
  { prototypes::id::CanvasRenderingContext2D },
5669
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5670
  JSJitInfo::Getter,
5671
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5672
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
5673
  true,  /* isInfallible. False in setters. */
5674
  false,  /* isMovable.  Not relevant for setters. */
5675
  false, /* isEliminatable.  Not relevant for setters. */
5676
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5677
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5678
  false,  /* isTypedMethod.  Only relevant for methods. */
5679
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5680
};
5681
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5682
static_assert(0 < 1, "There is no slot for us");
5683
static const JSJitInfo shadowBlur_setterinfo = {
5684
  { (JSJitGetterOp)set_shadowBlur },
5685
  { prototypes::id::CanvasRenderingContext2D },
5686
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5687
  JSJitInfo::Setter,
5688
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5689
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5690
  false,  /* isInfallible. False in setters. */
5691
  false,  /* isMovable.  Not relevant for setters. */
5692
  false, /* isEliminatable.  Not relevant for setters. */
5693
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5694
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5695
  false,  /* isTypedMethod.  Only relevant for methods. */
5696
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5697
};
5698
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5699
static_assert(0 < 1, "There is no slot for us");
5700
5701
MOZ_CAN_RUN_SCRIPT static bool
5702
get_shadowColor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
5703
0
{
5704
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.shadowColor", DOM, cx);
5705
0
5706
0
  DOMString result;
5707
0
  self->GetShadowColor(result);
5708
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5709
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
5710
0
    return false;
5711
0
  }
5712
0
  return true;
5713
0
}
5714
5715
MOZ_CAN_RUN_SCRIPT static bool
5716
set_shadowColor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
5717
0
{
5718
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.shadowColor", DOM, cx);
5719
0
5720
0
  binding_detail::FakeString arg0;
5721
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
5722
0
    return false;
5723
0
  }
5724
0
  self->SetShadowColor(NonNullHelper(Constify(arg0)));
5725
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5726
0
5727
0
  return true;
5728
0
}
5729
5730
static const JSJitInfo shadowColor_getterinfo = {
5731
  { (JSJitGetterOp)get_shadowColor },
5732
  { prototypes::id::CanvasRenderingContext2D },
5733
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5734
  JSJitInfo::Getter,
5735
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5736
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
5737
  false,  /* isInfallible. False in setters. */
5738
  false,  /* isMovable.  Not relevant for setters. */
5739
  false, /* isEliminatable.  Not relevant for setters. */
5740
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5741
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5742
  false,  /* isTypedMethod.  Only relevant for methods. */
5743
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5744
};
5745
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5746
static_assert(0 < 1, "There is no slot for us");
5747
static const JSJitInfo shadowColor_setterinfo = {
5748
  { (JSJitGetterOp)set_shadowColor },
5749
  { prototypes::id::CanvasRenderingContext2D },
5750
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5751
  JSJitInfo::Setter,
5752
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5753
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5754
  false,  /* isInfallible. False in setters. */
5755
  false,  /* isMovable.  Not relevant for setters. */
5756
  false, /* isEliminatable.  Not relevant for setters. */
5757
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5758
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5759
  false,  /* isTypedMethod.  Only relevant for methods. */
5760
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5761
};
5762
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5763
static_assert(0 < 1, "There is no slot for us");
5764
5765
MOZ_CAN_RUN_SCRIPT static bool
5766
save(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5767
0
{
5768
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.save", DOM, cx);
5769
0
5770
0
  self->Save();
5771
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5772
0
  args.rval().setUndefined();
5773
0
  return true;
5774
0
}
5775
5776
static const JSJitInfo save_methodinfo = {
5777
  { (JSJitGetterOp)save },
5778
  { prototypes::id::CanvasRenderingContext2D },
5779
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5780
  JSJitInfo::Method,
5781
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5782
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5783
  true,  /* isInfallible. False in setters. */
5784
  false,  /* isMovable.  Not relevant for setters. */
5785
  false, /* isEliminatable.  Not relevant for setters. */
5786
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5787
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5788
  false,  /* isTypedMethod.  Only relevant for methods. */
5789
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5790
};
5791
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5792
static_assert(0 < 1, "There is no slot for us");
5793
5794
MOZ_CAN_RUN_SCRIPT static bool
5795
restore(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5796
0
{
5797
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.restore", DOM, cx);
5798
0
5799
0
  self->Restore();
5800
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5801
0
  args.rval().setUndefined();
5802
0
  return true;
5803
0
}
5804
5805
static const JSJitInfo restore_methodinfo = {
5806
  { (JSJitGetterOp)restore },
5807
  { prototypes::id::CanvasRenderingContext2D },
5808
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5809
  JSJitInfo::Method,
5810
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5811
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5812
  true,  /* isInfallible. False in setters. */
5813
  false,  /* isMovable.  Not relevant for setters. */
5814
  false, /* isEliminatable.  Not relevant for setters. */
5815
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5816
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5817
  false,  /* isTypedMethod.  Only relevant for methods. */
5818
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5819
};
5820
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5821
static_assert(0 < 1, "There is no slot for us");
5822
5823
MOZ_CAN_RUN_SCRIPT static bool
5824
fillText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5825
0
{
5826
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.fillText", DOM, cx);
5827
0
5828
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
5829
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.fillText");
5830
0
  }
5831
0
  bool foundNonFiniteFloat = false;
5832
0
  binding_detail::FakeString arg0;
5833
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
5834
0
    return false;
5835
0
  }
5836
0
  double arg1;
5837
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5838
0
    return false;
5839
0
  } else if (!mozilla::IsFinite(arg1)) {
5840
0
    foundNonFiniteFloat = true;
5841
0
  }
5842
0
  double arg2;
5843
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5844
0
    return false;
5845
0
  } else if (!mozilla::IsFinite(arg2)) {
5846
0
    foundNonFiniteFloat = true;
5847
0
  }
5848
0
  Optional<double> arg3;
5849
0
  if (args.hasDefined(3)) {
5850
0
    arg3.Construct();
5851
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3.Value())) {
5852
0
      return false;
5853
0
    } else if (!mozilla::IsFinite(arg3.Value())) {
5854
0
      foundNonFiniteFloat = true;
5855
0
    }
5856
0
  }
5857
0
  if (foundNonFiniteFloat) {
5858
0
    args.rval().setUndefined();
5859
0
    return true;
5860
0
  }
5861
0
  FastErrorResult rv;
5862
0
  self->FillText(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), rv);
5863
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
5864
0
    return false;
5865
0
  }
5866
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5867
0
  args.rval().setUndefined();
5868
0
  return true;
5869
0
}
5870
5871
static const JSJitInfo fillText_methodinfo = {
5872
  { (JSJitGetterOp)fillText },
5873
  { prototypes::id::CanvasRenderingContext2D },
5874
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5875
  JSJitInfo::Method,
5876
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5877
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5878
  false,  /* isInfallible. False in setters. */
5879
  false,  /* isMovable.  Not relevant for setters. */
5880
  false, /* isEliminatable.  Not relevant for setters. */
5881
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5882
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5883
  false,  /* isTypedMethod.  Only relevant for methods. */
5884
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5885
};
5886
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5887
static_assert(0 < 1, "There is no slot for us");
5888
5889
MOZ_CAN_RUN_SCRIPT static bool
5890
strokeText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5891
0
{
5892
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.strokeText", DOM, cx);
5893
0
5894
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
5895
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.strokeText");
5896
0
  }
5897
0
  bool foundNonFiniteFloat = false;
5898
0
  binding_detail::FakeString arg0;
5899
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
5900
0
    return false;
5901
0
  }
5902
0
  double arg1;
5903
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
5904
0
    return false;
5905
0
  } else if (!mozilla::IsFinite(arg1)) {
5906
0
    foundNonFiniteFloat = true;
5907
0
  }
5908
0
  double arg2;
5909
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
5910
0
    return false;
5911
0
  } else if (!mozilla::IsFinite(arg2)) {
5912
0
    foundNonFiniteFloat = true;
5913
0
  }
5914
0
  Optional<double> arg3;
5915
0
  if (args.hasDefined(3)) {
5916
0
    arg3.Construct();
5917
0
    if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3.Value())) {
5918
0
      return false;
5919
0
    } else if (!mozilla::IsFinite(arg3.Value())) {
5920
0
      foundNonFiniteFloat = true;
5921
0
    }
5922
0
  }
5923
0
  if (foundNonFiniteFloat) {
5924
0
    args.rval().setUndefined();
5925
0
    return true;
5926
0
  }
5927
0
  FastErrorResult rv;
5928
0
  self->StrokeText(NonNullHelper(Constify(arg0)), arg1, arg2, Constify(arg3), rv);
5929
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
5930
0
    return false;
5931
0
  }
5932
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5933
0
  args.rval().setUndefined();
5934
0
  return true;
5935
0
}
5936
5937
static const JSJitInfo strokeText_methodinfo = {
5938
  { (JSJitGetterOp)strokeText },
5939
  { prototypes::id::CanvasRenderingContext2D },
5940
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5941
  JSJitInfo::Method,
5942
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5943
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
5944
  false,  /* isInfallible. False in setters. */
5945
  false,  /* isMovable.  Not relevant for setters. */
5946
  false, /* isEliminatable.  Not relevant for setters. */
5947
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5948
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5949
  false,  /* isTypedMethod.  Only relevant for methods. */
5950
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5951
};
5952
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5953
static_assert(0 < 1, "There is no slot for us");
5954
5955
MOZ_CAN_RUN_SCRIPT static bool
5956
measureText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
5957
0
{
5958
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.measureText", DOM, cx);
5959
0
5960
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
5961
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.measureText");
5962
0
  }
5963
0
  binding_detail::FakeString arg0;
5964
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
5965
0
    return false;
5966
0
  }
5967
0
  FastErrorResult rv;
5968
0
  auto result(StrongOrRawPtr<mozilla::dom::TextMetrics>(self->MeasureText(NonNullHelper(Constify(arg0)), rv)));
5969
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
5970
0
    return false;
5971
0
  }
5972
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
5973
0
  static_assert(!IsPointer<decltype(result)>::value,
5974
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
5975
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
5976
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
5977
0
    return false;
5978
0
  }
5979
0
  return true;
5980
0
}
5981
5982
static const JSJitInfo measureText_methodinfo = {
5983
  { (JSJitGetterOp)measureText },
5984
  { prototypes::id::CanvasRenderingContext2D },
5985
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
5986
  JSJitInfo::Method,
5987
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
5988
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
5989
  false,  /* isInfallible. False in setters. */
5990
  false,  /* isMovable.  Not relevant for setters. */
5991
  false, /* isEliminatable.  Not relevant for setters. */
5992
  false, /* isAlwaysInSlot.  Only relevant for getters. */
5993
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
5994
  false,  /* isTypedMethod.  Only relevant for methods. */
5995
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
5996
};
5997
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
5998
static_assert(0 < 1, "There is no slot for us");
5999
6000
MOZ_CAN_RUN_SCRIPT static bool
6001
get_font(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
6002
0
{
6003
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.font", DOM, cx);
6004
0
6005
0
  DOMString result;
6006
0
  self->GetFont(result);
6007
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6008
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
6009
0
    return false;
6010
0
  }
6011
0
  return true;
6012
0
}
6013
6014
MOZ_CAN_RUN_SCRIPT static bool
6015
set_font(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
6016
0
{
6017
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.font", DOM, cx);
6018
0
6019
0
  binding_detail::FakeString arg0;
6020
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
6021
0
    return false;
6022
0
  }
6023
0
  FastErrorResult rv;
6024
0
  self->SetFont(NonNullHelper(Constify(arg0)), rv);
6025
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6026
0
    return false;
6027
0
  }
6028
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6029
0
6030
0
  return true;
6031
0
}
6032
6033
static const JSJitInfo font_getterinfo = {
6034
  { (JSJitGetterOp)get_font },
6035
  { prototypes::id::CanvasRenderingContext2D },
6036
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6037
  JSJitInfo::Getter,
6038
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6039
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
6040
  false,  /* isInfallible. False in setters. */
6041
  false,  /* isMovable.  Not relevant for setters. */
6042
  false, /* isEliminatable.  Not relevant for setters. */
6043
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6044
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6045
  false,  /* isTypedMethod.  Only relevant for methods. */
6046
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6047
};
6048
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6049
static_assert(0 < 1, "There is no slot for us");
6050
static const JSJitInfo font_setterinfo = {
6051
  { (JSJitGetterOp)set_font },
6052
  { prototypes::id::CanvasRenderingContext2D },
6053
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6054
  JSJitInfo::Setter,
6055
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6056
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6057
  false,  /* isInfallible. False in setters. */
6058
  false,  /* isMovable.  Not relevant for setters. */
6059
  false, /* isEliminatable.  Not relevant for setters. */
6060
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6061
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6062
  false,  /* isTypedMethod.  Only relevant for methods. */
6063
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6064
};
6065
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6066
static_assert(0 < 1, "There is no slot for us");
6067
6068
MOZ_CAN_RUN_SCRIPT static bool
6069
get_textAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
6070
0
{
6071
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.textAlign", DOM, cx);
6072
0
6073
0
  DOMString result;
6074
0
  self->GetTextAlign(result);
6075
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6076
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
6077
0
    return false;
6078
0
  }
6079
0
  return true;
6080
0
}
6081
6082
MOZ_CAN_RUN_SCRIPT static bool
6083
set_textAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
6084
0
{
6085
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.textAlign", DOM, cx);
6086
0
6087
0
  binding_detail::FakeString arg0;
6088
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
6089
0
    return false;
6090
0
  }
6091
0
  self->SetTextAlign(NonNullHelper(Constify(arg0)));
6092
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6093
0
6094
0
  return true;
6095
0
}
6096
6097
static const JSJitInfo textAlign_getterinfo = {
6098
  { (JSJitGetterOp)get_textAlign },
6099
  { prototypes::id::CanvasRenderingContext2D },
6100
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6101
  JSJitInfo::Getter,
6102
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6103
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
6104
  false,  /* isInfallible. False in setters. */
6105
  false,  /* isMovable.  Not relevant for setters. */
6106
  false, /* isEliminatable.  Not relevant for setters. */
6107
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6108
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6109
  false,  /* isTypedMethod.  Only relevant for methods. */
6110
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6111
};
6112
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6113
static_assert(0 < 1, "There is no slot for us");
6114
static const JSJitInfo textAlign_setterinfo = {
6115
  { (JSJitGetterOp)set_textAlign },
6116
  { prototypes::id::CanvasRenderingContext2D },
6117
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6118
  JSJitInfo::Setter,
6119
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6120
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6121
  false,  /* isInfallible. False in setters. */
6122
  false,  /* isMovable.  Not relevant for setters. */
6123
  false, /* isEliminatable.  Not relevant for setters. */
6124
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6125
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6126
  false,  /* isTypedMethod.  Only relevant for methods. */
6127
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6128
};
6129
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6130
static_assert(0 < 1, "There is no slot for us");
6131
6132
MOZ_CAN_RUN_SCRIPT static bool
6133
get_textBaseline(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitGetterCallArgs args)
6134
0
{
6135
0
  AUTO_PROFILER_LABEL_FAST("get CanvasRenderingContext2D.textBaseline", DOM, cx);
6136
0
6137
0
  DOMString result;
6138
0
  self->GetTextBaseline(result);
6139
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6140
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
6141
0
    return false;
6142
0
  }
6143
0
  return true;
6144
0
}
6145
6146
MOZ_CAN_RUN_SCRIPT static bool
6147
set_textBaseline(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, JSJitSetterCallArgs args)
6148
0
{
6149
0
  AUTO_PROFILER_LABEL_FAST("set CanvasRenderingContext2D.textBaseline", DOM, cx);
6150
0
6151
0
  binding_detail::FakeString arg0;
6152
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
6153
0
    return false;
6154
0
  }
6155
0
  self->SetTextBaseline(NonNullHelper(Constify(arg0)));
6156
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6157
0
6158
0
  return true;
6159
0
}
6160
6161
static const JSJitInfo textBaseline_getterinfo = {
6162
  { (JSJitGetterOp)get_textBaseline },
6163
  { prototypes::id::CanvasRenderingContext2D },
6164
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6165
  JSJitInfo::Getter,
6166
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6167
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
6168
  false,  /* isInfallible. False in setters. */
6169
  false,  /* isMovable.  Not relevant for setters. */
6170
  false, /* isEliminatable.  Not relevant for setters. */
6171
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6172
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6173
  false,  /* isTypedMethod.  Only relevant for methods. */
6174
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6175
};
6176
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6177
static_assert(0 < 1, "There is no slot for us");
6178
static const JSJitInfo textBaseline_setterinfo = {
6179
  { (JSJitGetterOp)set_textBaseline },
6180
  { prototypes::id::CanvasRenderingContext2D },
6181
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6182
  JSJitInfo::Setter,
6183
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6184
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6185
  false,  /* isInfallible. False in setters. */
6186
  false,  /* isMovable.  Not relevant for setters. */
6187
  false, /* isEliminatable.  Not relevant for setters. */
6188
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6189
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6190
  false,  /* isTypedMethod.  Only relevant for methods. */
6191
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6192
};
6193
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6194
static_assert(0 < 1, "There is no slot for us");
6195
6196
MOZ_CAN_RUN_SCRIPT static bool
6197
scale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6198
0
{
6199
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.scale", DOM, cx);
6200
0
6201
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
6202
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.scale");
6203
0
  }
6204
0
  bool foundNonFiniteFloat = false;
6205
0
  double arg0;
6206
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
6207
0
    return false;
6208
0
  } else if (!mozilla::IsFinite(arg0)) {
6209
0
    foundNonFiniteFloat = true;
6210
0
  }
6211
0
  double arg1;
6212
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
6213
0
    return false;
6214
0
  } else if (!mozilla::IsFinite(arg1)) {
6215
0
    foundNonFiniteFloat = true;
6216
0
  }
6217
0
  if (foundNonFiniteFloat) {
6218
0
    args.rval().setUndefined();
6219
0
    return true;
6220
0
  }
6221
0
  FastErrorResult rv;
6222
0
  self->Scale(arg0, arg1, rv);
6223
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6224
0
    return false;
6225
0
  }
6226
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6227
0
  args.rval().setUndefined();
6228
0
  return true;
6229
0
}
6230
6231
static const JSJitInfo scale_methodinfo = {
6232
  { (JSJitGetterOp)scale },
6233
  { prototypes::id::CanvasRenderingContext2D },
6234
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6235
  JSJitInfo::Method,
6236
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6237
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6238
  false,  /* isInfallible. False in setters. */
6239
  false,  /* isMovable.  Not relevant for setters. */
6240
  false, /* isEliminatable.  Not relevant for setters. */
6241
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6242
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6243
  false,  /* isTypedMethod.  Only relevant for methods. */
6244
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6245
};
6246
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6247
static_assert(0 < 1, "There is no slot for us");
6248
6249
MOZ_CAN_RUN_SCRIPT static bool
6250
rotate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6251
0
{
6252
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.rotate", DOM, cx);
6253
0
6254
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
6255
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.rotate");
6256
0
  }
6257
0
  bool foundNonFiniteFloat = false;
6258
0
  double arg0;
6259
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
6260
0
    return false;
6261
0
  } else if (!mozilla::IsFinite(arg0)) {
6262
0
    foundNonFiniteFloat = true;
6263
0
  }
6264
0
  if (foundNonFiniteFloat) {
6265
0
    args.rval().setUndefined();
6266
0
    return true;
6267
0
  }
6268
0
  FastErrorResult rv;
6269
0
  self->Rotate(arg0, rv);
6270
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6271
0
    return false;
6272
0
  }
6273
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6274
0
  args.rval().setUndefined();
6275
0
  return true;
6276
0
}
6277
6278
static const JSJitInfo rotate_methodinfo = {
6279
  { (JSJitGetterOp)rotate },
6280
  { prototypes::id::CanvasRenderingContext2D },
6281
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6282
  JSJitInfo::Method,
6283
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6284
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6285
  false,  /* isInfallible. False in setters. */
6286
  false,  /* isMovable.  Not relevant for setters. */
6287
  false, /* isEliminatable.  Not relevant for setters. */
6288
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6289
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6290
  false,  /* isTypedMethod.  Only relevant for methods. */
6291
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6292
};
6293
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6294
static_assert(0 < 1, "There is no slot for us");
6295
6296
MOZ_CAN_RUN_SCRIPT static bool
6297
translate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6298
0
{
6299
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.translate", DOM, cx);
6300
0
6301
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
6302
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.translate");
6303
0
  }
6304
0
  bool foundNonFiniteFloat = false;
6305
0
  double arg0;
6306
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
6307
0
    return false;
6308
0
  } else if (!mozilla::IsFinite(arg0)) {
6309
0
    foundNonFiniteFloat = true;
6310
0
  }
6311
0
  double arg1;
6312
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
6313
0
    return false;
6314
0
  } else if (!mozilla::IsFinite(arg1)) {
6315
0
    foundNonFiniteFloat = true;
6316
0
  }
6317
0
  if (foundNonFiniteFloat) {
6318
0
    args.rval().setUndefined();
6319
0
    return true;
6320
0
  }
6321
0
  FastErrorResult rv;
6322
0
  self->Translate(arg0, arg1, rv);
6323
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6324
0
    return false;
6325
0
  }
6326
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6327
0
  args.rval().setUndefined();
6328
0
  return true;
6329
0
}
6330
6331
static const JSJitInfo translate_methodinfo = {
6332
  { (JSJitGetterOp)translate },
6333
  { prototypes::id::CanvasRenderingContext2D },
6334
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6335
  JSJitInfo::Method,
6336
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6337
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6338
  false,  /* isInfallible. False in setters. */
6339
  false,  /* isMovable.  Not relevant for setters. */
6340
  false, /* isEliminatable.  Not relevant for setters. */
6341
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6342
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6343
  false,  /* isTypedMethod.  Only relevant for methods. */
6344
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6345
};
6346
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6347
static_assert(0 < 1, "There is no slot for us");
6348
6349
MOZ_CAN_RUN_SCRIPT static bool
6350
transform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6351
0
{
6352
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.transform", DOM, cx);
6353
0
6354
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
6355
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.transform");
6356
0
  }
6357
0
  bool foundNonFiniteFloat = false;
6358
0
  double arg0;
6359
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
6360
0
    return false;
6361
0
  } else if (!mozilla::IsFinite(arg0)) {
6362
0
    foundNonFiniteFloat = true;
6363
0
  }
6364
0
  double arg1;
6365
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
6366
0
    return false;
6367
0
  } else if (!mozilla::IsFinite(arg1)) {
6368
0
    foundNonFiniteFloat = true;
6369
0
  }
6370
0
  double arg2;
6371
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
6372
0
    return false;
6373
0
  } else if (!mozilla::IsFinite(arg2)) {
6374
0
    foundNonFiniteFloat = true;
6375
0
  }
6376
0
  double arg3;
6377
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
6378
0
    return false;
6379
0
  } else if (!mozilla::IsFinite(arg3)) {
6380
0
    foundNonFiniteFloat = true;
6381
0
  }
6382
0
  double arg4;
6383
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
6384
0
    return false;
6385
0
  } else if (!mozilla::IsFinite(arg4)) {
6386
0
    foundNonFiniteFloat = true;
6387
0
  }
6388
0
  double arg5;
6389
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
6390
0
    return false;
6391
0
  } else if (!mozilla::IsFinite(arg5)) {
6392
0
    foundNonFiniteFloat = true;
6393
0
  }
6394
0
  if (foundNonFiniteFloat) {
6395
0
    args.rval().setUndefined();
6396
0
    return true;
6397
0
  }
6398
0
  FastErrorResult rv;
6399
0
  self->Transform(arg0, arg1, arg2, arg3, arg4, arg5, rv);
6400
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6401
0
    return false;
6402
0
  }
6403
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6404
0
  args.rval().setUndefined();
6405
0
  return true;
6406
0
}
6407
6408
static const JSJitInfo transform_methodinfo = {
6409
  { (JSJitGetterOp)transform },
6410
  { prototypes::id::CanvasRenderingContext2D },
6411
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6412
  JSJitInfo::Method,
6413
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6414
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6415
  false,  /* isInfallible. False in setters. */
6416
  false,  /* isMovable.  Not relevant for setters. */
6417
  false, /* isEliminatable.  Not relevant for setters. */
6418
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6419
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6420
  false,  /* isTypedMethod.  Only relevant for methods. */
6421
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6422
};
6423
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6424
static_assert(0 < 1, "There is no slot for us");
6425
6426
MOZ_CAN_RUN_SCRIPT static bool
6427
setTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6428
0
{
6429
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.setTransform", DOM, cx);
6430
0
6431
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
6432
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.setTransform");
6433
0
  }
6434
0
  bool foundNonFiniteFloat = false;
6435
0
  double arg0;
6436
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
6437
0
    return false;
6438
0
  } else if (!mozilla::IsFinite(arg0)) {
6439
0
    foundNonFiniteFloat = true;
6440
0
  }
6441
0
  double arg1;
6442
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
6443
0
    return false;
6444
0
  } else if (!mozilla::IsFinite(arg1)) {
6445
0
    foundNonFiniteFloat = true;
6446
0
  }
6447
0
  double arg2;
6448
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
6449
0
    return false;
6450
0
  } else if (!mozilla::IsFinite(arg2)) {
6451
0
    foundNonFiniteFloat = true;
6452
0
  }
6453
0
  double arg3;
6454
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
6455
0
    return false;
6456
0
  } else if (!mozilla::IsFinite(arg3)) {
6457
0
    foundNonFiniteFloat = true;
6458
0
  }
6459
0
  double arg4;
6460
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
6461
0
    return false;
6462
0
  } else if (!mozilla::IsFinite(arg4)) {
6463
0
    foundNonFiniteFloat = true;
6464
0
  }
6465
0
  double arg5;
6466
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
6467
0
    return false;
6468
0
  } else if (!mozilla::IsFinite(arg5)) {
6469
0
    foundNonFiniteFloat = true;
6470
0
  }
6471
0
  if (foundNonFiniteFloat) {
6472
0
    args.rval().setUndefined();
6473
0
    return true;
6474
0
  }
6475
0
  FastErrorResult rv;
6476
0
  self->SetTransform(arg0, arg1, arg2, arg3, arg4, arg5, rv);
6477
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6478
0
    return false;
6479
0
  }
6480
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6481
0
  args.rval().setUndefined();
6482
0
  return true;
6483
0
}
6484
6485
static const JSJitInfo setTransform_methodinfo = {
6486
  { (JSJitGetterOp)setTransform },
6487
  { prototypes::id::CanvasRenderingContext2D },
6488
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6489
  JSJitInfo::Method,
6490
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6491
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6492
  false,  /* isInfallible. False in setters. */
6493
  false,  /* isMovable.  Not relevant for setters. */
6494
  false, /* isEliminatable.  Not relevant for setters. */
6495
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6496
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6497
  false,  /* isTypedMethod.  Only relevant for methods. */
6498
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6499
};
6500
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6501
static_assert(0 < 1, "There is no slot for us");
6502
6503
MOZ_CAN_RUN_SCRIPT static bool
6504
resetTransform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6505
0
{
6506
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.resetTransform", DOM, cx);
6507
0
6508
0
  FastErrorResult rv;
6509
0
  self->ResetTransform(rv);
6510
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6511
0
    return false;
6512
0
  }
6513
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6514
0
  args.rval().setUndefined();
6515
0
  return true;
6516
0
}
6517
6518
static const JSJitInfo resetTransform_methodinfo = {
6519
  { (JSJitGetterOp)resetTransform },
6520
  { prototypes::id::CanvasRenderingContext2D },
6521
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6522
  JSJitInfo::Method,
6523
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6524
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6525
  false,  /* isInfallible. False in setters. */
6526
  false,  /* isMovable.  Not relevant for setters. */
6527
  false, /* isEliminatable.  Not relevant for setters. */
6528
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6529
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6530
  false,  /* isTypedMethod.  Only relevant for methods. */
6531
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6532
};
6533
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6534
static_assert(0 < 1, "There is no slot for us");
6535
6536
MOZ_CAN_RUN_SCRIPT static bool
6537
drawFocusIfNeeded(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6538
0
{
6539
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.drawFocusIfNeeded", DOM, cx);
6540
0
6541
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
6542
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawFocusIfNeeded");
6543
0
  }
6544
0
  NonNull<mozilla::dom::Element> arg0;
6545
0
  if (args[0].isObject()) {
6546
0
    {
6547
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
6548
0
      if (NS_FAILED(rv)) {
6549
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.drawFocusIfNeeded", "Element");
6550
0
        return false;
6551
0
      }
6552
0
    }
6553
0
  } else {
6554
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.drawFocusIfNeeded");
6555
0
    return false;
6556
0
  }
6557
0
  FastErrorResult rv;
6558
0
  self->DrawFocusIfNeeded(MOZ_KnownLive(NonNullHelper(arg0)), rv);
6559
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6560
0
    return false;
6561
0
  }
6562
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6563
0
  args.rval().setUndefined();
6564
0
  return true;
6565
0
}
6566
6567
static const JSJitInfo drawFocusIfNeeded_methodinfo = {
6568
  { (JSJitGetterOp)drawFocusIfNeeded },
6569
  { prototypes::id::CanvasRenderingContext2D },
6570
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6571
  JSJitInfo::Method,
6572
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6573
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
6574
  false,  /* isInfallible. False in setters. */
6575
  false,  /* isMovable.  Not relevant for setters. */
6576
  false, /* isEliminatable.  Not relevant for setters. */
6577
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6578
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6579
  false,  /* isTypedMethod.  Only relevant for methods. */
6580
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6581
};
6582
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6583
static_assert(0 < 1, "There is no slot for us");
6584
6585
MOZ_CAN_RUN_SCRIPT static bool
6586
drawCustomFocusRing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasRenderingContext2D* self, const JSJitMethodCallArgs& args)
6587
0
{
6588
0
  AUTO_PROFILER_LABEL_FAST("CanvasRenderingContext2D.drawCustomFocusRing", DOM, cx);
6589
0
6590
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
6591
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CanvasRenderingContext2D.drawCustomFocusRing");
6592
0
  }
6593
0
  NonNull<mozilla::dom::Element> arg0;
6594
0
  if (args[0].isObject()) {
6595
0
    {
6596
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(args[0], arg0);
6597
0
      if (NS_FAILED(rv)) {
6598
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of CanvasRenderingContext2D.drawCustomFocusRing", "Element");
6599
0
        return false;
6600
0
      }
6601
0
    }
6602
0
  } else {
6603
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of CanvasRenderingContext2D.drawCustomFocusRing");
6604
0
    return false;
6605
0
  }
6606
0
  bool result(self->DrawCustomFocusRing(MOZ_KnownLive(NonNullHelper(arg0))));
6607
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
6608
0
  args.rval().setBoolean(result);
6609
0
  return true;
6610
0
}
6611
6612
static const JSJitInfo drawCustomFocusRing_methodinfo = {
6613
  { (JSJitGetterOp)drawCustomFocusRing },
6614
  { prototypes::id::CanvasRenderingContext2D },
6615
  { PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth },
6616
  JSJitInfo::Method,
6617
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
6618
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
6619
  false,  /* isInfallible. False in setters. */
6620
  false,  /* isMovable.  Not relevant for setters. */
6621
  false, /* isEliminatable.  Not relevant for setters. */
6622
  false, /* isAlwaysInSlot.  Only relevant for getters. */
6623
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
6624
  false,  /* isTypedMethod.  Only relevant for methods. */
6625
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
6626
};
6627
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
6628
static_assert(0 < 1, "There is no slot for us");
6629
6630
static bool
6631
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
6632
0
{
6633
0
  mozilla::dom::CanvasRenderingContext2D* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasRenderingContext2D>(obj);
6634
0
  // We don't want to preserve if we don't have a wrapper, and we
6635
0
  // obviously can't preserve if we're not initialized.
6636
0
  if (self && self->GetWrapperPreserveColor()) {
6637
0
    PreserveWrapper(self);
6638
0
  }
6639
0
  return true;
6640
0
}
6641
6642
static void
6643
_finalize(js::FreeOp* fop, JSObject* obj)
6644
0
{
6645
0
  mozilla::dom::CanvasRenderingContext2D* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasRenderingContext2D>(obj);
6646
0
  if (self) {
6647
0
    ClearWrapper(self, self, obj);
6648
0
    AddForDeferredFinalization<mozilla::dom::CanvasRenderingContext2D>(self);
6649
0
  }
6650
0
}
6651
6652
static size_t
6653
_objectMoved(JSObject* obj, JSObject* old)
6654
0
{
6655
0
  mozilla::dom::CanvasRenderingContext2D* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasRenderingContext2D>(obj);
6656
0
  if (self) {
6657
0
    UpdateWrapper(self, self, obj, old);
6658
0
  }
6659
0
6660
0
  return 0;
6661
0
}
6662
6663
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
6664
#if defined(__clang__)
6665
#pragma clang diagnostic push
6666
#pragma clang diagnostic ignored "-Wmissing-braces"
6667
#endif
6668
static const JSFunctionSpec sMethods_specs[] = {
6669
  JS_FNSPEC("drawWindow", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawWindow_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
6670
  JS_FS_END,
6671
  JS_FNSPEC("drawImage", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawImage_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
6672
  JS_FNSPEC("beginPath", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&beginPath_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6673
  JS_FNSPEC("fill", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&fill_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6674
  JS_FNSPEC("stroke", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stroke_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6675
  JS_FNSPEC("clip", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clip_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6676
  JS_FNSPEC("isPointInPath", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isPointInPath_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6677
  JS_FNSPEC("isPointInStroke", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isPointInStroke_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6678
  JS_FNSPEC("createLinearGradient", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createLinearGradient_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6679
  JS_FNSPEC("createRadialGradient", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createRadialGradient_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
6680
  JS_FNSPEC("createPattern", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createPattern_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6681
  JS_FS_END,
6682
  JS_FNSPEC("addHitRegion", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addHitRegion_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6683
  JS_FNSPEC("removeHitRegion", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeHitRegion_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6684
  JS_FNSPEC("clearHitRegions", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearHitRegions_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6685
  JS_FS_END,
6686
  JS_FNSPEC("createImageData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createImageData_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6687
  JS_FNSPEC("getImageData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getImageData_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6688
  JS_FNSPEC("putImageData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&putImageData_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
6689
  JS_FNSPEC("setLineDash", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setLineDash_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6690
  JS_FNSPEC("getLineDash", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getLineDash_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6691
  JS_FNSPEC("closePath", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&closePath_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6692
  JS_FNSPEC("moveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&moveTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6693
  JS_FNSPEC("lineTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&lineTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6694
  JS_FNSPEC("quadraticCurveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&quadraticCurveTo_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6695
  JS_FNSPEC("bezierCurveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bezierCurveTo_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
6696
  JS_FNSPEC("arcTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&arcTo_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
6697
  JS_FNSPEC("rect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&rect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6698
  JS_FNSPEC("arc", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&arc_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
6699
  JS_FNSPEC("ellipse", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&ellipse_methodinfo), 7, JSPROP_ENUMERATE, nullptr),
6700
  JS_FNSPEC("clearRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearRect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6701
  JS_FNSPEC("fillRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&fillRect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6702
  JS_FNSPEC("strokeRect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&strokeRect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
6703
  JS_FNSPEC("save", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&save_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6704
  JS_FNSPEC("restore", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&restore_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6705
  JS_FNSPEC("fillText", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&fillText_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
6706
  JS_FNSPEC("strokeText", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&strokeText_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
6707
  JS_FNSPEC("measureText", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&measureText_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6708
  JS_FNSPEC("scale", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scale_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6709
  JS_FNSPEC("rotate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&rotate_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6710
  JS_FNSPEC("translate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&translate_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
6711
  JS_FNSPEC("transform", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&transform_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
6712
  JS_FNSPEC("setTransform", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setTransform_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
6713
  JS_FNSPEC("resetTransform", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&resetTransform_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6714
  JS_FS_END,
6715
  JS_FNSPEC("drawFocusIfNeeded", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawFocusIfNeeded_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6716
  JS_FS_END,
6717
  JS_FNSPEC("drawCustomFocusRing", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawCustomFocusRing_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
6718
  JS_FS_END
6719
};
6720
#if defined(__clang__)
6721
#pragma clang diagnostic pop
6722
#endif
6723
6724
// Can't be const because the pref-enabled boolean needs to be writable
6725
static PrefableDisablers sMethods_disablers0 = {
6726
  true, false, 0, &CanvasUtils::HasDrawWindowPrivilege
6727
};
6728
6729
// Can't be const because the pref-enabled boolean needs to be writable
6730
static PrefableDisablers sMethods_disablers13 = {
6731
  true, false, 0, nullptr
6732
};
6733
6734
// Can't be const because the pref-enabled boolean needs to be writable
6735
static PrefableDisablers sMethods_disablers46 = {
6736
  true, false, 0, nullptr
6737
};
6738
6739
// Can't be const because the pref-enabled boolean needs to be writable
6740
static PrefableDisablers sMethods_disablers48 = {
6741
  true, false, 0, nullptr
6742
};
6743
6744
static const Prefable<const JSFunctionSpec> sMethods[] = {
6745
  { &sMethods_disablers0, &sMethods_specs[0] },
6746
  { nullptr, &sMethods_specs[2] },
6747
  { &sMethods_disablers13, &sMethods_specs[13] },
6748
  { nullptr, &sMethods_specs[17] },
6749
  { &sMethods_disablers46, &sMethods_specs[46] },
6750
  { &sMethods_disablers48, &sMethods_specs[48] },
6751
  { nullptr, nullptr }
6752
};
6753
6754
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
6755
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
6756
static_assert(28 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
6757
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
6758
6759
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
6760
#if defined(__clang__)
6761
#pragma clang diagnostic push
6762
#pragma clang diagnostic ignored "-Wmissing-braces"
6763
#endif
6764
static const JSFunctionSpec sChromeMethods_specs[] = {
6765
  JS_FNSPEC("demote", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&demote_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
6766
  JS_FS_END
6767
};
6768
#if defined(__clang__)
6769
#pragma clang diagnostic pop
6770
#endif
6771
6772
6773
static const Prefable<const JSFunctionSpec> sChromeMethods[] = {
6774
  { nullptr, &sChromeMethods_specs[0] },
6775
  { nullptr, nullptr }
6776
};
6777
6778
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
6779
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
6780
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
6781
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
6782
6783
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
6784
#if defined(__clang__)
6785
#pragma clang diagnostic push
6786
#pragma clang diagnostic ignored "-Wmissing-braces"
6787
#endif
6788
static const JSPropertySpec sAttributes_specs[] = {
6789
  { "canvas", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &canvas_getterinfo, nullptr, nullptr },
6790
  { "mozCurrentTransform", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozCurrentTransform_getterinfo, GenericSetter<NormalThisPolicy>, &mozCurrentTransform_setterinfo },
6791
  { "mozCurrentTransformInverse", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozCurrentTransformInverse_getterinfo, GenericSetter<NormalThisPolicy>, &mozCurrentTransformInverse_setterinfo },
6792
  { "mozTextStyle", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozTextStyle_getterinfo, GenericSetter<NormalThisPolicy>, &mozTextStyle_setterinfo },
6793
  { "mozImageSmoothingEnabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mozImageSmoothingEnabled_getterinfo, GenericSetter<NormalThisPolicy>, &mozImageSmoothingEnabled_setterinfo },
6794
  { "globalAlpha", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &globalAlpha_getterinfo, GenericSetter<NormalThisPolicy>, &globalAlpha_setterinfo },
6795
  { "globalCompositeOperation", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &globalCompositeOperation_getterinfo, GenericSetter<NormalThisPolicy>, &globalCompositeOperation_setterinfo },
6796
  { "strokeStyle", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &strokeStyle_getterinfo, GenericSetter<NormalThisPolicy>, &strokeStyle_setterinfo },
6797
  { "fillStyle", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fillStyle_getterinfo, GenericSetter<NormalThisPolicy>, &fillStyle_setterinfo },
6798
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
6799
  { "filter", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &filter_getterinfo, GenericSetter<NormalThisPolicy>, &filter_setterinfo },
6800
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
6801
  { "imageSmoothingEnabled", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &imageSmoothingEnabled_getterinfo, GenericSetter<NormalThisPolicy>, &imageSmoothingEnabled_setterinfo },
6802
  { "lineWidth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lineWidth_getterinfo, GenericSetter<NormalThisPolicy>, &lineWidth_setterinfo },
6803
  { "lineCap", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lineCap_getterinfo, GenericSetter<NormalThisPolicy>, &lineCap_setterinfo },
6804
  { "lineJoin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lineJoin_getterinfo, GenericSetter<NormalThisPolicy>, &lineJoin_setterinfo },
6805
  { "miterLimit", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &miterLimit_getterinfo, GenericSetter<NormalThisPolicy>, &miterLimit_setterinfo },
6806
  { "lineDashOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lineDashOffset_getterinfo, GenericSetter<NormalThisPolicy>, &lineDashOffset_setterinfo },
6807
  { "shadowOffsetX", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shadowOffsetX_getterinfo, GenericSetter<NormalThisPolicy>, &shadowOffsetX_setterinfo },
6808
  { "shadowOffsetY", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shadowOffsetY_getterinfo, GenericSetter<NormalThisPolicy>, &shadowOffsetY_setterinfo },
6809
  { "shadowBlur", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shadowBlur_getterinfo, GenericSetter<NormalThisPolicy>, &shadowBlur_setterinfo },
6810
  { "shadowColor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shadowColor_getterinfo, GenericSetter<NormalThisPolicy>, &shadowColor_setterinfo },
6811
  { "font", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &font_getterinfo, GenericSetter<NormalThisPolicy>, &font_setterinfo },
6812
  { "textAlign", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &textAlign_getterinfo, GenericSetter<NormalThisPolicy>, &textAlign_setterinfo },
6813
  { "textBaseline", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &textBaseline_getterinfo, GenericSetter<NormalThisPolicy>, &textBaseline_setterinfo },
6814
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
6815
};
6816
#if defined(__clang__)
6817
#pragma clang diagnostic pop
6818
#endif
6819
6820
// Can't be const because the pref-enabled boolean needs to be writable
6821
static PrefableDisablers sAttributes_disablers10 = {
6822
  true, false, 0, nullptr
6823
};
6824
6825
static const Prefable<const JSPropertySpec> sAttributes[] = {
6826
  { nullptr, &sAttributes_specs[0] },
6827
  { &sAttributes_disablers10, &sAttributes_specs[10] },
6828
  { nullptr, &sAttributes_specs[12] },
6829
  { nullptr, nullptr }
6830
};
6831
6832
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
6833
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
6834
static_assert(13 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
6835
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
6836
6837
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
6838
#if defined(__clang__)
6839
#pragma clang diagnostic push
6840
#pragma clang diagnostic ignored "-Wmissing-braces"
6841
#endif
6842
static const ConstantSpec sConstants_specs[] = {
6843
  { "DRAWWINDOW_DRAW_CARET", JS::NumberValue(1U) },
6844
  { "DRAWWINDOW_DO_NOT_FLUSH", JS::NumberValue(2U) },
6845
  { "DRAWWINDOW_DRAW_VIEW", JS::NumberValue(4U) },
6846
  { "DRAWWINDOW_USE_WIDGET_LAYERS", JS::NumberValue(8U) },
6847
  { "DRAWWINDOW_ASYNC_DECODE_IMAGES", JS::NumberValue(16U) },
6848
  { 0, JS::UndefinedValue() }
6849
};
6850
#if defined(__clang__)
6851
#pragma clang diagnostic pop
6852
#endif
6853
6854
// Can't be const because the pref-enabled boolean needs to be writable
6855
static PrefableDisablers sConstants_disablers0 = {
6856
  true, false, 0, &CanvasUtils::HasDrawWindowPrivilege
6857
};
6858
6859
static const Prefable<const ConstantSpec> sConstants[] = {
6860
  { &sConstants_disablers0, &sConstants_specs[0] },
6861
  { nullptr, nullptr }
6862
};
6863
6864
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
6865
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
6866
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
6867
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
6868
6869
6870
static uint16_t sNativeProperties_sortedPropertyIndices[72];
6871
static PropertyInfo sNativeProperties_propertyInfos[72];
6872
6873
static const NativePropertiesN<3> sNativeProperties = {
6874
  false, 0,
6875
  false, 0,
6876
  true,  0 /* sMethods */,
6877
  true,  1 /* sAttributes */,
6878
  false, 0,
6879
  false, 0,
6880
  true,  2 /* sConstants */,
6881
  -1,
6882
  72,
6883
  sNativeProperties_sortedPropertyIndices,
6884
  {
6885
    { sMethods, &sNativeProperties_propertyInfos[0] },
6886
    { sAttributes, &sNativeProperties_propertyInfos[44] },
6887
    { sConstants, &sNativeProperties_propertyInfos[67] }
6888
  }
6889
};
6890
static_assert(72 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
6891
    "We have a property info count that is oversized");
6892
6893
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
6894
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
6895
6896
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
6897
  false, 0,
6898
  false, 0,
6899
  true,  0 /* sChromeMethods */,
6900
  false, 0,
6901
  false, 0,
6902
  false, 0,
6903
  false, 0,
6904
  -1,
6905
  1,
6906
  sChromeOnlyNativeProperties_sortedPropertyIndices,
6907
  {
6908
    { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
6909
  }
6910
};
6911
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
6912
    "We have a property info count that is oversized");
6913
6914
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
6915
  {
6916
    "Function",
6917
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
6918
    &sBoringInterfaceObjectClassClassOps,
6919
    JS_NULL_CLASS_SPEC,
6920
    JS_NULL_CLASS_EXT,
6921
    &sInterfaceObjectClassObjectOps
6922
  },
6923
  eInterface,
6924
  true,
6925
  prototypes::id::CanvasRenderingContext2D,
6926
  PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth,
6927
  sNativePropertyHooks,
6928
  "function CanvasRenderingContext2D() {\n    [native code]\n}",
6929
  JS::GetRealmFunctionPrototype
6930
};
6931
6932
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
6933
  {
6934
    "CanvasRenderingContext2DPrototype",
6935
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
6936
    JS_NULL_CLASS_OPS,
6937
    JS_NULL_CLASS_SPEC,
6938
    JS_NULL_CLASS_EXT,
6939
    JS_NULL_OBJECT_OPS
6940
  },
6941
  eInterfacePrototype,
6942
  false,
6943
  prototypes::id::CanvasRenderingContext2D,
6944
  PrototypeTraits<prototypes::id::CanvasRenderingContext2D>::Depth,
6945
  sNativePropertyHooks,
6946
  "[object CanvasRenderingContext2DPrototype]",
6947
  JS::GetRealmObjectPrototype
6948
};
6949
6950
static const js::ClassOps sClassOps = {
6951
  _addProperty, /* addProperty */
6952
  nullptr,               /* delProperty */
6953
  nullptr,               /* enumerate */
6954
  nullptr, /* newEnumerate */
6955
  nullptr, /* resolve */
6956
  nullptr, /* mayResolve */
6957
  _finalize, /* finalize */
6958
  nullptr, /* call */
6959
  nullptr,               /* hasInstance */
6960
  nullptr,               /* construct */
6961
  nullptr, /* trace */
6962
};
6963
6964
static const js::ClassExtension sClassExtension = {
6965
  nullptr, /* weakmapKeyDelegateOp */
6966
  _objectMoved /* objectMovedOp */
6967
};
6968
6969
static const DOMJSClass sClass = {
6970
  { "CanvasRenderingContext2D",
6971
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
6972
    &sClassOps,
6973
    JS_NULL_CLASS_SPEC,
6974
    &sClassExtension,
6975
    JS_NULL_OBJECT_OPS
6976
  },
6977
  { prototypes::id::CanvasRenderingContext2D, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
6978
  IsBaseOf<nsISupports, mozilla::dom::CanvasRenderingContext2D >::value,
6979
  sNativePropertyHooks,
6980
  FindAssociatedGlobalForNative<mozilla::dom::CanvasRenderingContext2D>::Get,
6981
  GetProtoObjectHandle,
6982
  GetCCParticipant<mozilla::dom::CanvasRenderingContext2D>::Get()
6983
};
6984
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
6985
              "Must have the right minimal number of reserved slots.");
6986
static_assert(1 >= 1,
6987
              "Must have enough reserved slots.");
6988
6989
const JSClass*
6990
GetJSClass()
6991
0
{
6992
0
  return sClass.ToJSClass();
6993
0
}
6994
6995
bool
6996
Wrap(JSContext* aCx, mozilla::dom::CanvasRenderingContext2D* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
6997
0
{
6998
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CanvasRenderingContext2D>::value,
6999
0
                "Shouldn't have wrappercached things that are not refcounted.");
7000
0
  MOZ_ASSERT(static_cast<mozilla::dom::CanvasRenderingContext2D*>(aObject) ==
7001
0
             reinterpret_cast<mozilla::dom::CanvasRenderingContext2D*>(aObject),
7002
0
             "Multiple inheritance for mozilla::dom::CanvasRenderingContext2D is broken.");
7003
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
7004
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
7005
0
  MOZ_ASSERT(!aCache->GetWrapper(),
7006
0
             "You should probably not be using Wrap() directly; use "
7007
0
             "GetOrCreateDOMReflector instead");
7008
0
7009
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
7010
0
             "nsISupports must be on our primary inheritance chain");
7011
0
7012
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
7013
0
  if (!global) {
7014
0
    return false;
7015
0
  }
7016
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
7017
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
7018
0
7019
0
  // That might have ended up wrapping us already, due to the wonders
7020
0
  // of XBL.  Check for that, and bail out as needed.
7021
0
  aReflector.set(aCache->GetWrapper());
7022
0
  if (aReflector) {
7023
#ifdef DEBUG
7024
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
7025
#endif // DEBUG
7026
    return true;
7027
0
  }
7028
0
7029
0
  JSAutoRealm ar(aCx, global);
7030
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
7031
0
  if (!canonicalProto) {
7032
0
    return false;
7033
0
  }
7034
0
  JS::Rooted<JSObject*> proto(aCx);
7035
0
  if (aGivenProto) {
7036
0
    proto = aGivenProto;
7037
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
7038
0
    // coming in, we changed compartments to that of "parent" so may need
7039
0
    // to wrap the proto here.
7040
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
7041
0
      if (!JS_WrapObject(aCx, &proto)) {
7042
0
        return false;
7043
0
      }
7044
0
    }
7045
0
  } else {
7046
0
    proto = canonicalProto;
7047
0
  }
7048
0
7049
0
  BindingJSObjectCreator<mozilla::dom::CanvasRenderingContext2D> creator(aCx);
7050
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
7051
0
  if (!aReflector) {
7052
0
    return false;
7053
0
  }
7054
0
7055
0
  aCache->SetWrapper(aReflector);
7056
0
  creator.InitializationSucceeded();
7057
0
7058
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
7059
0
             aCache->GetWrapperPreserveColor() == aReflector);
7060
0
  // If proto != canonicalProto, we have to preserve our wrapper;
7061
0
  // otherwise we won't be able to properly recreate it later, since
7062
0
  // we won't know what proto to use.  Note that we don't check
7063
0
  // aGivenProto here, since it's entirely possible (and even
7064
0
  // somewhat common) to have a non-null aGivenProto which is the
7065
0
  // same as canonicalProto.
7066
0
  if (proto != canonicalProto) {
7067
0
    PreserveWrapper(aObject);
7068
0
  }
7069
0
7070
0
  return true;
7071
0
}
7072
7073
const NativePropertyHooks sNativePropertyHooks[] = { {
7074
  nullptr,
7075
  nullptr,
7076
  nullptr,
7077
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
7078
  prototypes::id::CanvasRenderingContext2D,
7079
  constructors::id::CanvasRenderingContext2D,
7080
  nullptr,
7081
  &DefaultXrayExpandoObjectClass
7082
} };
7083
7084
void
7085
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
7086
0
{
7087
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
7088
0
  if (!parentProto) {
7089
0
    return;
7090
0
  }
7091
0
7092
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
7093
0
  if (!constructorProto) {
7094
0
    return;
7095
0
  }
7096
0
7097
0
  static bool sIdsInited = false;
7098
0
  if (!sIdsInited && NS_IsMainThread()) {
7099
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
7100
0
      return;
7101
0
    }
7102
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
7103
0
      return;
7104
0
    }
7105
0
    sIdsInited = true;
7106
0
  }
7107
0
7108
0
  static bool sPrefCachesInited = false;
7109
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
7110
0
    sPrefCachesInited = true;
7111
0
    Preferences::AddBoolVarCache(&sMethods[2].disablers->enabled, "canvas.hitregions.enabled");
7112
0
    Preferences::AddBoolVarCache(&sMethods[4].disablers->enabled, "canvas.focusring.enabled");
7113
0
    Preferences::AddBoolVarCache(&sMethods[5].disablers->enabled, "canvas.customfocusring.enabled");
7114
0
    Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "canvas.filters.enabled");
7115
0
  }
7116
0
7117
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CanvasRenderingContext2D);
7118
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CanvasRenderingContext2D);
7119
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
7120
0
                              &sPrototypeClass.mBase, protoCache,
7121
0
                              nullptr,
7122
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
7123
0
                              interfaceCache,
7124
0
                              sNativeProperties.Upcast(),
7125
0
                              sChromeOnlyNativeProperties.Upcast(),
7126
0
                              "CanvasRenderingContext2D", aDefineOnGlobal,
7127
0
                              nullptr,
7128
0
                              false);
7129
0
}
7130
7131
JSObject*
7132
GetConstructorObject(JSContext* aCx)
7133
0
{
7134
0
  return GetConstructorObjectHandle(aCx);
7135
0
}
7136
7137
} // namespace CanvasRenderingContext2D_Binding
7138
7139
7140
7141
namespace Path2D_Binding {
7142
7143
MOZ_CAN_RUN_SCRIPT static bool
7144
addPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7145
0
{
7146
0
  AUTO_PROFILER_LABEL_FAST("Path2D.addPath", DOM, cx);
7147
0
7148
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
7149
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.addPath");
7150
0
  }
7151
0
  NonNull<mozilla::dom::CanvasPath> arg0;
7152
0
  if (args[0].isObject()) {
7153
0
    {
7154
0
      nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
7155
0
      if (NS_FAILED(rv)) {
7156
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Path2D.addPath", "Path2D");
7157
0
        return false;
7158
0
      }
7159
0
    }
7160
0
  } else {
7161
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Path2D.addPath");
7162
0
    return false;
7163
0
  }
7164
0
  Optional<NonNull<mozilla::dom::SVGMatrix>> arg1;
7165
0
  if (args.hasDefined(1)) {
7166
0
    arg1.Construct();
7167
0
    if (args[1].isObject()) {
7168
0
      {
7169
0
        nsresult rv = UnwrapObject<prototypes::id::SVGMatrix, mozilla::dom::SVGMatrix>(args[1], arg1.Value());
7170
0
        if (NS_FAILED(rv)) {
7171
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of Path2D.addPath", "SVGMatrix");
7172
0
          return false;
7173
0
        }
7174
0
      }
7175
0
    } else {
7176
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Path2D.addPath");
7177
0
      return false;
7178
0
    }
7179
0
  }
7180
0
  self->AddPath(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(Constify(arg1))));
7181
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7182
0
  args.rval().setUndefined();
7183
0
  return true;
7184
0
}
7185
7186
static const JSJitInfo addPath_methodinfo = {
7187
  { (JSJitGetterOp)addPath },
7188
  { prototypes::id::Path2D },
7189
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7190
  JSJitInfo::Method,
7191
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7192
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7193
  false,  /* isInfallible. False in setters. */
7194
  false,  /* isMovable.  Not relevant for setters. */
7195
  false, /* isEliminatable.  Not relevant for setters. */
7196
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7197
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7198
  false,  /* isTypedMethod.  Only relevant for methods. */
7199
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7200
};
7201
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7202
static_assert(0 < 1, "There is no slot for us");
7203
7204
MOZ_CAN_RUN_SCRIPT static bool
7205
closePath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7206
0
{
7207
0
  AUTO_PROFILER_LABEL_FAST("Path2D.closePath", DOM, cx);
7208
0
7209
0
  self->ClosePath();
7210
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7211
0
  args.rval().setUndefined();
7212
0
  return true;
7213
0
}
7214
7215
static const JSJitInfo closePath_methodinfo = {
7216
  { (JSJitGetterOp)closePath },
7217
  { prototypes::id::Path2D },
7218
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7219
  JSJitInfo::Method,
7220
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7221
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7222
  true,  /* isInfallible. False in setters. */
7223
  false,  /* isMovable.  Not relevant for setters. */
7224
  false, /* isEliminatable.  Not relevant for setters. */
7225
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7226
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7227
  false,  /* isTypedMethod.  Only relevant for methods. */
7228
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7229
};
7230
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7231
static_assert(0 < 1, "There is no slot for us");
7232
7233
MOZ_CAN_RUN_SCRIPT static bool
7234
moveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7235
0
{
7236
0
  AUTO_PROFILER_LABEL_FAST("Path2D.moveTo", DOM, cx);
7237
0
7238
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
7239
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.moveTo");
7240
0
  }
7241
0
  bool foundNonFiniteFloat = false;
7242
0
  double arg0;
7243
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7244
0
    return false;
7245
0
  } else if (!mozilla::IsFinite(arg0)) {
7246
0
    foundNonFiniteFloat = true;
7247
0
  }
7248
0
  double arg1;
7249
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7250
0
    return false;
7251
0
  } else if (!mozilla::IsFinite(arg1)) {
7252
0
    foundNonFiniteFloat = true;
7253
0
  }
7254
0
  if (foundNonFiniteFloat) {
7255
0
    args.rval().setUndefined();
7256
0
    return true;
7257
0
  }
7258
0
  self->MoveTo(arg0, arg1);
7259
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7260
0
  args.rval().setUndefined();
7261
0
  return true;
7262
0
}
7263
7264
static const JSJitInfo moveTo_methodinfo = {
7265
  { (JSJitGetterOp)moveTo },
7266
  { prototypes::id::Path2D },
7267
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7268
  JSJitInfo::Method,
7269
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7270
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7271
  false,  /* isInfallible. False in setters. */
7272
  false,  /* isMovable.  Not relevant for setters. */
7273
  false, /* isEliminatable.  Not relevant for setters. */
7274
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7275
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7276
  false,  /* isTypedMethod.  Only relevant for methods. */
7277
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7278
};
7279
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7280
static_assert(0 < 1, "There is no slot for us");
7281
7282
MOZ_CAN_RUN_SCRIPT static bool
7283
lineTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7284
0
{
7285
0
  AUTO_PROFILER_LABEL_FAST("Path2D.lineTo", DOM, cx);
7286
0
7287
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
7288
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.lineTo");
7289
0
  }
7290
0
  bool foundNonFiniteFloat = false;
7291
0
  double arg0;
7292
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7293
0
    return false;
7294
0
  } else if (!mozilla::IsFinite(arg0)) {
7295
0
    foundNonFiniteFloat = true;
7296
0
  }
7297
0
  double arg1;
7298
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7299
0
    return false;
7300
0
  } else if (!mozilla::IsFinite(arg1)) {
7301
0
    foundNonFiniteFloat = true;
7302
0
  }
7303
0
  if (foundNonFiniteFloat) {
7304
0
    args.rval().setUndefined();
7305
0
    return true;
7306
0
  }
7307
0
  self->LineTo(arg0, arg1);
7308
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7309
0
  args.rval().setUndefined();
7310
0
  return true;
7311
0
}
7312
7313
static const JSJitInfo lineTo_methodinfo = {
7314
  { (JSJitGetterOp)lineTo },
7315
  { prototypes::id::Path2D },
7316
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7317
  JSJitInfo::Method,
7318
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7319
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7320
  false,  /* isInfallible. False in setters. */
7321
  false,  /* isMovable.  Not relevant for setters. */
7322
  false, /* isEliminatable.  Not relevant for setters. */
7323
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7324
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7325
  false,  /* isTypedMethod.  Only relevant for methods. */
7326
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7327
};
7328
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7329
static_assert(0 < 1, "There is no slot for us");
7330
7331
MOZ_CAN_RUN_SCRIPT static bool
7332
quadraticCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7333
0
{
7334
0
  AUTO_PROFILER_LABEL_FAST("Path2D.quadraticCurveTo", DOM, cx);
7335
0
7336
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
7337
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.quadraticCurveTo");
7338
0
  }
7339
0
  bool foundNonFiniteFloat = false;
7340
0
  double arg0;
7341
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7342
0
    return false;
7343
0
  } else if (!mozilla::IsFinite(arg0)) {
7344
0
    foundNonFiniteFloat = true;
7345
0
  }
7346
0
  double arg1;
7347
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7348
0
    return false;
7349
0
  } else if (!mozilla::IsFinite(arg1)) {
7350
0
    foundNonFiniteFloat = true;
7351
0
  }
7352
0
  double arg2;
7353
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
7354
0
    return false;
7355
0
  } else if (!mozilla::IsFinite(arg2)) {
7356
0
    foundNonFiniteFloat = true;
7357
0
  }
7358
0
  double arg3;
7359
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
7360
0
    return false;
7361
0
  } else if (!mozilla::IsFinite(arg3)) {
7362
0
    foundNonFiniteFloat = true;
7363
0
  }
7364
0
  if (foundNonFiniteFloat) {
7365
0
    args.rval().setUndefined();
7366
0
    return true;
7367
0
  }
7368
0
  self->QuadraticCurveTo(arg0, arg1, arg2, arg3);
7369
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7370
0
  args.rval().setUndefined();
7371
0
  return true;
7372
0
}
7373
7374
static const JSJitInfo quadraticCurveTo_methodinfo = {
7375
  { (JSJitGetterOp)quadraticCurveTo },
7376
  { prototypes::id::Path2D },
7377
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7378
  JSJitInfo::Method,
7379
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7380
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7381
  false,  /* isInfallible. False in setters. */
7382
  false,  /* isMovable.  Not relevant for setters. */
7383
  false, /* isEliminatable.  Not relevant for setters. */
7384
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7385
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7386
  false,  /* isTypedMethod.  Only relevant for methods. */
7387
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7388
};
7389
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7390
static_assert(0 < 1, "There is no slot for us");
7391
7392
MOZ_CAN_RUN_SCRIPT static bool
7393
bezierCurveTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7394
0
{
7395
0
  AUTO_PROFILER_LABEL_FAST("Path2D.bezierCurveTo", DOM, cx);
7396
0
7397
0
  if (MOZ_UNLIKELY(args.length() < 6)) {
7398
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.bezierCurveTo");
7399
0
  }
7400
0
  bool foundNonFiniteFloat = false;
7401
0
  double arg0;
7402
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7403
0
    return false;
7404
0
  } else if (!mozilla::IsFinite(arg0)) {
7405
0
    foundNonFiniteFloat = true;
7406
0
  }
7407
0
  double arg1;
7408
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7409
0
    return false;
7410
0
  } else if (!mozilla::IsFinite(arg1)) {
7411
0
    foundNonFiniteFloat = true;
7412
0
  }
7413
0
  double arg2;
7414
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
7415
0
    return false;
7416
0
  } else if (!mozilla::IsFinite(arg2)) {
7417
0
    foundNonFiniteFloat = true;
7418
0
  }
7419
0
  double arg3;
7420
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
7421
0
    return false;
7422
0
  } else if (!mozilla::IsFinite(arg3)) {
7423
0
    foundNonFiniteFloat = true;
7424
0
  }
7425
0
  double arg4;
7426
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
7427
0
    return false;
7428
0
  } else if (!mozilla::IsFinite(arg4)) {
7429
0
    foundNonFiniteFloat = true;
7430
0
  }
7431
0
  double arg5;
7432
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
7433
0
    return false;
7434
0
  } else if (!mozilla::IsFinite(arg5)) {
7435
0
    foundNonFiniteFloat = true;
7436
0
  }
7437
0
  if (foundNonFiniteFloat) {
7438
0
    args.rval().setUndefined();
7439
0
    return true;
7440
0
  }
7441
0
  self->BezierCurveTo(arg0, arg1, arg2, arg3, arg4, arg5);
7442
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7443
0
  args.rval().setUndefined();
7444
0
  return true;
7445
0
}
7446
7447
static const JSJitInfo bezierCurveTo_methodinfo = {
7448
  { (JSJitGetterOp)bezierCurveTo },
7449
  { prototypes::id::Path2D },
7450
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7451
  JSJitInfo::Method,
7452
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7453
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7454
  false,  /* isInfallible. False in setters. */
7455
  false,  /* isMovable.  Not relevant for setters. */
7456
  false, /* isEliminatable.  Not relevant for setters. */
7457
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7458
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7459
  false,  /* isTypedMethod.  Only relevant for methods. */
7460
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7461
};
7462
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7463
static_assert(0 < 1, "There is no slot for us");
7464
7465
MOZ_CAN_RUN_SCRIPT static bool
7466
arcTo(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7467
0
{
7468
0
  AUTO_PROFILER_LABEL_FAST("Path2D.arcTo", DOM, cx);
7469
0
7470
0
  if (MOZ_UNLIKELY(args.length() < 5)) {
7471
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.arcTo");
7472
0
  }
7473
0
  bool foundNonFiniteFloat = false;
7474
0
  double arg0;
7475
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7476
0
    return false;
7477
0
  } else if (!mozilla::IsFinite(arg0)) {
7478
0
    foundNonFiniteFloat = true;
7479
0
  }
7480
0
  double arg1;
7481
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7482
0
    return false;
7483
0
  } else if (!mozilla::IsFinite(arg1)) {
7484
0
    foundNonFiniteFloat = true;
7485
0
  }
7486
0
  double arg2;
7487
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
7488
0
    return false;
7489
0
  } else if (!mozilla::IsFinite(arg2)) {
7490
0
    foundNonFiniteFloat = true;
7491
0
  }
7492
0
  double arg3;
7493
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
7494
0
    return false;
7495
0
  } else if (!mozilla::IsFinite(arg3)) {
7496
0
    foundNonFiniteFloat = true;
7497
0
  }
7498
0
  double arg4;
7499
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
7500
0
    return false;
7501
0
  } else if (!mozilla::IsFinite(arg4)) {
7502
0
    foundNonFiniteFloat = true;
7503
0
  }
7504
0
  if (foundNonFiniteFloat) {
7505
0
    args.rval().setUndefined();
7506
0
    return true;
7507
0
  }
7508
0
  FastErrorResult rv;
7509
0
  self->ArcTo(arg0, arg1, arg2, arg3, arg4, rv);
7510
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
7511
0
    return false;
7512
0
  }
7513
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7514
0
  args.rval().setUndefined();
7515
0
  return true;
7516
0
}
7517
7518
static const JSJitInfo arcTo_methodinfo = {
7519
  { (JSJitGetterOp)arcTo },
7520
  { prototypes::id::Path2D },
7521
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7522
  JSJitInfo::Method,
7523
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7524
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7525
  false,  /* isInfallible. False in setters. */
7526
  false,  /* isMovable.  Not relevant for setters. */
7527
  false, /* isEliminatable.  Not relevant for setters. */
7528
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7529
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7530
  false,  /* isTypedMethod.  Only relevant for methods. */
7531
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7532
};
7533
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7534
static_assert(0 < 1, "There is no slot for us");
7535
7536
MOZ_CAN_RUN_SCRIPT static bool
7537
rect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7538
0
{
7539
0
  AUTO_PROFILER_LABEL_FAST("Path2D.rect", DOM, cx);
7540
0
7541
0
  if (MOZ_UNLIKELY(args.length() < 4)) {
7542
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.rect");
7543
0
  }
7544
0
  bool foundNonFiniteFloat = false;
7545
0
  double arg0;
7546
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7547
0
    return false;
7548
0
  } else if (!mozilla::IsFinite(arg0)) {
7549
0
    foundNonFiniteFloat = true;
7550
0
  }
7551
0
  double arg1;
7552
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7553
0
    return false;
7554
0
  } else if (!mozilla::IsFinite(arg1)) {
7555
0
    foundNonFiniteFloat = true;
7556
0
  }
7557
0
  double arg2;
7558
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
7559
0
    return false;
7560
0
  } else if (!mozilla::IsFinite(arg2)) {
7561
0
    foundNonFiniteFloat = true;
7562
0
  }
7563
0
  double arg3;
7564
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
7565
0
    return false;
7566
0
  } else if (!mozilla::IsFinite(arg3)) {
7567
0
    foundNonFiniteFloat = true;
7568
0
  }
7569
0
  if (foundNonFiniteFloat) {
7570
0
    args.rval().setUndefined();
7571
0
    return true;
7572
0
  }
7573
0
  self->Rect(arg0, arg1, arg2, arg3);
7574
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7575
0
  args.rval().setUndefined();
7576
0
  return true;
7577
0
}
7578
7579
static const JSJitInfo rect_methodinfo = {
7580
  { (JSJitGetterOp)rect },
7581
  { prototypes::id::Path2D },
7582
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7583
  JSJitInfo::Method,
7584
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7585
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7586
  false,  /* isInfallible. False in setters. */
7587
  false,  /* isMovable.  Not relevant for setters. */
7588
  false, /* isEliminatable.  Not relevant for setters. */
7589
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7590
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7591
  false,  /* isTypedMethod.  Only relevant for methods. */
7592
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7593
};
7594
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7595
static_assert(0 < 1, "There is no slot for us");
7596
7597
MOZ_CAN_RUN_SCRIPT static bool
7598
arc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7599
0
{
7600
0
  AUTO_PROFILER_LABEL_FAST("Path2D.arc", DOM, cx);
7601
0
7602
0
  if (MOZ_UNLIKELY(args.length() < 5)) {
7603
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.arc");
7604
0
  }
7605
0
  bool foundNonFiniteFloat = false;
7606
0
  double arg0;
7607
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7608
0
    return false;
7609
0
  } else if (!mozilla::IsFinite(arg0)) {
7610
0
    foundNonFiniteFloat = true;
7611
0
  }
7612
0
  double arg1;
7613
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7614
0
    return false;
7615
0
  } else if (!mozilla::IsFinite(arg1)) {
7616
0
    foundNonFiniteFloat = true;
7617
0
  }
7618
0
  double arg2;
7619
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
7620
0
    return false;
7621
0
  } else if (!mozilla::IsFinite(arg2)) {
7622
0
    foundNonFiniteFloat = true;
7623
0
  }
7624
0
  double arg3;
7625
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
7626
0
    return false;
7627
0
  } else if (!mozilla::IsFinite(arg3)) {
7628
0
    foundNonFiniteFloat = true;
7629
0
  }
7630
0
  double arg4;
7631
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
7632
0
    return false;
7633
0
  } else if (!mozilla::IsFinite(arg4)) {
7634
0
    foundNonFiniteFloat = true;
7635
0
  }
7636
0
  bool arg5;
7637
0
  if (args.hasDefined(5)) {
7638
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[5], &arg5)) {
7639
0
      return false;
7640
0
    }
7641
0
  } else {
7642
0
    arg5 = false;
7643
0
  }
7644
0
  if (foundNonFiniteFloat) {
7645
0
    args.rval().setUndefined();
7646
0
    return true;
7647
0
  }
7648
0
  FastErrorResult rv;
7649
0
  self->Arc(arg0, arg1, arg2, arg3, arg4, arg5, rv);
7650
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
7651
0
    return false;
7652
0
  }
7653
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7654
0
  args.rval().setUndefined();
7655
0
  return true;
7656
0
}
7657
7658
static const JSJitInfo arc_methodinfo = {
7659
  { (JSJitGetterOp)arc },
7660
  { prototypes::id::Path2D },
7661
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7662
  JSJitInfo::Method,
7663
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7664
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7665
  false,  /* isInfallible. False in setters. */
7666
  false,  /* isMovable.  Not relevant for setters. */
7667
  false, /* isEliminatable.  Not relevant for setters. */
7668
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7669
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7670
  false,  /* isTypedMethod.  Only relevant for methods. */
7671
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7672
};
7673
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7674
static_assert(0 < 1, "There is no slot for us");
7675
7676
MOZ_CAN_RUN_SCRIPT static bool
7677
ellipse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CanvasPath* self, const JSJitMethodCallArgs& args)
7678
0
{
7679
0
  AUTO_PROFILER_LABEL_FAST("Path2D.ellipse", DOM, cx);
7680
0
7681
0
  if (MOZ_UNLIKELY(args.length() < 7)) {
7682
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D.ellipse");
7683
0
  }
7684
0
  bool foundNonFiniteFloat = false;
7685
0
  double arg0;
7686
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
7687
0
    return false;
7688
0
  } else if (!mozilla::IsFinite(arg0)) {
7689
0
    foundNonFiniteFloat = true;
7690
0
  }
7691
0
  double arg1;
7692
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
7693
0
    return false;
7694
0
  } else if (!mozilla::IsFinite(arg1)) {
7695
0
    foundNonFiniteFloat = true;
7696
0
  }
7697
0
  double arg2;
7698
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
7699
0
    return false;
7700
0
  } else if (!mozilla::IsFinite(arg2)) {
7701
0
    foundNonFiniteFloat = true;
7702
0
  }
7703
0
  double arg3;
7704
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
7705
0
    return false;
7706
0
  } else if (!mozilla::IsFinite(arg3)) {
7707
0
    foundNonFiniteFloat = true;
7708
0
  }
7709
0
  double arg4;
7710
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[4], &arg4)) {
7711
0
    return false;
7712
0
  } else if (!mozilla::IsFinite(arg4)) {
7713
0
    foundNonFiniteFloat = true;
7714
0
  }
7715
0
  double arg5;
7716
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[5], &arg5)) {
7717
0
    return false;
7718
0
  } else if (!mozilla::IsFinite(arg5)) {
7719
0
    foundNonFiniteFloat = true;
7720
0
  }
7721
0
  double arg6;
7722
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[6], &arg6)) {
7723
0
    return false;
7724
0
  } else if (!mozilla::IsFinite(arg6)) {
7725
0
    foundNonFiniteFloat = true;
7726
0
  }
7727
0
  bool arg7;
7728
0
  if (args.hasDefined(7)) {
7729
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[7], &arg7)) {
7730
0
      return false;
7731
0
    }
7732
0
  } else {
7733
0
    arg7 = false;
7734
0
  }
7735
0
  if (foundNonFiniteFloat) {
7736
0
    args.rval().setUndefined();
7737
0
    return true;
7738
0
  }
7739
0
  FastErrorResult rv;
7740
0
  self->Ellipse(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, rv);
7741
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
7742
0
    return false;
7743
0
  }
7744
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
7745
0
  args.rval().setUndefined();
7746
0
  return true;
7747
0
}
7748
7749
static const JSJitInfo ellipse_methodinfo = {
7750
  { (JSJitGetterOp)ellipse },
7751
  { prototypes::id::Path2D },
7752
  { PrototypeTraits<prototypes::id::Path2D>::Depth },
7753
  JSJitInfo::Method,
7754
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
7755
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
7756
  false,  /* isInfallible. False in setters. */
7757
  false,  /* isMovable.  Not relevant for setters. */
7758
  false, /* isEliminatable.  Not relevant for setters. */
7759
  false, /* isAlwaysInSlot.  Only relevant for getters. */
7760
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
7761
  false,  /* isTypedMethod.  Only relevant for methods. */
7762
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
7763
};
7764
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
7765
static_assert(0 < 1, "There is no slot for us");
7766
7767
static bool
7768
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
7769
0
{
7770
0
  mozilla::dom::CanvasPath* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPath>(obj);
7771
0
  // We don't want to preserve if we don't have a wrapper, and we
7772
0
  // obviously can't preserve if we're not initialized.
7773
0
  if (self && self->GetWrapperPreserveColor()) {
7774
0
    PreserveWrapper(self);
7775
0
  }
7776
0
  return true;
7777
0
}
7778
7779
static void
7780
_finalize(js::FreeOp* fop, JSObject* obj)
7781
0
{
7782
0
  mozilla::dom::CanvasPath* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPath>(obj);
7783
0
  if (self) {
7784
0
    ClearWrapper(self, self, obj);
7785
0
    AddForDeferredFinalization<mozilla::dom::CanvasPath>(self);
7786
0
  }
7787
0
}
7788
7789
static size_t
7790
_objectMoved(JSObject* obj, JSObject* old)
7791
0
{
7792
0
  mozilla::dom::CanvasPath* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CanvasPath>(obj);
7793
0
  if (self) {
7794
0
    UpdateWrapper(self, self, obj, old);
7795
0
  }
7796
0
7797
0
  return 0;
7798
0
}
7799
7800
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
7801
#if defined(__clang__)
7802
#pragma clang diagnostic push
7803
#pragma clang diagnostic ignored "-Wmissing-braces"
7804
#endif
7805
static const JSFunctionSpec sMethods_specs[] = {
7806
  JS_FNSPEC("addPath", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addPath_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
7807
  JS_FNSPEC("closePath", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&closePath_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
7808
  JS_FNSPEC("moveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&moveTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
7809
  JS_FNSPEC("lineTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&lineTo_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
7810
  JS_FNSPEC("quadraticCurveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&quadraticCurveTo_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
7811
  JS_FNSPEC("bezierCurveTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bezierCurveTo_methodinfo), 6, JSPROP_ENUMERATE, nullptr),
7812
  JS_FNSPEC("arcTo", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&arcTo_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
7813
  JS_FNSPEC("rect", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&rect_methodinfo), 4, JSPROP_ENUMERATE, nullptr),
7814
  JS_FNSPEC("arc", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&arc_methodinfo), 5, JSPROP_ENUMERATE, nullptr),
7815
  JS_FNSPEC("ellipse", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&ellipse_methodinfo), 7, JSPROP_ENUMERATE, nullptr),
7816
  JS_FS_END
7817
};
7818
#if defined(__clang__)
7819
#pragma clang diagnostic pop
7820
#endif
7821
7822
7823
static const Prefable<const JSFunctionSpec> sMethods[] = {
7824
  { nullptr, &sMethods_specs[0] },
7825
  { nullptr, nullptr }
7826
};
7827
7828
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
7829
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
7830
static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
7831
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
7832
7833
7834
static uint16_t sNativeProperties_sortedPropertyIndices[10];
7835
static PropertyInfo sNativeProperties_propertyInfos[10];
7836
7837
static const NativePropertiesN<1> sNativeProperties = {
7838
  false, 0,
7839
  false, 0,
7840
  true,  0 /* sMethods */,
7841
  false, 0,
7842
  false, 0,
7843
  false, 0,
7844
  false, 0,
7845
  -1,
7846
  10,
7847
  sNativeProperties_sortedPropertyIndices,
7848
  {
7849
    { sMethods, &sNativeProperties_propertyInfos[0] }
7850
  }
7851
};
7852
static_assert(10 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
7853
    "We have a property info count that is oversized");
7854
7855
static bool
7856
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
7857
0
{
7858
0
  AUTO_PROFILER_LABEL_FAST("Path2D constructor", DOM, cx);
7859
0
7860
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
7861
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
7862
0
  if (!args.isConstructing()) {
7863
0
    // XXXbz wish I could get the name from the callee instead of
7864
0
    // Adding more relocations
7865
0
    return ThrowConstructorWithoutNew(cx, "Path2D");
7866
0
  }
7867
0
7868
0
  JS::Rooted<JSObject*> desiredProto(cx);
7869
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
7870
0
    return false;
7871
0
  }
7872
0
7873
0
  unsigned argcount = std::min(args.length(), 1u);
7874
0
  switch (argcount) {
7875
0
    case 0: {
7876
0
      GlobalObject global(cx, obj);
7877
0
      if (global.Failed()) {
7878
0
        return false;
7879
0
      }
7880
0
7881
0
      bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
7882
0
      Maybe<JSAutoRealm> ar;
7883
0
      if (objIsXray) {
7884
0
        obj = js::CheckedUnwrap(obj);
7885
0
        if (!obj) {
7886
0
          return false;
7887
0
        }
7888
0
        ar.emplace(cx, obj);
7889
0
        if (!JS_WrapObject(cx, &desiredProto)) {
7890
0
          return false;
7891
0
        }
7892
0
      }
7893
0
      FastErrorResult rv;
7894
0
      auto result(StrongOrRawPtr<mozilla::dom::CanvasPath>(mozilla::dom::CanvasPath::Constructor(global, rv)));
7895
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
7896
0
        return false;
7897
0
      }
7898
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
7899
0
      static_assert(!IsPointer<decltype(result)>::value,
7900
0
                    "NewObject implies that we need to keep the object alive with a strong reference.");
7901
0
      if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
7902
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
7903
0
        return false;
7904
0
      }
7905
0
      return true;
7906
0
      break;
7907
0
    }
7908
0
    case 1: {
7909
0
      if (args[0].isObject()) {
7910
0
        do {
7911
0
          NonNull<mozilla::dom::CanvasPath> arg0;
7912
0
          {
7913
0
            nsresult rv = UnwrapObject<prototypes::id::Path2D, mozilla::dom::CanvasPath>(args[0], arg0);
7914
0
            if (NS_FAILED(rv)) {
7915
0
              break;
7916
0
            }
7917
0
          }
7918
0
          GlobalObject global(cx, obj);
7919
0
          if (global.Failed()) {
7920
0
            return false;
7921
0
          }
7922
0
7923
0
          bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
7924
0
          Maybe<JSAutoRealm> ar;
7925
0
          if (objIsXray) {
7926
0
            obj = js::CheckedUnwrap(obj);
7927
0
            if (!obj) {
7928
0
              return false;
7929
0
            }
7930
0
            ar.emplace(cx, obj);
7931
0
            if (!JS_WrapObject(cx, &desiredProto)) {
7932
0
              return false;
7933
0
            }
7934
0
          }
7935
0
          FastErrorResult rv;
7936
0
          auto result(StrongOrRawPtr<mozilla::dom::CanvasPath>(mozilla::dom::CanvasPath::Constructor(global, MOZ_KnownLive(NonNullHelper(arg0)), rv)));
7937
0
          if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
7938
0
            return false;
7939
0
          }
7940
0
          MOZ_ASSERT(!JS_IsExceptionPending(cx));
7941
0
          static_assert(!IsPointer<decltype(result)>::value,
7942
0
                        "NewObject implies that we need to keep the object alive with a strong reference.");
7943
0
          if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
7944
0
            MOZ_ASSERT(JS_IsExceptionPending(cx));
7945
0
            return false;
7946
0
          }
7947
0
          return true;
7948
0
        } while (false);
7949
0
      }
7950
0
      GlobalObject global(cx, obj);
7951
0
      if (global.Failed()) {
7952
0
        return false;
7953
0
      }
7954
0
7955
0
      bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
7956
0
      binding_detail::FakeString arg0;
7957
0
      if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
7958
0
        return false;
7959
0
      }
7960
0
      Maybe<JSAutoRealm> ar;
7961
0
      if (objIsXray) {
7962
0
        obj = js::CheckedUnwrap(obj);
7963
0
        if (!obj) {
7964
0
          return false;
7965
0
        }
7966
0
        ar.emplace(cx, obj);
7967
0
        if (!JS_WrapObject(cx, &desiredProto)) {
7968
0
          return false;
7969
0
        }
7970
0
      }
7971
0
      FastErrorResult rv;
7972
0
      auto result(StrongOrRawPtr<mozilla::dom::CanvasPath>(mozilla::dom::CanvasPath::Constructor(global, NonNullHelper(Constify(arg0)), rv)));
7973
0
      if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
7974
0
        return false;
7975
0
      }
7976
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
7977
0
      static_assert(!IsPointer<decltype(result)>::value,
7978
0
                    "NewObject implies that we need to keep the object alive with a strong reference.");
7979
0
      if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
7980
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
7981
0
        return false;
7982
0
      }
7983
0
      return true;
7984
0
      break;
7985
0
    }
7986
0
    default: {
7987
0
      return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Path2D");
7988
0
      break;
7989
0
    }
7990
0
  }
7991
0
  MOZ_CRASH("We have an always-returning default case");
7992
0
  return false;
7993
0
}
7994
7995
static const js::ClassOps sInterfaceObjectClassOps = {
7996
    nullptr,               /* addProperty */
7997
    nullptr,               /* delProperty */
7998
    nullptr,               /* enumerate */
7999
    nullptr,               /* newEnumerate */
8000
    nullptr,               /* resolve */
8001
    nullptr,               /* mayResolve */
8002
    nullptr,               /* finalize */
8003
    _constructor, /* call */
8004
    nullptr,               /* hasInstance */
8005
    _constructor, /* construct */
8006
    nullptr,               /* trace */
8007
};
8008
8009
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
8010
  {
8011
    "Function",
8012
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
8013
    &sInterfaceObjectClassOps,
8014
    JS_NULL_CLASS_SPEC,
8015
    JS_NULL_CLASS_EXT,
8016
    &sInterfaceObjectClassObjectOps
8017
  },
8018
  eInterface,
8019
  true,
8020
  prototypes::id::Path2D,
8021
  PrototypeTraits<prototypes::id::Path2D>::Depth,
8022
  sNativePropertyHooks,
8023
  "function Path2D() {\n    [native code]\n}",
8024
  JS::GetRealmFunctionPrototype
8025
};
8026
8027
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
8028
  {
8029
    "Path2DPrototype",
8030
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
8031
    JS_NULL_CLASS_OPS,
8032
    JS_NULL_CLASS_SPEC,
8033
    JS_NULL_CLASS_EXT,
8034
    JS_NULL_OBJECT_OPS
8035
  },
8036
  eInterfacePrototype,
8037
  false,
8038
  prototypes::id::Path2D,
8039
  PrototypeTraits<prototypes::id::Path2D>::Depth,
8040
  sNativePropertyHooks,
8041
  "[object Path2DPrototype]",
8042
  JS::GetRealmObjectPrototype
8043
};
8044
8045
bool
8046
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
8047
0
{
8048
0
  static bool sPrefValue;
8049
0
  static bool sPrefCacheSetUp = false;
8050
0
  if (!sPrefCacheSetUp) {
8051
0
    sPrefCacheSetUp = true;
8052
0
    Preferences::AddBoolVarCache(&sPrefValue, "canvas.path.enabled");
8053
0
  }
8054
0
8055
0
  return sPrefValue;
8056
0
}
8057
8058
static const js::ClassOps sClassOps = {
8059
  _addProperty, /* addProperty */
8060
  nullptr,               /* delProperty */
8061
  nullptr,               /* enumerate */
8062
  nullptr, /* newEnumerate */
8063
  nullptr, /* resolve */
8064
  nullptr, /* mayResolve */
8065
  _finalize, /* finalize */
8066
  nullptr, /* call */
8067
  nullptr,               /* hasInstance */
8068
  nullptr,               /* construct */
8069
  nullptr, /* trace */
8070
};
8071
8072
static const js::ClassExtension sClassExtension = {
8073
  nullptr, /* weakmapKeyDelegateOp */
8074
  _objectMoved /* objectMovedOp */
8075
};
8076
8077
static const DOMJSClass sClass = {
8078
  { "Path2D",
8079
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
8080
    &sClassOps,
8081
    JS_NULL_CLASS_SPEC,
8082
    &sClassExtension,
8083
    JS_NULL_OBJECT_OPS
8084
  },
8085
  { prototypes::id::Path2D, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
8086
  IsBaseOf<nsISupports, mozilla::dom::CanvasPath >::value,
8087
  sNativePropertyHooks,
8088
  FindAssociatedGlobalForNative<mozilla::dom::CanvasPath>::Get,
8089
  GetProtoObjectHandle,
8090
  GetCCParticipant<mozilla::dom::CanvasPath>::Get()
8091
};
8092
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
8093
              "Must have the right minimal number of reserved slots.");
8094
static_assert(1 >= 1,
8095
              "Must have enough reserved slots.");
8096
8097
const JSClass*
8098
GetJSClass()
8099
0
{
8100
0
  return sClass.ToJSClass();
8101
0
}
8102
8103
bool
8104
Wrap(JSContext* aCx, mozilla::dom::CanvasPath* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
8105
0
{
8106
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::CanvasPath>::value,
8107
0
                "Shouldn't have wrappercached things that are not refcounted.");
8108
0
  MOZ_ASSERT(static_cast<mozilla::dom::CanvasPath*>(aObject) ==
8109
0
             reinterpret_cast<mozilla::dom::CanvasPath*>(aObject),
8110
0
             "Multiple inheritance for mozilla::dom::CanvasPath is broken.");
8111
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
8112
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
8113
0
  MOZ_ASSERT(!aCache->GetWrapper(),
8114
0
             "You should probably not be using Wrap() directly; use "
8115
0
             "GetOrCreateDOMReflector instead");
8116
0
8117
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
8118
0
             "nsISupports must be on our primary inheritance chain");
8119
0
8120
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
8121
0
  if (!global) {
8122
0
    return false;
8123
0
  }
8124
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
8125
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
8126
0
8127
0
  // That might have ended up wrapping us already, due to the wonders
8128
0
  // of XBL.  Check for that, and bail out as needed.
8129
0
  aReflector.set(aCache->GetWrapper());
8130
0
  if (aReflector) {
8131
#ifdef DEBUG
8132
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
8133
#endif // DEBUG
8134
    return true;
8135
0
  }
8136
0
8137
0
  JSAutoRealm ar(aCx, global);
8138
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
8139
0
  if (!canonicalProto) {
8140
0
    return false;
8141
0
  }
8142
0
  JS::Rooted<JSObject*> proto(aCx);
8143
0
  if (aGivenProto) {
8144
0
    proto = aGivenProto;
8145
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
8146
0
    // coming in, we changed compartments to that of "parent" so may need
8147
0
    // to wrap the proto here.
8148
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
8149
0
      if (!JS_WrapObject(aCx, &proto)) {
8150
0
        return false;
8151
0
      }
8152
0
    }
8153
0
  } else {
8154
0
    proto = canonicalProto;
8155
0
  }
8156
0
8157
0
  BindingJSObjectCreator<mozilla::dom::CanvasPath> creator(aCx);
8158
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
8159
0
  if (!aReflector) {
8160
0
    return false;
8161
0
  }
8162
0
8163
0
  aCache->SetWrapper(aReflector);
8164
0
  creator.InitializationSucceeded();
8165
0
8166
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
8167
0
             aCache->GetWrapperPreserveColor() == aReflector);
8168
0
  // If proto != canonicalProto, we have to preserve our wrapper;
8169
0
  // otherwise we won't be able to properly recreate it later, since
8170
0
  // we won't know what proto to use.  Note that we don't check
8171
0
  // aGivenProto here, since it's entirely possible (and even
8172
0
  // somewhat common) to have a non-null aGivenProto which is the
8173
0
  // same as canonicalProto.
8174
0
  if (proto != canonicalProto) {
8175
0
    PreserveWrapper(aObject);
8176
0
  }
8177
0
8178
0
  return true;
8179
0
}
8180
8181
const NativePropertyHooks sNativePropertyHooks[] = { {
8182
  nullptr,
8183
  nullptr,
8184
  nullptr,
8185
  { sNativeProperties.Upcast(), nullptr },
8186
  prototypes::id::Path2D,
8187
  constructors::id::Path2D,
8188
  nullptr,
8189
  &DefaultXrayExpandoObjectClass
8190
} };
8191
8192
void
8193
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
8194
0
{
8195
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
8196
0
  if (!parentProto) {
8197
0
    return;
8198
0
  }
8199
0
8200
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
8201
0
  if (!constructorProto) {
8202
0
    return;
8203
0
  }
8204
0
8205
0
  static bool sIdsInited = false;
8206
0
  if (!sIdsInited && NS_IsMainThread()) {
8207
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
8208
0
      return;
8209
0
    }
8210
0
    sIdsInited = true;
8211
0
  }
8212
0
8213
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Path2D);
8214
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Path2D);
8215
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
8216
0
                              &sPrototypeClass.mBase, protoCache,
8217
0
                              nullptr,
8218
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
8219
0
                              interfaceCache,
8220
0
                              sNativeProperties.Upcast(),
8221
0
                              nullptr,
8222
0
                              "Path2D", aDefineOnGlobal,
8223
0
                              nullptr,
8224
0
                              false);
8225
0
}
8226
8227
JSObject*
8228
GetConstructorObject(JSContext* aCx)
8229
0
{
8230
0
  return GetConstructorObjectHandle(aCx);
8231
0
}
8232
8233
} // namespace Path2D_Binding
8234
8235
8236
8237
namespace TextMetrics_Binding {
8238
8239
MOZ_CAN_RUN_SCRIPT static bool
8240
get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextMetrics* self, JSJitGetterCallArgs args)
8241
0
{
8242
0
  AUTO_PROFILER_LABEL_FAST("get TextMetrics.width", DOM, cx);
8243
0
8244
0
  double result(self->Width());
8245
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
8246
0
  args.rval().set(JS_NumberValue(double(result)));
8247
0
  return true;
8248
0
}
8249
8250
static const JSJitInfo width_getterinfo = {
8251
  { (JSJitGetterOp)get_width },
8252
  { prototypes::id::TextMetrics },
8253
  { PrototypeTraits<prototypes::id::TextMetrics>::Depth },
8254
  JSJitInfo::Getter,
8255
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
8256
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
8257
  true,  /* isInfallible. False in setters. */
8258
  false,  /* isMovable.  Not relevant for setters. */
8259
  false, /* isEliminatable.  Not relevant for setters. */
8260
  false, /* isAlwaysInSlot.  Only relevant for getters. */
8261
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
8262
  false,  /* isTypedMethod.  Only relevant for methods. */
8263
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
8264
};
8265
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
8266
static_assert(0 < 1, "There is no slot for us");
8267
8268
static void
8269
_finalize(js::FreeOp* fop, JSObject* obj)
8270
0
{
8271
0
  mozilla::dom::TextMetrics* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextMetrics>(obj);
8272
0
  if (self) {
8273
0
    AddForDeferredFinalization<mozilla::dom::TextMetrics>(self);
8274
0
  }
8275
0
}
8276
8277
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
8278
#if defined(__clang__)
8279
#pragma clang diagnostic push
8280
#pragma clang diagnostic ignored "-Wmissing-braces"
8281
#endif
8282
static const JSPropertySpec sAttributes_specs[] = {
8283
  { "width", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &width_getterinfo, nullptr, nullptr },
8284
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
8285
};
8286
#if defined(__clang__)
8287
#pragma clang diagnostic pop
8288
#endif
8289
8290
8291
static const Prefable<const JSPropertySpec> sAttributes[] = {
8292
  { nullptr, &sAttributes_specs[0] },
8293
  { nullptr, nullptr }
8294
};
8295
8296
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
8297
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
8298
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
8299
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
8300
8301
8302
static uint16_t sNativeProperties_sortedPropertyIndices[1];
8303
static PropertyInfo sNativeProperties_propertyInfos[1];
8304
8305
static const NativePropertiesN<1> sNativeProperties = {
8306
  false, 0,
8307
  false, 0,
8308
  false, 0,
8309
  true,  0 /* sAttributes */,
8310
  false, 0,
8311
  false, 0,
8312
  false, 0,
8313
  -1,
8314
  1,
8315
  sNativeProperties_sortedPropertyIndices,
8316
  {
8317
    { sAttributes, &sNativeProperties_propertyInfos[0] }
8318
  }
8319
};
8320
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
8321
    "We have a property info count that is oversized");
8322
8323
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
8324
  {
8325
    "Function",
8326
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
8327
    &sBoringInterfaceObjectClassClassOps,
8328
    JS_NULL_CLASS_SPEC,
8329
    JS_NULL_CLASS_EXT,
8330
    &sInterfaceObjectClassObjectOps
8331
  },
8332
  eInterface,
8333
  true,
8334
  prototypes::id::TextMetrics,
8335
  PrototypeTraits<prototypes::id::TextMetrics>::Depth,
8336
  sNativePropertyHooks,
8337
  "function TextMetrics() {\n    [native code]\n}",
8338
  JS::GetRealmFunctionPrototype
8339
};
8340
8341
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
8342
  {
8343
    "TextMetricsPrototype",
8344
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
8345
    JS_NULL_CLASS_OPS,
8346
    JS_NULL_CLASS_SPEC,
8347
    JS_NULL_CLASS_EXT,
8348
    JS_NULL_OBJECT_OPS
8349
  },
8350
  eInterfacePrototype,
8351
  false,
8352
  prototypes::id::TextMetrics,
8353
  PrototypeTraits<prototypes::id::TextMetrics>::Depth,
8354
  sNativePropertyHooks,
8355
  "[object TextMetricsPrototype]",
8356
  JS::GetRealmObjectPrototype
8357
};
8358
8359
static const js::ClassOps sClassOps = {
8360
  nullptr, /* addProperty */
8361
  nullptr,               /* delProperty */
8362
  nullptr,               /* enumerate */
8363
  nullptr, /* newEnumerate */
8364
  nullptr, /* resolve */
8365
  nullptr, /* mayResolve */
8366
  _finalize, /* finalize */
8367
  nullptr, /* call */
8368
  nullptr,               /* hasInstance */
8369
  nullptr,               /* construct */
8370
  nullptr, /* trace */
8371
};
8372
8373
static const js::ClassExtension sClassExtension = {
8374
  nullptr, /* weakmapKeyDelegateOp */
8375
  nullptr /* objectMovedOp */
8376
};
8377
8378
static const DOMJSClass sClass = {
8379
  { "TextMetrics",
8380
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
8381
    &sClassOps,
8382
    JS_NULL_CLASS_SPEC,
8383
    &sClassExtension,
8384
    JS_NULL_OBJECT_OPS
8385
  },
8386
  { prototypes::id::TextMetrics, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
8387
  IsBaseOf<nsISupports, mozilla::dom::TextMetrics >::value,
8388
  sNativePropertyHooks,
8389
  FindAssociatedGlobalForNative<mozilla::dom::TextMetrics>::Get,
8390
  GetProtoObjectHandle,
8391
  GetCCParticipant<mozilla::dom::TextMetrics>::Get()
8392
};
8393
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
8394
              "Must have the right minimal number of reserved slots.");
8395
static_assert(1 >= 1,
8396
              "Must have enough reserved slots.");
8397
8398
const JSClass*
8399
GetJSClass()
8400
0
{
8401
0
  return sClass.ToJSClass();
8402
0
}
8403
8404
bool
8405
Wrap(JSContext* aCx, mozilla::dom::TextMetrics* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
8406
0
{
8407
0
  MOZ_ASSERT(static_cast<mozilla::dom::TextMetrics*>(aObject) ==
8408
0
             reinterpret_cast<mozilla::dom::TextMetrics*>(aObject),
8409
0
             "Multiple inheritance for mozilla::dom::TextMetrics is broken.");
8410
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
8411
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
8412
0
8413
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
8414
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
8415
0
  if (!canonicalProto) {
8416
0
    return false;
8417
0
  }
8418
0
  JS::Rooted<JSObject*> proto(aCx);
8419
0
  if (aGivenProto) {
8420
0
    proto = aGivenProto;
8421
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
8422
0
    // coming in, we changed compartments to that of "parent" so may need
8423
0
    // to wrap the proto here.
8424
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
8425
0
      if (!JS_WrapObject(aCx, &proto)) {
8426
0
        return false;
8427
0
      }
8428
0
    }
8429
0
  } else {
8430
0
    proto = canonicalProto;
8431
0
  }
8432
0
8433
0
  BindingJSObjectCreator<mozilla::dom::TextMetrics> creator(aCx);
8434
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
8435
0
  if (!aReflector) {
8436
0
    return false;
8437
0
  }
8438
0
8439
0
8440
0
8441
0
  creator.InitializationSucceeded();
8442
0
  return true;
8443
0
}
8444
8445
const NativePropertyHooks sNativePropertyHooks[] = { {
8446
  nullptr,
8447
  nullptr,
8448
  nullptr,
8449
  { sNativeProperties.Upcast(), nullptr },
8450
  prototypes::id::TextMetrics,
8451
  constructors::id::TextMetrics,
8452
  nullptr,
8453
  &DefaultXrayExpandoObjectClass
8454
} };
8455
8456
void
8457
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
8458
0
{
8459
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
8460
0
  if (!parentProto) {
8461
0
    return;
8462
0
  }
8463
0
8464
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
8465
0
  if (!constructorProto) {
8466
0
    return;
8467
0
  }
8468
0
8469
0
  static bool sIdsInited = false;
8470
0
  if (!sIdsInited && NS_IsMainThread()) {
8471
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
8472
0
      return;
8473
0
    }
8474
0
    sIdsInited = true;
8475
0
  }
8476
0
8477
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TextMetrics);
8478
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TextMetrics);
8479
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
8480
0
                              &sPrototypeClass.mBase, protoCache,
8481
0
                              nullptr,
8482
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
8483
0
                              interfaceCache,
8484
0
                              sNativeProperties.Upcast(),
8485
0
                              nullptr,
8486
0
                              "TextMetrics", aDefineOnGlobal,
8487
0
                              nullptr,
8488
0
                              false);
8489
0
}
8490
8491
JSObject*
8492
GetConstructorObject(JSContext* aCx)
8493
0
{
8494
0
  return GetConstructorObjectHandle(aCx);
8495
0
}
8496
8497
} // namespace TextMetrics_Binding
8498
8499
8500
8501
} // namespace dom
8502
} // namespace mozilla