Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / nsPIDOMWindow.h
blob53d89b5f828d588e56e2fb8cd3ebcb8f639a53ed
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef nsPIDOMWindow_h__
9 #define nsPIDOMWindow_h__
11 #include "nsIDOMWindow.h"
13 #include "nsCOMPtr.h"
14 #include "nsAutoPtr.h"
15 #include "nsTArray.h"
16 #include "mozilla/dom/EventTarget.h"
17 #include "js/TypeDecls.h"
19 #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
20 #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
21 #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed"
23 class nsIArray;
24 class nsIContent;
25 class nsIDocShell;
26 class nsIDocument;
27 class nsIIdleObserver;
28 class nsIPrincipal;
29 class nsIScriptTimeoutHandler;
30 class nsIURI;
31 class nsPerformance;
32 class nsPIWindowRoot;
33 class nsXBLPrototypeHandler;
34 struct nsTimeout;
36 namespace mozilla {
37 namespace dom {
38 class AudioContext;
39 class Element;
41 namespace gfx {
42 class VRHMDInfo;
46 // Popup control state enum. The values in this enum must go from most
47 // permissive to least permissive so that it's safe to push state in
48 // all situations. Pushing popup state onto the stack never makes the
49 // current popup state less permissive (see
50 // nsGlobalWindow::PushPopupControlState()).
51 enum PopupControlState {
52 openAllowed = 0, // open that window without worries
53 openControlled, // it's a popup, but allow it
54 openAbused, // it's a popup. disallow it, but allow domain override.
55 openOverridden // disallow window open
58 enum UIStateChangeType
60 UIStateChangeType_NoChange,
61 UIStateChangeType_Set,
62 UIStateChangeType_Clear
65 #define NS_PIDOMWINDOW_IID \
66 { 0x19fb3019, 0x7b5d, 0x4235, \
67 { 0xa9, 0x59, 0xa2, 0x31, 0xa2, 0xe7, 0x94, 0x79 } }
69 class nsPIDOMWindow : public nsIDOMWindowInternal
71 public:
72 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOW_IID)
74 virtual nsPIDOMWindow* GetPrivateRoot() = 0;
76 // Outer windows only.
77 virtual void ActivateOrDeactivate(bool aActivate) = 0;
79 // this is called GetTopWindowRoot to avoid conflicts with nsIDOMWindow::GetWindowRoot
80 virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() = 0;
82 // Inner windows only.
83 virtual nsresult RegisterIdleObserver(nsIIdleObserver* aIdleObserver) = 0;
84 virtual nsresult UnregisterIdleObserver(nsIIdleObserver* aIdleObserver) = 0;
86 // Outer windows only.
87 virtual void SetActive(bool aActive)
89 MOZ_ASSERT(IsOuterWindow());
90 mIsActive = aActive;
92 bool IsActive()
94 MOZ_ASSERT(IsOuterWindow());
95 return mIsActive;
98 // Outer windows only.
99 virtual void SetIsBackground(bool aIsBackground)
101 MOZ_ASSERT(IsOuterWindow());
102 mIsBackground = aIsBackground;
104 bool IsBackground()
106 MOZ_ASSERT(IsOuterWindow());
107 return mIsBackground;
110 mozilla::dom::EventTarget* GetChromeEventHandler() const
112 return mChromeEventHandler;
115 // Outer windows only.
116 virtual void SetChromeEventHandler(mozilla::dom::EventTarget* aChromeEventHandler) = 0;
118 mozilla::dom::EventTarget* GetParentTarget()
120 if (!mParentTarget) {
121 UpdateParentTarget();
123 return mParentTarget;
126 bool HasMutationListeners(uint32_t aMutationEventType) const
128 MOZ_ASSERT(IsInnerWindow());
130 if (!mOuterWindow) {
131 NS_ERROR("HasMutationListeners() called on orphan inner window!");
133 return false;
136 return (mMutationBits & aMutationEventType) != 0;
139 void SetMutationListeners(uint32_t aType)
141 MOZ_ASSERT(IsInnerWindow());
143 if (!mOuterWindow) {
144 NS_ERROR("HasMutationListeners() called on orphan inner window!");
146 return;
149 mMutationBits |= aType;
152 virtual void MaybeUpdateTouchState() {}
153 virtual void UpdateTouchState() {}
155 nsIDocument* GetExtantDoc() const
157 return mDoc;
159 nsIURI* GetDocumentURI() const;
160 nsIURI* GetDocBaseURI() const;
162 nsIDocument* GetDoc()
164 if (!mDoc) {
165 MaybeCreateDoc();
167 return mDoc;
170 virtual bool IsRunningTimeout() = 0;
172 // Audio API
173 bool GetAudioMuted() const;
174 void SetAudioMuted(bool aMuted);
176 float GetAudioVolume() const;
177 nsresult SetAudioVolume(float aVolume);
179 float GetAudioGlobalVolume();
181 protected:
182 // Lazily instantiate an about:blank document if necessary, and if
183 // we have what it takes to do so.
184 void MaybeCreateDoc();
186 float GetAudioGlobalVolumeInternal(float aVolume);
187 void RefreshMediaElements();
189 public:
190 // Internal getter/setter for the frame element, this version of the
191 // getter crosses chrome boundaries whereas the public scriptable
192 // one doesn't for security reasons.
193 mozilla::dom::Element* GetFrameElementInternal() const;
194 void SetFrameElementInternal(mozilla::dom::Element* aFrameElement);
196 bool IsLoadingOrRunningTimeout() const
198 const nsPIDOMWindow* win = IsInnerWindow() ? this : GetCurrentInnerWindow();
199 return !win->mIsDocumentLoaded || win->mRunningTimeout;
202 // Check whether a document is currently loading
203 bool IsLoading() const
205 const nsPIDOMWindow *win;
207 if (IsOuterWindow()) {
208 win = GetCurrentInnerWindow();
210 if (!win) {
211 NS_ERROR("No current inner window available!");
213 return false;
215 } else {
216 if (!mOuterWindow) {
217 NS_ERROR("IsLoading() called on orphan inner window!");
219 return false;
222 win = this;
225 return !win->mIsDocumentLoaded;
228 bool IsHandlingResizeEvent() const
230 const nsPIDOMWindow *win;
232 if (IsOuterWindow()) {
233 win = GetCurrentInnerWindow();
235 if (!win) {
236 NS_ERROR("No current inner window available!");
238 return false;
240 } else {
241 if (!mOuterWindow) {
242 NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
244 return false;
247 win = this;
250 return win->mIsHandlingResizeEvent;
253 // Set the window up with an about:blank document with the current subject
254 // principal.
255 // Outer windows only.
256 virtual void SetInitialPrincipalToSubject() = 0;
258 virtual PopupControlState PushPopupControlState(PopupControlState aState,
259 bool aForce) const = 0;
260 virtual void PopPopupControlState(PopupControlState state) const = 0;
261 virtual PopupControlState GetPopupControlState() const = 0;
263 // Returns an object containing the window's state. This also suspends
264 // all running timeouts in the window.
265 virtual already_AddRefed<nsISupports> SaveWindowState() = 0;
267 // Restore the window state from aState.
268 virtual nsresult RestoreWindowState(nsISupports *aState) = 0;
270 // Suspend timeouts in this window and in child windows.
271 virtual void SuspendTimeouts(uint32_t aIncrease = 1,
272 bool aFreezeChildren = true) = 0;
274 // Resume suspended timeouts in this window and in child windows.
275 virtual nsresult ResumeTimeouts(bool aThawChildren = true) = 0;
277 virtual uint32_t TimeoutSuspendCount() = 0;
279 // Fire any DOM notification events related to things that happened while
280 // the window was frozen.
281 virtual nsresult FireDelayedDOMEvents() = 0;
283 virtual bool IsFrozen() const = 0;
285 // Add a timeout to this window.
286 virtual nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
287 int32_t interval,
288 bool aIsInterval, int32_t *aReturn) = 0;
290 // Clear a timeout from this window.
291 virtual nsresult ClearTimeoutOrInterval(int32_t aTimerID) = 0;
293 nsPIDOMWindow *GetOuterWindow()
295 return mIsInnerWindow ? mOuterWindow.get() : this;
298 nsPIDOMWindow *GetCurrentInnerWindow() const
300 MOZ_ASSERT(IsOuterWindow());
301 return mInnerWindow;
304 nsPIDOMWindow *EnsureInnerWindow()
306 NS_ASSERTION(IsOuterWindow(), "EnsureInnerWindow called on inner window");
307 // GetDoc forces inner window creation if there isn't one already
308 GetDoc();
309 return GetCurrentInnerWindow();
312 bool IsInnerWindow() const
314 return mIsInnerWindow;
317 // Returns true if this object has an outer window and it is the current inner
318 // window of that outer. Only call this on inner windows.
319 bool IsCurrentInnerWindow() const
321 MOZ_ASSERT(IsInnerWindow(),
322 "It doesn't make sense to call this on outer windows.");
323 return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this;
326 // Returns true if the document of this window is the active document. This
327 // is not identical to IsCurrentInnerWindow() because document.open() will
328 // keep the same document active but create a new window.
329 bool HasActiveDocument()
331 MOZ_ASSERT(IsInnerWindow());
332 return IsCurrentInnerWindow() ||
333 (mOuterWindow &&
334 mOuterWindow->GetCurrentInnerWindow() &&
335 mOuterWindow->GetCurrentInnerWindow()->GetDoc() == mDoc);
338 bool IsOuterWindow() const
340 return !IsInnerWindow();
343 // Outer windows only.
344 virtual bool WouldReuseInnerWindow(nsIDocument* aNewDocument) = 0;
347 * Get the docshell in this window.
349 nsIDocShell *GetDocShell()
351 if (mOuterWindow) {
352 return mOuterWindow->mDocShell;
355 return mDocShell;
359 * Set the docshell in the window. Must not be called with a null docshell
360 * (use DetachFromDocShell for that).
362 virtual void SetDocShell(nsIDocShell *aDocShell) = 0;
365 * Detach an outer window from its docshell.
367 virtual void DetachFromDocShell() = 0;
370 * Set a new document in the window. Calling this method will in
371 * most cases create a new inner window. If this method is called on
372 * an inner window the call will be forewarded to the outer window,
373 * if the inner window is not the current inner window an
374 * NS_ERROR_NOT_AVAILABLE error code will be returned. This may be
375 * called with a pointer to the current document, in that case the
376 * document remains unchanged, but a new inner window will be
377 * created.
379 * aDocument must not be null.
381 virtual nsresult SetNewDocument(nsIDocument *aDocument,
382 nsISupports *aState,
383 bool aForceReuseInnerWindow) = 0;
386 * Set the opener window. aOriginalOpener is true if and only if this is the
387 * original opener for the window. That is, it can only be true at most once
388 * during the life cycle of a window, and then only the first time
389 * SetOpenerWindow is called. It might never be true, of course, if the
390 * window does not have an opener when it's created.
392 virtual void SetOpenerWindow(nsIDOMWindow* aOpener,
393 bool aOriginalOpener) = 0;
395 virtual void EnsureSizeUpToDate() = 0;
398 * Callback for notifying a window about a modal dialog being
399 * opened/closed with the window as a parent.
401 virtual void EnterModalState() = 0;
402 virtual void LeaveModalState() = 0;
404 // Outer windows only.
405 virtual bool CanClose() = 0;
406 virtual void ForceClose() = 0;
408 bool IsModalContentWindow() const
410 return mIsModalContentWindow;
414 * Call this to indicate that some node (this window, its document,
415 * or content in that document) has a paint event listener.
417 void SetHasPaintEventListeners()
419 mMayHavePaintEventListener = true;
423 * Call this to check whether some node (this window, its document,
424 * or content in that document) has a paint event listener.
426 bool HasPaintEventListeners()
428 return mMayHavePaintEventListener;
432 * Call this to indicate that some node (this window, its document,
433 * or content in that document) has a touch event listener.
435 void SetHasTouchEventListeners()
437 mMayHaveTouchEventListener = true;
438 MaybeUpdateTouchState();
441 bool HasTouchEventListeners()
443 return mMayHaveTouchEventListener;
447 * Call this to indicate that some node (this window, its document,
448 * or content in that document) has a scroll wheel event listener.
450 void SetHasScrollWheelEventListeners()
452 mMayHaveScrollWheelEventListener = true;
455 bool HasScrollWheelEventListeners()
457 return mMayHaveScrollWheelEventListener;
461 * Returns whether or not any event listeners are present that APZ must be
462 * aware of.
464 bool HasApzAwareEventListeners()
466 return HasTouchEventListeners() || HasScrollWheelEventListeners();
470 * Will be called when touch caret visibility has changed. mMayHaveTouchCaret
471 * is set if that some node (this window, its document, or content in that
472 * document) has a visible touch caret.
474 void SetMayHaveTouchCaret(bool aSetValue)
476 mMayHaveTouchCaret = aSetValue;
479 bool MayHaveTouchCaret()
481 return mMayHaveTouchCaret;
485 * Moves the top-level window into fullscreen mode if aIsFullScreen is true,
486 * otherwise exits fullscreen. If aRequireTrust is true, this method only
487 * changes window state in a context trusted for write.
489 * If aHMD is not null, the window is made full screen on the given VR HMD
490 * device instead of its currrent display.
492 * Outer windows only.
494 virtual nsresult SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust,
495 mozilla::gfx::VRHMDInfo *aHMD = nullptr) = 0;
498 * Call this to check whether some node (this window, its document,
499 * or content in that document) has a mouseenter/leave event listener.
501 bool HasMouseEnterLeaveEventListeners()
503 return mMayHaveMouseEnterLeaveEventListener;
507 * Call this to indicate that some node (this window, its document,
508 * or content in that document) has a mouseenter/leave event listener.
510 void SetHasMouseEnterLeaveEventListeners()
512 mMayHaveMouseEnterLeaveEventListener = true;
516 * Call this to check whether some node (this window, its document,
517 * or content in that document) has a Pointerenter/leave event listener.
519 bool HasPointerEnterLeaveEventListeners()
521 return mMayHavePointerEnterLeaveEventListener;
525 * Call this to indicate that some node (this window, its document,
526 * or content in that document) has a Pointerenter/leave event listener.
528 void SetHasPointerEnterLeaveEventListeners()
530 mMayHavePointerEnterLeaveEventListener = true;
534 virtual JSObject* GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) = 0;
535 virtual void CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
536 JS::Handle<JSObject*> aHandler) = 0;
539 * Get and set the currently focused element within the document. If
540 * aNeedsFocus is true, then set mNeedsFocus to true to indicate that a
541 * document focus event is needed.
543 * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER
544 * INSTEAD.
546 nsIContent* GetFocusedNode()
548 if (IsOuterWindow()) {
549 return mInnerWindow ? mInnerWindow->mFocusedNode.get() : nullptr;
551 return mFocusedNode;
553 virtual void SetFocusedNode(nsIContent* aNode,
554 uint32_t aFocusMethod = 0,
555 bool aNeedsFocus = false) = 0;
558 * Retrieves the method that was used to focus the current node.
560 virtual uint32_t GetFocusMethod() = 0;
563 * Tells the window that it now has focus or has lost focus, based on the
564 * state of aFocus. If this method returns true, then the document loaded
565 * in the window has never received a focus event and expects to receive
566 * one. If false is returned, the document has received a focus event before
567 * and should only receive one if the window is being focused.
569 * aFocusMethod may be set to one of the focus method constants in
570 * nsIFocusManager to indicate how focus was set.
572 virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod) = 0;
575 * Indicates that the window may now accept a document focus event. This
576 * should be called once a document has been loaded into the window.
578 virtual void SetReadyForFocus() = 0;
581 * Whether the focused content within the window should show a focus ring.
583 virtual bool ShouldShowFocusRing() = 0;
586 * Set the keyboard indicator state for accelerators and focus rings.
588 virtual void SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
589 UIStateChangeType aShowFocusRings) = 0;
592 * Get the keyboard indicator state for accelerators and focus rings.
594 virtual void GetKeyboardIndicators(bool* aShowAccelerators,
595 bool* aShowFocusRings) = 0;
598 * Indicates that the page in the window has been hidden. This is used to
599 * reset the focus state.
601 virtual void PageHidden() = 0;
604 * Instructs this window to asynchronously dispatch a hashchange event. This
605 * method must be called on an inner window.
607 virtual nsresult DispatchAsyncHashchange(nsIURI *aOldURI,
608 nsIURI *aNewURI) = 0;
611 * Instructs this window to synchronously dispatch a popState event.
613 virtual nsresult DispatchSyncPopState() = 0;
616 * Tell this window that it should listen for sensor changes of the given
617 * type.
619 * Inner windows only.
621 virtual void EnableDeviceSensor(uint32_t aType) = 0;
624 * Tell this window that it should remove itself from sensor change
625 * notifications.
627 * Inner windows only.
629 virtual void DisableDeviceSensor(uint32_t aType) = 0;
631 virtual void EnableTimeChangeNotifications() = 0;
632 virtual void DisableTimeChangeNotifications() = 0;
634 #ifdef MOZ_B2G
636 * Tell the window that it should start to listen to the network event of the
637 * given aType.
639 * Inner windows only.
641 virtual void EnableNetworkEvent(uint32_t aType) = 0;
644 * Tell the window that it should stop to listen to the network event of the
645 * given aType.
647 * Inner windows only.
649 virtual void DisableNetworkEvent(uint32_t aType) = 0;
650 #endif // MOZ_B2G
653 * Tell this window that there is an observer for gamepad input
655 * Inner windows only.
657 virtual void SetHasGamepadEventListener(bool aHasGamepad = true) = 0;
660 * Set a arguments for this window. This will be set on the window
661 * right away (if there's an existing document) and it will also be
662 * installed on the window when the next document is loaded.
664 * This function serves double-duty for passing both |arguments| and
665 * |dialogArguments| back from nsWindowWatcher to nsGlobalWindow. For the
666 * latter, the array is an array of length 0 whose only element is a
667 * DialogArgumentsHolder representing the JS value passed to showModalDialog.
669 * Outer windows only.
671 virtual nsresult SetArguments(nsIArray *aArguments) = 0;
674 * NOTE! This function *will* be called on multiple threads so the
675 * implementation must not do any AddRef/Release or other actions that will
676 * mutate internal state.
678 virtual uint32_t GetSerial() = 0;
681 * Return the window id of this window
683 uint64_t WindowID() const { return mWindowID; }
686 * Dispatch a custom event with name aEventName targeted at this window.
687 * Returns whether the default action should be performed.
689 * Outer windows only.
691 virtual bool DispatchCustomEvent(const nsAString& aEventName) = 0;
694 * Call when the document principal may have changed and the compartment
695 * principal needs to be updated.
697 * Inner windows only.
699 virtual void RefreshCompartmentPrincipal() = 0;
702 * Like nsIDOMWindow::Open, except that we don't navigate to the given URL.
704 * Outer windows only.
706 virtual nsresult
707 OpenNoNavigate(const nsAString& aUrl, const nsAString& aName,
708 const nsAString& aOptions, nsIDOMWindow **_retval) = 0;
711 * Fire a popup blocked event on the document.
713 virtual void
714 FirePopupBlockedEvent(nsIDocument* aDoc,
715 nsIURI* aPopupURI,
716 const nsAString& aPopupWindowName,
717 const nsAString& aPopupWindowFeatures) = 0;
719 // Inner windows only.
720 void AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
721 void RemoveAudioContext(mozilla::dom::AudioContext* aAudioContext);
722 void MuteAudioContexts();
723 void UnmuteAudioContexts();
725 // Given an inner window, return its outer if the inner is the current inner.
726 // Otherwise (argument null or not an inner or not current) return null.
727 static nsPIDOMWindow* GetOuterFromCurrentInner(nsPIDOMWindow* aInner)
729 if (!aInner) {
730 return nullptr;
733 nsPIDOMWindow* outer = aInner->GetOuterWindow();
734 if (!outer || outer->GetCurrentInnerWindow() != aInner) {
735 return nullptr;
738 return outer;
741 // WebIDL-ish APIs
742 nsPerformance* GetPerformance();
744 void MarkUncollectableForCCGeneration(uint32_t aGeneration)
746 mMarkedCCGeneration = aGeneration;
749 uint32_t GetMarkedCCGeneration()
751 return mMarkedCCGeneration;
754 // Sets the condition that we send an NS_AFTER_REMOTE_PAINT message just before the next
755 // composite. Used in non-e10s implementations.
756 void SetRequestNotifyAfterRemotePaint()
758 mSendAfterRemotePaint = true;
761 // Sends an NS_AFTER_REMOTE_PAINT message if requested by
762 // SetRequestNotifyAfterRemotePaint().
763 void SendAfterRemotePaintIfRequested();
765 protected:
766 // The nsPIDOMWindow constructor. The aOuterWindow argument should
767 // be null if and only if the created window itself is an outer
768 // window. In all other cases aOuterWindow should be the outer
769 // window for the inner window that is being created.
770 explicit nsPIDOMWindow(nsPIDOMWindow *aOuterWindow);
772 ~nsPIDOMWindow();
774 void SetChromeEventHandlerInternal(mozilla::dom::EventTarget* aChromeEventHandler) {
775 mChromeEventHandler = aChromeEventHandler;
776 // mParentTarget will be set when the next event is dispatched.
777 mParentTarget = nullptr;
780 virtual void UpdateParentTarget() = 0;
782 // Helper for creating performance objects.
783 // Inner windows only.
784 void CreatePerformanceObjectIfNeeded();
786 // These two variables are special in that they're set to the same
787 // value on both the outer window and the current inner window. Make
788 // sure you keep them in sync!
789 nsCOMPtr<mozilla::dom::EventTarget> mChromeEventHandler; // strong
790 nsCOMPtr<nsIDocument> mDoc; // strong
791 // Cache the URI when mDoc is cleared.
792 nsCOMPtr<nsIURI> mDocumentURI; // strong
793 nsCOMPtr<nsIURI> mDocBaseURI; // strong
795 nsCOMPtr<mozilla::dom::EventTarget> mParentTarget; // strong
797 // These members are only used on outer windows.
798 nsCOMPtr<mozilla::dom::Element> mFrameElement;
799 nsIDocShell *mDocShell; // Weak Reference
801 // mPerformance is only used on inner windows.
802 nsRefPtr<nsPerformance> mPerformance;
804 uint32_t mModalStateDepth;
806 // These variables are only used on inner windows.
807 nsTimeout *mRunningTimeout;
809 uint32_t mMutationBits;
811 bool mIsDocumentLoaded;
812 bool mIsHandlingResizeEvent;
813 bool mIsInnerWindow;
814 bool mMayHavePaintEventListener;
815 bool mMayHaveTouchEventListener;
816 bool mMayHaveTouchCaret;
817 bool mMayHaveScrollWheelEventListener;
818 bool mMayHaveMouseEnterLeaveEventListener;
819 bool mMayHavePointerEnterLeaveEventListener;
821 // This variable is used on both inner and outer windows (and they
822 // should match).
823 bool mIsModalContentWindow;
825 // Tracks activation state that's used for :-moz-window-inactive.
826 // Only used on outer windows.
827 bool mIsActive;
829 // Tracks whether our docshell is active. If it is, mIsBackground
830 // is false. Too bad we have so many different concepts of
831 // "active". Only used on outer windows.
832 bool mIsBackground;
834 bool mAudioMuted;
835 float mAudioVolume;
837 // And these are the references between inner and outer windows.
838 nsPIDOMWindow *mInnerWindow;
839 nsCOMPtr<nsPIDOMWindow> mOuterWindow;
841 // the element within the document that is currently focused when this
842 // window is active
843 nsCOMPtr<nsIContent> mFocusedNode;
845 // The AudioContexts created for the current document, if any.
846 nsTArray<mozilla::dom::AudioContext*> mAudioContexts; // Weak
848 // A unique (as long as our 64-bit counter doesn't roll over) id for
849 // this window.
850 uint64_t mWindowID;
852 // This is only used by the inner window. Set to true once we've sent
853 // the (chrome|content)-document-global-created notification.
854 bool mHasNotifiedGlobalCreated;
856 uint32_t mMarkedCCGeneration;
858 // If true, send an NS_AFTER_REMOTE_PAINT message before compositing in a
859 // non-e10s implementation.
860 bool mSendAfterRemotePaint;
864 NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindow, NS_PIDOMWINDOW_IID)
866 #ifdef MOZILLA_INTERNAL_API
867 PopupControlState
868 PushPopupControlState(PopupControlState aState, bool aForce);
870 void
871 PopPopupControlState(PopupControlState aState);
873 #define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherInternal
874 #else
875 #define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherExternal
876 #endif
878 // Helper class that helps with pushing and popping popup control
879 // state. Note that this class looks different from within code that's
880 // part of the layout library than it does in code outside the layout
881 // library. We give the two object layouts different names so the symbols
882 // don't conflict, but code should always use the name
883 // |nsAutoPopupStatePusher|.
884 class NS_AUTO_POPUP_STATE_PUSHER
886 public:
887 #ifdef MOZILLA_INTERNAL_API
888 explicit NS_AUTO_POPUP_STATE_PUSHER(PopupControlState aState, bool aForce = false)
889 : mOldState(::PushPopupControlState(aState, aForce))
893 ~NS_AUTO_POPUP_STATE_PUSHER()
895 PopPopupControlState(mOldState);
897 #else
898 NS_AUTO_POPUP_STATE_PUSHER(nsPIDOMWindow *aWindow, PopupControlState aState)
899 : mWindow(aWindow), mOldState(openAbused)
901 if (aWindow) {
902 mOldState = aWindow->PushPopupControlState(aState, false);
906 ~NS_AUTO_POPUP_STATE_PUSHER()
908 if (mWindow) {
909 mWindow->PopPopupControlState(mOldState);
912 #endif
914 protected:
915 #ifndef MOZILLA_INTERNAL_API
916 nsCOMPtr<nsPIDOMWindow> mWindow;
917 #endif
918 PopupControlState mOldState;
920 private:
921 // Hide so that this class can only be stack-allocated
922 static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nullptr; }
923 static void operator delete(void* /*memory*/) {}
926 #define nsAutoPopupStatePusher NS_AUTO_POPUP_STATE_PUSHER
928 #endif // nsPIDOMWindow_h__