diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.cpp b/mozilla/xpfe/appshell/src/nsXULWindow.cpp index f4436a80b05..23f27fcc2c9 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsXULWindow.cpp @@ -86,17 +86,41 @@ NS_IMETHODIMP nsXULWindow::GetPrimaryContentShell(nsIDocShellTreeItem** aDocShellTreeItem) { NS_ENSURE_ARG_POINTER(aDocShellTreeItem); + *aDocShellTreeItem = nsnull; + + PRInt32 count = mContentShells.Count(); + for(PRInt32 i = 0; i < count; i++) + { + nsContentShellInfo* shellInfo = (nsContentShellInfo*)mContentShells.ElementAt(i); + if(shellInfo->primary) + { + *aDocShellTreeItem = shellInfo->child; + NS_ADDREF(*aDocShellTreeItem); + return NS_OK; + } + } - //XXX First Check - NS_ERROR("Not Yet Implemented"); return NS_ERROR_FAILURE; } NS_IMETHODIMP nsXULWindow::GetContentShellById(const PRUnichar* aID, nsIDocShellTreeItem** aDocShellTreeItem) { - //XXX First Check - NS_ERROR("Not Yet Implemented"); + NS_ENSURE_ARG_POINTER(aDocShellTreeItem); + *aDocShellTreeItem = nsnull; + + PRInt32 count = mContentShells.Count(); + for(PRInt32 i = 0; i < count; i++) + { + nsContentShellInfo* shellInfo = (nsContentShellInfo*)mContentShells.ElementAt(i); + if(shellInfo->id == aID) + { + *aDocShellTreeItem = shellInfo->child; + NS_ADDREF(*aDocShellTreeItem); + return NS_OK; + } + } + return NS_ERROR_FAILURE; } @@ -214,6 +238,16 @@ NS_IMETHODIMP nsXULWindow::Create() NS_IMETHODIMP nsXULWindow::Destroy() { + // Remove our ref on the content shells + PRInt32 count; + count = mContentShells.Count(); + for(PRInt32 i = 0; i < count; i++) + { + nsContentShellInfo* shellInfo = (nsContentShellInfo*)(mContentShells.ElementAt(i)); + delete shellInfo; + } + mContentShells.Clear(); + if(mDocShell) { nsCOMPtr shellAsWin(do_QueryInterface(mDocShell)); @@ -525,5 +559,17 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize //***************************************************************************** // nsXULWindow: Accessors +//***************************************************************************** + +//***************************************************************************** +//*** nsContentShellInfo: Object Management //***************************************************************************** +nsContentShellInfo::nsContentShellInfo(const nsString& aID, PRBool aPrimary, + nsIDocShellTreeItem* aContentShell) : id(aID), primary(aPrimary), child(aContentShell) +{ +} + +nsContentShellInfo::~nsContentShellInfo() +{ +} diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.h b/mozilla/xpfe/appshell/src/nsXULWindow.h index 7369f6c251c..a95eae5e03a 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.h +++ b/mozilla/xpfe/appshell/src/nsXULWindow.h @@ -23,13 +23,23 @@ #ifndef nsXULWindow_h__ #define nsXULWindow_h__ +// Local Includes +#include "nsChromeTreeOwner.h" +#include "nsContentTreeOwner.h" + +// Helper classes #include "nsCOMPtr.h" +#include "nsVoidArray.h" +#include "nsString.h" + +// Interfaces needed #include "nsIXULWindow.h" #include "nsIBaseWindow.h" #include "nsIDocShell.h" #include "nsIWidget.h" -#include "nsChromeTreeOwner.h" -#include "nsContentTreeOwner.h" +#include "nsIDocShellTreeItem.h" + +// nsXULWindow class nsXULWindow : public nsIXULWindow, public nsIBaseWindow { @@ -58,6 +68,21 @@ protected: nsContentTreeOwner* mContentTreeOwner; nsCOMPtr mWindow; nsCOMPtr mDocShell; + nsVoidArray mContentShells; +}; + +// nsContentShellInfo + +class nsContentShellInfo +{ +public: + nsContentShellInfo(const nsString& aID, PRBool aPrimary, nsIDocShellTreeItem* aContentShell); + ~nsContentShellInfo(); + +public: + nsAutoString id; // The identifier of the content shell + PRBool primary; // Signals the fact that the shell is primary + nsCOMPtr child; // content shell }; #endif /* nsXULWindow_h__ */