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