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:
@@ -94,13 +94,21 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
|
|||||||
|
|
||||||
nsAutoString name(aName);
|
nsAutoString name(aName);
|
||||||
|
|
||||||
|
PRBool fIs_Content = PR_FALSE;
|
||||||
|
|
||||||
/* Special Cases */
|
/* Special Cases */
|
||||||
if(name.Length() == 0)
|
if(name.Length() == 0)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
if(name.EqualsIgnoreCase("_blank"))
|
if(name.EqualsIgnoreCase("_blank"))
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
if(name.EqualsIgnoreCase("_content"))
|
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));
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
||||||
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
||||||
@@ -119,10 +127,19 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
|
|||||||
nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
|
nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
|
||||||
NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE);
|
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;
|
nsCOMPtr<nsIDocShell> shell;
|
||||||
xulWindow->GetDocShell(getter_AddRefs(shell));
|
xulWindow->GetDocShell(getter_AddRefs(shell));
|
||||||
|
shellAsTreeItem = do_QueryInterface(shell);
|
||||||
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem(do_QueryInterface(shell));
|
|
||||||
if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get()))
|
if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get()))
|
||||||
{
|
{
|
||||||
// Do this so we can pass in the tree owner as the requestor so the child knows not
|
// 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));
|
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
|
||||||
|
|
||||||
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
|
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(*aFoundItem)
|
if(*aFoundItem)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
|
||||||
windowEnumerator->HasMoreElements(&more);
|
windowEnumerator->HasMoreElements(&more);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -100,13 +100,20 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
|
|||||||
|
|
||||||
nsAutoString name(aName);
|
nsAutoString name(aName);
|
||||||
|
|
||||||
|
PRBool fIs_Content = PR_FALSE;
|
||||||
|
|
||||||
/* Special Cases */
|
/* Special Cases */
|
||||||
if(name.Length() == 0)
|
if(name.Length() == 0)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
if(name.EqualsIgnoreCase("_blank"))
|
if(name.EqualsIgnoreCase("_blank"))
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
if(name.EqualsIgnoreCase("_content"))
|
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));
|
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
||||||
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
||||||
@@ -127,7 +134,12 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
|
|||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem;
|
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem;
|
||||||
xulWindow->GetPrimaryContentShell(getter_AddRefs(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
|
// Do this so we can pass in the tree owner as the requestor so the child knows not
|
||||||
// to call back up.
|
// to call back up.
|
||||||
@@ -136,6 +148,7 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
|
|||||||
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
|
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
|
||||||
|
|
||||||
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
|
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, aFoundItem);
|
||||||
|
}
|
||||||
if(*aFoundItem)
|
if(*aFoundItem)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user