michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsWindowMediator_h_ michael@0: #define nsWindowMediator_h_ michael@0: michael@0: #include "mozilla/Mutex.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIWindowMediator.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsTArray.h" michael@0: #include "nsXPIDLString.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsCRT.h" michael@0: #include "nsCOMArray.h" michael@0: michael@0: class nsAppShellWindowEnumerator; michael@0: class nsASXULWindowEarlyToLateEnumerator; michael@0: class nsASDOMWindowEarlyToLateEnumerator; michael@0: class nsASDOMWindowFrontToBackEnumerator; michael@0: class nsASXULWindowFrontToBackEnumerator; michael@0: class nsASDOMWindowBackToFrontEnumerator; michael@0: class nsASXULWindowBackToFrontEnumerator; michael@0: class nsIWindowMediatorListener; michael@0: struct nsWindowInfo; michael@0: struct PRLock; michael@0: michael@0: class nsWindowMediator : michael@0: public nsIWindowMediator, michael@0: public nsIObserver, michael@0: public nsSupportsWeakReference michael@0: { michael@0: friend class nsAppShellWindowEnumerator; michael@0: friend class nsASXULWindowEarlyToLateEnumerator; michael@0: friend class nsASDOMWindowEarlyToLateEnumerator; michael@0: friend class nsASDOMWindowFrontToBackEnumerator; michael@0: friend class nsASXULWindowFrontToBackEnumerator; michael@0: friend class nsASDOMWindowBackToFrontEnumerator; michael@0: friend class nsASXULWindowBackToFrontEnumerator; michael@0: michael@0: public: michael@0: nsWindowMediator(); michael@0: virtual ~nsWindowMediator(); michael@0: michael@0: nsresult Init(); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIWINDOWMEDIATOR michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: static nsresult GetDOMWindow(nsIXULWindow* inWindow, michael@0: nsCOMPtr& outDOMWindow); michael@0: michael@0: private: michael@0: int32_t AddEnumerator(nsAppShellWindowEnumerator* inEnumerator); michael@0: int32_t RemoveEnumerator(nsAppShellWindowEnumerator* inEnumerator); michael@0: nsWindowInfo *MostRecentWindowInfo(const char16_t* inType); michael@0: michael@0: nsresult UnregisterWindow(nsWindowInfo *inInfo); michael@0: nsWindowInfo *GetInfoFor(nsIXULWindow *aWindow); michael@0: nsWindowInfo *GetInfoFor(nsIWidget *aWindow); michael@0: void SortZOrderFrontToBack(); michael@0: void SortZOrderBackToFront(); michael@0: michael@0: nsTArray mEnumeratorList; michael@0: nsWindowInfo *mOldestWindow; michael@0: nsWindowInfo *mTopmostWindow; michael@0: int32_t mTimeStamp; michael@0: bool mSortingZOrder; michael@0: bool mReady; michael@0: mozilla::Mutex mListLock; michael@0: michael@0: nsCOMArray mListeners; michael@0: }; michael@0: michael@0: #endif