/work/obj-fuzz/dist/include/mozilla/dom/WindowBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Window.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_WindowBinding_h |
4 | | #define mozilla_dom_WindowBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "ImageBitmapBinding.h" |
8 | | #include "WindowBinding.h" |
9 | | #include "jsapi.h" |
10 | | #include "mozilla/ErrorResult.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/CallbackFunction.h" |
13 | | #include "mozilla/dom/FakeString.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrototypeList.h" |
16 | | #include "mozilla/dom/ToJSValue.h" |
17 | | #include "mozilla/dom/UnionMember.h" |
18 | | |
19 | | class nsGlobalWindowInner; |
20 | | struct nsGlobalWindowInnerAtoms; |
21 | | class nsPIDOMWindowOuter; |
22 | | |
23 | | namespace mozilla { |
24 | | namespace dom { |
25 | | |
26 | | class External; |
27 | | class FrameRequestCallback; |
28 | | class IdleDeadline; |
29 | | class IdleRequestCallback; |
30 | | struct IdleRequestOptionsAtoms; |
31 | | struct NativePropertyHooks; |
32 | | class OwningExternalOrWindowProxy; |
33 | | class PromiseDocumentFlushedCallback; |
34 | | class ProtoAndIfaceCache; |
35 | | struct ScrollOptionsAtoms; |
36 | | struct ScrollToOptionsAtoms; |
37 | | |
38 | | } // namespace dom |
39 | | } // namespace mozilla |
40 | | |
41 | | namespace mozilla { |
42 | | namespace dom { |
43 | | |
44 | | enum class ScrollBehavior : uint8_t { |
45 | | Auto, |
46 | | Instant, |
47 | | Smooth, |
48 | | EndGuard_ |
49 | | }; |
50 | | |
51 | | namespace ScrollBehaviorValues { |
52 | | extern const EnumEntry strings[4]; |
53 | | } // namespace ScrollBehaviorValues |
54 | | |
55 | | bool |
56 | | ToJSValue(JSContext* aCx, ScrollBehavior aArgument, JS::MutableHandle<JS::Value> aValue); |
57 | | |
58 | | |
59 | | void |
60 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningExternalOrWindowProxy& aUnion, const char* aName, uint32_t aFlags = 0); |
61 | | |
62 | | |
63 | | void |
64 | | ImplCycleCollectionUnlink(OwningExternalOrWindowProxy& aUnion); |
65 | | |
66 | | |
67 | | class ExternalOrWindowProxy |
68 | | { |
69 | | friend class ExternalOrWindowProxyArgument; |
70 | | enum Type |
71 | | { |
72 | | eUninitialized, |
73 | | eExternal, |
74 | | eWindowProxy |
75 | | }; |
76 | | |
77 | | union Value |
78 | | { |
79 | | UnionMember<NonNull<mozilla::dom::External> > mExternal; |
80 | | UnionMember<nsPIDOMWindowOuter* > mWindowProxy; |
81 | | |
82 | | }; |
83 | | |
84 | | Type mType; |
85 | | Value mValue; |
86 | | |
87 | | ExternalOrWindowProxy(const ExternalOrWindowProxy&) = delete; |
88 | | ExternalOrWindowProxy& operator=(const ExternalOrWindowProxy&) = delete; |
89 | | public: |
90 | | explicit inline ExternalOrWindowProxy() |
91 | | : mType(eUninitialized) |
92 | 0 | { |
93 | 0 | } |
94 | | |
95 | | inline ~ExternalOrWindowProxy() |
96 | 0 | { |
97 | 0 | Uninit(); |
98 | 0 | } |
99 | | |
100 | | inline NonNull<mozilla::dom::External>& |
101 | | RawSetAsExternal() |
102 | 0 | { |
103 | 0 | if (mType == eExternal) { |
104 | 0 | return mValue.mExternal.Value(); |
105 | 0 | } |
106 | 0 | MOZ_ASSERT(mType == eUninitialized); |
107 | 0 | mType = eExternal; |
108 | 0 | return mValue.mExternal.SetValue(); |
109 | 0 | } |
110 | | |
111 | | inline NonNull<mozilla::dom::External>& |
112 | | SetAsExternal() |
113 | 0 | { |
114 | 0 | if (mType == eExternal) { |
115 | 0 | return mValue.mExternal.Value(); |
116 | 0 | } |
117 | 0 | Uninit(); |
118 | 0 | mType = eExternal; |
119 | 0 | return mValue.mExternal.SetValue(); |
120 | 0 | } |
121 | | |
122 | | inline bool |
123 | | IsExternal() const |
124 | 0 | { |
125 | 0 | return mType == eExternal; |
126 | 0 | } |
127 | | |
128 | | inline NonNull<mozilla::dom::External>& |
129 | | GetAsExternal() |
130 | 0 | { |
131 | 0 | MOZ_ASSERT(IsExternal(), "Wrong type!"); |
132 | 0 | return mValue.mExternal.Value(); |
133 | 0 | } |
134 | | |
135 | | inline mozilla::dom::External& |
136 | | GetAsExternal() const |
137 | 0 | { |
138 | 0 | MOZ_ASSERT(IsExternal(), "Wrong type!"); |
139 | 0 | return mValue.mExternal.Value(); |
140 | 0 | } |
141 | | |
142 | | inline nsPIDOMWindowOuter*& |
143 | | RawSetAsWindowProxy() |
144 | 0 | { |
145 | 0 | if (mType == eWindowProxy) { |
146 | 0 | return mValue.mWindowProxy.Value(); |
147 | 0 | } |
148 | 0 | MOZ_ASSERT(mType == eUninitialized); |
149 | 0 | mType = eWindowProxy; |
150 | 0 | return mValue.mWindowProxy.SetValue(); |
151 | 0 | } |
152 | | |
153 | | inline nsPIDOMWindowOuter*& |
154 | | SetAsWindowProxy() |
155 | 0 | { |
156 | 0 | if (mType == eWindowProxy) { |
157 | 0 | return mValue.mWindowProxy.Value(); |
158 | 0 | } |
159 | 0 | Uninit(); |
160 | 0 | mType = eWindowProxy; |
161 | 0 | return mValue.mWindowProxy.SetValue(); |
162 | 0 | } |
163 | | |
164 | | inline bool |
165 | | IsWindowProxy() const |
166 | 0 | { |
167 | 0 | return mType == eWindowProxy; |
168 | 0 | } |
169 | | |
170 | | inline nsPIDOMWindowOuter*& |
171 | | GetAsWindowProxy() |
172 | 0 | { |
173 | 0 | MOZ_ASSERT(IsWindowProxy(), "Wrong type!"); |
174 | 0 | return mValue.mWindowProxy.Value(); |
175 | 0 | } |
176 | | |
177 | | inline nsPIDOMWindowOuter* |
178 | | GetAsWindowProxy() const |
179 | 0 | { |
180 | 0 | MOZ_ASSERT(IsWindowProxy(), "Wrong type!"); |
181 | 0 | return mValue.mWindowProxy.Value(); |
182 | 0 | } |
183 | | |
184 | | inline void |
185 | | Uninit() |
186 | 0 | { |
187 | 0 | switch (mType) { |
188 | 0 | case eUninitialized: { |
189 | 0 | break; |
190 | 0 | } |
191 | 0 | case eExternal: { |
192 | 0 | DestroyExternal(); |
193 | 0 | break; |
194 | 0 | } |
195 | 0 | case eWindowProxy: { |
196 | 0 | DestroyWindowProxy(); |
197 | 0 | break; |
198 | 0 | } |
199 | 0 | } |
200 | 0 | } |
201 | | |
202 | | bool |
203 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
204 | | |
205 | | private: |
206 | | inline void |
207 | | DestroyExternal() |
208 | 0 | { |
209 | 0 | MOZ_ASSERT(IsExternal(), "Wrong type!"); |
210 | 0 | mValue.mExternal.Destroy(); |
211 | 0 | mType = eUninitialized; |
212 | 0 | } |
213 | | |
214 | | inline void |
215 | | DestroyWindowProxy() |
216 | 0 | { |
217 | 0 | MOZ_ASSERT(IsWindowProxy(), "Wrong type!"); |
218 | 0 | mValue.mWindowProxy.Destroy(); |
219 | 0 | mType = eUninitialized; |
220 | 0 | } |
221 | | }; |
222 | | |
223 | | |
224 | | class OwningExternalOrWindowProxy : public AllOwningUnionBase |
225 | | { |
226 | | friend void ImplCycleCollectionUnlink(OwningExternalOrWindowProxy& aUnion); |
227 | | enum Type |
228 | | { |
229 | | eUninitialized, |
230 | | eExternal, |
231 | | eWindowProxy |
232 | | }; |
233 | | |
234 | | union Value |
235 | | { |
236 | | UnionMember<OwningNonNull<mozilla::dom::External> > mExternal; |
237 | | UnionMember<RefPtr<nsPIDOMWindowOuter> > mWindowProxy; |
238 | | |
239 | | }; |
240 | | |
241 | | Type mType; |
242 | | Value mValue; |
243 | | |
244 | | public: |
245 | | explicit inline OwningExternalOrWindowProxy() |
246 | | : mType(eUninitialized) |
247 | 0 | { |
248 | 0 | } |
249 | | |
250 | | explicit inline OwningExternalOrWindowProxy(const OwningExternalOrWindowProxy& aOther) |
251 | | : mType(eUninitialized) |
252 | 0 | { |
253 | 0 | *this = aOther; |
254 | 0 | } |
255 | | |
256 | | inline ~OwningExternalOrWindowProxy() |
257 | 0 | { |
258 | 0 | Uninit(); |
259 | 0 | } |
260 | | |
261 | | OwningNonNull<mozilla::dom::External>& |
262 | | RawSetAsExternal(); |
263 | | |
264 | | OwningNonNull<mozilla::dom::External>& |
265 | | SetAsExternal(); |
266 | | |
267 | | bool |
268 | | TrySetToExternal(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
269 | | |
270 | | inline bool |
271 | | IsExternal() const |
272 | 0 | { |
273 | 0 | return mType == eExternal; |
274 | 0 | } |
275 | | |
276 | | inline OwningNonNull<mozilla::dom::External>& |
277 | | GetAsExternal() |
278 | 0 | { |
279 | 0 | MOZ_ASSERT(IsExternal(), "Wrong type!"); |
280 | 0 | return mValue.mExternal.Value(); |
281 | 0 | } |
282 | | |
283 | | inline OwningNonNull<mozilla::dom::External> const & |
284 | | GetAsExternal() const |
285 | 0 | { |
286 | 0 | MOZ_ASSERT(IsExternal(), "Wrong type!"); |
287 | 0 | return mValue.mExternal.Value(); |
288 | 0 | } |
289 | | |
290 | | RefPtr<nsPIDOMWindowOuter>& |
291 | | RawSetAsWindowProxy(); |
292 | | |
293 | | RefPtr<nsPIDOMWindowOuter>& |
294 | | SetAsWindowProxy(); |
295 | | |
296 | | bool |
297 | | TrySetToWindowProxy(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
298 | | |
299 | | inline bool |
300 | | IsWindowProxy() const |
301 | 0 | { |
302 | 0 | return mType == eWindowProxy; |
303 | 0 | } |
304 | | |
305 | | inline RefPtr<nsPIDOMWindowOuter>& |
306 | | GetAsWindowProxy() |
307 | 0 | { |
308 | 0 | MOZ_ASSERT(IsWindowProxy(), "Wrong type!"); |
309 | 0 | return mValue.mWindowProxy.Value(); |
310 | 0 | } |
311 | | |
312 | | inline RefPtr<nsPIDOMWindowOuter> const & |
313 | | GetAsWindowProxy() const |
314 | 0 | { |
315 | 0 | MOZ_ASSERT(IsWindowProxy(), "Wrong type!"); |
316 | 0 | return mValue.mWindowProxy.Value(); |
317 | 0 | } |
318 | | |
319 | | void |
320 | | Uninit(); |
321 | | |
322 | | bool |
323 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
324 | | |
325 | | void |
326 | | TraceUnion(JSTracer* trc); |
327 | | |
328 | | OwningExternalOrWindowProxy& |
329 | | operator=(const OwningExternalOrWindowProxy& aOther); |
330 | | |
331 | | private: |
332 | | void |
333 | | DestroyExternal(); |
334 | | |
335 | | void |
336 | | DestroyWindowProxy(); |
337 | | }; |
338 | | |
339 | | |
340 | | struct IdleRequestOptions : public DictionaryBase |
341 | | { |
342 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mTimeout; |
343 | | |
344 | | IdleRequestOptions(); |
345 | | |
346 | | explicit inline IdleRequestOptions(const FastDictionaryInitializer& ) |
347 | 0 | { |
348 | 0 | // Do nothing here; this is used by our "Fast" subclass |
349 | 0 | } |
350 | | |
351 | | explicit inline IdleRequestOptions(const IdleRequestOptions& aOther) |
352 | 0 | { |
353 | 0 | *this = aOther; |
354 | 0 | } |
355 | | |
356 | | bool |
357 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
358 | | |
359 | | bool |
360 | | Init(const nsAString& aJSON); |
361 | | |
362 | | bool |
363 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
364 | | |
365 | | bool |
366 | | ToJSON(nsAString& aJSON) const; |
367 | | |
368 | | void |
369 | | TraceDictionary(JSTracer* trc); |
370 | | |
371 | | IdleRequestOptions& |
372 | | operator=(const IdleRequestOptions& aOther); |
373 | | |
374 | | private: |
375 | | static bool |
376 | | InitIds(JSContext* cx, IdleRequestOptionsAtoms* atomsCache); |
377 | | }; |
378 | | |
379 | | namespace binding_detail { |
380 | | struct FastIdleRequestOptions : public IdleRequestOptions |
381 | | { |
382 | | inline FastIdleRequestOptions() |
383 | | : IdleRequestOptions(FastDictionaryInitializer()) |
384 | 0 | { |
385 | 0 | // Doesn't matter what int we pass to the parent constructor |
386 | 0 | } |
387 | | }; |
388 | | } // namespace binding_detail |
389 | | |
390 | | |
391 | | struct ScrollOptions : public DictionaryBase |
392 | | { |
393 | | MOZ_INIT_OUTSIDE_CTOR ScrollBehavior mBehavior; |
394 | | |
395 | | ScrollOptions(); |
396 | | |
397 | | explicit inline ScrollOptions(const FastDictionaryInitializer& ) |
398 | 0 | { |
399 | 0 | // Do nothing here; this is used by our "Fast" subclass |
400 | 0 | } |
401 | | |
402 | | explicit inline ScrollOptions(const ScrollOptions& aOther) |
403 | 0 | { |
404 | 0 | *this = aOther; |
405 | 0 | } |
406 | | |
407 | | bool |
408 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
409 | | |
410 | | bool |
411 | | Init(const nsAString& aJSON); |
412 | | |
413 | | bool |
414 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
415 | | |
416 | | bool |
417 | | ToJSON(nsAString& aJSON) const; |
418 | | |
419 | | void |
420 | | TraceDictionary(JSTracer* trc); |
421 | | |
422 | | ScrollOptions& |
423 | | operator=(const ScrollOptions& aOther); |
424 | | |
425 | | private: |
426 | | static bool |
427 | | InitIds(JSContext* cx, ScrollOptionsAtoms* atomsCache); |
428 | | }; |
429 | | |
430 | | namespace binding_detail { |
431 | | struct FastScrollOptions : public ScrollOptions |
432 | | { |
433 | | inline FastScrollOptions() |
434 | | : ScrollOptions(FastDictionaryInitializer()) |
435 | 0 | { |
436 | 0 | // Doesn't matter what int we pass to the parent constructor |
437 | 0 | } |
438 | | }; |
439 | | } // namespace binding_detail |
440 | | |
441 | | |
442 | | struct ScrollToOptions : public ScrollOptions |
443 | | { |
444 | | MOZ_INIT_OUTSIDE_CTOR Optional<double> mLeft; |
445 | | MOZ_INIT_OUTSIDE_CTOR Optional<double> mTop; |
446 | | |
447 | | ScrollToOptions(); |
448 | | |
449 | | explicit inline ScrollToOptions(const FastDictionaryInitializer& ) |
450 | | : ScrollOptions(FastDictionaryInitializer()) |
451 | 0 | { |
452 | 0 | // Do nothing here; this is used by our "Fast" subclass |
453 | 0 | } |
454 | | |
455 | | explicit inline ScrollToOptions(const ScrollToOptions& aOther) |
456 | 0 | { |
457 | 0 | *this = aOther; |
458 | 0 | } |
459 | | |
460 | | bool |
461 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
462 | | |
463 | | bool |
464 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
465 | | |
466 | | void |
467 | | TraceDictionary(JSTracer* trc); |
468 | | |
469 | | ScrollToOptions& |
470 | | operator=(const ScrollToOptions& aOther); |
471 | | |
472 | | private: |
473 | | static bool |
474 | | InitIds(JSContext* cx, ScrollToOptionsAtoms* atomsCache); |
475 | | }; |
476 | | |
477 | | namespace binding_detail { |
478 | | struct FastScrollToOptions : public ScrollToOptions |
479 | | { |
480 | | inline FastScrollToOptions() |
481 | | : ScrollToOptions(FastDictionaryInitializer()) |
482 | 0 | { |
483 | 0 | // Doesn't matter what int we pass to the parent constructor |
484 | 0 | } |
485 | | }; |
486 | | } // namespace binding_detail |
487 | | |
488 | | |
489 | | class FrameRequestCallback : public CallbackFunction |
490 | | { |
491 | | public: |
492 | | explicit inline FrameRequestCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
493 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
494 | 0 | { |
495 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
496 | 0 | } |
497 | | |
498 | | explicit inline FrameRequestCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
499 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
500 | 0 | { |
501 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
502 | 0 | } |
503 | | |
504 | | explicit inline FrameRequestCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
505 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
506 | 0 | { |
507 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
508 | 0 | } |
509 | | |
510 | | explicit inline FrameRequestCallback(CallbackFunction* aOther) |
511 | | : CallbackFunction(aOther) |
512 | 0 | { |
513 | 0 | } |
514 | | |
515 | | template <typename T> |
516 | | inline void |
517 | | Call(const T& thisVal, double time, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
518 | | { |
519 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
520 | | if (!aExecutionReason) { |
521 | | aExecutionReason = "FrameRequestCallback"; |
522 | | } |
523 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
524 | | if (!s.GetContext()) { |
525 | | MOZ_ASSERT(aRv.Failed()); |
526 | | return; |
527 | | } |
528 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
529 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
530 | | aRv.Throw(NS_ERROR_FAILURE); |
531 | | return; |
532 | | } |
533 | | return Call(s.GetContext(), thisValJS, time, aRv); |
534 | | } |
535 | | |
536 | | inline void |
537 | | Call(double time, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
538 | 0 | { |
539 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
540 | 0 | if (!aExecutionReason) { |
541 | 0 | aExecutionReason = "FrameRequestCallback"; |
542 | 0 | } |
543 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
544 | 0 | if (!s.GetContext()) { |
545 | 0 | MOZ_ASSERT(aRv.Failed()); |
546 | 0 | return; |
547 | 0 | } |
548 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, time, aRv); |
549 | 0 | } |
550 | | |
551 | | template <typename T> |
552 | | inline void |
553 | | Call(const T& thisVal, double time, const char* aExecutionReason = nullptr) |
554 | | { |
555 | | return Call(thisVal, time, IgnoreErrors(), aExecutionReason); |
556 | | } |
557 | | |
558 | | inline void |
559 | | Call(double time, const char* aExecutionReason = nullptr) |
560 | 0 | { |
561 | 0 | return Call(time, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
562 | 0 | } |
563 | | |
564 | | inline bool |
565 | | operator==(const FrameRequestCallback& aOther) const |
566 | 0 | { |
567 | 0 | return CallbackFunction::operator==(aOther); |
568 | 0 | } |
569 | | |
570 | | private: |
571 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, double time, ErrorResult& aRv); |
572 | | }; |
573 | | |
574 | | |
575 | | class PromiseDocumentFlushedCallback : public CallbackFunction |
576 | | { |
577 | | public: |
578 | | explicit inline PromiseDocumentFlushedCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
579 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
580 | 0 | { |
581 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
582 | 0 | } |
583 | | |
584 | | explicit inline PromiseDocumentFlushedCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
585 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
586 | 0 | { |
587 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
588 | 0 | } |
589 | | |
590 | | explicit inline PromiseDocumentFlushedCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
591 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
592 | 0 | { |
593 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
594 | 0 | } |
595 | | |
596 | | explicit inline PromiseDocumentFlushedCallback(CallbackFunction* aOther) |
597 | | : CallbackFunction(aOther) |
598 | 0 | { |
599 | 0 | } |
600 | | |
601 | | template <typename T> |
602 | | inline void |
603 | | Call(const T& thisVal, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
604 | | { |
605 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
606 | | if (!aExecutionReason) { |
607 | | aExecutionReason = "PromiseDocumentFlushedCallback"; |
608 | | } |
609 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
610 | | if (!s.GetContext()) { |
611 | | MOZ_ASSERT(aRv.Failed()); |
612 | | return; |
613 | | } |
614 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
615 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
616 | | aRv.Throw(NS_ERROR_FAILURE); |
617 | | return; |
618 | | } |
619 | | return Call(s.GetContext(), thisValJS, aRetVal, aRv); |
620 | | } |
621 | | |
622 | | inline void |
623 | | Call(JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
624 | 0 | { |
625 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
626 | 0 | if (!aExecutionReason) { |
627 | 0 | aExecutionReason = "PromiseDocumentFlushedCallback"; |
628 | 0 | } |
629 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
630 | 0 | if (!s.GetContext()) { |
631 | 0 | MOZ_ASSERT(aRv.Failed()); |
632 | 0 | return; |
633 | 0 | } |
634 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, aRetVal, aRv); |
635 | 0 | } |
636 | | |
637 | | template <typename T> |
638 | | inline void |
639 | | Call(const T& thisVal, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
640 | | { |
641 | | return Call(thisVal, aRetVal, IgnoreErrors(), aExecutionReason); |
642 | | } |
643 | | |
644 | | inline void |
645 | | Call(JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
646 | 0 | { |
647 | 0 | return Call(aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
648 | 0 | } |
649 | | |
650 | | inline bool |
651 | | operator==(const PromiseDocumentFlushedCallback& aOther) const |
652 | 0 | { |
653 | 0 | return CallbackFunction::operator==(aOther); |
654 | 0 | } |
655 | | |
656 | | private: |
657 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv); |
658 | | }; |
659 | | |
660 | | |
661 | | class IdleRequestCallback : public CallbackFunction |
662 | | { |
663 | | public: |
664 | | explicit inline IdleRequestCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
665 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
666 | 0 | { |
667 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
668 | 0 | } |
669 | | |
670 | | explicit inline IdleRequestCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
671 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
672 | 0 | { |
673 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
674 | 0 | } |
675 | | |
676 | | explicit inline IdleRequestCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
677 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
678 | 0 | { |
679 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
680 | 0 | } |
681 | | |
682 | | explicit inline IdleRequestCallback(CallbackFunction* aOther) |
683 | | : CallbackFunction(aOther) |
684 | 0 | { |
685 | 0 | } |
686 | | |
687 | | template <typename T> |
688 | | inline void |
689 | | Call(const T& thisVal, IdleDeadline& deadline, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
690 | | { |
691 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
692 | | if (!aExecutionReason) { |
693 | | aExecutionReason = "IdleRequestCallback"; |
694 | | } |
695 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
696 | | if (!s.GetContext()) { |
697 | | MOZ_ASSERT(aRv.Failed()); |
698 | | return; |
699 | | } |
700 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
701 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
702 | | aRv.Throw(NS_ERROR_FAILURE); |
703 | | return; |
704 | | } |
705 | | return Call(s.GetContext(), thisValJS, deadline, aRv); |
706 | | } |
707 | | |
708 | | inline void |
709 | | Call(IdleDeadline& deadline, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
710 | 0 | { |
711 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
712 | 0 | if (!aExecutionReason) { |
713 | 0 | aExecutionReason = "IdleRequestCallback"; |
714 | 0 | } |
715 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
716 | 0 | if (!s.GetContext()) { |
717 | 0 | MOZ_ASSERT(aRv.Failed()); |
718 | 0 | return; |
719 | 0 | } |
720 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, deadline, aRv); |
721 | 0 | } |
722 | | |
723 | | template <typename T> |
724 | | inline void |
725 | | Call(const T& thisVal, IdleDeadline& deadline, const char* aExecutionReason = nullptr) |
726 | | { |
727 | | return Call(thisVal, deadline, IgnoreErrors(), aExecutionReason); |
728 | | } |
729 | | |
730 | | inline void |
731 | | Call(IdleDeadline& deadline, const char* aExecutionReason = nullptr) |
732 | 0 | { |
733 | 0 | return Call(deadline, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
734 | 0 | } |
735 | | |
736 | | inline bool |
737 | | operator==(const IdleRequestCallback& aOther) const |
738 | 0 | { |
739 | 0 | return CallbackFunction::operator==(aOther); |
740 | 0 | } |
741 | | |
742 | | private: |
743 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, IdleDeadline& deadline, ErrorResult& aRv); |
744 | | }; |
745 | | |
746 | | |
747 | | namespace binding_detail { |
748 | | class FastFrameRequestCallback : public FrameRequestCallback |
749 | | { |
750 | | public: |
751 | | explicit inline FastFrameRequestCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
752 | | : FrameRequestCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
753 | 0 | { |
754 | 0 | } |
755 | | |
756 | | inline void |
757 | | Trace(JSTracer* aTracer) |
758 | 0 | { |
759 | 0 | FrameRequestCallback::Trace(aTracer); |
760 | 0 | } |
761 | | |
762 | | inline void |
763 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
764 | 0 | { |
765 | 0 | FrameRequestCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
766 | 0 | } |
767 | | }; |
768 | | } // namespace binding_detail |
769 | | |
770 | | |
771 | | namespace binding_detail { |
772 | | class FastPromiseDocumentFlushedCallback : public PromiseDocumentFlushedCallback |
773 | | { |
774 | | public: |
775 | | explicit inline FastPromiseDocumentFlushedCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
776 | | : PromiseDocumentFlushedCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
777 | 0 | { |
778 | 0 | } |
779 | | |
780 | | inline void |
781 | | Trace(JSTracer* aTracer) |
782 | 0 | { |
783 | 0 | PromiseDocumentFlushedCallback::Trace(aTracer); |
784 | 0 | } |
785 | | |
786 | | inline void |
787 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
788 | 0 | { |
789 | 0 | PromiseDocumentFlushedCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
790 | 0 | } |
791 | | }; |
792 | | } // namespace binding_detail |
793 | | |
794 | | |
795 | | namespace binding_detail { |
796 | | class FastIdleRequestCallback : public IdleRequestCallback |
797 | | { |
798 | | public: |
799 | | explicit inline FastIdleRequestCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
800 | | : IdleRequestCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
801 | 0 | { |
802 | 0 | } |
803 | | |
804 | | inline void |
805 | | Trace(JSTracer* aTracer) |
806 | 0 | { |
807 | 0 | IdleRequestCallback::Trace(aTracer); |
808 | 0 | } |
809 | | |
810 | | inline void |
811 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
812 | 0 | { |
813 | 0 | IdleRequestCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
814 | 0 | } |
815 | | }; |
816 | | } // namespace binding_detail |
817 | | |
818 | | |
819 | | namespace Window_Binding { |
820 | | |
821 | | typedef nsGlobalWindowInner NativeType; |
822 | | |
823 | | static const uint16_t STATE_MAXIMIZED = 1; |
824 | | static const uint16_t STATE_MINIMIZED = 2; |
825 | | static const uint16_t STATE_NORMAL = 3; |
826 | | static const uint16_t STATE_FULLSCREEN = 4; |
827 | | const JSClass* |
828 | | GetJSClass(); |
829 | | |
830 | | bool |
831 | | Wrap(JSContext* aCx, nsGlobalWindowInner* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector); |
832 | | |
833 | | // We declare this as an array so that retrieving a pointer to this |
834 | | // binding's property hooks only requires compile/link-time resolvable |
835 | | // address arithmetic. Declaring it as a pointer instead would require |
836 | | // doing a run-time load to fetch a pointer to this binding's property |
837 | | // hooks. And then structures which embedded a pointer to this structure |
838 | | // would require a run-time load for proper initialization, which would |
839 | | // then induce static constructors. Lots of static constructors. |
840 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
841 | | |
842 | | bool |
843 | | ClearCachedDocumentValue(JSContext* aCx, nsGlobalWindowInner* aObject); |
844 | | |
845 | | bool |
846 | | ClearCachedPerformanceValue(JSContext* aCx, nsGlobalWindowInner* aObject); |
847 | | |
848 | | void |
849 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
850 | | |
851 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
852 | 0 | { |
853 | 0 | /* Get the interface prototype object for this class. This will create the |
854 | 0 | object as needed. */ |
855 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::Window, |
856 | 0 | &CreateInterfaceObjects, |
857 | 0 | /* aDefineOnGlobal = */ true); |
858 | 0 |
|
859 | 0 | } |
860 | | |
861 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
862 | 0 | { |
863 | 0 | /* Get the interface object for this class. This will create the object as |
864 | 0 | needed. */ |
865 | 0 |
|
866 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::Window, |
867 | 0 | &CreateInterfaceObjects, |
868 | 0 | aDefineOnGlobal); |
869 | 0 | } |
870 | | |
871 | | JSObject* |
872 | | GetConstructorObject(JSContext* aCx); |
873 | | |
874 | | inline bool IsPermitted(JSFlatString* prop, char16_t propFirstChar, bool set) |
875 | 0 | { |
876 | 0 | switch (propFirstChar) { |
877 | 0 | case 'b': { |
878 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "blur")) { |
879 | 0 | return true; |
880 | 0 | } |
881 | 0 | break; |
882 | 0 | } |
883 | 0 | case 'c': { |
884 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "close")) { |
885 | 0 | return true; |
886 | 0 | } |
887 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "closed")) { |
888 | 0 | return true; |
889 | 0 | } |
890 | 0 | break; |
891 | 0 | } |
892 | 0 | case 'f': { |
893 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "focus")) { |
894 | 0 | return true; |
895 | 0 | } |
896 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "frames")) { |
897 | 0 | return true; |
898 | 0 | } |
899 | 0 | break; |
900 | 0 | } |
901 | 0 | case 'l': { |
902 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "length")) { |
903 | 0 | return true; |
904 | 0 | } |
905 | 0 | if (JS_FlatStringEqualsAscii(prop, "location")) { |
906 | 0 | return true; |
907 | 0 | } |
908 | 0 | break; |
909 | 0 | } |
910 | 0 | case 'o': { |
911 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "opener")) { |
912 | 0 | return true; |
913 | 0 | } |
914 | 0 | break; |
915 | 0 | } |
916 | 0 | case 'p': { |
917 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "parent")) { |
918 | 0 | return true; |
919 | 0 | } |
920 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "postMessage")) { |
921 | 0 | return true; |
922 | 0 | } |
923 | 0 | break; |
924 | 0 | } |
925 | 0 | case 's': { |
926 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "self")) { |
927 | 0 | return true; |
928 | 0 | } |
929 | 0 | break; |
930 | 0 | } |
931 | 0 | case 't': { |
932 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "top")) { |
933 | 0 | return true; |
934 | 0 | } |
935 | 0 | break; |
936 | 0 | } |
937 | 0 | case 'w': { |
938 | 0 | if (!set && JS_FlatStringEqualsAscii(prop, "window")) { |
939 | 0 | return true; |
940 | 0 | } |
941 | 0 | break; |
942 | 0 | } |
943 | 0 | } |
944 | 0 | |
945 | 0 | return false; |
946 | 0 | } |
947 | | |
948 | | } // namespace Window_Binding |
949 | | |
950 | | |
951 | | |
952 | | } // namespace dom |
953 | | } // namespace mozilla |
954 | | |
955 | | #endif // mozilla_dom_WindowBinding_h |