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