Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/FontFaceBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM FontFace.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "FontFaceBinding.h"
5
#include "WrapperFactory.h"
6
#include "jsapi.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/Preferences.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/FontFace.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/Promise.h"
14
#include "mozilla/dom/ScriptSettings.h"
15
#include "mozilla/dom/SimpleGlobalObject.h"
16
#include "mozilla/dom/ToJSValue.h"
17
#include "mozilla/dom/UnionConversions.h"
18
#include "mozilla/dom/XrayExpandoClass.h"
19
20
namespace mozilla {
21
namespace dom {
22
23
namespace binding_detail {}; // Just to make sure it's known as a namespace
24
using namespace mozilla::dom::binding_detail;
25
26
27
namespace FontFaceLoadStatusValues {
28
extern const EnumEntry strings[5] = {
29
  {"unloaded", 8},
30
  {"loading", 7},
31
  {"loaded", 6},
32
  {"error", 5},
33
  { nullptr, 0 }
34
};
35
} // namespace FontFaceLoadStatusValues
36
37
bool
38
ToJSValue(JSContext* aCx, FontFaceLoadStatus aArgument, JS::MutableHandle<JS::Value> aValue)
39
0
{
40
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(FontFaceLoadStatusValues::strings));
41
0
  JSString* resultStr =
42
0
    JS_NewStringCopyN(aCx, FontFaceLoadStatusValues::strings[uint32_t(aArgument)].value,
43
0
                      FontFaceLoadStatusValues::strings[uint32_t(aArgument)].length);
44
0
  if (!resultStr) {
45
0
    return false;
46
0
  }
47
0
  aValue.setString(resultStr);
48
0
  return true;
49
0
}
50
51
52
53
FontFaceDescriptors::FontFaceDescriptors()
54
0
{
55
0
  // Safe to pass a null context if we pass a null value
56
0
  Init(nullptr, JS::NullHandleValue);
57
0
}
58
59
60
61
bool
62
FontFaceDescriptors::InitIds(JSContext* cx, FontFaceDescriptorsAtoms* atomsCache)
63
0
{
64
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
65
0
66
0
  // Initialize these in reverse order so that any failure leaves the first one
67
0
  // uninitialized.
68
0
  if (!atomsCache->weight_id.init(cx, "weight") ||
69
0
      !atomsCache->variationSettings_id.init(cx, "variationSettings") ||
70
0
      !atomsCache->variant_id.init(cx, "variant") ||
71
0
      !atomsCache->unicodeRange_id.init(cx, "unicodeRange") ||
72
0
      !atomsCache->style_id.init(cx, "style") ||
73
0
      !atomsCache->stretch_id.init(cx, "stretch") ||
74
0
      !atomsCache->featureSettings_id.init(cx, "featureSettings") ||
75
0
      !atomsCache->display_id.init(cx, "display")) {
76
0
    return false;
77
0
  }
78
0
  return true;
79
0
}
80
81
bool
82
FontFaceDescriptors::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
83
0
{
84
0
  // Passing a null JSContext is OK only if we're initing from null,
85
0
  // Since in that case we will not have to do any property gets
86
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
87
0
  // checkers by static analysis tools
88
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
89
0
  FontFaceDescriptorsAtoms* atomsCache = nullptr;
90
0
  if (cx) {
91
0
    atomsCache = GetAtomCache<FontFaceDescriptorsAtoms>(cx);
92
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
93
0
      return false;
94
0
    }
95
0
  }
96
0
97
0
  if (!IsConvertibleToDictionary(val)) {
98
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
99
0
  }
100
0
101
0
  bool isNull = val.isNullOrUndefined();
102
0
  // We only need these if !isNull, in which case we have |cx|.
103
0
  Maybe<JS::Rooted<JSObject *> > object;
104
0
  Maybe<JS::Rooted<JS::Value> > temp;
105
0
  if (!isNull) {
106
0
    MOZ_ASSERT(cx);
107
0
    object.emplace(cx, &val.toObject());
108
0
    temp.emplace(cx);
109
0
  }
110
0
  if (!isNull) {
111
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->display_id, temp.ptr())) {
112
0
      return false;
113
0
    }
114
0
  }
115
0
  if (!isNull && !temp->isUndefined()) {
116
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDisplay)) {
117
0
      return false;
118
0
    }
119
0
  } else {
120
0
    static const char16_t data[] = { 'a', 'u', 't', 'o', 0 };
121
0
    mDisplay.Rebind(data, ArrayLength(data) - 1);
122
0
  }
123
0
  mIsAnyMemberPresent = true;
124
0
125
0
  if (!isNull) {
126
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->featureSettings_id, temp.ptr())) {
127
0
      return false;
128
0
    }
129
0
  }
130
0
  if (!isNull && !temp->isUndefined()) {
131
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFeatureSettings)) {
132
0
      return false;
133
0
    }
134
0
  } else {
135
0
    static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
136
0
    mFeatureSettings.Rebind(data, ArrayLength(data) - 1);
137
0
  }
138
0
  mIsAnyMemberPresent = true;
139
0
140
0
  if (!isNull) {
141
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->stretch_id, temp.ptr())) {
142
0
      return false;
143
0
    }
144
0
  }
145
0
  if (!isNull && !temp->isUndefined()) {
146
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mStretch)) {
147
0
      return false;
148
0
    }
149
0
  } else {
150
0
    static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
151
0
    mStretch.Rebind(data, ArrayLength(data) - 1);
152
0
  }
153
0
  mIsAnyMemberPresent = true;
154
0
155
0
  if (!isNull) {
156
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->style_id, temp.ptr())) {
157
0
      return false;
158
0
    }
159
0
  }
160
0
  if (!isNull && !temp->isUndefined()) {
161
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mStyle)) {
162
0
      return false;
163
0
    }
164
0
  } else {
165
0
    static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
166
0
    mStyle.Rebind(data, ArrayLength(data) - 1);
167
0
  }
168
0
  mIsAnyMemberPresent = true;
169
0
170
0
  if (!isNull) {
171
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->unicodeRange_id, temp.ptr())) {
172
0
      return false;
173
0
    }
174
0
  }
175
0
  if (!isNull && !temp->isUndefined()) {
176
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mUnicodeRange)) {
177
0
      return false;
178
0
    }
179
0
  } else {
180
0
    static const char16_t data[] = { 'U', '+', '0', '-', '1', '0', 'F', 'F', 'F', 'F', 0 };
181
0
    mUnicodeRange.Rebind(data, ArrayLength(data) - 1);
182
0
  }
183
0
  mIsAnyMemberPresent = true;
184
0
185
0
  if (!isNull) {
186
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->variant_id, temp.ptr())) {
187
0
      return false;
188
0
    }
189
0
  }
190
0
  if (!isNull && !temp->isUndefined()) {
191
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mVariant)) {
192
0
      return false;
193
0
    }
194
0
  } else {
195
0
    static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
196
0
    mVariant.Rebind(data, ArrayLength(data) - 1);
197
0
  }
198
0
  mIsAnyMemberPresent = true;
199
0
200
0
  if (!isNull) {
201
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->variationSettings_id, temp.ptr())) {
202
0
      return false;
203
0
    }
204
0
  }
205
0
  if (!isNull && !temp->isUndefined()) {
206
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mVariationSettings)) {
207
0
      return false;
208
0
    }
209
0
  } else {
210
0
    static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
211
0
    mVariationSettings.Rebind(data, ArrayLength(data) - 1);
212
0
  }
213
0
  mIsAnyMemberPresent = true;
214
0
215
0
  if (!isNull) {
216
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->weight_id, temp.ptr())) {
217
0
      return false;
218
0
    }
219
0
  }
220
0
  if (!isNull && !temp->isUndefined()) {
221
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mWeight)) {
222
0
      return false;
223
0
    }
224
0
  } else {
225
0
    static const char16_t data[] = { 'n', 'o', 'r', 'm', 'a', 'l', 0 };
226
0
    mWeight.Rebind(data, ArrayLength(data) - 1);
227
0
  }
228
0
  mIsAnyMemberPresent = true;
229
0
  return true;
230
0
}
231
232
bool
233
FontFaceDescriptors::Init(const nsAString& aJSON)
234
0
{
235
0
  AutoJSAPI jsapi;
236
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
237
0
  if (!cleanGlobal) {
238
0
    return false;
239
0
  }
240
0
  if (!jsapi.Init(cleanGlobal)) {
241
0
    return false;
242
0
  }
243
0
  JSContext* cx = jsapi.cx();
244
0
  JS::Rooted<JS::Value> json(cx);
245
0
  bool ok = ParseJSON(cx, aJSON, &json);
246
0
  NS_ENSURE_TRUE(ok, false);
247
0
  return Init(cx, json);
248
0
}
249
250
bool
251
FontFaceDescriptors::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
252
0
{
253
0
  FontFaceDescriptorsAtoms* atomsCache = GetAtomCache<FontFaceDescriptorsAtoms>(cx);
254
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
255
0
    return false;
256
0
  }
257
0
258
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
259
0
  if (!obj) {
260
0
    return false;
261
0
  }
262
0
  rval.set(JS::ObjectValue(*obj));
263
0
264
0
  do {
265
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
266
0
    JS::Rooted<JS::Value> temp(cx);
267
0
    nsString const & currentValue = mDisplay;
268
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
269
0
      return false;
270
0
    }
271
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->display_id, temp, JSPROP_ENUMERATE)) {
272
0
      return false;
273
0
    }
274
0
    break;
275
0
  } while(false);
276
0
277
0
  do {
278
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
279
0
    JS::Rooted<JS::Value> temp(cx);
280
0
    nsString const & currentValue = mFeatureSettings;
281
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
282
0
      return false;
283
0
    }
284
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->featureSettings_id, temp, JSPROP_ENUMERATE)) {
285
0
      return false;
286
0
    }
287
0
    break;
288
0
  } while(false);
289
0
290
0
  do {
291
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
292
0
    JS::Rooted<JS::Value> temp(cx);
293
0
    nsString const & currentValue = mStretch;
294
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
295
0
      return false;
296
0
    }
297
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->stretch_id, temp, JSPROP_ENUMERATE)) {
298
0
      return false;
299
0
    }
300
0
    break;
301
0
  } while(false);
302
0
303
0
  do {
304
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
305
0
    JS::Rooted<JS::Value> temp(cx);
306
0
    nsString const & currentValue = mStyle;
307
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
308
0
      return false;
309
0
    }
310
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->style_id, temp, JSPROP_ENUMERATE)) {
311
0
      return false;
312
0
    }
313
0
    break;
314
0
  } while(false);
315
0
316
0
  do {
317
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
318
0
    JS::Rooted<JS::Value> temp(cx);
319
0
    nsString const & currentValue = mUnicodeRange;
320
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
321
0
      return false;
322
0
    }
323
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->unicodeRange_id, temp, JSPROP_ENUMERATE)) {
324
0
      return false;
325
0
    }
326
0
    break;
327
0
  } while(false);
328
0
329
0
  do {
330
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
331
0
    JS::Rooted<JS::Value> temp(cx);
332
0
    nsString const & currentValue = mVariant;
333
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
334
0
      return false;
335
0
    }
336
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->variant_id, temp, JSPROP_ENUMERATE)) {
337
0
      return false;
338
0
    }
339
0
    break;
340
0
  } while(false);
341
0
342
0
  do {
343
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
344
0
    JS::Rooted<JS::Value> temp(cx);
345
0
    nsString const & currentValue = mVariationSettings;
346
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
347
0
      return false;
348
0
    }
349
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->variationSettings_id, temp, JSPROP_ENUMERATE)) {
350
0
      return false;
351
0
    }
352
0
    break;
353
0
  } while(false);
354
0
355
0
  do {
356
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
357
0
    JS::Rooted<JS::Value> temp(cx);
358
0
    nsString const & currentValue = mWeight;
359
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
360
0
      return false;
361
0
    }
362
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->weight_id, temp, JSPROP_ENUMERATE)) {
363
0
      return false;
364
0
    }
365
0
    break;
366
0
  } while(false);
367
0
368
0
  return true;
369
0
}
370
371
bool
372
FontFaceDescriptors::ToJSON(nsAString& aJSON) const
373
0
{
374
0
  AutoJSAPI jsapi;
375
0
  jsapi.Init();
376
0
  JSContext *cx = jsapi.cx();
377
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
378
0
  // because we'll only be creating objects, in ways that have no
379
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
380
0
  // which likewise guarantees no side-effects for the sorts of
381
0
  // things we will pass it.
382
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
383
0
  JS::Rooted<JS::Value> val(cx);
384
0
  if (!ToObjectInternal(cx, &val)) {
385
0
    return false;
386
0
  }
387
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
388
0
  return StringifyToJSON(cx, obj, aJSON);
389
0
}
390
391
void
392
FontFaceDescriptors::TraceDictionary(JSTracer* trc)
393
0
{
394
0
}
395
396
FontFaceDescriptors&
397
FontFaceDescriptors::operator=(const FontFaceDescriptors& aOther)
398
0
{
399
0
  DictionaryBase::operator=(aOther);
400
0
  mDisplay = aOther.mDisplay;
401
0
  mFeatureSettings = aOther.mFeatureSettings;
402
0
  mStretch = aOther.mStretch;
403
0
  mStyle = aOther.mStyle;
404
0
  mUnicodeRange = aOther.mUnicodeRange;
405
0
  mVariant = aOther.mVariant;
406
0
  mVariationSettings = aOther.mVariationSettings;
407
0
  mWeight = aOther.mWeight;
408
0
  return *this;
409
0
}
410
411
namespace binding_detail {
412
} // namespace binding_detail
413
414
415
bool
416
StringOrArrayBufferOrArrayBufferView::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
417
0
{
418
0
  switch (mType) {
419
0
    case eUninitialized: {
420
0
      return false;
421
0
      break;
422
0
    }
423
0
    case eString: {
424
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
425
0
        return false;
426
0
      }
427
0
      return true;
428
0
      break;
429
0
    }
430
0
    case eArrayBuffer: {
431
0
      rval.setObject(*mValue.mArrayBuffer.Value().Obj());
432
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
433
0
        return false;
434
0
      }
435
0
      return true;
436
0
      break;
437
0
    }
438
0
    case eArrayBufferView: {
439
0
      rval.setObject(*mValue.mArrayBufferView.Value().Obj());
440
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
441
0
        return false;
442
0
      }
443
0
      return true;
444
0
      break;
445
0
    }
446
0
    default: {
447
0
      return false;
448
0
      break;
449
0
    }
450
0
  }
451
0
452
0
  return false;
453
0
}
454
455
456
nsString&
457
OwningStringOrArrayBufferOrArrayBufferView::RawSetAsString()
458
0
{
459
0
  if (mType == eString) {
460
0
    return mValue.mString.Value();
461
0
  }
462
0
  MOZ_ASSERT(mType == eUninitialized);
463
0
  mType = eString;
464
0
  return mValue.mString.SetValue();
465
0
}
466
467
nsString&
468
OwningStringOrArrayBufferOrArrayBufferView::SetAsString()
469
0
{
470
0
  if (mType == eString) {
471
0
    return mValue.mString.Value();
472
0
  }
473
0
  Uninit();
474
0
  mType = eString;
475
0
  return mValue.mString.SetValue();
476
0
}
477
478
bool
479
OwningStringOrArrayBufferOrArrayBufferView::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
480
0
{
481
0
  tryNext = false;
482
0
  { // scope for memberSlot
483
0
    nsString& memberSlot = RawSetAsString();
484
0
    if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
485
0
      return false;
486
0
    }
487
0
  }
488
0
  return true;
489
0
}
490
491
492
void
493
OwningStringOrArrayBufferOrArrayBufferView::DestroyString()
494
0
{
495
0
  MOZ_ASSERT(IsString(), "Wrong type!");
496
0
  mValue.mString.Destroy();
497
0
  mType = eUninitialized;
498
0
}
499
500
501
502
503
ArrayBuffer&
504
OwningStringOrArrayBufferOrArrayBufferView::RawSetAsArrayBuffer()
505
0
{
506
0
  if (mType == eArrayBuffer) {
507
0
    return mValue.mArrayBuffer.Value();
508
0
  }
509
0
  MOZ_ASSERT(mType == eUninitialized);
510
0
  mType = eArrayBuffer;
511
0
  return mValue.mArrayBuffer.SetValue();
512
0
}
513
514
ArrayBuffer&
515
OwningStringOrArrayBufferOrArrayBufferView::SetAsArrayBuffer()
516
0
{
517
0
  if (mType == eArrayBuffer) {
518
0
    return mValue.mArrayBuffer.Value();
519
0
  }
520
0
  Uninit();
521
0
  mType = eArrayBuffer;
522
0
  return mValue.mArrayBuffer.SetValue();
523
0
}
524
525
bool
526
OwningStringOrArrayBufferOrArrayBufferView::TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
527
0
{
528
0
  tryNext = false;
529
0
  { // scope for memberSlot
530
0
    ArrayBuffer& memberSlot = RawSetAsArrayBuffer();
531
0
    if (!memberSlot.Init(&value.toObject())) {
532
0
      DestroyArrayBuffer();
533
0
      tryNext = true;
534
0
      return true;
535
0
    }
536
0
  }
537
0
  return true;
538
0
}
539
540
void
541
OwningStringOrArrayBufferOrArrayBufferView::DestroyArrayBuffer()
542
0
{
543
0
  MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
544
0
  mValue.mArrayBuffer.Destroy();
545
0
  mType = eUninitialized;
546
0
}
547
548
549
550
551
ArrayBufferView&
552
OwningStringOrArrayBufferOrArrayBufferView::RawSetAsArrayBufferView()
553
0
{
554
0
  if (mType == eArrayBufferView) {
555
0
    return mValue.mArrayBufferView.Value();
556
0
  }
557
0
  MOZ_ASSERT(mType == eUninitialized);
558
0
  mType = eArrayBufferView;
559
0
  return mValue.mArrayBufferView.SetValue();
560
0
}
561
562
ArrayBufferView&
563
OwningStringOrArrayBufferOrArrayBufferView::SetAsArrayBufferView()
564
0
{
565
0
  if (mType == eArrayBufferView) {
566
0
    return mValue.mArrayBufferView.Value();
567
0
  }
568
0
  Uninit();
569
0
  mType = eArrayBufferView;
570
0
  return mValue.mArrayBufferView.SetValue();
571
0
}
572
573
bool
574
OwningStringOrArrayBufferOrArrayBufferView::TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
575
0
{
576
0
  tryNext = false;
577
0
  { // scope for memberSlot
578
0
    ArrayBufferView& memberSlot = RawSetAsArrayBufferView();
579
0
    if (!memberSlot.Init(&value.toObject())) {
580
0
      DestroyArrayBufferView();
581
0
      tryNext = true;
582
0
      return true;
583
0
    }
584
0
  }
585
0
  return true;
586
0
}
587
588
void
589
OwningStringOrArrayBufferOrArrayBufferView::DestroyArrayBufferView()
590
0
{
591
0
  MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
592
0
  mValue.mArrayBufferView.Destroy();
593
0
  mType = eUninitialized;
594
0
}
595
596
597
598
599
void
600
OwningStringOrArrayBufferOrArrayBufferView::Uninit()
601
{
602
  switch (mType) {
603
    case eUninitialized: {
604
      break;
605
    }
606
    case eString: {
607
      DestroyString();
608
      break;
609
    }
610
    case eArrayBuffer: {
611
      DestroyArrayBuffer();
612
      break;
613
    }
614
    case eArrayBufferView: {
615
      DestroyArrayBufferView();
616
      break;
617
    }
618
  }
619
}
620
621
bool
622
OwningStringOrArrayBufferOrArrayBufferView::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
623
0
{
624
0
  switch (mType) {
625
0
    case eUninitialized: {
626
0
      return false;
627
0
      break;
628
0
    }
629
0
    case eString: {
630
0
      if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
631
0
        return false;
632
0
      }
633
0
      return true;
634
0
      break;
635
0
    }
636
0
    case eArrayBuffer: {
637
0
      rval.setObject(*mValue.mArrayBuffer.Value().Obj());
638
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
639
0
        return false;
640
0
      }
641
0
      return true;
642
0
      break;
643
0
    }
644
0
    case eArrayBufferView: {
645
0
      rval.setObject(*mValue.mArrayBufferView.Value().Obj());
646
0
      if (!MaybeWrapNonDOMObjectValue(cx, rval)) {
647
0
        return false;
648
0
      }
649
0
      return true;
650
0
      break;
651
0
    }
652
0
    default: {
653
0
      return false;
654
0
      break;
655
0
    }
656
0
  }
657
0
658
0
  return false;
659
0
}
660
661
void
662
OwningStringOrArrayBufferOrArrayBufferView::TraceUnion(JSTracer* trc)
663
{
664
  switch (mType) {
665
    case eArrayBuffer: {
666
      mValue.mArrayBuffer.Value().TraceSelf(trc);
667
      break;
668
    }
669
    case eArrayBufferView: {
670
      mValue.mArrayBufferView.Value().TraceSelf(trc);
671
      break;
672
    }
673
    default: {
674
      break;
675
    }
676
  }
677
}
678
679
680
namespace FontFace_Binding {
681
682
MOZ_CAN_RUN_SCRIPT static bool
683
get_family(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
684
0
{
685
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.family", DOM, cx);
686
0
687
0
  DOMString result;
688
0
  self->GetFamily(result);
689
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
690
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
691
0
    return false;
692
0
  }
693
0
  return true;
694
0
}
695
696
MOZ_CAN_RUN_SCRIPT static bool
697
set_family(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
698
0
{
699
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.family", DOM, cx);
700
0
701
0
  binding_detail::FakeString arg0;
702
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
703
0
    return false;
704
0
  }
705
0
  FastErrorResult rv;
706
0
  self->SetFamily(NonNullHelper(Constify(arg0)), rv);
707
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
708
0
    return false;
709
0
  }
710
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
711
0
712
0
  return true;
713
0
}
714
715
static const JSJitInfo family_getterinfo = {
716
  { (JSJitGetterOp)get_family },
717
  { prototypes::id::FontFace },
718
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
719
  JSJitInfo::Getter,
720
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
721
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
722
  false,  /* isInfallible. False in setters. */
723
  false,  /* isMovable.  Not relevant for setters. */
724
  false, /* isEliminatable.  Not relevant for setters. */
725
  false, /* isAlwaysInSlot.  Only relevant for getters. */
726
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
727
  false,  /* isTypedMethod.  Only relevant for methods. */
728
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
729
};
730
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
731
static_assert(0 < 1, "There is no slot for us");
732
static const JSJitInfo family_setterinfo = {
733
  { (JSJitGetterOp)set_family },
734
  { prototypes::id::FontFace },
735
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
736
  JSJitInfo::Setter,
737
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
738
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
739
  false,  /* isInfallible. False in setters. */
740
  false,  /* isMovable.  Not relevant for setters. */
741
  false, /* isEliminatable.  Not relevant for setters. */
742
  false, /* isAlwaysInSlot.  Only relevant for getters. */
743
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
744
  false,  /* isTypedMethod.  Only relevant for methods. */
745
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
746
};
747
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
748
static_assert(0 < 1, "There is no slot for us");
749
750
MOZ_CAN_RUN_SCRIPT static bool
751
get_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
752
0
{
753
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.style", DOM, cx);
754
0
755
0
  DOMString result;
756
0
  self->GetStyle(result);
757
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
758
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
759
0
    return false;
760
0
  }
761
0
  return true;
762
0
}
763
764
MOZ_CAN_RUN_SCRIPT static bool
765
set_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
766
0
{
767
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.style", DOM, cx);
768
0
769
0
  binding_detail::FakeString arg0;
770
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
771
0
    return false;
772
0
  }
773
0
  FastErrorResult rv;
774
0
  self->SetStyle(NonNullHelper(Constify(arg0)), rv);
775
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
776
0
    return false;
777
0
  }
778
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
779
0
780
0
  return true;
781
0
}
782
783
static const JSJitInfo style_getterinfo = {
784
  { (JSJitGetterOp)get_style },
785
  { prototypes::id::FontFace },
786
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
787
  JSJitInfo::Getter,
788
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
789
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
790
  false,  /* isInfallible. False in setters. */
791
  false,  /* isMovable.  Not relevant for setters. */
792
  false, /* isEliminatable.  Not relevant for setters. */
793
  false, /* isAlwaysInSlot.  Only relevant for getters. */
794
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
795
  false,  /* isTypedMethod.  Only relevant for methods. */
796
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
797
};
798
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
799
static_assert(0 < 1, "There is no slot for us");
800
static const JSJitInfo style_setterinfo = {
801
  { (JSJitGetterOp)set_style },
802
  { prototypes::id::FontFace },
803
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
804
  JSJitInfo::Setter,
805
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
806
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
807
  false,  /* isInfallible. False in setters. */
808
  false,  /* isMovable.  Not relevant for setters. */
809
  false, /* isEliminatable.  Not relevant for setters. */
810
  false, /* isAlwaysInSlot.  Only relevant for getters. */
811
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
812
  false,  /* isTypedMethod.  Only relevant for methods. */
813
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
814
};
815
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
816
static_assert(0 < 1, "There is no slot for us");
817
818
MOZ_CAN_RUN_SCRIPT static bool
819
get_weight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
820
0
{
821
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.weight", DOM, cx);
822
0
823
0
  DOMString result;
824
0
  self->GetWeight(result);
825
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
826
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
827
0
    return false;
828
0
  }
829
0
  return true;
830
0
}
831
832
MOZ_CAN_RUN_SCRIPT static bool
833
set_weight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
834
0
{
835
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.weight", DOM, cx);
836
0
837
0
  binding_detail::FakeString arg0;
838
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
839
0
    return false;
840
0
  }
841
0
  FastErrorResult rv;
842
0
  self->SetWeight(NonNullHelper(Constify(arg0)), rv);
843
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
844
0
    return false;
845
0
  }
846
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
847
0
848
0
  return true;
849
0
}
850
851
static const JSJitInfo weight_getterinfo = {
852
  { (JSJitGetterOp)get_weight },
853
  { prototypes::id::FontFace },
854
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
855
  JSJitInfo::Getter,
856
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
857
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
858
  false,  /* isInfallible. False in setters. */
859
  false,  /* isMovable.  Not relevant for setters. */
860
  false, /* isEliminatable.  Not relevant for setters. */
861
  false, /* isAlwaysInSlot.  Only relevant for getters. */
862
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
863
  false,  /* isTypedMethod.  Only relevant for methods. */
864
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
865
};
866
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
867
static_assert(0 < 1, "There is no slot for us");
868
static const JSJitInfo weight_setterinfo = {
869
  { (JSJitGetterOp)set_weight },
870
  { prototypes::id::FontFace },
871
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
872
  JSJitInfo::Setter,
873
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
874
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
875
  false,  /* isInfallible. False in setters. */
876
  false,  /* isMovable.  Not relevant for setters. */
877
  false, /* isEliminatable.  Not relevant for setters. */
878
  false, /* isAlwaysInSlot.  Only relevant for getters. */
879
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
880
  false,  /* isTypedMethod.  Only relevant for methods. */
881
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
882
};
883
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
884
static_assert(0 < 1, "There is no slot for us");
885
886
MOZ_CAN_RUN_SCRIPT static bool
887
get_stretch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
888
0
{
889
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.stretch", DOM, cx);
890
0
891
0
  DOMString result;
892
0
  self->GetStretch(result);
893
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
894
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
895
0
    return false;
896
0
  }
897
0
  return true;
898
0
}
899
900
MOZ_CAN_RUN_SCRIPT static bool
901
set_stretch(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
902
0
{
903
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.stretch", DOM, cx);
904
0
905
0
  binding_detail::FakeString arg0;
906
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
907
0
    return false;
908
0
  }
909
0
  FastErrorResult rv;
910
0
  self->SetStretch(NonNullHelper(Constify(arg0)), rv);
911
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
912
0
    return false;
913
0
  }
914
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
915
0
916
0
  return true;
917
0
}
918
919
static const JSJitInfo stretch_getterinfo = {
920
  { (JSJitGetterOp)get_stretch },
921
  { prototypes::id::FontFace },
922
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
923
  JSJitInfo::Getter,
924
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
925
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
926
  false,  /* isInfallible. False in setters. */
927
  false,  /* isMovable.  Not relevant for setters. */
928
  false, /* isEliminatable.  Not relevant for setters. */
929
  false, /* isAlwaysInSlot.  Only relevant for getters. */
930
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
931
  false,  /* isTypedMethod.  Only relevant for methods. */
932
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
933
};
934
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
935
static_assert(0 < 1, "There is no slot for us");
936
static const JSJitInfo stretch_setterinfo = {
937
  { (JSJitGetterOp)set_stretch },
938
  { prototypes::id::FontFace },
939
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
940
  JSJitInfo::Setter,
941
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
942
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
943
  false,  /* isInfallible. False in setters. */
944
  false,  /* isMovable.  Not relevant for setters. */
945
  false, /* isEliminatable.  Not relevant for setters. */
946
  false, /* isAlwaysInSlot.  Only relevant for getters. */
947
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
948
  false,  /* isTypedMethod.  Only relevant for methods. */
949
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
950
};
951
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
952
static_assert(0 < 1, "There is no slot for us");
953
954
MOZ_CAN_RUN_SCRIPT static bool
955
get_unicodeRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
956
0
{
957
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.unicodeRange", DOM, cx);
958
0
959
0
  DOMString result;
960
0
  self->GetUnicodeRange(result);
961
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
962
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
963
0
    return false;
964
0
  }
965
0
  return true;
966
0
}
967
968
MOZ_CAN_RUN_SCRIPT static bool
969
set_unicodeRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
970
0
{
971
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.unicodeRange", DOM, cx);
972
0
973
0
  binding_detail::FakeString arg0;
974
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
975
0
    return false;
976
0
  }
977
0
  FastErrorResult rv;
978
0
  self->SetUnicodeRange(NonNullHelper(Constify(arg0)), rv);
979
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
980
0
    return false;
981
0
  }
982
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
983
0
984
0
  return true;
985
0
}
986
987
static const JSJitInfo unicodeRange_getterinfo = {
988
  { (JSJitGetterOp)get_unicodeRange },
989
  { prototypes::id::FontFace },
990
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
991
  JSJitInfo::Getter,
992
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
993
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
994
  false,  /* isInfallible. False in setters. */
995
  false,  /* isMovable.  Not relevant for setters. */
996
  false, /* isEliminatable.  Not relevant for setters. */
997
  false, /* isAlwaysInSlot.  Only relevant for getters. */
998
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
999
  false,  /* isTypedMethod.  Only relevant for methods. */
1000
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1001
};
1002
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1003
static_assert(0 < 1, "There is no slot for us");
1004
static const JSJitInfo unicodeRange_setterinfo = {
1005
  { (JSJitGetterOp)set_unicodeRange },
1006
  { prototypes::id::FontFace },
1007
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1008
  JSJitInfo::Setter,
1009
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1010
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1011
  false,  /* isInfallible. False in setters. */
1012
  false,  /* isMovable.  Not relevant for setters. */
1013
  false, /* isEliminatable.  Not relevant for setters. */
1014
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1015
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1016
  false,  /* isTypedMethod.  Only relevant for methods. */
1017
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1018
};
1019
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1020
static_assert(0 < 1, "There is no slot for us");
1021
1022
MOZ_CAN_RUN_SCRIPT static bool
1023
get_variant(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1024
0
{
1025
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.variant", DOM, cx);
1026
0
1027
0
  DOMString result;
1028
0
  self->GetVariant(result);
1029
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1030
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1031
0
    return false;
1032
0
  }
1033
0
  return true;
1034
0
}
1035
1036
MOZ_CAN_RUN_SCRIPT static bool
1037
set_variant(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
1038
0
{
1039
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.variant", DOM, cx);
1040
0
1041
0
  binding_detail::FakeString arg0;
1042
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1043
0
    return false;
1044
0
  }
1045
0
  FastErrorResult rv;
1046
0
  self->SetVariant(NonNullHelper(Constify(arg0)), rv);
1047
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1048
0
    return false;
1049
0
  }
1050
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1051
0
1052
0
  return true;
1053
0
}
1054
1055
static const JSJitInfo variant_getterinfo = {
1056
  { (JSJitGetterOp)get_variant },
1057
  { prototypes::id::FontFace },
1058
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1059
  JSJitInfo::Getter,
1060
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1061
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1062
  false,  /* isInfallible. False in setters. */
1063
  false,  /* isMovable.  Not relevant for setters. */
1064
  false, /* isEliminatable.  Not relevant for setters. */
1065
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1066
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1067
  false,  /* isTypedMethod.  Only relevant for methods. */
1068
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1069
};
1070
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1071
static_assert(0 < 1, "There is no slot for us");
1072
static const JSJitInfo variant_setterinfo = {
1073
  { (JSJitGetterOp)set_variant },
1074
  { prototypes::id::FontFace },
1075
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1076
  JSJitInfo::Setter,
1077
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1078
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1079
  false,  /* isInfallible. False in setters. */
1080
  false,  /* isMovable.  Not relevant for setters. */
1081
  false, /* isEliminatable.  Not relevant for setters. */
1082
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1083
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1084
  false,  /* isTypedMethod.  Only relevant for methods. */
1085
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1086
};
1087
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1088
static_assert(0 < 1, "There is no slot for us");
1089
1090
MOZ_CAN_RUN_SCRIPT static bool
1091
get_featureSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1092
0
{
1093
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.featureSettings", DOM, cx);
1094
0
1095
0
  DOMString result;
1096
0
  self->GetFeatureSettings(result);
1097
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1098
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1099
0
    return false;
1100
0
  }
1101
0
  return true;
1102
0
}
1103
1104
MOZ_CAN_RUN_SCRIPT static bool
1105
set_featureSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
1106
0
{
1107
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.featureSettings", DOM, cx);
1108
0
1109
0
  binding_detail::FakeString arg0;
1110
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1111
0
    return false;
1112
0
  }
1113
0
  FastErrorResult rv;
1114
0
  self->SetFeatureSettings(NonNullHelper(Constify(arg0)), rv);
1115
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1116
0
    return false;
1117
0
  }
1118
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1119
0
1120
0
  return true;
1121
0
}
1122
1123
static const JSJitInfo featureSettings_getterinfo = {
1124
  { (JSJitGetterOp)get_featureSettings },
1125
  { prototypes::id::FontFace },
1126
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1127
  JSJitInfo::Getter,
1128
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1129
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1130
  false,  /* isInfallible. False in setters. */
1131
  false,  /* isMovable.  Not relevant for setters. */
1132
  false, /* isEliminatable.  Not relevant for setters. */
1133
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1134
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1135
  false,  /* isTypedMethod.  Only relevant for methods. */
1136
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1137
};
1138
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1139
static_assert(0 < 1, "There is no slot for us");
1140
static const JSJitInfo featureSettings_setterinfo = {
1141
  { (JSJitGetterOp)set_featureSettings },
1142
  { prototypes::id::FontFace },
1143
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1144
  JSJitInfo::Setter,
1145
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1146
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1147
  false,  /* isInfallible. False in setters. */
1148
  false,  /* isMovable.  Not relevant for setters. */
1149
  false, /* isEliminatable.  Not relevant for setters. */
1150
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1151
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1152
  false,  /* isTypedMethod.  Only relevant for methods. */
1153
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1154
};
1155
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1156
static_assert(0 < 1, "There is no slot for us");
1157
1158
MOZ_CAN_RUN_SCRIPT static bool
1159
get_variationSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1160
0
{
1161
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.variationSettings", DOM, cx);
1162
0
1163
0
  DOMString result;
1164
0
  self->GetVariationSettings(result);
1165
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1166
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1167
0
    return false;
1168
0
  }
1169
0
  return true;
1170
0
}
1171
1172
MOZ_CAN_RUN_SCRIPT static bool
1173
set_variationSettings(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
1174
0
{
1175
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.variationSettings", DOM, cx);
1176
0
1177
0
  binding_detail::FakeString arg0;
1178
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1179
0
    return false;
1180
0
  }
1181
0
  FastErrorResult rv;
1182
0
  self->SetVariationSettings(NonNullHelper(Constify(arg0)), rv);
1183
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1184
0
    return false;
1185
0
  }
1186
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1187
0
1188
0
  return true;
1189
0
}
1190
1191
static const JSJitInfo variationSettings_getterinfo = {
1192
  { (JSJitGetterOp)get_variationSettings },
1193
  { prototypes::id::FontFace },
1194
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1195
  JSJitInfo::Getter,
1196
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1197
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1198
  false,  /* isInfallible. False in setters. */
1199
  false,  /* isMovable.  Not relevant for setters. */
1200
  false, /* isEliminatable.  Not relevant for setters. */
1201
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1202
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1203
  false,  /* isTypedMethod.  Only relevant for methods. */
1204
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1205
};
1206
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1207
static_assert(0 < 1, "There is no slot for us");
1208
static const JSJitInfo variationSettings_setterinfo = {
1209
  { (JSJitGetterOp)set_variationSettings },
1210
  { prototypes::id::FontFace },
1211
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1212
  JSJitInfo::Setter,
1213
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1214
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1215
  false,  /* isInfallible. False in setters. */
1216
  false,  /* isMovable.  Not relevant for setters. */
1217
  false, /* isEliminatable.  Not relevant for setters. */
1218
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1219
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1220
  false,  /* isTypedMethod.  Only relevant for methods. */
1221
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1222
};
1223
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1224
static_assert(0 < 1, "There is no slot for us");
1225
1226
MOZ_CAN_RUN_SCRIPT static bool
1227
get_display(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1228
0
{
1229
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.display", DOM, cx);
1230
0
1231
0
  DOMString result;
1232
0
  self->GetDisplay(result);
1233
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1234
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1235
0
    return false;
1236
0
  }
1237
0
  return true;
1238
0
}
1239
1240
MOZ_CAN_RUN_SCRIPT static bool
1241
set_display(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitSetterCallArgs args)
1242
0
{
1243
0
  AUTO_PROFILER_LABEL_FAST("set FontFace.display", DOM, cx);
1244
0
1245
0
  binding_detail::FakeString arg0;
1246
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1247
0
    return false;
1248
0
  }
1249
0
  FastErrorResult rv;
1250
0
  self->SetDisplay(NonNullHelper(Constify(arg0)), rv);
1251
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1252
0
    return false;
1253
0
  }
1254
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1255
0
1256
0
  return true;
1257
0
}
1258
1259
static const JSJitInfo display_getterinfo = {
1260
  { (JSJitGetterOp)get_display },
1261
  { prototypes::id::FontFace },
1262
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1263
  JSJitInfo::Getter,
1264
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1265
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1266
  false,  /* isInfallible. False in setters. */
1267
  false,  /* isMovable.  Not relevant for setters. */
1268
  false, /* isEliminatable.  Not relevant for setters. */
1269
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1270
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1271
  false,  /* isTypedMethod.  Only relevant for methods. */
1272
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1273
};
1274
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1275
static_assert(0 < 1, "There is no slot for us");
1276
static const JSJitInfo display_setterinfo = {
1277
  { (JSJitGetterOp)set_display },
1278
  { prototypes::id::FontFace },
1279
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1280
  JSJitInfo::Setter,
1281
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1282
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1283
  false,  /* isInfallible. False in setters. */
1284
  false,  /* isMovable.  Not relevant for setters. */
1285
  false, /* isEliminatable.  Not relevant for setters. */
1286
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1287
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1288
  false,  /* isTypedMethod.  Only relevant for methods. */
1289
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1290
};
1291
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1292
static_assert(0 < 1, "There is no slot for us");
1293
1294
MOZ_CAN_RUN_SCRIPT static bool
1295
get_status(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1296
0
{
1297
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.status", DOM, cx);
1298
0
1299
0
  FontFaceLoadStatus result(self->Status());
1300
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1301
0
  if (!ToJSValue(cx, result, args.rval())) {
1302
0
    return false;
1303
0
  }
1304
0
  return true;
1305
0
}
1306
1307
static const JSJitInfo status_getterinfo = {
1308
  { (JSJitGetterOp)get_status },
1309
  { prototypes::id::FontFace },
1310
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1311
  JSJitInfo::Getter,
1312
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1313
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1314
  false,  /* isInfallible. False in setters. */
1315
  false,  /* isMovable.  Not relevant for setters. */
1316
  false, /* isEliminatable.  Not relevant for setters. */
1317
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1318
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1319
  false,  /* isTypedMethod.  Only relevant for methods. */
1320
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1321
};
1322
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1323
static_assert(0 < 1, "There is no slot for us");
1324
1325
MOZ_CAN_RUN_SCRIPT static bool
1326
load(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, const JSJitMethodCallArgs& args)
1327
0
{
1328
0
  AUTO_PROFILER_LABEL_FAST("FontFace.load", DOM, cx);
1329
0
1330
0
  FastErrorResult rv;
1331
0
  auto result(StrongOrRawPtr<Promise>(self->Load(rv)));
1332
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1333
0
    return false;
1334
0
  }
1335
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1336
0
  if (!ToJSValue(cx, result, args.rval())) {
1337
0
    return false;
1338
0
  }
1339
0
  return true;
1340
0
}
1341
1342
MOZ_CAN_RUN_SCRIPT static bool
1343
load_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, const JSJitMethodCallArgs& args)
1344
0
{
1345
0
  bool ok = load(cx, obj, self, args);
1346
0
  if (ok) {
1347
0
    return true;
1348
0
  }
1349
0
  return ConvertExceptionToPromise(cx, args.rval());
1350
0
}
1351
1352
static const JSJitInfo load_methodinfo = {
1353
  { (JSJitGetterOp)load_promiseWrapper },
1354
  { prototypes::id::FontFace },
1355
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1356
  JSJitInfo::Method,
1357
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1358
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1359
  false,  /* isInfallible. False in setters. */
1360
  false,  /* isMovable.  Not relevant for setters. */
1361
  false, /* isEliminatable.  Not relevant for setters. */
1362
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1363
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1364
  false,  /* isTypedMethod.  Only relevant for methods. */
1365
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1366
};
1367
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1368
static_assert(0 < 1, "There is no slot for us");
1369
1370
MOZ_CAN_RUN_SCRIPT static bool
1371
get_loaded(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1372
0
{
1373
0
  AUTO_PROFILER_LABEL_FAST("get FontFace.loaded", DOM, cx);
1374
0
1375
0
  FastErrorResult rv;
1376
0
  auto result(StrongOrRawPtr<Promise>(self->GetLoaded(rv)));
1377
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1378
0
    return false;
1379
0
  }
1380
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1381
0
  if (!ToJSValue(cx, result, args.rval())) {
1382
0
    return false;
1383
0
  }
1384
0
  return true;
1385
0
}
1386
1387
MOZ_CAN_RUN_SCRIPT static bool
1388
get_loaded_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::FontFace* self, JSJitGetterCallArgs args)
1389
0
{
1390
0
  bool ok = get_loaded(cx, obj, self, args);
1391
0
  if (ok) {
1392
0
    return true;
1393
0
  }
1394
0
  return ConvertExceptionToPromise(cx, args.rval());
1395
0
}
1396
1397
static const JSJitInfo loaded_getterinfo = {
1398
  { (JSJitGetterOp)get_loaded_promiseWrapper },
1399
  { prototypes::id::FontFace },
1400
  { PrototypeTraits<prototypes::id::FontFace>::Depth },
1401
  JSJitInfo::Getter,
1402
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1403
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1404
  false,  /* isInfallible. False in setters. */
1405
  false,  /* isMovable.  Not relevant for setters. */
1406
  false, /* isEliminatable.  Not relevant for setters. */
1407
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1408
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1409
  false,  /* isTypedMethod.  Only relevant for methods. */
1410
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1411
};
1412
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1413
static_assert(0 < 1, "There is no slot for us");
1414
1415
static bool
1416
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1417
0
{
1418
0
  mozilla::dom::FontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFace>(obj);
1419
0
  // We don't want to preserve if we don't have a wrapper, and we
1420
0
  // obviously can't preserve if we're not initialized.
1421
0
  if (self && self->GetWrapperPreserveColor()) {
1422
0
    PreserveWrapper(self);
1423
0
  }
1424
0
  return true;
1425
0
}
1426
1427
static void
1428
_finalize(js::FreeOp* fop, JSObject* obj)
1429
0
{
1430
0
  mozilla::dom::FontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFace>(obj);
1431
0
  if (self) {
1432
0
    ClearWrapper(self, self, obj);
1433
0
    AddForDeferredFinalization<mozilla::dom::FontFace>(self);
1434
0
  }
1435
0
}
1436
1437
static size_t
1438
_objectMoved(JSObject* obj, JSObject* old)
1439
0
{
1440
0
  mozilla::dom::FontFace* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::FontFace>(obj);
1441
0
  if (self) {
1442
0
    UpdateWrapper(self, self, obj, old);
1443
0
  }
1444
0
1445
0
  return 0;
1446
0
}
1447
1448
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1449
#if defined(__clang__)
1450
#pragma clang diagnostic push
1451
#pragma clang diagnostic ignored "-Wmissing-braces"
1452
#endif
1453
static const JSFunctionSpec sMethods_specs[] = {
1454
  JS_FNSPEC("load", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&load_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1455
  JS_FS_END
1456
};
1457
#if defined(__clang__)
1458
#pragma clang diagnostic pop
1459
#endif
1460
1461
1462
static const Prefable<const JSFunctionSpec> sMethods[] = {
1463
  { nullptr, &sMethods_specs[0] },
1464
  { nullptr, nullptr }
1465
};
1466
1467
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1468
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1469
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1470
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1471
1472
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1473
#if defined(__clang__)
1474
#pragma clang diagnostic push
1475
#pragma clang diagnostic ignored "-Wmissing-braces"
1476
#endif
1477
static const JSPropertySpec sAttributes_specs[] = {
1478
  { "family", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &family_getterinfo, GenericSetter<NormalThisPolicy>, &family_setterinfo },
1479
  { "style", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &style_getterinfo, GenericSetter<NormalThisPolicy>, &style_setterinfo },
1480
  { "weight", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &weight_getterinfo, GenericSetter<NormalThisPolicy>, &weight_setterinfo },
1481
  { "stretch", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &stretch_getterinfo, GenericSetter<NormalThisPolicy>, &stretch_setterinfo },
1482
  { "unicodeRange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &unicodeRange_getterinfo, GenericSetter<NormalThisPolicy>, &unicodeRange_setterinfo },
1483
  { "variant", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &variant_getterinfo, GenericSetter<NormalThisPolicy>, &variant_setterinfo },
1484
  { "featureSettings", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &featureSettings_getterinfo, GenericSetter<NormalThisPolicy>, &featureSettings_setterinfo },
1485
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1486
  { "variationSettings", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &variationSettings_getterinfo, GenericSetter<NormalThisPolicy>, &variationSettings_setterinfo },
1487
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1488
  { "display", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &display_getterinfo, GenericSetter<NormalThisPolicy>, &display_setterinfo },
1489
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1490
  { "status", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &status_getterinfo, nullptr, nullptr },
1491
  { "loaded", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ConvertExceptionsToPromises>, &loaded_getterinfo, nullptr, nullptr },
1492
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1493
};
1494
#if defined(__clang__)
1495
#pragma clang diagnostic pop
1496
#endif
1497
1498
// Can't be const because the pref-enabled boolean needs to be writable
1499
static PrefableDisablers sAttributes_disablers8 = {
1500
  true, false, 0, nullptr
1501
};
1502
1503
// Can't be const because the pref-enabled boolean needs to be writable
1504
static PrefableDisablers sAttributes_disablers10 = {
1505
  true, false, 0, nullptr
1506
};
1507
1508
static const Prefable<const JSPropertySpec> sAttributes[] = {
1509
  { nullptr, &sAttributes_specs[0] },
1510
  { &sAttributes_disablers8, &sAttributes_specs[8] },
1511
  { &sAttributes_disablers10, &sAttributes_specs[10] },
1512
  { nullptr, &sAttributes_specs[12] },
1513
  { nullptr, nullptr }
1514
};
1515
1516
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1517
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1518
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1519
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1520
1521
1522
static uint16_t sNativeProperties_sortedPropertyIndices[12];
1523
static PropertyInfo sNativeProperties_propertyInfos[12];
1524
1525
static const NativePropertiesN<2> sNativeProperties = {
1526
  false, 0,
1527
  false, 0,
1528
  true,  0 /* sMethods */,
1529
  true,  1 /* sAttributes */,
1530
  false, 0,
1531
  false, 0,
1532
  false, 0,
1533
  -1,
1534
  12,
1535
  sNativeProperties_sortedPropertyIndices,
1536
  {
1537
    { sMethods, &sNativeProperties_propertyInfos[0] },
1538
    { sAttributes, &sNativeProperties_propertyInfos[1] }
1539
  }
1540
};
1541
static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1542
    "We have a property info count that is oversized");
1543
1544
static bool
1545
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1546
0
{
1547
0
  AUTO_PROFILER_LABEL_FAST("FontFace constructor", DOM, cx);
1548
0
1549
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1550
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1551
0
  if (!args.isConstructing()) {
1552
0
    // XXXbz wish I could get the name from the callee instead of
1553
0
    // Adding more relocations
1554
0
    return ThrowConstructorWithoutNew(cx, "FontFace");
1555
0
  }
1556
0
1557
0
  JS::Rooted<JSObject*> desiredProto(cx);
1558
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1559
0
    return false;
1560
0
  }
1561
0
1562
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
1563
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "FontFace");
1564
0
  }
1565
0
  GlobalObject global(cx, obj);
1566
0
  if (global.Failed()) {
1567
0
    return false;
1568
0
  }
1569
0
1570
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1571
0
  binding_detail::FakeString arg0;
1572
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1573
0
    return false;
1574
0
  }
1575
0
  StringOrArrayBufferOrArrayBufferView arg1;
1576
0
  StringOrArrayBufferOrArrayBufferViewArgument arg1_holder(arg1);
1577
0
  {
1578
0
    bool done = false, failed = false, tryNext;
1579
0
    if (args[1].isObject()) {
1580
0
      done = (failed = !arg1_holder.TrySetToArrayBuffer(cx, args[1], tryNext, false)) || !tryNext ||
1581
0
             (failed = !arg1_holder.TrySetToArrayBufferView(cx, args[1], tryNext, false)) || !tryNext;
1582
0
1583
0
    }
1584
0
    if (!done) {
1585
0
      do {
1586
0
        done = (failed = !arg1_holder.TrySetToString(cx, args[1], tryNext)) || !tryNext;
1587
0
        break;
1588
0
      } while (false);
1589
0
    }
1590
0
    if (failed) {
1591
0
      return false;
1592
0
    }
1593
0
    if (!done) {
1594
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of FontFace.constructor", "ArrayBuffer, ArrayBufferView");
1595
0
      return false;
1596
0
    }
1597
0
  }
1598
0
  binding_detail::FastFontFaceDescriptors arg2;
1599
0
  if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of FontFace.constructor", false)) {
1600
0
    return false;
1601
0
  }
1602
0
  Maybe<JSAutoRealm> ar;
1603
0
  if (objIsXray) {
1604
0
    obj = js::CheckedUnwrap(obj);
1605
0
    if (!obj) {
1606
0
      return false;
1607
0
    }
1608
0
    ar.emplace(cx, obj);
1609
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1610
0
      return false;
1611
0
    }
1612
0
    if (arg1.IsArrayBuffer()) {
1613
0
      if (!arg1.GetAsArrayBuffer().WrapIntoNewCompartment(cx)) {
1614
0
        return false;
1615
0
      }
1616
0
    }
1617
0
    else if (arg1.IsArrayBufferView()) {
1618
0
      if (!arg1.GetAsArrayBufferView().WrapIntoNewCompartment(cx)) {
1619
0
        return false;
1620
0
      }
1621
0
    }
1622
0
  }
1623
0
  FastErrorResult rv;
1624
0
  auto result(StrongOrRawPtr<mozilla::dom::FontFace>(mozilla::dom::FontFace::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), Constify(arg2), rv)));
1625
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1626
0
    return false;
1627
0
  }
1628
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1629
0
  static_assert(!IsPointer<decltype(result)>::value,
1630
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1631
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1632
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1633
0
    return false;
1634
0
  }
1635
0
  return true;
1636
0
}
1637
1638
static const js::ClassOps sInterfaceObjectClassOps = {
1639
    nullptr,               /* addProperty */
1640
    nullptr,               /* delProperty */
1641
    nullptr,               /* enumerate */
1642
    nullptr,               /* newEnumerate */
1643
    nullptr,               /* resolve */
1644
    nullptr,               /* mayResolve */
1645
    nullptr,               /* finalize */
1646
    _constructor, /* call */
1647
    nullptr,               /* hasInstance */
1648
    _constructor, /* construct */
1649
    nullptr,               /* trace */
1650
};
1651
1652
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1653
  {
1654
    "Function",
1655
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1656
    &sInterfaceObjectClassOps,
1657
    JS_NULL_CLASS_SPEC,
1658
    JS_NULL_CLASS_EXT,
1659
    &sInterfaceObjectClassObjectOps
1660
  },
1661
  eInterface,
1662
  true,
1663
  prototypes::id::FontFace,
1664
  PrototypeTraits<prototypes::id::FontFace>::Depth,
1665
  sNativePropertyHooks,
1666
  "function FontFace() {\n    [native code]\n}",
1667
  JS::GetRealmFunctionPrototype
1668
};
1669
1670
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1671
  {
1672
    "FontFacePrototype",
1673
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1674
    JS_NULL_CLASS_OPS,
1675
    JS_NULL_CLASS_SPEC,
1676
    JS_NULL_CLASS_EXT,
1677
    JS_NULL_OBJECT_OPS
1678
  },
1679
  eInterfacePrototype,
1680
  false,
1681
  prototypes::id::FontFace,
1682
  PrototypeTraits<prototypes::id::FontFace>::Depth,
1683
  sNativePropertyHooks,
1684
  "[object FontFacePrototype]",
1685
  JS::GetRealmObjectPrototype
1686
};
1687
1688
bool
1689
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1690
0
{
1691
0
  static bool sPrefValue;
1692
0
  static bool sPrefCacheSetUp = false;
1693
0
  if (!sPrefCacheSetUp) {
1694
0
    sPrefCacheSetUp = true;
1695
0
    Preferences::AddBoolVarCache(&sPrefValue, "layout.css.font-loading-api.enabled");
1696
0
  }
1697
0
1698
0
  return sPrefValue;
1699
0
}
1700
1701
static const js::ClassOps sClassOps = {
1702
  _addProperty, /* addProperty */
1703
  nullptr,               /* delProperty */
1704
  nullptr,               /* enumerate */
1705
  nullptr, /* newEnumerate */
1706
  nullptr, /* resolve */
1707
  nullptr, /* mayResolve */
1708
  _finalize, /* finalize */
1709
  nullptr, /* call */
1710
  nullptr,               /* hasInstance */
1711
  nullptr,               /* construct */
1712
  nullptr, /* trace */
1713
};
1714
1715
static const js::ClassExtension sClassExtension = {
1716
  nullptr, /* weakmapKeyDelegateOp */
1717
  _objectMoved /* objectMovedOp */
1718
};
1719
1720
static const DOMJSClass sClass = {
1721
  { "FontFace",
1722
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1723
    &sClassOps,
1724
    JS_NULL_CLASS_SPEC,
1725
    &sClassExtension,
1726
    JS_NULL_OBJECT_OPS
1727
  },
1728
  { prototypes::id::FontFace, 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 },
1729
  IsBaseOf<nsISupports, mozilla::dom::FontFace >::value,
1730
  sNativePropertyHooks,
1731
  FindAssociatedGlobalForNative<mozilla::dom::FontFace>::Get,
1732
  GetProtoObjectHandle,
1733
  GetCCParticipant<mozilla::dom::FontFace>::Get()
1734
};
1735
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1736
              "Must have the right minimal number of reserved slots.");
1737
static_assert(1 >= 1,
1738
              "Must have enough reserved slots.");
1739
1740
const JSClass*
1741
GetJSClass()
1742
0
{
1743
0
  return sClass.ToJSClass();
1744
0
}
1745
1746
bool
1747
Wrap(JSContext* aCx, mozilla::dom::FontFace* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1748
0
{
1749
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::FontFace>::value,
1750
0
                "Shouldn't have wrappercached things that are not refcounted.");
1751
0
  MOZ_ASSERT(static_cast<mozilla::dom::FontFace*>(aObject) ==
1752
0
             reinterpret_cast<mozilla::dom::FontFace*>(aObject),
1753
0
             "Multiple inheritance for mozilla::dom::FontFace is broken.");
1754
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1755
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1756
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1757
0
             "You should probably not be using Wrap() directly; use "
1758
0
             "GetOrCreateDOMReflector instead");
1759
0
1760
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1761
0
             "nsISupports must be on our primary inheritance chain");
1762
0
1763
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1764
0
  if (!global) {
1765
0
    return false;
1766
0
  }
1767
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1768
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1769
0
1770
0
  // That might have ended up wrapping us already, due to the wonders
1771
0
  // of XBL.  Check for that, and bail out as needed.
1772
0
  aReflector.set(aCache->GetWrapper());
1773
0
  if (aReflector) {
1774
#ifdef DEBUG
1775
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1776
#endif // DEBUG
1777
    return true;
1778
0
  }
1779
0
1780
0
  JSAutoRealm ar(aCx, global);
1781
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1782
0
  if (!canonicalProto) {
1783
0
    return false;
1784
0
  }
1785
0
  JS::Rooted<JSObject*> proto(aCx);
1786
0
  if (aGivenProto) {
1787
0
    proto = aGivenProto;
1788
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1789
0
    // coming in, we changed compartments to that of "parent" so may need
1790
0
    // to wrap the proto here.
1791
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1792
0
      if (!JS_WrapObject(aCx, &proto)) {
1793
0
        return false;
1794
0
      }
1795
0
    }
1796
0
  } else {
1797
0
    proto = canonicalProto;
1798
0
  }
1799
0
1800
0
  BindingJSObjectCreator<mozilla::dom::FontFace> creator(aCx);
1801
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1802
0
  if (!aReflector) {
1803
0
    return false;
1804
0
  }
1805
0
1806
0
  aCache->SetWrapper(aReflector);
1807
0
  creator.InitializationSucceeded();
1808
0
1809
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1810
0
             aCache->GetWrapperPreserveColor() == aReflector);
1811
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1812
0
  // otherwise we won't be able to properly recreate it later, since
1813
0
  // we won't know what proto to use.  Note that we don't check
1814
0
  // aGivenProto here, since it's entirely possible (and even
1815
0
  // somewhat common) to have a non-null aGivenProto which is the
1816
0
  // same as canonicalProto.
1817
0
  if (proto != canonicalProto) {
1818
0
    PreserveWrapper(aObject);
1819
0
  }
1820
0
1821
0
  return true;
1822
0
}
1823
1824
const NativePropertyHooks sNativePropertyHooks[] = { {
1825
  nullptr,
1826
  nullptr,
1827
  nullptr,
1828
  { sNativeProperties.Upcast(), nullptr },
1829
  prototypes::id::FontFace,
1830
  constructors::id::FontFace,
1831
  nullptr,
1832
  &DefaultXrayExpandoObjectClass
1833
} };
1834
1835
void
1836
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1837
0
{
1838
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1839
0
  if (!parentProto) {
1840
0
    return;
1841
0
  }
1842
0
1843
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1844
0
  if (!constructorProto) {
1845
0
    return;
1846
0
  }
1847
0
1848
0
  static bool sIdsInited = false;
1849
0
  if (!sIdsInited && NS_IsMainThread()) {
1850
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1851
0
      return;
1852
0
    }
1853
0
    sIdsInited = true;
1854
0
  }
1855
0
1856
0
  static bool sPrefCachesInited = false;
1857
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
1858
0
    sPrefCachesInited = true;
1859
0
    Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "layout.css.font-variations.enabled");
1860
0
    Preferences::AddBoolVarCache(&sAttributes[2].disablers->enabled, "layout.css.font-display.enabled");
1861
0
  }
1862
0
1863
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::FontFace);
1864
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::FontFace);
1865
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1866
0
                              &sPrototypeClass.mBase, protoCache,
1867
0
                              nullptr,
1868
0
                              constructorProto, &sInterfaceObjectClass.mBase, 2, nullptr,
1869
0
                              interfaceCache,
1870
0
                              sNativeProperties.Upcast(),
1871
0
                              nullptr,
1872
0
                              "FontFace", aDefineOnGlobal,
1873
0
                              nullptr,
1874
0
                              false);
1875
0
}
1876
1877
JSObject*
1878
GetConstructorObject(JSContext* aCx)
1879
0
{
1880
0
  return GetConstructorObjectHandle(aCx);
1881
0
}
1882
1883
} // namespace FontFace_Binding
1884
1885
1886
1887
} // namespace dom
1888
} // namespace mozilla