1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is the Mozilla browser.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications, Inc.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
24 * Travis Bogard <travis@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef nsXULWindow_h__
41 #define nsXULWindow_h__
44 #include "nsChromeTreeOwner.h"
45 #include "nsContentTreeOwner.h"
49 #include "nsVoidArray.h"
51 #include "nsWeakReference.h"
52 #include "nsCOMArray.h"
55 #include "nsIBaseWindow.h"
56 #include "nsIDocShell.h"
57 #include "nsIDocShellTreeItem.h"
58 #include "nsIDOMWindowInternal.h"
59 #include "nsIInterfaceRequestor.h"
60 #include "nsIInterfaceRequestorUtils.h"
61 #include "nsIWidget.h"
62 #include "nsIXULWindow.h"
63 #include "nsIPrompt.h"
64 #include "nsIAuthPrompt.h"
65 #include "nsGUIEvent.h"
66 #include "nsIXULBrowserWindow.h"
67 #include "nsIWeakReference.h"
71 #define NS_XULWINDOW_IMPL_CID \
72 { /* 2a38ef7e-3174-44ad-a785-b5a863cf5588 */ \
76 { 0xa7, 0x85, 0xb5, 0xa8, 0x63, 0xcf, 0x55, 0x88 } \
79 class nsXULWindow
: public nsIBaseWindow
,
80 public nsIInterfaceRequestor
,
82 public nsSupportsWeakReference
84 friend class nsChromeTreeOwner
;
85 friend class nsContentTreeOwner
;
90 NS_DECL_NSIINTERFACEREQUESTOR
94 NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID
)
96 void LockUntilChromeLoad() { mLockedUntilChromeLoad
= PR_TRUE
; }
97 PRBool
IsLocked() const { return mLockedUntilChromeLoad
; }
100 enum persistentAttributes
{
107 virtual ~nsXULWindow();
109 NS_IMETHOD
EnsureChromeTreeOwner();
110 NS_IMETHOD
EnsureContentTreeOwner();
111 NS_IMETHOD
EnsurePrimaryContentTreeOwner();
112 NS_IMETHOD
EnsurePrompter();
113 NS_IMETHOD
EnsureAuthPrompter();
115 void OnChromeLoaded();
116 void StaggerPosition(PRInt32
&aRequestedX
, PRInt32
&aRequestedY
,
117 PRInt32 aSpecWidth
, PRInt32 aSpecHeight
);
118 PRBool
LoadPositionFromXUL();
119 PRBool
LoadSizeFromXUL();
120 PRBool
LoadMiscPersistentAttributesFromXUL();
121 nsresult
LoadChromeHidingFromXUL();
122 NS_IMETHOD
LoadWindowClassFromXUL();
123 NS_IMETHOD
LoadIconFromXUL();
124 NS_IMETHOD
SavePersistentAttributes();
126 NS_IMETHOD
GetWindowDOMWindow(nsIDOMWindowInternal
** aDOMWindow
);
127 NS_IMETHOD
GetWindowDOMElement(nsIDOMElement
** aDOMElement
);
128 NS_IMETHOD
GetDOMElementById(char* aID
, nsIDOMElement
** aDOMElement
);
130 // See nsIDocShellTreeOwner for docs on next two methods
131 NS_HIDDEN_(nsresult
) ContentShellAdded(nsIDocShellTreeItem
* aContentShell
,
132 PRBool aPrimary
, PRBool aTargetable
,
133 const nsAString
& aID
);
134 NS_HIDDEN_(nsresult
) ContentShellRemoved(nsIDocShellTreeItem
* aContentShell
);
135 NS_IMETHOD
SizeShellTo(nsIDocShellTreeItem
* aShellItem
, PRInt32 aCX
,
137 NS_IMETHOD
ExitModalLoop(nsresult aStatus
);
138 NS_IMETHOD
CreateNewChromeWindow(PRInt32 aChromeFlags
,
139 nsIAppShell
* aAppShell
, nsIXULWindow
**_retval
);
140 NS_IMETHOD
CreateNewContentWindow(PRInt32 aChromeFlags
,
141 nsIAppShell
* aAppShell
, nsIXULWindow
**_retval
);
143 void EnableParent(PRBool aEnable
);
144 PRBool
ConstrainToZLevel(PRBool aImmediate
, nsWindowZ
*aPlacement
,
145 nsIWidget
*aReqBelow
, nsIWidget
**aActualBelow
);
146 void PlaceWindowLayersBehind(PRUint32 aLowLevel
, PRUint32 aHighLevel
,
147 nsIXULWindow
*aBehind
);
148 void SetContentScrollbarVisibility(PRBool aVisible
);
149 PRBool
GetContentScrollbarVisibility();
150 void PersistentAttributesDirty(PRUint32 aDirtyFlags
);
152 nsChromeTreeOwner
* mChromeTreeOwner
;
153 nsContentTreeOwner
* mContentTreeOwner
;
154 nsContentTreeOwner
* mPrimaryContentTreeOwner
;
155 nsCOMPtr
<nsIWidget
> mWindow
;
156 nsCOMPtr
<nsIDocShell
> mDocShell
;
157 nsCOMPtr
<nsIDOMWindowInternal
> mDOMWindow
;
158 nsCOMPtr
<nsIWeakReference
> mParentWindow
;
159 nsCOMPtr
<nsIPrompt
> mPrompter
;
160 nsCOMPtr
<nsIAuthPrompt
> mAuthPrompter
;
161 nsCOMPtr
<nsIXULBrowserWindow
> mXULBrowserWindow
;
162 nsCOMPtr
<nsIDocShellTreeItem
> mPrimaryContentShell
;
163 nsVoidArray mContentShells
; // array of doc shells by id
164 nsresult mModalStatus
;
165 PRPackedBool mContinueModalLoop
;
166 PRPackedBool mDebuting
; // being made visible right now
167 PRPackedBool mChromeLoaded
; // True when chrome has loaded
168 PRPackedBool mShowAfterLoad
;
169 PRPackedBool mIntrinsicallySized
;
170 PRPackedBool mCenterAfterLoad
;
171 PRPackedBool mIsHiddenWindow
;
172 PRPackedBool mLockedUntilChromeLoad
;
173 PRUint32 mContextFlags
;
174 PRUint32 mBlurSuppressionLevel
;
175 PRUint32 mPersistentAttributesDirty
; // persistentAttributes
176 PRUint32 mPersistentAttributesMask
;
177 PRUint32 mChromeFlags
;
180 nsCOMArray
<nsIWeakReference
> mTargetableShells
; // targetable shells only
183 NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow
, NS_XULWINDOW_IMPL_CID
)
185 // nsContentShellInfo
186 // Used (in an nsVoidArray) to map shell IDs to nsIDocShellTreeItems.
188 class nsContentShellInfo
191 nsContentShellInfo(const nsAString
& aID
,
192 nsIWeakReference
* aContentShell
);
193 ~nsContentShellInfo();
196 nsAutoString id
; // The identifier of the content shell
197 nsWeakPtr child
; // content shell (weak reference to nsIDocShellTreeItem)
200 #endif /* nsXULWindow_h__ */