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