1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpfe/appshell/src/nsXULWindow.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,178 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsXULWindow_h__ 1.11 +#define nsXULWindow_h__ 1.12 + 1.13 +// Local Includes 1.14 +#include "nsChromeTreeOwner.h" 1.15 +#include "nsContentTreeOwner.h" 1.16 + 1.17 +// Helper classes 1.18 +#include "nsCOMPtr.h" 1.19 +#include "nsTArray.h" 1.20 +#include "nsString.h" 1.21 +#include "nsWeakReference.h" 1.22 +#include "nsCOMArray.h" 1.23 +#include "nsRect.h" 1.24 + 1.25 +// Interfaces needed 1.26 +#include "nsIBaseWindow.h" 1.27 +#include "nsIDocShell.h" 1.28 +#include "nsIDocShellTreeItem.h" 1.29 +#include "nsIDOMWindow.h" 1.30 +#include "nsIInterfaceRequestor.h" 1.31 +#include "nsIInterfaceRequestorUtils.h" 1.32 +#include "nsIXULWindow.h" 1.33 +#include "nsIPrompt.h" 1.34 +#include "nsIAuthPrompt.h" 1.35 +#include "nsIXULBrowserWindow.h" 1.36 +#include "nsIWeakReference.h" 1.37 +#include "nsIWidgetListener.h" 1.38 + 1.39 +namespace mozilla { 1.40 +namespace dom { 1.41 +class Element; 1.42 +} 1.43 +} 1.44 + 1.45 +// nsXULWindow 1.46 + 1.47 +#define NS_XULWINDOW_IMPL_CID \ 1.48 +{ /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \ 1.49 + 0x8eaec2f3, \ 1.50 + 0xed02, \ 1.51 + 0x4be2, \ 1.52 + { 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \ 1.53 +} 1.54 + 1.55 +class nsContentShellInfo; 1.56 + 1.57 +class nsXULWindow : public nsIBaseWindow, 1.58 + public nsIInterfaceRequestor, 1.59 + public nsIXULWindow, 1.60 + public nsSupportsWeakReference 1.61 +{ 1.62 +friend class nsChromeTreeOwner; 1.63 +friend class nsContentTreeOwner; 1.64 + 1.65 +public: 1.66 + NS_DECL_THREADSAFE_ISUPPORTS 1.67 + 1.68 + NS_DECL_NSIINTERFACEREQUESTOR 1.69 + NS_DECL_NSIXULWINDOW 1.70 + NS_DECL_NSIBASEWINDOW 1.71 + 1.72 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID) 1.73 + 1.74 + void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; } 1.75 + bool IsLocked() const { return mLockedUntilChromeLoad; } 1.76 + void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; } 1.77 + 1.78 +protected: 1.79 + enum persistentAttributes { 1.80 + PAD_MISC = 0x1, 1.81 + PAD_POSITION = 0x2, 1.82 + PAD_SIZE = 0x4 1.83 + }; 1.84 + 1.85 + nsXULWindow(uint32_t aChromeFlags); 1.86 + virtual ~nsXULWindow(); 1.87 + 1.88 + NS_IMETHOD EnsureChromeTreeOwner(); 1.89 + NS_IMETHOD EnsureContentTreeOwner(); 1.90 + NS_IMETHOD EnsurePrimaryContentTreeOwner(); 1.91 + NS_IMETHOD EnsurePrompter(); 1.92 + NS_IMETHOD EnsureAuthPrompter(); 1.93 + 1.94 + void OnChromeLoaded(); 1.95 + void StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY, 1.96 + int32_t aSpecWidth, int32_t aSpecHeight); 1.97 + bool LoadPositionFromXUL(); 1.98 + bool LoadSizeFromXUL(); 1.99 + bool LoadMiscPersistentAttributesFromXUL(); 1.100 + void SyncAttributesToWidget(); 1.101 + NS_IMETHOD SavePersistentAttributes(); 1.102 + 1.103 + NS_IMETHOD GetWindowDOMWindow(nsIDOMWindow** aDOMWindow); 1.104 + mozilla::dom::Element* GetWindowDOMElement() const; 1.105 + 1.106 + // See nsIDocShellTreeOwner for docs on next two methods 1.107 + NS_HIDDEN_(nsresult) ContentShellAdded(nsIDocShellTreeItem* aContentShell, 1.108 + bool aPrimary, bool aTargetable, 1.109 + const nsAString& aID); 1.110 + NS_HIDDEN_(nsresult) ContentShellRemoved(nsIDocShellTreeItem* aContentShell); 1.111 + NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, 1.112 + int32_t aCY); 1.113 + NS_IMETHOD ExitModalLoop(nsresult aStatus); 1.114 + NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags, nsIXULWindow **_retval); 1.115 + NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags, nsIXULWindow **_retval); 1.116 + 1.117 + void EnableParent(bool aEnable); 1.118 + bool ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement, 1.119 + nsIWidget *aReqBelow, nsIWidget **aActualBelow); 1.120 + void PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, 1.121 + nsIXULWindow *aBehind); 1.122 + void SetContentScrollbarVisibility(bool aVisible); 1.123 + bool GetContentScrollbarVisibility(); 1.124 + void PersistentAttributesDirty(uint32_t aDirtyFlags); 1.125 + 1.126 + nsChromeTreeOwner* mChromeTreeOwner; 1.127 + nsContentTreeOwner* mContentTreeOwner; 1.128 + nsContentTreeOwner* mPrimaryContentTreeOwner; 1.129 + nsCOMPtr<nsIWidget> mWindow; 1.130 + nsCOMPtr<nsIDocShell> mDocShell; 1.131 + nsCOMPtr<nsIDOMWindow> mDOMWindow; 1.132 + nsCOMPtr<nsIWeakReference> mParentWindow; 1.133 + nsCOMPtr<nsIPrompt> mPrompter; 1.134 + nsCOMPtr<nsIAuthPrompt> mAuthPrompter; 1.135 + nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow; 1.136 + nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell; 1.137 + nsTArray<nsContentShellInfo*> mContentShells; // array of doc shells by id 1.138 + nsresult mModalStatus; 1.139 + bool mContinueModalLoop; 1.140 + bool mDebuting; // being made visible right now 1.141 + bool mChromeLoaded; // True when chrome has loaded 1.142 + bool mShowAfterLoad; 1.143 + bool mIntrinsicallySized; 1.144 + bool mCenterAfterLoad; 1.145 + bool mIsHiddenWindow; 1.146 + bool mLockedUntilChromeLoad; 1.147 + bool mIgnoreXULSize; 1.148 + bool mIgnoreXULPosition; 1.149 + bool mChromeFlagsFrozen; 1.150 + bool mIgnoreXULSizeMode; 1.151 + // mDestroying is used to prevent reentry into into Destroy(), which can 1.152 + // otherwise happen due to script running as we tear down various things. 1.153 + bool mDestroying; 1.154 + uint32_t mContextFlags; 1.155 + uint32_t mPersistentAttributesDirty; // persistentAttributes 1.156 + uint32_t mPersistentAttributesMask; 1.157 + uint32_t mChromeFlags; 1.158 + nsString mTitle; 1.159 + nsIntRect mOpenerScreenRect; // the screen rect of the opener 1.160 + 1.161 + nsCOMArray<nsIWeakReference> mTargetableShells; // targetable shells only 1.162 +}; 1.163 + 1.164 +NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID) 1.165 + 1.166 +// nsContentShellInfo 1.167 +// Used to map shell IDs to nsIDocShellTreeItems. 1.168 + 1.169 +class nsContentShellInfo 1.170 +{ 1.171 +public: 1.172 + nsContentShellInfo(const nsAString& aID, 1.173 + nsIWeakReference* aContentShell); 1.174 + ~nsContentShellInfo(); 1.175 + 1.176 +public: 1.177 + nsAutoString id; // The identifier of the content shell 1.178 + nsWeakPtr child; // content shell (weak reference to nsIDocShellTreeItem) 1.179 +}; 1.180 + 1.181 +#endif /* nsXULWindow_h__ */