Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/GeometryUtilsBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM GeometryUtils.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_GeometryUtilsBinding_h
4
#define mozilla_dom_GeometryUtilsBinding_h
5
6
#include "GeckoProfiler.h"
7
#include "js/RootingAPI.h"
8
#include "jspubtd.h"
9
#include "mozilla/ErrorResult.h"
10
#include "mozilla/dom/BindingDeclarations.h"
11
#include "mozilla/dom/FakeString.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/UnionMember.h"
14
15
class nsIDocument;
16
17
namespace mozilla {
18
namespace dom {
19
20
struct BoxQuadOptionsAtoms;
21
struct ConvertCoordinateOptionsAtoms;
22
class Element;
23
struct NativePropertyHooks;
24
class OwningTextOrElementOrDocument;
25
class ProtoAndIfaceCache;
26
class Text;
27
class TextOrElementOrDocument;
28
29
} // namespace dom
30
} // namespace mozilla
31
32
namespace mozilla {
33
namespace dom {
34
35
enum class CSSBoxType : uint8_t {
36
  Margin,
37
  Border,
38
  Padding,
39
  Content,
40
  EndGuard_
41
};
42
43
namespace CSSBoxTypeValues {
44
extern const EnumEntry strings[5];
45
} // namespace CSSBoxTypeValues
46
47
bool
48
ToJSValue(JSContext* aCx, CSSBoxType aArgument, JS::MutableHandle<JS::Value> aValue);
49
50
51
void
52
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningTextOrElementOrDocument& aUnion, const char* aName, uint32_t aFlags = 0);
53
54
55
void
56
ImplCycleCollectionUnlink(OwningTextOrElementOrDocument& aUnion);
57
58
59
struct ConvertCoordinateOptions : public DictionaryBase
60
{
61
  MOZ_INIT_OUTSIDE_CTOR CSSBoxType mFromBox;
62
  MOZ_INIT_OUTSIDE_CTOR CSSBoxType mToBox;
63
64
  ConvertCoordinateOptions();
65
66
  explicit inline ConvertCoordinateOptions(const FastDictionaryInitializer& )
67
0
  {
68
0
    // Do nothing here; this is used by our "Fast" subclass
69
0
  }
70
71
  explicit inline ConvertCoordinateOptions(const ConvertCoordinateOptions& aOther)
72
0
  {
73
0
    *this = aOther;
74
0
  }
75
76
  bool
77
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
78
79
  bool
80
  Init(const nsAString& aJSON);
81
82
  bool
83
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
84
85
  bool
86
  ToJSON(nsAString& aJSON) const;
87
88
  void
89
  TraceDictionary(JSTracer* trc);
90
91
  ConvertCoordinateOptions&
92
  operator=(const ConvertCoordinateOptions& aOther);
93
94
private:
95
  static bool
96
  InitIds(JSContext* cx, ConvertCoordinateOptionsAtoms* atomsCache);
97
};
98
99
namespace binding_detail {
100
struct FastConvertCoordinateOptions : public ConvertCoordinateOptions
101
{
102
  inline FastConvertCoordinateOptions()
103
    : ConvertCoordinateOptions(FastDictionaryInitializer())
104
0
  {
105
0
    // Doesn't matter what int we pass to the parent constructor
106
0
  }
107
};
108
} // namespace binding_detail
109
110
111
class TextOrElementOrDocument
112
{
113
  friend class TextOrElementOrDocumentArgument;
114
  enum Type
115
  {
116
    eUninitialized,
117
    eText,
118
    eElement,
119
    eDocument
120
  };
121
122
  union Value
123
  {
124
    UnionMember<NonNull<mozilla::dom::Text> > mText;
125
    UnionMember<NonNull<mozilla::dom::Element> > mElement;
126
    UnionMember<NonNull<nsIDocument> > mDocument;
127
128
  };
129
130
  Type mType;
131
  Value mValue;
132
133
  TextOrElementOrDocument(const TextOrElementOrDocument&) = delete;
134
  TextOrElementOrDocument& operator=(const TextOrElementOrDocument&) = delete;
135
public:
136
  explicit inline TextOrElementOrDocument()
137
    : mType(eUninitialized)
138
0
  {
139
0
  }
140
141
  inline ~TextOrElementOrDocument()
142
0
  {
143
0
    Uninit();
144
0
  }
145
146
  inline NonNull<mozilla::dom::Text>&
147
  RawSetAsText()
148
0
  {
149
0
    if (mType == eText) {
150
0
      return mValue.mText.Value();
151
0
    }
152
0
    MOZ_ASSERT(mType == eUninitialized);
153
0
    mType = eText;
154
0
    return mValue.mText.SetValue();
155
0
  }
156
157
  inline NonNull<mozilla::dom::Text>&
158
  SetAsText()
159
0
  {
160
0
    if (mType == eText) {
161
0
      return mValue.mText.Value();
162
0
    }
163
0
    Uninit();
164
0
    mType = eText;
165
0
    return mValue.mText.SetValue();
166
0
  }
167
168
  inline bool
169
  IsText() const
170
0
  {
171
0
    return mType == eText;
172
0
  }
173
174
  inline NonNull<mozilla::dom::Text>&
175
  GetAsText()
176
0
  {
177
0
    MOZ_ASSERT(IsText(), "Wrong type!");
178
0
    return mValue.mText.Value();
179
0
  }
180
181
  inline mozilla::dom::Text&
182
  GetAsText() const
183
0
  {
184
0
    MOZ_ASSERT(IsText(), "Wrong type!");
185
0
    return mValue.mText.Value();
186
0
  }
187
188
  inline NonNull<mozilla::dom::Element>&
189
  RawSetAsElement()
190
0
  {
191
0
    if (mType == eElement) {
192
0
      return mValue.mElement.Value();
193
0
    }
194
0
    MOZ_ASSERT(mType == eUninitialized);
195
0
    mType = eElement;
196
0
    return mValue.mElement.SetValue();
197
0
  }
198
199
  inline NonNull<mozilla::dom::Element>&
200
  SetAsElement()
201
0
  {
202
0
    if (mType == eElement) {
203
0
      return mValue.mElement.Value();
204
0
    }
205
0
    Uninit();
206
0
    mType = eElement;
207
0
    return mValue.mElement.SetValue();
208
0
  }
209
210
  inline bool
211
  IsElement() const
212
0
  {
213
0
    return mType == eElement;
214
0
  }
215
216
  inline NonNull<mozilla::dom::Element>&
217
  GetAsElement()
218
0
  {
219
0
    MOZ_ASSERT(IsElement(), "Wrong type!");
220
0
    return mValue.mElement.Value();
221
0
  }
222
223
  inline mozilla::dom::Element&
224
  GetAsElement() const
225
0
  {
226
0
    MOZ_ASSERT(IsElement(), "Wrong type!");
227
0
    return mValue.mElement.Value();
228
0
  }
229
230
  inline NonNull<nsIDocument>&
231
  RawSetAsDocument()
232
0
  {
233
0
    if (mType == eDocument) {
234
0
      return mValue.mDocument.Value();
235
0
    }
236
0
    MOZ_ASSERT(mType == eUninitialized);
237
0
    mType = eDocument;
238
0
    return mValue.mDocument.SetValue();
239
0
  }
240
241
  inline NonNull<nsIDocument>&
242
  SetAsDocument()
243
0
  {
244
0
    if (mType == eDocument) {
245
0
      return mValue.mDocument.Value();
246
0
    }
247
0
    Uninit();
248
0
    mType = eDocument;
249
0
    return mValue.mDocument.SetValue();
250
0
  }
251
252
  inline bool
253
  IsDocument() const
254
0
  {
255
0
    return mType == eDocument;
256
0
  }
257
258
  inline NonNull<nsIDocument>&
259
  GetAsDocument()
260
0
  {
261
0
    MOZ_ASSERT(IsDocument(), "Wrong type!");
262
0
    return mValue.mDocument.Value();
263
0
  }
264
265
  inline nsIDocument&
266
  GetAsDocument() const
267
0
  {
268
0
    MOZ_ASSERT(IsDocument(), "Wrong type!");
269
0
    return mValue.mDocument.Value();
270
0
  }
271
272
  inline void
273
  Uninit()
274
  {
275
    switch (mType) {
276
      case eUninitialized: {
277
        break;
278
      }
279
      case eText: {
280
        DestroyText();
281
        break;
282
      }
283
      case eElement: {
284
        DestroyElement();
285
        break;
286
      }
287
      case eDocument: {
288
        DestroyDocument();
289
        break;
290
      }
291
    }
292
  }
293
294
  bool
295
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
296
297
private:
298
  inline void
299
  DestroyText()
300
0
  {
301
0
    MOZ_ASSERT(IsText(), "Wrong type!");
302
0
    mValue.mText.Destroy();
303
0
    mType = eUninitialized;
304
0
  }
305
306
  inline void
307
  DestroyElement()
308
0
  {
309
0
    MOZ_ASSERT(IsElement(), "Wrong type!");
310
0
    mValue.mElement.Destroy();
311
0
    mType = eUninitialized;
312
0
  }
313
314
  inline void
315
  DestroyDocument()
316
0
  {
317
0
    MOZ_ASSERT(IsDocument(), "Wrong type!");
318
0
    mValue.mDocument.Destroy();
319
0
    mType = eUninitialized;
320
0
  }
321
};
322
323
324
class OwningTextOrElementOrDocument : public AllOwningUnionBase
325
{
326
  friend void ImplCycleCollectionUnlink(OwningTextOrElementOrDocument& aUnion);
327
  enum Type
328
  {
329
    eUninitialized,
330
    eText,
331
    eElement,
332
    eDocument
333
  };
334
335
  union Value
336
  {
337
    UnionMember<OwningNonNull<mozilla::dom::Text> > mText;
338
    UnionMember<OwningNonNull<mozilla::dom::Element> > mElement;
339
    UnionMember<OwningNonNull<nsIDocument> > mDocument;
340
341
  };
342
343
  Type mType;
344
  Value mValue;
345
346
public:
347
  explicit inline OwningTextOrElementOrDocument()
348
    : mType(eUninitialized)
349
0
  {
350
0
  }
351
352
  explicit inline OwningTextOrElementOrDocument(const OwningTextOrElementOrDocument& aOther)
353
    : mType(eUninitialized)
354
0
  {
355
0
    *this = aOther;
356
0
  }
357
358
  inline ~OwningTextOrElementOrDocument()
359
0
  {
360
0
    Uninit();
361
0
  }
362
363
  OwningNonNull<mozilla::dom::Text>&
364
  RawSetAsText();
365
366
  OwningNonNull<mozilla::dom::Text>&
367
  SetAsText();
368
369
  bool
370
  TrySetToText(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
371
372
  inline bool
373
  IsText() const
374
0
  {
375
0
    return mType == eText;
376
0
  }
377
378
  inline OwningNonNull<mozilla::dom::Text>&
379
  GetAsText()
380
0
  {
381
0
    MOZ_ASSERT(IsText(), "Wrong type!");
382
0
    return mValue.mText.Value();
383
0
  }
384
385
  inline OwningNonNull<mozilla::dom::Text> const &
386
  GetAsText() const
387
0
  {
388
0
    MOZ_ASSERT(IsText(), "Wrong type!");
389
0
    return mValue.mText.Value();
390
0
  }
391
392
  OwningNonNull<mozilla::dom::Element>&
393
  RawSetAsElement();
394
395
  OwningNonNull<mozilla::dom::Element>&
396
  SetAsElement();
397
398
  bool
399
  TrySetToElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
400
401
  inline bool
402
  IsElement() const
403
0
  {
404
0
    return mType == eElement;
405
0
  }
406
407
  inline OwningNonNull<mozilla::dom::Element>&
408
  GetAsElement()
409
0
  {
410
0
    MOZ_ASSERT(IsElement(), "Wrong type!");
411
0
    return mValue.mElement.Value();
412
0
  }
413
414
  inline OwningNonNull<mozilla::dom::Element> const &
415
  GetAsElement() const
416
0
  {
417
0
    MOZ_ASSERT(IsElement(), "Wrong type!");
418
0
    return mValue.mElement.Value();
419
0
  }
420
421
  OwningNonNull<nsIDocument>&
422
  RawSetAsDocument();
423
424
  OwningNonNull<nsIDocument>&
425
  SetAsDocument();
426
427
  bool
428
  TrySetToDocument(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
429
430
  inline bool
431
  IsDocument() const
432
0
  {
433
0
    return mType == eDocument;
434
0
  }
435
436
  inline OwningNonNull<nsIDocument>&
437
  GetAsDocument()
438
0
  {
439
0
    MOZ_ASSERT(IsDocument(), "Wrong type!");
440
0
    return mValue.mDocument.Value();
441
0
  }
442
443
  inline OwningNonNull<nsIDocument> const &
444
  GetAsDocument() const
445
0
  {
446
0
    MOZ_ASSERT(IsDocument(), "Wrong type!");
447
0
    return mValue.mDocument.Value();
448
0
  }
449
450
  void
451
  Uninit();
452
453
  bool
454
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
455
456
  void
457
  TraceUnion(JSTracer* trc);
458
459
  OwningTextOrElementOrDocument&
460
  operator=(const OwningTextOrElementOrDocument& aOther);
461
462
private:
463
  void
464
  DestroyText();
465
466
  void
467
  DestroyElement();
468
469
  void
470
  DestroyDocument();
471
};
472
473
474
struct BoxQuadOptions : public DictionaryBase
475
{
476
  MOZ_INIT_OUTSIDE_CTOR CSSBoxType mBox;
477
  MOZ_INIT_OUTSIDE_CTOR Optional<OwningTextOrElementOrDocument> mRelativeTo;
478
479
  BoxQuadOptions();
480
481
  explicit inline BoxQuadOptions(const FastDictionaryInitializer& )
482
0
  {
483
0
    // Do nothing here; this is used by our "Fast" subclass
484
0
  }
485
486
  explicit inline BoxQuadOptions(const BoxQuadOptions& aOther)
487
0
  {
488
0
    *this = aOther;
489
0
  }
490
491
  bool
492
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
493
494
  bool
495
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
496
497
  void
498
  TraceDictionary(JSTracer* trc);
499
500
  inline void
501
  TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
502
0
  {
503
0
    ImplCycleCollectionTraverse(aCallback, mRelativeTo, "mRelativeTo", aFlags);
504
0
  }
505
506
  inline void
507
  UnlinkForCC()
508
0
  {
509
0
    ImplCycleCollectionUnlink(mRelativeTo);
510
0
  }
511
512
  BoxQuadOptions&
513
  operator=(const BoxQuadOptions& aOther);
514
515
private:
516
  static bool
517
  InitIds(JSContext* cx, BoxQuadOptionsAtoms* atomsCache);
518
};
519
520
namespace binding_detail {
521
struct FastBoxQuadOptions : public BoxQuadOptions
522
{
523
  inline FastBoxQuadOptions()
524
    : BoxQuadOptions(FastDictionaryInitializer())
525
0
  {
526
0
    // Doesn't matter what int we pass to the parent constructor
527
0
  }
528
};
529
} // namespace binding_detail
530
531
532
} // namespace dom
533
} // namespace mozilla
534
535
#endif // mozilla_dom_GeometryUtilsBinding_h