nsXULWindow now maintains a list of content shells. Implemented GetPrimaryContentShell() and GetContentShellById(). [Not hooked to the build]
git-svn-id: svn://10.0.0.236/trunk@58634 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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<nsIBaseWindow> 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()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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<nsIWidget> mWindow;
|
||||
nsCOMPtr<nsIDocShell> 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<nsIDocShellTreeItem> child; // content shell
|
||||
};
|
||||
|
||||
#endif /* nsXULWindow_h__ */
|
||||
|
||||
Reference in New Issue
Block a user