Line data Source code
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 :
38 : namespace mozilla {
39 : namespace dom {
40 : class Element;
41 : } // namespace dom
42 : } // namespace mozilla
43 :
44 : // nsXULWindow
45 :
46 : #define NS_XULWINDOW_IMPL_CID \
47 : { /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \
48 : 0x8eaec2f3, \
49 : 0xed02, \
50 : 0x4be2, \
51 : { 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \
52 : }
53 :
54 : class nsContentShellInfo;
55 :
56 : class nsXULWindow : public nsIBaseWindow,
57 : public nsIInterfaceRequestor,
58 : public nsIXULWindow,
59 : public nsSupportsWeakReference
60 : {
61 : friend class nsChromeTreeOwner;
62 : friend class nsContentTreeOwner;
63 :
64 : public:
65 : NS_DECL_THREADSAFE_ISUPPORTS
66 :
67 : NS_DECL_NSIINTERFACEREQUESTOR
68 : NS_DECL_NSIXULWINDOW
69 : NS_DECL_NSIBASEWINDOW
70 :
71 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID)
72 :
73 0 : void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; }
74 2 : bool IsLocked() const { return mLockedUntilChromeLoad; }
75 : void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; }
76 1 : void WasRegistered() { mRegistered = true; }
77 :
78 : protected:
79 : enum persistentAttributes {
80 : PAD_MISC = 0x1,
81 : PAD_POSITION = 0x2,
82 : PAD_SIZE = 0x4
83 : };
84 :
85 : explicit nsXULWindow(uint32_t aChromeFlags);
86 : virtual ~nsXULWindow();
87 :
88 : NS_IMETHOD EnsureChromeTreeOwner();
89 : NS_IMETHOD EnsureContentTreeOwner();
90 : NS_IMETHOD EnsurePrimaryContentTreeOwner();
91 : NS_IMETHOD EnsurePrompter();
92 : NS_IMETHOD EnsureAuthPrompter();
93 : NS_IMETHOD ForceRoundedDimensions();
94 : NS_IMETHOD GetAvailScreenSize(int32_t* aAvailWidth, int32_t* aAvailHeight);
95 :
96 : void OnChromeLoaded();
97 : void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY,
98 : int32_t aSpecWidth, int32_t aSpecHeight);
99 : bool LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight);
100 : bool LoadSizeFromXUL(int32_t& aSpecWidth, int32_t& aSpecHeight);
101 : void SetSpecifiedSize(int32_t aSpecWidth, int32_t aSpecHeight);
102 : bool LoadMiscPersistentAttributesFromXUL();
103 : void SyncAttributesToWidget();
104 : NS_IMETHOD SavePersistentAttributes();
105 :
106 : NS_IMETHOD GetWindowDOMWindow(mozIDOMWindowProxy** aDOMWindow);
107 : mozilla::dom::Element* GetWindowDOMElement() const;
108 :
109 : // See nsIDocShellTreeOwner for docs on next two methods
110 : nsresult ContentShellAdded(nsIDocShellTreeItem* aContentShell,
111 : bool aPrimary);
112 : nsresult ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
113 : NS_IMETHOD GetPrimaryContentSize(int32_t* aWidth,
114 : int32_t* aHeight);
115 : NS_IMETHOD SetPrimaryContentSize(int32_t aWidth,
116 : int32_t aHeight);
117 : nsresult GetRootShellSize(int32_t* aWidth,
118 : int32_t* aHeight);
119 : nsresult SetRootShellSize(int32_t aWidth,
120 : int32_t aHeight);
121 :
122 : NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX,
123 : int32_t aCY);
124 : NS_IMETHOD ExitModalLoop(nsresult aStatus);
125 : NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags, nsITabParent* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, nsIXULWindow **_retval);
126 : NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags,
127 : nsITabParent* aOpeningTab,
128 : mozIDOMWindowProxy* aOpenerWindow,
129 : uint64_t aNextTabParentId,
130 : nsIXULWindow **_retval);
131 : NS_IMETHOD GetHasPrimaryContent(bool* aResult);
132 :
133 : void EnableParent(bool aEnable);
134 : bool ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement,
135 : nsIWidget *aReqBelow, nsIWidget **aActualBelow);
136 : void PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel,
137 : nsIXULWindow *aBehind);
138 : void SetContentScrollbarVisibility(bool aVisible);
139 : bool GetContentScrollbarVisibility();
140 : void PersistentAttributesDirty(uint32_t aDirtyFlags);
141 : nsresult GetTabCount(uint32_t* aResult);
142 :
143 : nsChromeTreeOwner* mChromeTreeOwner;
144 : nsContentTreeOwner* mContentTreeOwner;
145 : nsContentTreeOwner* mPrimaryContentTreeOwner;
146 : nsCOMPtr<nsIWidget> mWindow;
147 : nsCOMPtr<nsIDocShell> mDocShell;
148 : nsCOMPtr<nsPIDOMWindowOuter> mDOMWindow;
149 : nsCOMPtr<nsIWeakReference> mParentWindow;
150 : nsCOMPtr<nsIPrompt> mPrompter;
151 : nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
152 : nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
153 : nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell;
154 : nsresult mModalStatus;
155 : bool mContinueModalLoop;
156 : bool mDebuting; // being made visible right now
157 : bool mChromeLoaded; // True when chrome has loaded
158 : bool mShowAfterLoad;
159 : bool mIntrinsicallySized;
160 : bool mCenterAfterLoad;
161 : bool mIsHiddenWindow;
162 : bool mLockedUntilChromeLoad;
163 : bool mIgnoreXULSize;
164 : bool mIgnoreXULPosition;
165 : bool mChromeFlagsFrozen;
166 : bool mIgnoreXULSizeMode;
167 : // mDestroying is used to prevent reentry into into Destroy(), which can
168 : // otherwise happen due to script running as we tear down various things.
169 : bool mDestroying;
170 : bool mRegistered;
171 : uint32_t mPersistentAttributesDirty; // persistentAttributes
172 : uint32_t mPersistentAttributesMask;
173 : uint32_t mChromeFlags;
174 : uint64_t mNextTabParentId;
175 : nsString mTitle;
176 : nsIntRect mOpenerScreenRect; // the screen rect of the opener
177 :
178 : nsCOMPtr<nsITabParent> mPrimaryTabParent;
179 : private:
180 : nsresult GetPrimaryTabParentSize(int32_t* aWidth, int32_t* aHeight);
181 : nsresult GetPrimaryContentShellSize(int32_t* aWidth, int32_t* aHeight);
182 : nsresult SetPrimaryTabParentSize(int32_t aWidth, int32_t aHeight);
183 : };
184 :
185 : NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID)
186 : #endif /* nsXULWindow_h__ */
|