Undo the checkin for bug 135811 and refix it better. Fixes bug 279495.

r=danm, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2005-01-31 20:46:24 +00:00
Родитель 2082b5ec62
Коммит 7f9e2bbb9a
3 изменённых файлов: 28 добавлений и 13 удалений

Просмотреть файл

@ -2089,7 +2089,7 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
// This may fail, but comparing against null serves the same purpose // This may fail, but comparing against null serves the same purpose
nsCOMPtr<nsIDocShellTreeOwner> nsCOMPtr<nsIDocShellTreeOwner>
reqAsTreeOwner(do_GetInterface(aRequestor)); reqAsTreeOwner(do_QueryInterface(aRequestor));
if (mTreeOwner && mTreeOwner != reqAsTreeOwner) { if (mTreeOwner && mTreeOwner != reqAsTreeOwner) {
return mTreeOwner-> return mTreeOwner->

Просмотреть файл

@ -214,16 +214,21 @@ NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
if(fIs_Content) if(fIs_Content)
{ {
xulWindow->GetPrimaryContentShell(getter_AddRefs(shellAsTreeItem)); xulWindow->GetPrimaryContentShell(aFoundItem);
if(shellAsTreeItem)
*aFoundItem = shellAsTreeItem;
} }
else else
{ {
nsCOMPtr<nsIDocShell> shell; nsCOMPtr<nsIDocShell> shell;
xulWindow->GetDocShell(getter_AddRefs(shell)); xulWindow->GetDocShell(getter_AddRefs(shell));
shellAsTreeItem = do_QueryInterface(shell); shellAsTreeItem = do_QueryInterface(shell);
if(shellAsTreeItem && (aRequestor != shellAsTreeItem.get())) if (shellAsTreeItem) {
// Get the root tree item of same type, since roots are the only
// things that call into the treeowner to look for named items.
nsCOMPtr<nsIDocShellTreeItem> root;
shellAsTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
shellAsTreeItem = root;
}
if(shellAsTreeItem && aRequestor != shellAsTreeItem)
{ {
// 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.

Просмотреть файл

@ -221,16 +221,26 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
*aFoundItem = shellAsTreeItem; *aFoundItem = shellAsTreeItem;
NS_ADDREF(*aFoundItem); NS_ADDREF(*aFoundItem);
} }
else if(aRequestor != shellAsTreeItem.get()) else
{ {
// Do this so we can pass in the tree owner as the requestor so the child knows not // Get the root tree item of same type, since roots are the only
// to call back up. // things that call into the treeowner to look for named items.
nsCOMPtr<nsIDocShellTreeItem> root;
shellAsTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
NS_ASSERTION(root, "Must have root tree item of same type");
shellAsTreeItem = root;
if(aRequestor != shellAsTreeItem)
{
// Do this so we can pass in the tree owner as the
// requestor so the child knows not to call back up.
nsCOMPtr<nsIDocShellTreeOwner> shellOwner; nsCOMPtr<nsIDocShellTreeOwner> shellOwner;
shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner)); shellAsTreeItem->GetTreeOwner(getter_AddRefs(shellOwner));
nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner)); nsCOMPtr<nsISupports> shellOwnerSupports(do_QueryInterface(shellOwner));
shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports, shellAsTreeItem->FindItemWithName(aName, shellOwnerSupports,
aOriginalRequestor, aFoundItem); aOriginalRequestor,
aFoundItem);
}
} }
if(*aFoundItem) if(*aFoundItem)
return NS_OK; return NS_OK;