/src/mozilla-central/xpfe/appshell/nsXULWindow.h
Line | Count | Source (jump to first uncovered line) |
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 | | #include "Units.h" |
22 | | |
23 | | // Interfaces needed |
24 | | #include "nsIBaseWindow.h" |
25 | | #include "nsIDocShell.h" |
26 | | #include "nsIDocShellTreeItem.h" |
27 | | #include "nsIDOMWindow.h" |
28 | | #include "nsIInterfaceRequestor.h" |
29 | | #include "nsIInterfaceRequestorUtils.h" |
30 | | #include "nsIXULWindow.h" |
31 | | #include "nsIPrompt.h" |
32 | | #include "nsIAuthPrompt.h" |
33 | | #include "nsIXULBrowserWindow.h" |
34 | | #include "nsIWeakReference.h" |
35 | | #include "nsIWidgetListener.h" |
36 | | #include "nsITabParent.h" |
37 | | #include "nsIXULStore.h" |
38 | | |
39 | | namespace mozilla { |
40 | | namespace dom { |
41 | | class Element; |
42 | | } // namespace dom |
43 | | } // namespace mozilla |
44 | | |
45 | | class nsAtom; |
46 | | class nsXULTooltipListener; |
47 | | |
48 | | // nsXULWindow |
49 | | |
50 | | #define NS_XULWINDOW_IMPL_CID \ |
51 | | { /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \ |
52 | | 0x8eaec2f3, \ |
53 | | 0xed02, \ |
54 | | 0x4be2, \ |
55 | | { 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \ |
56 | | } |
57 | | |
58 | | class nsContentShellInfo; |
59 | | |
60 | | class nsXULWindow : public nsIBaseWindow, |
61 | | public nsIInterfaceRequestor, |
62 | | public nsIXULWindow, |
63 | | public nsSupportsWeakReference |
64 | | { |
65 | | friend class nsChromeTreeOwner; |
66 | | friend class nsContentTreeOwner; |
67 | | |
68 | | public: |
69 | | NS_DECL_THREADSAFE_ISUPPORTS |
70 | | |
71 | | NS_DECL_NSIINTERFACEREQUESTOR |
72 | | NS_DECL_NSIXULWINDOW |
73 | | NS_DECL_NSIBASEWINDOW |
74 | | |
75 | | NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID) |
76 | | |
77 | 0 | void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; } |
78 | 0 | bool IsLocked() const { return mLockedUntilChromeLoad; } |
79 | 0 | void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; } |
80 | 0 | void WasRegistered() { mRegistered = true; } |
81 | | |
82 | | protected: |
83 | | enum persistentAttributes { |
84 | | PAD_MISC = 0x1, |
85 | | PAD_POSITION = 0x2, |
86 | | PAD_SIZE = 0x4 |
87 | | }; |
88 | | |
89 | | explicit nsXULWindow(uint32_t aChromeFlags); |
90 | | virtual ~nsXULWindow(); |
91 | | |
92 | | NS_IMETHOD EnsureChromeTreeOwner(); |
93 | | NS_IMETHOD EnsureContentTreeOwner(); |
94 | | NS_IMETHOD EnsurePrimaryContentTreeOwner(); |
95 | | NS_IMETHOD EnsurePrompter(); |
96 | | NS_IMETHOD EnsureAuthPrompter(); |
97 | | NS_IMETHOD ForceRoundedDimensions(); |
98 | | NS_IMETHOD GetAvailScreenSize(int32_t* aAvailWidth, int32_t* aAvailHeight); |
99 | | |
100 | | void ApplyChromeFlags(); |
101 | | void SizeShell(); |
102 | | void OnChromeLoaded(); |
103 | | void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY, |
104 | | int32_t aSpecWidth, int32_t aSpecHeight); |
105 | | bool LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight); |
106 | | bool LoadSizeFromXUL(int32_t& aSpecWidth, int32_t& aSpecHeight); |
107 | | void SetSpecifiedSize(int32_t aSpecWidth, int32_t aSpecHeight); |
108 | | bool UpdateWindowStateFromMiscXULAttributes(); |
109 | | void SyncAttributesToWidget(); |
110 | | NS_IMETHOD SavePersistentAttributes(); |
111 | | |
112 | | bool NeedsTooltipListener(); |
113 | | void AddTooltipSupport(); |
114 | | void RemoveTooltipSupport(); |
115 | | |
116 | | NS_IMETHOD GetWindowDOMWindow(mozIDOMWindowProxy** aDOMWindow); |
117 | | mozilla::dom::Element* GetWindowDOMElement() const; |
118 | | |
119 | | // See nsIDocShellTreeOwner for docs on next two methods |
120 | | nsresult ContentShellAdded(nsIDocShellTreeItem* aContentShell, |
121 | | bool aPrimary); |
122 | | nsresult ContentShellRemoved(nsIDocShellTreeItem* aContentShell); |
123 | | NS_IMETHOD GetPrimaryContentSize(int32_t* aWidth, |
124 | | int32_t* aHeight); |
125 | | NS_IMETHOD SetPrimaryContentSize(int32_t aWidth, |
126 | | int32_t aHeight); |
127 | | nsresult GetRootShellSize(int32_t* aWidth, |
128 | | int32_t* aHeight); |
129 | | nsresult SetRootShellSize(int32_t aWidth, |
130 | | int32_t aHeight); |
131 | | |
132 | | NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, |
133 | | int32_t aCY); |
134 | | NS_IMETHOD ExitModalLoop(nsresult aStatus); |
135 | | NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags, nsITabParent* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, nsIXULWindow **_retval); |
136 | | NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags, |
137 | | nsITabParent* aOpeningTab, |
138 | | mozIDOMWindowProxy* aOpenerWindow, |
139 | | uint64_t aNextTabParentId, |
140 | | nsIXULWindow **_retval); |
141 | | NS_IMETHOD GetHasPrimaryContent(bool* aResult); |
142 | | |
143 | | void EnableParent(bool aEnable); |
144 | | bool ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement, |
145 | | nsIWidget *aReqBelow, nsIWidget **aActualBelow); |
146 | | void PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, |
147 | | nsIXULWindow *aBehind); |
148 | | void SetContentScrollbarVisibility(bool aVisible); |
149 | | bool GetContentScrollbarVisibility(); |
150 | | void PersistentAttributesDirty(uint32_t aDirtyFlags); |
151 | | nsresult GetTabCount(uint32_t* aResult); |
152 | | |
153 | | void LoadPersistentWindowState(); |
154 | | nsresult GetPersistentValue(const nsAtom* aAttr, |
155 | | nsAString& aValue); |
156 | | nsresult SetPersistentValue(const nsAtom* aAttr, |
157 | | const nsAString& aValue); |
158 | | |
159 | | nsChromeTreeOwner* mChromeTreeOwner; |
160 | | nsContentTreeOwner* mContentTreeOwner; |
161 | | nsContentTreeOwner* mPrimaryContentTreeOwner; |
162 | | nsCOMPtr<nsIWidget> mWindow; |
163 | | nsCOMPtr<nsIDocShell> mDocShell; |
164 | | nsCOMPtr<nsPIDOMWindowOuter> mDOMWindow; |
165 | | nsCOMPtr<nsIWeakReference> mParentWindow; |
166 | | nsCOMPtr<nsIPrompt> mPrompter; |
167 | | nsCOMPtr<nsIAuthPrompt> mAuthPrompter; |
168 | | nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow; |
169 | | nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell; |
170 | | nsresult mModalStatus; |
171 | | bool mContinueModalLoop; |
172 | | bool mDebuting; // being made visible right now |
173 | | bool mChromeLoaded; // True when chrome has loaded |
174 | | bool mSizingShellFromXUL; // true when in SizeShell() |
175 | | bool mShowAfterLoad; |
176 | | bool mIntrinsicallySized; |
177 | | bool mCenterAfterLoad; |
178 | | bool mIsHiddenWindow; |
179 | | bool mLockedUntilChromeLoad; |
180 | | bool mIgnoreXULSize; |
181 | | bool mIgnoreXULPosition; |
182 | | bool mChromeFlagsFrozen; |
183 | | bool mIgnoreXULSizeMode; |
184 | | // mDestroying is used to prevent reentry into into Destroy(), which can |
185 | | // otherwise happen due to script running as we tear down various things. |
186 | | bool mDestroying; |
187 | | bool mRegistered; |
188 | | uint32_t mPersistentAttributesDirty; // persistentAttributes |
189 | | uint32_t mPersistentAttributesMask; |
190 | | uint32_t mChromeFlags; |
191 | | uint64_t mNextTabParentId; |
192 | | nsString mTitle; |
193 | | nsIntRect mOpenerScreenRect; // the screen rect of the opener |
194 | | |
195 | | nsCOMPtr<nsITabParent> mPrimaryTabParent; |
196 | | private: |
197 | | // GetPrimaryTabParentSize is called from xpidl methods and we don't have a |
198 | | // good way to annotate those with MOZ_CAN_RUN_SCRIPT yet. It takes no |
199 | | // refcounted args other than "this", and the "this" uses seem ok. |
200 | | MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult GetPrimaryTabParentSize(int32_t* aWidth, int32_t* aHeight); |
201 | | nsresult GetPrimaryContentShellSize(int32_t* aWidth, int32_t* aHeight); |
202 | | nsresult SetPrimaryTabParentSize(int32_t aWidth, int32_t aHeight); |
203 | | nsCOMPtr<nsIXULStore> mLocalStore; |
204 | | }; |
205 | | |
206 | | NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID) |
207 | | #endif /* nsXULWindow_h__ */ |