Fix for bug 5850:

1) Add a RemoveChild() method to nsIWebshell.
2) nsWebshell::Destroy() calls this method on its parent to remove itself from the parent's child list.
3) Call nsWebshell::Destroy() from nsHTMLFrameInnerFrame's detructor.


git-svn-id: svn://10.0.0.236/trunk@30304 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nisheeth%netscape.com
1999-05-05 00:23:51 +00:00
parent 6cc6d8d9b0
commit 84d9443f3f
4 changed files with 42 additions and 4 deletions

View File

@@ -171,6 +171,7 @@ public:
NS_IMETHOD GetParentEvenIfChrome(nsIWebShell*& aParent);
NS_IMETHOD GetChildCount(PRInt32& aResult);
NS_IMETHOD AddChild(nsIWebShell* aChild);
NS_IMETHOD RemoveChild(nsIWebShell* aChild);
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIWebShell*& aResult);
NS_IMETHOD GetName(const PRUnichar** aName);
NS_IMETHOD SetName(const PRUnichar* aName);
@@ -888,6 +889,11 @@ nsWebShell::Destroy()
SetObserver(nsnull);
SetDocLoaderObserver(nsnull);
// Remove this webshell from its parent's child list
if (nsnull != mParent) {
mParent->RemoveChild(this);
}
if (nsnull != mDocLoader) {
mDocLoader->SetContainer(nsnull);
}
@@ -1214,6 +1220,20 @@ nsWebShell::AddChild(nsIWebShell* aChild)
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::RemoveChild(nsIWebShell* aChild)
{
NS_PRECONDITION(nsnull != aChild, "nsWebShell::RemoveChild(): null ptr");
if (nsnull == aChild) {
return NS_ERROR_NULL_POINTER;
}
mChildren.RemoveElement(aChild);
aChild->SetParent(nsnull);
NS_RELEASE(aChild);
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::ChildAt(PRInt32 aIndex, nsIWebShell*& aResult)
{