xpfe/appshell/src/nsXULWindow.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5b54cb962723
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef nsXULWindow_h__
8 #define nsXULWindow_h__
9
10 // Local Includes
11 #include "nsChromeTreeOwner.h"
12 #include "nsContentTreeOwner.h"
13
14 // Helper classes
15 #include "nsCOMPtr.h"
16 #include "nsTArray.h"
17 #include "nsString.h"
18 #include "nsWeakReference.h"
19 #include "nsCOMArray.h"
20 #include "nsRect.h"
21
22 // Interfaces needed
23 #include "nsIBaseWindow.h"
24 #include "nsIDocShell.h"
25 #include "nsIDocShellTreeItem.h"
26 #include "nsIDOMWindow.h"
27 #include "nsIInterfaceRequestor.h"
28 #include "nsIInterfaceRequestorUtils.h"
29 #include "nsIXULWindow.h"
30 #include "nsIPrompt.h"
31 #include "nsIAuthPrompt.h"
32 #include "nsIXULBrowserWindow.h"
33 #include "nsIWeakReference.h"
34 #include "nsIWidgetListener.h"
35
36 namespace mozilla {
37 namespace dom {
38 class Element;
39 }
40 }
41
42 // nsXULWindow
43
44 #define NS_XULWINDOW_IMPL_CID \
45 { /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \
46 0x8eaec2f3, \
47 0xed02, \
48 0x4be2, \
49 { 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \
50 }
51
52 class nsContentShellInfo;
53
54 class nsXULWindow : public nsIBaseWindow,
55 public nsIInterfaceRequestor,
56 public nsIXULWindow,
57 public nsSupportsWeakReference
58 {
59 friend class nsChromeTreeOwner;
60 friend class nsContentTreeOwner;
61
62 public:
63 NS_DECL_THREADSAFE_ISUPPORTS
64
65 NS_DECL_NSIINTERFACEREQUESTOR
66 NS_DECL_NSIXULWINDOW
67 NS_DECL_NSIBASEWINDOW
68
69 NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID)
70
71 void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; }
72 bool IsLocked() const { return mLockedUntilChromeLoad; }
73 void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; }
74
75 protected:
76 enum persistentAttributes {
77 PAD_MISC = 0x1,
78 PAD_POSITION = 0x2,
79 PAD_SIZE = 0x4
80 };
81
82 nsXULWindow(uint32_t aChromeFlags);
83 virtual ~nsXULWindow();
84
85 NS_IMETHOD EnsureChromeTreeOwner();
86 NS_IMETHOD EnsureContentTreeOwner();
87 NS_IMETHOD EnsurePrimaryContentTreeOwner();
88 NS_IMETHOD EnsurePrompter();
89 NS_IMETHOD EnsureAuthPrompter();
90
91 void OnChromeLoaded();
92 void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY,
93 int32_t aSpecWidth, int32_t aSpecHeight);
94 bool LoadPositionFromXUL();
95 bool LoadSizeFromXUL();
96 bool LoadMiscPersistentAttributesFromXUL();
97 void SyncAttributesToWidget();
98 NS_IMETHOD SavePersistentAttributes();
99
100 NS_IMETHOD GetWindowDOMWindow(nsIDOMWindow** aDOMWindow);
101 mozilla::dom::Element* GetWindowDOMElement() const;
102
103 // See nsIDocShellTreeOwner for docs on next two methods
104 NS_HIDDEN_(nsresult) ContentShellAdded(nsIDocShellTreeItem* aContentShell,
105 bool aPrimary, bool aTargetable,
106 const nsAString& aID);
107 NS_HIDDEN_(nsresult) ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
108 NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX,
109 int32_t aCY);
110 NS_IMETHOD ExitModalLoop(nsresult aStatus);
111 NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags, nsIXULWindow **_retval);
112 NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags, nsIXULWindow **_retval);
113
114 void EnableParent(bool aEnable);
115 bool ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement,
116 nsIWidget *aReqBelow, nsIWidget **aActualBelow);
117 void PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel,
118 nsIXULWindow *aBehind);
119 void SetContentScrollbarVisibility(bool aVisible);
120 bool GetContentScrollbarVisibility();
121 void PersistentAttributesDirty(uint32_t aDirtyFlags);
122
123 nsChromeTreeOwner* mChromeTreeOwner;
124 nsContentTreeOwner* mContentTreeOwner;
125 nsContentTreeOwner* mPrimaryContentTreeOwner;
126 nsCOMPtr<nsIWidget> mWindow;
127 nsCOMPtr<nsIDocShell> mDocShell;
128 nsCOMPtr<nsIDOMWindow> mDOMWindow;
129 nsCOMPtr<nsIWeakReference> mParentWindow;
130 nsCOMPtr<nsIPrompt> mPrompter;
131 nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
132 nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
133 nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell;
134 nsTArray<nsContentShellInfo*> mContentShells; // array of doc shells by id
135 nsresult mModalStatus;
136 bool mContinueModalLoop;
137 bool mDebuting; // being made visible right now
138 bool mChromeLoaded; // True when chrome has loaded
139 bool mShowAfterLoad;
140 bool mIntrinsicallySized;
141 bool mCenterAfterLoad;
142 bool mIsHiddenWindow;
143 bool mLockedUntilChromeLoad;
144 bool mIgnoreXULSize;
145 bool mIgnoreXULPosition;
146 bool mChromeFlagsFrozen;
147 bool mIgnoreXULSizeMode;
148 // mDestroying is used to prevent reentry into into Destroy(), which can
149 // otherwise happen due to script running as we tear down various things.
150 bool mDestroying;
151 uint32_t mContextFlags;
152 uint32_t mPersistentAttributesDirty; // persistentAttributes
153 uint32_t mPersistentAttributesMask;
154 uint32_t mChromeFlags;
155 nsString mTitle;
156 nsIntRect mOpenerScreenRect; // the screen rect of the opener
157
158 nsCOMArray<nsIWeakReference> mTargetableShells; // targetable shells only
159 };
160
161 NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID)
162
163 // nsContentShellInfo
164 // Used to map shell IDs to nsIDocShellTreeItems.
165
166 class nsContentShellInfo
167 {
168 public:
169 nsContentShellInfo(const nsAString& aID,
170 nsIWeakReference* aContentShell);
171 ~nsContentShellInfo();
172
173 public:
174 nsAutoString id; // The identifier of the content shell
175 nsWeakPtr child; // content shell (weak reference to nsIDocShellTreeItem)
176 };
177
178 #endif /* nsXULWindow_h__ */

mercurial