michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * 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 nsXULWindow_h__ michael@0: #define nsXULWindow_h__ michael@0: michael@0: // Local Includes michael@0: #include "nsChromeTreeOwner.h" michael@0: #include "nsContentTreeOwner.h" michael@0: michael@0: // Helper classes michael@0: #include "nsCOMPtr.h" michael@0: #include "nsTArray.h" michael@0: #include "nsString.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsCOMArray.h" michael@0: #include "nsRect.h" michael@0: michael@0: // Interfaces needed michael@0: #include "nsIBaseWindow.h" michael@0: #include "nsIDocShell.h" michael@0: #include "nsIDocShellTreeItem.h" michael@0: #include "nsIDOMWindow.h" michael@0: #include "nsIInterfaceRequestor.h" michael@0: #include "nsIInterfaceRequestorUtils.h" michael@0: #include "nsIXULWindow.h" michael@0: #include "nsIPrompt.h" michael@0: #include "nsIAuthPrompt.h" michael@0: #include "nsIXULBrowserWindow.h" michael@0: #include "nsIWeakReference.h" michael@0: #include "nsIWidgetListener.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: class Element; michael@0: } michael@0: } michael@0: michael@0: // nsXULWindow michael@0: michael@0: #define NS_XULWINDOW_IMPL_CID \ michael@0: { /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \ michael@0: 0x8eaec2f3, \ michael@0: 0xed02, \ michael@0: 0x4be2, \ michael@0: { 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \ michael@0: } michael@0: michael@0: class nsContentShellInfo; michael@0: michael@0: class nsXULWindow : public nsIBaseWindow, michael@0: public nsIInterfaceRequestor, michael@0: public nsIXULWindow, michael@0: public nsSupportsWeakReference michael@0: { michael@0: friend class nsChromeTreeOwner; michael@0: friend class nsContentTreeOwner; michael@0: michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: michael@0: NS_DECL_NSIINTERFACEREQUESTOR michael@0: NS_DECL_NSIXULWINDOW michael@0: NS_DECL_NSIBASEWINDOW michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID) michael@0: michael@0: void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; } michael@0: bool IsLocked() const { return mLockedUntilChromeLoad; } michael@0: void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; } michael@0: michael@0: protected: michael@0: enum persistentAttributes { michael@0: PAD_MISC = 0x1, michael@0: PAD_POSITION = 0x2, michael@0: PAD_SIZE = 0x4 michael@0: }; michael@0: michael@0: nsXULWindow(uint32_t aChromeFlags); michael@0: virtual ~nsXULWindow(); michael@0: michael@0: NS_IMETHOD EnsureChromeTreeOwner(); michael@0: NS_IMETHOD EnsureContentTreeOwner(); michael@0: NS_IMETHOD EnsurePrimaryContentTreeOwner(); michael@0: NS_IMETHOD EnsurePrompter(); michael@0: NS_IMETHOD EnsureAuthPrompter(); michael@0: michael@0: void OnChromeLoaded(); michael@0: void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY, michael@0: int32_t aSpecWidth, int32_t aSpecHeight); michael@0: bool LoadPositionFromXUL(); michael@0: bool LoadSizeFromXUL(); michael@0: bool LoadMiscPersistentAttributesFromXUL(); michael@0: void SyncAttributesToWidget(); michael@0: NS_IMETHOD SavePersistentAttributes(); michael@0: michael@0: NS_IMETHOD GetWindowDOMWindow(nsIDOMWindow** aDOMWindow); michael@0: mozilla::dom::Element* GetWindowDOMElement() const; michael@0: michael@0: // See nsIDocShellTreeOwner for docs on next two methods michael@0: NS_HIDDEN_(nsresult) ContentShellAdded(nsIDocShellTreeItem* aContentShell, michael@0: bool aPrimary, bool aTargetable, michael@0: const nsAString& aID); michael@0: NS_HIDDEN_(nsresult) ContentShellRemoved(nsIDocShellTreeItem* aContentShell); michael@0: NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, michael@0: int32_t aCY); michael@0: NS_IMETHOD ExitModalLoop(nsresult aStatus); michael@0: NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags, nsIXULWindow **_retval); michael@0: NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags, nsIXULWindow **_retval); michael@0: michael@0: void EnableParent(bool aEnable); michael@0: bool ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement, michael@0: nsIWidget *aReqBelow, nsIWidget **aActualBelow); michael@0: void PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, michael@0: nsIXULWindow *aBehind); michael@0: void SetContentScrollbarVisibility(bool aVisible); michael@0: bool GetContentScrollbarVisibility(); michael@0: void PersistentAttributesDirty(uint32_t aDirtyFlags); michael@0: michael@0: nsChromeTreeOwner* mChromeTreeOwner; michael@0: nsContentTreeOwner* mContentTreeOwner; michael@0: nsContentTreeOwner* mPrimaryContentTreeOwner; michael@0: nsCOMPtr mWindow; michael@0: nsCOMPtr mDocShell; michael@0: nsCOMPtr mDOMWindow; michael@0: nsCOMPtr mParentWindow; michael@0: nsCOMPtr mPrompter; michael@0: nsCOMPtr mAuthPrompter; michael@0: nsCOMPtr mXULBrowserWindow; michael@0: nsCOMPtr mPrimaryContentShell; michael@0: nsTArray mContentShells; // array of doc shells by id michael@0: nsresult mModalStatus; michael@0: bool mContinueModalLoop; michael@0: bool mDebuting; // being made visible right now michael@0: bool mChromeLoaded; // True when chrome has loaded michael@0: bool mShowAfterLoad; michael@0: bool mIntrinsicallySized; michael@0: bool mCenterAfterLoad; michael@0: bool mIsHiddenWindow; michael@0: bool mLockedUntilChromeLoad; michael@0: bool mIgnoreXULSize; michael@0: bool mIgnoreXULPosition; michael@0: bool mChromeFlagsFrozen; michael@0: bool mIgnoreXULSizeMode; michael@0: // mDestroying is used to prevent reentry into into Destroy(), which can michael@0: // otherwise happen due to script running as we tear down various things. michael@0: bool mDestroying; michael@0: uint32_t mContextFlags; michael@0: uint32_t mPersistentAttributesDirty; // persistentAttributes michael@0: uint32_t mPersistentAttributesMask; michael@0: uint32_t mChromeFlags; michael@0: nsString mTitle; michael@0: nsIntRect mOpenerScreenRect; // the screen rect of the opener michael@0: michael@0: nsCOMArray mTargetableShells; // targetable shells only michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID) michael@0: michael@0: // nsContentShellInfo michael@0: // Used to map shell IDs to nsIDocShellTreeItems. michael@0: michael@0: class nsContentShellInfo michael@0: { michael@0: public: michael@0: nsContentShellInfo(const nsAString& aID, michael@0: nsIWeakReference* aContentShell); michael@0: ~nsContentShellInfo(); michael@0: michael@0: public: michael@0: nsAutoString id; // The identifier of the content shell michael@0: nsWeakPtr child; // content shell (weak reference to nsIDocShellTreeItem) michael@0: }; michael@0: michael@0: #endif /* nsXULWindow_h__ */