1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : *
3 : * ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
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/
10 : *
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
14 : * License.
15 : *
16 : * The Original Code is the Mozilla browser.
17 : *
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.
22 : *
23 : * Contributor(s):
24 : * Travis Bogard <travis@netscape.com>
25 : *
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.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef nsXULWindow_h__
41 : #define nsXULWindow_h__
42 :
43 : // Local Includes
44 : #include "nsChromeTreeOwner.h"
45 : #include "nsContentTreeOwner.h"
46 :
47 : // Helper classes
48 : #include "nsCOMPtr.h"
49 : #include "nsTArray.h"
50 : #include "nsString.h"
51 : #include "nsWeakReference.h"
52 : #include "nsCOMArray.h"
53 :
54 : // Interfaces needed
55 : #include "nsIBaseWindow.h"
56 : #include "nsIDocShell.h"
57 : #include "nsIDocShellTreeItem.h"
58 : #include "nsIDOMWindow.h"
59 : #include "nsIInterfaceRequestor.h"
60 : #include "nsIInterfaceRequestorUtils.h"
61 : #include "nsIXULWindow.h"
62 : #include "nsIPrompt.h"
63 : #include "nsIAuthPrompt.h"
64 : #include "nsGUIEvent.h"
65 : #include "nsIXULBrowserWindow.h"
66 : #include "nsIWeakReference.h"
67 :
68 : // nsXULWindow
69 :
70 : #define NS_XULWINDOW_IMPL_CID \
71 : { /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \
72 : 0x8eaec2f3, \
73 : 0xed02, \
74 : 0x4be2, \
75 : { 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \
76 : }
77 :
78 : class nsContentShellInfo;
79 :
80 : class nsXULWindow : public nsIBaseWindow,
81 : public nsIInterfaceRequestor,
82 : public nsIXULWindow,
83 : public nsSupportsWeakReference
84 : {
85 : friend class nsChromeTreeOwner;
86 : friend class nsContentTreeOwner;
87 :
88 : public:
89 : NS_DECL_ISUPPORTS
90 :
91 : NS_DECL_NSIINTERFACEREQUESTOR
92 : NS_DECL_NSIXULWINDOW
93 : NS_DECL_NSIBASEWINDOW
94 :
95 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID)
96 :
97 0 : void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; }
98 0 : bool IsLocked() const { return mLockedUntilChromeLoad; }
99 : void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; }
100 :
101 : protected:
102 : enum persistentAttributes {
103 : PAD_MISC = 0x1,
104 : PAD_POSITION = 0x2,
105 : PAD_SIZE = 0x4
106 : };
107 :
108 : nsXULWindow(PRUint32 aChromeFlags);
109 : virtual ~nsXULWindow();
110 :
111 : NS_IMETHOD EnsureChromeTreeOwner();
112 : NS_IMETHOD EnsureContentTreeOwner();
113 : NS_IMETHOD EnsurePrimaryContentTreeOwner();
114 : NS_IMETHOD EnsurePrompter();
115 : NS_IMETHOD EnsureAuthPrompter();
116 :
117 : void OnChromeLoaded();
118 : void StaggerPosition(PRInt32 &aRequestedX, PRInt32 &aRequestedY,
119 : PRInt32 aSpecWidth, PRInt32 aSpecHeight);
120 : bool LoadPositionFromXUL();
121 : bool LoadSizeFromXUL();
122 : bool LoadMiscPersistentAttributesFromXUL();
123 : void SyncAttributesToWidget();
124 : NS_IMETHOD SavePersistentAttributes();
125 :
126 : NS_IMETHOD GetWindowDOMWindow(nsIDOMWindow** aDOMWindow);
127 : NS_IMETHOD GetWindowDOMElement(nsIDOMElement** aDOMElement);
128 :
129 : // See nsIDocShellTreeOwner for docs on next two methods
130 : NS_HIDDEN_(nsresult) ContentShellAdded(nsIDocShellTreeItem* aContentShell,
131 : bool aPrimary, bool aTargetable,
132 : const nsAString& aID);
133 : NS_HIDDEN_(nsresult) ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
134 : NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, PRInt32 aCX,
135 : PRInt32 aCY);
136 : NS_IMETHOD ExitModalLoop(nsresult aStatus);
137 : NS_IMETHOD CreateNewChromeWindow(PRInt32 aChromeFlags, nsIXULWindow **_retval);
138 : NS_IMETHOD CreateNewContentWindow(PRInt32 aChromeFlags, nsIXULWindow **_retval);
139 :
140 : void EnableParent(bool aEnable);
141 : bool ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement,
142 : nsIWidget *aReqBelow, nsIWidget **aActualBelow);
143 : void PlaceWindowLayersBehind(PRUint32 aLowLevel, PRUint32 aHighLevel,
144 : nsIXULWindow *aBehind);
145 : void SetContentScrollbarVisibility(bool aVisible);
146 : bool GetContentScrollbarVisibility();
147 : void PersistentAttributesDirty(PRUint32 aDirtyFlags);
148 : PRUint32 AppUnitsPerDevPixel();
149 :
150 : nsChromeTreeOwner* mChromeTreeOwner;
151 : nsContentTreeOwner* mContentTreeOwner;
152 : nsContentTreeOwner* mPrimaryContentTreeOwner;
153 : nsCOMPtr<nsIWidget> mWindow;
154 : nsCOMPtr<nsIDocShell> mDocShell;
155 : nsCOMPtr<nsIDOMWindow> mDOMWindow;
156 : nsCOMPtr<nsIWeakReference> mParentWindow;
157 : nsCOMPtr<nsIPrompt> mPrompter;
158 : nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
159 : nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
160 : nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell;
161 : nsTArray<nsContentShellInfo*> mContentShells; // array of doc shells by id
162 : nsresult mModalStatus;
163 : bool mContinueModalLoop;
164 : bool mDebuting; // being made visible right now
165 : bool mChromeLoaded; // True when chrome has loaded
166 : bool mShowAfterLoad;
167 : bool mIntrinsicallySized;
168 : bool mCenterAfterLoad;
169 : bool mIsHiddenWindow;
170 : bool mLockedUntilChromeLoad;
171 : bool mIgnoreXULSize;
172 : bool mIgnoreXULPosition;
173 : bool mChromeFlagsFrozen;
174 : bool mIgnoreXULSizeMode;
175 : PRUint32 mContextFlags;
176 : PRUint32 mPersistentAttributesDirty; // persistentAttributes
177 : PRUint32 mPersistentAttributesMask;
178 : PRUint32 mChromeFlags;
179 : PRUint32 mAppPerDev; // sometimes needed when we can't get
180 : // it from the widget
181 : nsString mTitle;
182 : nsIntRect mOpenerScreenRect; // the screen rect of the opener
183 :
184 : nsCOMArray<nsIWeakReference> mTargetableShells; // targetable shells only
185 : };
186 :
187 : NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID)
188 :
189 : // nsContentShellInfo
190 : // Used to map shell IDs to nsIDocShellTreeItems.
191 :
192 : class nsContentShellInfo
193 : {
194 : public:
195 : nsContentShellInfo(const nsAString& aID,
196 : nsIWeakReference* aContentShell);
197 : ~nsContentShellInfo();
198 :
199 : public:
200 : nsAutoString id; // The identifier of the content shell
201 : nsWeakPtr child; // content shell (weak reference to nsIDocShellTreeItem)
202 : };
203 :
204 : #endif /* nsXULWindow_h__ */
|