mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
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.
This commit is contained in:
parent
3c41d4b24d
commit
18e8cf2a70
@ -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)
|
||||
{
|
||||
|
@ -432,8 +432,7 @@ nsHTMLFrameInnerFrame::~nsHTMLFrameInnerFrame()
|
||||
{
|
||||
//printf("nsHTMLFrameInnerFrame destructor %X \n", this);
|
||||
if (nsnull != mWebShell) {
|
||||
//XXX Let mWebShell's parent destroy it because now may not be a good time
|
||||
// mWebShell->Destroy();
|
||||
mWebShell->Destroy();
|
||||
NS_RELEASE(mWebShell);
|
||||
}
|
||||
NS_RELEASE(mTempObserver);
|
||||
|
@ -432,8 +432,7 @@ nsHTMLFrameInnerFrame::~nsHTMLFrameInnerFrame()
|
||||
{
|
||||
//printf("nsHTMLFrameInnerFrame destructor %X \n", this);
|
||||
if (nsnull != mWebShell) {
|
||||
//XXX Let mWebShell's parent destroy it because now may not be a good time
|
||||
// mWebShell->Destroy();
|
||||
mWebShell->Destroy();
|
||||
NS_RELEASE(mWebShell);
|
||||
}
|
||||
NS_RELEASE(mTempObserver);
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user