Back to index

lightning-sunbird  0.9+nobinonly
nsXULWindow.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Travis Bogard <travis@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef nsXULWindow_h__
00041 #define nsXULWindow_h__
00042 
00043 // Local Includes
00044 #include "nsChromeTreeOwner.h"
00045 #include "nsContentTreeOwner.h"
00046 
00047 // Helper classes
00048 #include "nsCOMPtr.h"
00049 #include "nsVoidArray.h"
00050 #include "nsString.h"
00051 #include "nsWeakReference.h"
00052 #include "nsCOMArray.h"
00053 
00054 // Interfaces needed
00055 #include "nsIBaseWindow.h"
00056 #include "nsIDocShell.h"
00057 #include "nsIDocShellTreeItem.h"
00058 #include "nsIDOMWindowInternal.h"
00059 #include "nsIEventQueueService.h"
00060 #include "nsIInterfaceRequestor.h"
00061 #include "nsIInterfaceRequestorUtils.h"
00062 #include "nsIWidget.h"
00063 #include "nsIXULWindow.h"
00064 #include "nsIPrompt.h"
00065 #include "nsIAuthPrompt.h"
00066 #include "nsGUIEvent.h"
00067 #include "nsIXULBrowserWindow.h"
00068 #include "nsIWeakReference.h"
00069 
00070 // nsXULWindow
00071 
00072 #define NS_XULWINDOW_IMPL_CID                         \
00073 { /* 2a38ef7e-3174-44ad-a785-b5a863cf5588 */          \
00074      0x2a38ef7e,                                      \
00075      0x3174,                                          \
00076      0x44ad,                                          \
00077    { 0xa7, 0x85, 0xb5, 0xa8, 0x63, 0xcf, 0x55, 0x88 } \
00078 }
00079 
00080 class nsXULWindow : public nsIBaseWindow,
00081                     public nsIInterfaceRequestor,
00082                     public nsIXULWindow,
00083                     public nsSupportsWeakReference
00084 {
00085 friend class nsChromeTreeOwner;
00086 friend class nsContentTreeOwner;
00087 
00088 public:
00089    NS_DECL_ISUPPORTS
00090 
00091    NS_DECL_NSIINTERFACEREQUESTOR
00092    NS_DECL_NSIXULWINDOW
00093    NS_DECL_NSIBASEWINDOW
00094 
00095    NS_DEFINE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID)
00096 
00097    void LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; }
00098    PRBool IsLocked() const { return mLockedUntilChromeLoad; }
00099 
00100 protected:
00101    enum persistentAttributes {
00102      PAD_MISC =         0x1,
00103      PAD_POSITION =     0x2,
00104      PAD_SIZE =         0x4
00105    };
00106 
00107    nsXULWindow();
00108    virtual ~nsXULWindow();
00109 
00110    NS_IMETHOD EnsureChromeTreeOwner();
00111    NS_IMETHOD EnsureContentTreeOwner();
00112    NS_IMETHOD EnsurePrimaryContentTreeOwner();
00113    NS_IMETHOD EnsurePrompter();
00114    NS_IMETHOD EnsureAuthPrompter();
00115    
00116    void OnChromeLoaded();
00117    void StaggerPosition(PRInt32 &aRequestedX, PRInt32 &aRequestedY,
00118                         PRInt32 aSpecWidth, PRInt32 aSpecHeight);
00119    PRBool     LoadPositionFromXUL();
00120    PRBool     LoadSizeFromXUL();
00121    PRBool     LoadMiscPersistentAttributesFromXUL();
00122    nsresult   LoadChromeHidingFromXUL();
00123    NS_IMETHOD LoadWindowClassFromXUL();
00124    NS_IMETHOD LoadIconFromXUL();
00125    NS_IMETHOD SavePersistentAttributes();
00126 
00127    NS_IMETHOD GetWindowDOMWindow(nsIDOMWindowInternal** aDOMWindow);
00128    NS_IMETHOD GetWindowDOMElement(nsIDOMElement** aDOMElement);
00129    NS_IMETHOD GetDOMElementById(char* aID, nsIDOMElement** aDOMElement);
00130 
00131   // See nsIDocShellTreeOwner_MOZILLA_1_8_BRANCH for docs on next two methods
00132    NS_HIDDEN_(nsresult) ContentShellAdded(nsIDocShellTreeItem* aContentShell,
00133                                           PRBool aPrimary, PRBool aTargetable,
00134                                           const nsAString& aID);
00135    NS_HIDDEN_(nsresult) ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
00136    NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, PRInt32 aCX, 
00137       PRInt32 aCY);
00138    NS_IMETHOD ExitModalLoop(nsresult aStatus);
00139    NS_IMETHOD CreateNewChromeWindow(PRInt32 aChromeFlags,
00140       nsIAppShell* aAppShell, nsIXULWindow **_retval);
00141    NS_IMETHOD CreateNewContentWindow(PRInt32 aChromeFlags,
00142       nsIAppShell* aAppShell, nsIXULWindow **_retval);
00143 
00144    void       EnableParent(PRBool aEnable);
00145    PRBool     ConstrainToZLevel(PRBool aImmediate, nsWindowZ *aPlacement,
00146                                 nsIWidget *aReqBelow, nsIWidget **aActualBelow);
00147    void       PlaceWindowLayersBehind(PRUint32 aLowLevel, PRUint32 aHighLevel,
00148                                       nsIXULWindow *aBehind);
00149    void       SetContentScrollbarVisibility(PRBool aVisible);
00150    PRBool     GetContentScrollbarVisibility();
00151    void       PersistentAttributesDirty(PRUint32 aDirtyFlags);
00152    nsresult   ApplyChromeFlags();
00153 
00154    nsChromeTreeOwner*      mChromeTreeOwner;
00155    nsContentTreeOwner*     mContentTreeOwner;
00156    nsContentTreeOwner*     mPrimaryContentTreeOwner;
00157    nsCOMPtr<nsIWidget>     mWindow;
00158    nsCOMPtr<nsIDocShell>   mDocShell;
00159    nsCOMPtr<nsIDOMWindowInternal>  mDOMWindow;
00160    nsCOMPtr<nsIWeakReference> mParentWindow;
00161    nsCOMPtr<nsIPrompt>     mPrompter;
00162    nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
00163    nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
00164    nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell;
00165    nsVoidArray             mContentShells; // array of doc shells by id
00166    nsresult                mModalStatus;
00167    PRPackedBool            mContinueModalLoop;
00168    PRPackedBool            mDebuting;       // being made visible right now
00169    PRPackedBool            mChromeLoaded; // True when chrome has loaded
00170    PRPackedBool            mShowAfterLoad;
00171    PRPackedBool            mIntrinsicallySized; 
00172    PRPackedBool            mCenterAfterLoad;
00173    PRPackedBool            mIsHiddenWindow;
00174    PRPackedBool            mLockedUntilChromeLoad;
00175    PRUint32                mContextFlags;
00176    PRUint32                mBlurSuppressionLevel;
00177    PRUint32                mPersistentAttributesDirty; // persistentAttributes
00178    PRUint32                mPersistentAttributesMask;
00179    PRUint32                mChromeFlags;
00180    nsString                mTitle;
00181 
00182    nsCOMArray<nsIWeakReference> mTargetableShells; // targetable shells only
00183 };
00184 
00185 // nsContentShellInfo
00186 // Used (in an nsVoidArray) to map shell IDs to nsIDocShellTreeItems.
00187 
00188 class nsContentShellInfo
00189 {
00190 public:
00191    nsContentShellInfo(const nsAString& aID,
00192                       nsIWeakReference* aContentShell);
00193    ~nsContentShellInfo();
00194 
00195 public:
00196    nsAutoString id; // The identifier of the content shell
00197    nsWeakPtr child; // content shell (weak reference to nsIDocShellTreeItem)
00198 };
00199 
00200 // nsEventQueueStack
00201 // a little utility object to push an event queue and pop it when it
00202 // goes out of scope. should probably be in a file of utility functions.
00203 class nsEventQueueStack
00204 {
00205 public:
00206    nsEventQueueStack();
00207    ~nsEventQueueStack();
00208 
00209    nsresult Success();
00210 
00211 protected:
00212    nsCOMPtr<nsIEventQueueService>   mService;
00213    nsCOMPtr<nsIEventQueue>          mQueue;
00214 };
00215 
00216 #endif /* nsXULWindow_h__ */