Coverage Report

Created: 2018-09-25 14:53

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