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