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