mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Fixing bug 205474. Making window.open() (and other ways to target things into existing windows) not reuse already closed windows. r=caillon@aillon.org, sr=bzbarsky@mit.edu
This commit is contained in:
parent
724dfc9b3c
commit
dd01342a24
@ -1769,6 +1769,23 @@ nsDocShell::GetSameTypeRootTreeItem(nsIDocShellTreeItem ** aRootTreeItem)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
ItemIsActive(nsIDocShellTreeItem *aItem)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> tmp(do_GetInterface(aItem));
|
||||
nsCOMPtr<nsIDOMWindowInternal> window(do_QueryInterface(tmp));
|
||||
|
||||
if (window) {
|
||||
PRBool isClosed;
|
||||
|
||||
if (NS_SUCCEEDED(window->GetClosed(&isClosed)) && !isClosed) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::FindItemWithName(const PRUnichar * aName,
|
||||
nsISupports * aRequestor,
|
||||
@ -1785,8 +1802,8 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
|
||||
reqAsTreeItem(do_QueryInterface(aRequestor));
|
||||
|
||||
// First we check our name.
|
||||
if (mName.Equals(aName)) {
|
||||
*_retval = NS_STATIC_CAST(nsIDocShellTreeItem *, this);
|
||||
if (mName.Equals(aName) && ItemIsActive(this)) {
|
||||
*_retval = this;
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2142,7 +2159,7 @@ nsDocShell::FindChildWithName(const PRUnichar * aName,
|
||||
|
||||
PRBool childNameEquals = PR_FALSE;
|
||||
child->NameEquals(aName, &childNameEquals);
|
||||
if (childNameEquals) {
|
||||
if (childNameEquals && ItemIsActive(child)) {
|
||||
*_retval = child;
|
||||
NS_ADDREF(*_retval);
|
||||
break;
|
||||
|
@ -217,6 +217,7 @@ GlobalWindowImpl::GlobalWindowImpl()
|
||||
mIsScopeClear(PR_TRUE),
|
||||
mIsDocumentLoaded(PR_FALSE),
|
||||
mFullScreen(PR_FALSE),
|
||||
mIsClosed(PR_FALSE),
|
||||
mLastMouseButtonAction(LL_ZERO),
|
||||
mGlobalObjectOwner(nsnull),
|
||||
mDocShell(nsnull),
|
||||
@ -1294,7 +1295,10 @@ GlobalWindowImpl::GetDirectories(nsIDOMBarProp** aDirectories)
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetClosed(PRBool* aClosed)
|
||||
{
|
||||
*aClosed = !mDocShell;
|
||||
// If someone called close(), or if we don't have a docshell, we're
|
||||
// closed.
|
||||
*aClosed = mIsClosed || !mDocShell;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3316,6 +3320,9 @@ GlobalWindowImpl::Close()
|
||||
}
|
||||
}
|
||||
|
||||
// Flag that we were closed.
|
||||
mIsClosed = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService(sJSStackContractID);
|
||||
|
||||
|
@ -300,6 +300,7 @@ protected:
|
||||
PRPackedBool mIsScopeClear;
|
||||
PRPackedBool mIsDocumentLoaded; // true between onload and onunload events
|
||||
PRPackedBool mFullScreen;
|
||||
PRPackedBool mIsClosed;
|
||||
PRTime mLastMouseButtonAction;
|
||||
nsString mStatus;
|
||||
nsString mDefaultStatus;
|
||||
|
Loading…
Reference in New Issue
Block a user