Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / xpfe / appshell / nsWindowMediator.h
blob578f901ea72a77c8f872cdc0806dbec3e8f31052
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsWindowMediator_h_
7 #define nsWindowMediator_h_
9 #include "nsCOMPtr.h"
10 #include "nsIWindowMediator.h"
11 #include "nsIObserver.h"
12 #include "nsTArray.h"
13 #include "nsPIDOMWindow.h"
14 #include "nsString.h"
15 #include "nsWeakReference.h"
16 #include "nsTObserverArray.h"
18 class nsAppShellWindowEnumerator;
19 class nsASAppWindowEarlyToLateEnumerator;
20 class nsASDOMWindowEarlyToLateEnumerator;
21 class nsASAppWindowFrontToBackEnumerator;
22 class nsASAppWindowBackToFrontEnumerator;
23 class nsIWindowMediatorListener;
24 struct nsWindowInfo;
26 class nsWindowMediator : public nsIWindowMediator,
27 public nsIObserver,
28 public nsSupportsWeakReference {
29 friend class nsAppShellWindowEnumerator;
30 friend class nsASAppWindowEarlyToLateEnumerator;
31 friend class nsASDOMWindowEarlyToLateEnumerator;
32 friend class nsASAppWindowFrontToBackEnumerator;
33 friend class nsASAppWindowBackToFrontEnumerator;
35 protected:
36 virtual ~nsWindowMediator();
38 public:
39 nsWindowMediator();
41 nsresult Init();
43 NS_DECL_ISUPPORTS
44 NS_DECL_NSIWINDOWMEDIATOR
45 NS_DECL_NSIOBSERVER
47 static nsresult GetDOMWindow(nsIAppWindow* inWindow,
48 nsCOMPtr<nsPIDOMWindowOuter>& outDOMWindow);
50 private:
51 void AddEnumerator(nsAppShellWindowEnumerator* inEnumerator);
52 int32_t RemoveEnumerator(nsAppShellWindowEnumerator* inEnumerator);
53 nsWindowInfo* MostRecentWindowInfo(const char16_t* inType,
54 bool aSkipPrivateBrowsingOrClosed = false);
56 nsresult UnregisterWindow(nsWindowInfo* inInfo);
57 nsWindowInfo* GetInfoFor(nsIAppWindow* aWindow);
58 nsWindowInfo* GetInfoFor(nsIWidget* aWindow);
59 void SortZOrderFrontToBack();
60 void SortZOrderBackToFront();
62 nsTArray<nsAppShellWindowEnumerator*> mEnumeratorList;
63 nsWindowInfo* mOldestWindow;
64 nsWindowInfo* mTopmostWindow;
65 int32_t mTimeStamp;
66 bool mSortingZOrder;
67 bool mReady;
69 typedef nsTObserverArray<nsCOMPtr<nsIWindowMediatorListener>> ListenerArray;
70 ListenerArray mListeners;
73 #endif