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 "mozilla/Mutex.h"
11 #include "nsIWindowMediator.h"
12 #include "nsIObserver.h"
14 #include "nsXPIDLString.h"
15 #include "nsWeakReference.h"
16 #include "nsCOMArray.h"
18 class nsAppShellWindowEnumerator
;
19 class nsASXULWindowEarlyToLateEnumerator
;
20 class nsASDOMWindowEarlyToLateEnumerator
;
21 class nsASDOMWindowFrontToBackEnumerator
;
22 class nsASXULWindowFrontToBackEnumerator
;
23 class nsASDOMWindowBackToFrontEnumerator
;
24 class nsASXULWindowBackToFrontEnumerator
;
25 class nsIWindowMediatorListener
;
29 class nsWindowMediator
:
30 public nsIWindowMediator
,
32 public nsSupportsWeakReference
34 friend class nsAppShellWindowEnumerator
;
35 friend class nsASXULWindowEarlyToLateEnumerator
;
36 friend class nsASDOMWindowEarlyToLateEnumerator
;
37 friend class nsASDOMWindowFrontToBackEnumerator
;
38 friend class nsASXULWindowFrontToBackEnumerator
;
39 friend class nsASDOMWindowBackToFrontEnumerator
;
40 friend class nsASXULWindowBackToFrontEnumerator
;
43 virtual ~nsWindowMediator();
51 NS_DECL_NSIWINDOWMEDIATOR
54 static nsresult
GetDOMWindow(nsIXULWindow
* inWindow
,
55 nsCOMPtr
<nsIDOMWindow
>& outDOMWindow
);
58 int32_t AddEnumerator(nsAppShellWindowEnumerator
* inEnumerator
);
59 int32_t RemoveEnumerator(nsAppShellWindowEnumerator
* inEnumerator
);
60 nsWindowInfo
*MostRecentWindowInfo(const char16_t
* inType
);
62 nsresult
UnregisterWindow(nsWindowInfo
*inInfo
);
63 nsWindowInfo
*GetInfoFor(nsIXULWindow
*aWindow
);
64 nsWindowInfo
*GetInfoFor(nsIWidget
*aWindow
);
65 void SortZOrderFrontToBack();
66 void SortZOrderBackToFront();
68 nsTArray
<nsAppShellWindowEnumerator
*> mEnumeratorList
;
69 nsWindowInfo
*mOldestWindow
;
70 nsWindowInfo
*mTopmostWindow
;
74 mozilla::Mutex mListLock
;
76 nsCOMArray
<nsIWindowMediatorListener
> mListeners
;