Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/FontFaceBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM FontFace.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_FontFaceBinding_h
4
#define mozilla_dom_FontFaceBinding_h
5
6
#include "GeckoProfiler.h"
7
#include "js/RootingAPI.h"
8
#include "jsfriendapi.h"
9
#include "jspubtd.h"
10
#include "mozilla/ErrorResult.h"
11
#include "mozilla/dom/BindingDeclarations.h"
12
#include "mozilla/dom/FakeString.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/PrototypeList.h"
15
#include "mozilla/dom/TypedArray.h"
16
#include "mozilla/dom/UnionMember.h"
17
18
namespace mozilla {
19
namespace dom {
20
21
class FontFace;
22
struct FontFaceAtoms;
23
struct FontFaceDescriptorsAtoms;
24
struct NativePropertyHooks;
25
class ProtoAndIfaceCache;
26
27
} // namespace dom
28
} // namespace mozilla
29
30
namespace mozilla {
31
namespace dom {
32
33
enum class FontFaceLoadStatus : uint8_t {
34
  Unloaded,
35
  Loading,
36
  Loaded,
37
  Error,
38
  EndGuard_
39
};
40
41
namespace FontFaceLoadStatusValues {
42
extern const EnumEntry strings[5];
43
} // namespace FontFaceLoadStatusValues
44
45
bool
46
ToJSValue(JSContext* aCx, FontFaceLoadStatus aArgument, JS::MutableHandle<JS::Value> aValue);
47
48
49
struct FontFaceDescriptors : public DictionaryBase
50
{
51
  MOZ_INIT_OUTSIDE_CTOR nsString mDisplay;
52
  MOZ_INIT_OUTSIDE_CTOR nsString mFeatureSettings;
53
  MOZ_INIT_OUTSIDE_CTOR nsString mStretch;
54
  MOZ_INIT_OUTSIDE_CTOR nsString mStyle;
55
  MOZ_INIT_OUTSIDE_CTOR nsString mUnicodeRange;
56
  MOZ_INIT_OUTSIDE_CTOR nsString mVariant;
57
  MOZ_INIT_OUTSIDE_CTOR nsString mVariationSettings;
58
  MOZ_INIT_OUTSIDE_CTOR nsString mWeight;
59
60
  FontFaceDescriptors();
61
62
  explicit inline FontFaceDescriptors(const FastDictionaryInitializer& )
63
0
  {
64
0
    // Do nothing here; this is used by our "Fast" subclass
65
0
  }
66
67
  explicit inline FontFaceDescriptors(const FontFaceDescriptors& aOther)
68
0
  {
69
0
    *this = aOther;
70
0
  }
71
72
  bool
73
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
74
75
  bool
76
  Init(const nsAString& aJSON);
77
78
  bool
79
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
80
81
  bool
82
  ToJSON(nsAString& aJSON) const;
83
84
  void
85
  TraceDictionary(JSTracer* trc);
86
87
  FontFaceDescriptors&
88
  operator=(const FontFaceDescriptors& aOther);
89
90
private:
91
  static bool
92
  InitIds(JSContext* cx, FontFaceDescriptorsAtoms* atomsCache);
93
};
94
95
namespace binding_detail {
96
struct FastFontFaceDescriptors : public FontFaceDescriptors
97
{
98
  inline FastFontFaceDescriptors()
99
    : FontFaceDescriptors(FastDictionaryInitializer())
100
0
  {
101
0
    // Doesn't matter what int we pass to the parent constructor
102
0
  }
103
};
104
} // namespace binding_detail
105
106
107
class StringOrArrayBufferOrArrayBufferView
108
{
109
  friend class StringOrArrayBufferOrArrayBufferViewArgument;
110
  enum Type
111
  {
112
    eUninitialized,
113
    eString,
114
    eArrayBuffer,
115
    eArrayBufferView
116
  };
117
118
  union Value
119
  {
120
    UnionMember<binding_detail::FakeString > mString;
121
    UnionMember<RootedSpiderMonkeyInterface<ArrayBuffer> > mArrayBuffer;
122
    UnionMember<RootedSpiderMonkeyInterface<ArrayBufferView> > mArrayBufferView;
123
124
  };
125
126
  Type mType;
127
  Value mValue;
128
129
  StringOrArrayBufferOrArrayBufferView(const StringOrArrayBufferOrArrayBufferView&) = delete;
130
  StringOrArrayBufferOrArrayBufferView& operator=(const StringOrArrayBufferOrArrayBufferView&) = delete;
131
public:
132
  explicit inline StringOrArrayBufferOrArrayBufferView()
133
    : mType(eUninitialized)
134
0
  {
135
0
  }
136
137
  inline ~StringOrArrayBufferOrArrayBufferView()
138
0
  {
139
0
    Uninit();
140
0
  }
141
142
  inline binding_detail::FakeString&
143
  RawSetAsString()
144
0
  {
145
0
    if (mType == eString) {
146
0
      return mValue.mString.Value();
147
0
    }
148
0
    MOZ_ASSERT(mType == eUninitialized);
149
0
    mType = eString;
150
0
    return mValue.mString.SetValue();
151
0
  }
152
153
  inline binding_detail::FakeString&
154
  SetAsString()
155
0
  {
156
0
    if (mType == eString) {
157
0
      return mValue.mString.Value();
158
0
    }
159
0
    Uninit();
160
0
    mType = eString;
161
0
    return mValue.mString.SetValue();
162
0
  }
163
164
  inline bool
165
  IsString() const
166
0
  {
167
0
    return mType == eString;
168
0
  }
169
170
  inline binding_detail::FakeString&
171
  GetAsString()
172
0
  {
173
0
    MOZ_ASSERT(IsString(), "Wrong type!");
174
0
    return mValue.mString.Value();
175
0
  }
176
177
  inline const nsAString&
178
  GetAsString() const
179
0
  {
180
0
    MOZ_ASSERT(IsString(), "Wrong type!");
181
0
    return mValue.mString.Value();
182
0
  }
183
184
  inline RootedSpiderMonkeyInterface<ArrayBuffer>&
185
  RawSetAsArrayBuffer(JSContext* cx)
186
0
  {
187
0
    if (mType == eArrayBuffer) {
188
0
      return mValue.mArrayBuffer.Value();
189
0
    }
190
0
    MOZ_ASSERT(mType == eUninitialized);
191
0
    mType = eArrayBuffer;
192
0
    return mValue.mArrayBuffer.SetValue(cx);
193
0
  }
194
195
  inline RootedSpiderMonkeyInterface<ArrayBuffer>&
196
  SetAsArrayBuffer(JSContext* cx)
197
0
  {
198
0
    if (mType == eArrayBuffer) {
199
0
      return mValue.mArrayBuffer.Value();
200
0
    }
201
0
    Uninit();
202
0
    mType = eArrayBuffer;
203
0
    return mValue.mArrayBuffer.SetValue(cx);
204
0
  }
205
206
  inline bool
207
  IsArrayBuffer() const
208
0
  {
209
0
    return mType == eArrayBuffer;
210
0
  }
211
212
  inline RootedSpiderMonkeyInterface<ArrayBuffer>&
213
  GetAsArrayBuffer()
214
0
  {
215
0
    MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
216
0
    return mValue.mArrayBuffer.Value();
217
0
  }
218
219
  inline ArrayBuffer const &
220
  GetAsArrayBuffer() const
221
0
  {
222
0
    MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
223
0
    return mValue.mArrayBuffer.Value();
224
0
  }
225
226
  inline RootedSpiderMonkeyInterface<ArrayBufferView>&
227
  RawSetAsArrayBufferView(JSContext* cx)
228
0
  {
229
0
    if (mType == eArrayBufferView) {
230
0
      return mValue.mArrayBufferView.Value();
231
0
    }
232
0
    MOZ_ASSERT(mType == eUninitialized);
233
0
    mType = eArrayBufferView;
234
0
    return mValue.mArrayBufferView.SetValue(cx);
235
0
  }
236
237
  inline RootedSpiderMonkeyInterface<ArrayBufferView>&
238
  SetAsArrayBufferView(JSContext* cx)
239
0
  {
240
0
    if (mType == eArrayBufferView) {
241
0
      return mValue.mArrayBufferView.Value();
242
0
    }
243
0
    Uninit();
244
0
    mType = eArrayBufferView;
245
0
    return mValue.mArrayBufferView.SetValue(cx);
246
0
  }
247
248
  inline bool
249
  IsArrayBufferView() const
250
0
  {
251
0
    return mType == eArrayBufferView;
252
0
  }
253
254
  inline RootedSpiderMonkeyInterface<ArrayBufferView>&
255
  GetAsArrayBufferView()
256
0
  {
257
0
    MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
258
0
    return mValue.mArrayBufferView.Value();
259
0
  }
260
261
  inline ArrayBufferView const &
262
  GetAsArrayBufferView() const
263
0
  {
264
0
    MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
265
0
    return mValue.mArrayBufferView.Value();
266
0
  }
267
268
  inline void
269
  Uninit()
270
  {
271
    switch (mType) {
272
      case eUninitialized: {
273
        break;
274
      }
275
      case eString: {
276
        DestroyString();
277
        break;
278
      }
279
      case eArrayBuffer: {
280
        DestroyArrayBuffer();
281
        break;
282
      }
283
      case eArrayBufferView: {
284
        DestroyArrayBufferView();
285
        break;
286
      }
287
    }
288
  }
289
290
  bool
291
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
292
293
private:
294
  inline void
295
  DestroyString()
296
0
  {
297
0
    MOZ_ASSERT(IsString(), "Wrong type!");
298
0
    mValue.mString.Destroy();
299
0
    mType = eUninitialized;
300
0
  }
301
302
  inline void
303
  DestroyArrayBuffer()
304
0
  {
305
0
    MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
306
0
    mValue.mArrayBuffer.Destroy();
307
0
    mType = eUninitialized;
308
0
  }
309
310
  inline void
311
  DestroyArrayBufferView()
312
0
  {
313
0
    MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
314
0
    mValue.mArrayBufferView.Destroy();
315
0
    mType = eUninitialized;
316
0
  }
317
};
318
319
320
class OwningStringOrArrayBufferOrArrayBufferView : public AllOwningUnionBase
321
{
322
  friend void ImplCycleCollectionUnlink(OwningStringOrArrayBufferOrArrayBufferView& aUnion);
323
  enum Type
324
  {
325
    eUninitialized,
326
    eString,
327
    eArrayBuffer,
328
    eArrayBufferView
329
  };
330
331
  union Value
332
  {
333
    UnionMember<nsString > mString;
334
    UnionMember<ArrayBuffer > mArrayBuffer;
335
    UnionMember<ArrayBufferView > mArrayBufferView;
336
337
  };
338
339
  Type mType;
340
  Value mValue;
341
342
  OwningStringOrArrayBufferOrArrayBufferView(const OwningStringOrArrayBufferOrArrayBufferView&) = delete;
343
  OwningStringOrArrayBufferOrArrayBufferView& operator=(const OwningStringOrArrayBufferOrArrayBufferView&) = delete;
344
public:
345
  explicit inline OwningStringOrArrayBufferOrArrayBufferView()
346
    : mType(eUninitialized)
347
0
  {
348
0
  }
349
350
  inline ~OwningStringOrArrayBufferOrArrayBufferView()
351
0
  {
352
0
    Uninit();
353
0
  }
354
355
  nsString&
356
  RawSetAsString();
357
358
  nsString&
359
  SetAsString();
360
361
  bool
362
  TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
363
364
  inline void
365
  SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
366
0
  {
367
0
    RawSetAsString().Assign(aData, aLength);
368
0
  }
369
370
  inline bool
371
  IsString() const
372
0
  {
373
0
    return mType == eString;
374
0
  }
375
376
  inline nsString&
377
  GetAsString()
378
0
  {
379
0
    MOZ_ASSERT(IsString(), "Wrong type!");
380
0
    return mValue.mString.Value();
381
0
  }
382
383
  inline nsString const &
384
  GetAsString() const
385
0
  {
386
0
    MOZ_ASSERT(IsString(), "Wrong type!");
387
0
    return mValue.mString.Value();
388
0
  }
389
390
  ArrayBuffer&
391
  RawSetAsArrayBuffer();
392
393
  ArrayBuffer&
394
  SetAsArrayBuffer();
395
396
  bool
397
  TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
398
399
  inline bool
400
  IsArrayBuffer() const
401
0
  {
402
0
    return mType == eArrayBuffer;
403
0
  }
404
405
  inline ArrayBuffer&
406
  GetAsArrayBuffer()
407
0
  {
408
0
    MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
409
0
    return mValue.mArrayBuffer.Value();
410
0
  }
411
412
  inline ArrayBuffer const &
413
  GetAsArrayBuffer() const
414
0
  {
415
0
    MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
416
0
    return mValue.mArrayBuffer.Value();
417
0
  }
418
419
  ArrayBufferView&
420
  RawSetAsArrayBufferView();
421
422
  ArrayBufferView&
423
  SetAsArrayBufferView();
424
425
  bool
426
  TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
427
428
  inline bool
429
  IsArrayBufferView() const
430
0
  {
431
0
    return mType == eArrayBufferView;
432
0
  }
433
434
  inline ArrayBufferView&
435
  GetAsArrayBufferView()
436
0
  {
437
0
    MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
438
0
    return mValue.mArrayBufferView.Value();
439
0
  }
440
441
  inline ArrayBufferView const &
442
  GetAsArrayBufferView() const
443
0
  {
444
0
    MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
445
0
    return mValue.mArrayBufferView.Value();
446
0
  }
447
448
  void
449
  Uninit();
450
451
  bool
452
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
453
454
  void
455
  TraceUnion(JSTracer* trc);
456
457
private:
458
  void
459
  DestroyString();
460
461
  void
462
  DestroyArrayBuffer();
463
464
  void
465
  DestroyArrayBufferView();
466
};
467
468
469
namespace FontFace_Binding {
470
471
  typedef mozilla::dom::FontFace NativeType;
472
473
  bool
474
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
475
476
  const JSClass*
477
  GetJSClass();
478
479
  bool
480
  Wrap(JSContext* aCx, mozilla::dom::FontFace* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
481
482
  template <class T>
483
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
484
0
  {
485
0
    JS::Rooted<JSObject*> reflector(aCx);
486
0
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
487
0
  }
488
489
  // We declare this as an array so that retrieving a pointer to this
490
  // binding's property hooks only requires compile/link-time resolvable
491
  // address arithmetic.  Declaring it as a pointer instead would require
492
  // doing a run-time load to fetch a pointer to this binding's property
493
  // hooks.  And then structures which embedded a pointer to this structure
494
  // would require a run-time load for proper initialization, which would
495
  // then induce static constructors.  Lots of static constructors.
496
  extern const NativePropertyHooks sNativePropertyHooks[];
497
498
  void
499
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
500
501
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
502
0
  {
503
0
    /* Get the interface prototype object for this class.  This will create the
504
0
       object as needed. */
505
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::FontFace,
506
0
                                       &CreateInterfaceObjects,
507
0
                                       /* aDefineOnGlobal = */ true);
508
0
509
0
  }
510
511
  inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
512
0
  {
513
0
    /* Get the interface object for this class.  This will create the object as
514
0
       needed. */
515
0
516
0
    return GetPerInterfaceObjectHandle(aCx, constructors::id::FontFace,
517
0
                                       &CreateInterfaceObjects,
518
0
                                       aDefineOnGlobal);
519
0
  }
520
521
  JSObject*
522
  GetConstructorObject(JSContext* aCx);
523
524
} // namespace FontFace_Binding
525
526
527
528
} // namespace dom
529
} // namespace mozilla
530
531
#endif // mozilla_dom_FontFaceBinding_h