Fixed a bug where when targetting to a "_content" window from within a XUL window that did not have a browser window would not find an already open browser to target into. r=hyatt

This commit is contained in:
tbogard@aol.net
2000-02-10 07:41:11 +00:00
parent 98395d3c38
commit adc2292522
2 changed files with 55 additions and 24 deletions

View File

@@ -94,13 +94,21 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
nsAutoString name(aName);
PRBool fIs_Content = PR_FALSE;
/* Special Cases */
if(name.Length() == 0)
return NS_OK;
if(name.EqualsIgnoreCase("_blank"))
return NS_OK;
if(name.EqualsIgnoreCase("_content"))
return mXULWindow->GetPrimaryContentShell(aFoundItem);
{
fIs_Content = PR_TRUE;
mXULWindow->GetPrimaryContentShell(aFoundItem);
if(*aFoundItem)
return NS_OK;
// Otherwise fall through and ask the other windows for a content area.
}
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
@@ -119,10 +127,19 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem;
if(fIs_Content)
{
xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem));
if(shellAsTreeItem)
*aFoundItem = shellAsTreeItem;
}
else
{
nsCOMPtr<nsIDocShell> shell;
xulWindow->GetDocShell(getter_AddRefs(shell));
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem(do_QueryInterface(shell));
shellAsTreeItem = do_QueryInterface(shell);
if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get()))
{
// Do this so we can pass in the tree owner as the requestor so the child knows not
@@ -132,9 +149,10 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
}
}
if(*aFoundItem)
return NS_OK;
}
windowEnumerator->HasMoreElements(&more);
}
return NS_OK;

View File

@@ -100,13 +100,20 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
nsAutoString name(aName);
PRBool fIs_Content = PR_FALSE;
/* Special Cases */
if(name.Length() == 0)
return NS_OK;
if(name.EqualsIgnoreCase("_blank"))
return NS_OK;
if(name.EqualsIgnoreCase("_content"))
return mXULWindow->GetPrimaryContentShell(aFoundItem);
{
fIs_Content = PR_TRUE;
mXULWindow->GetPrimaryContentShell(aFoundItem);
if(*aFoundItem)
return NS_OK;
}
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
@@ -127,7 +134,12 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem;
xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem));
if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get()))
if(shellAsTreeItem)
{
if(fIs_Content)
*aFoundItem = shellAsTreeItem;
else if(aRequestor != shellAsTreeItem.get())
{
// Do this so we can pass in the tree owner as the requestor so the child knows not
// to call back up.
@@ -136,6 +148,7 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
}
if(*aFoundItem)
return NS_OK;
}