Fix up FindItemWithName so it does the walk across windows (more) correctly.

Bug 278916, r=danm, sr=jst


git-svn-id: svn://10.0.0.236/trunk@168787 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2005-02-04 04:28:07 +00:00
parent d8776a9590
commit 17555c9ab9
2 changed files with 21 additions and 8 deletions

View File

@@ -266,11 +266,9 @@ nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
return NS_OK;
}
// finally, failing everything else, search all windows, if we're not already
if (mWebBrowser->mDocShellAsItem != aRequestor)
return FindItemWithNameAcrossWindows(aName, aOriginalRequestor, aFoundItem);
return NS_OK; // failed
// finally, failing everything else, search all windows
return FindItemWithNameAcrossWindows(aName, aRequestor, aOriginalRequestor,
aFoundItem);
}
nsresult
@@ -318,6 +316,7 @@ nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName, PRBool aRecurse,
nsresult
nsDocShellTreeOwner::FindItemWithNameAcrossWindows(const PRUnichar* aName,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem** aFoundItem)
{
@@ -346,9 +345,22 @@ nsDocShellTreeOwner::FindItemWithNameAcrossWindows(const PRUnichar* aName,
nsCOMPtr<nsIDocShellTreeItem> item =
do_QueryInterface(sgo->GetDocShell());
if (item) {
rv = item->FindItemWithName(aName, item, aOriginalRequestor, aFoundItem);
if (NS_FAILED(rv) || *aFoundItem)
break;
// 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;
item->GetSameTypeRootTreeItem(getter_AddRefs(root));
NS_ASSERTION(root, "Must have root tree item of same type");
// Make sure not to call back into our kid if we got called from it
if (root != aRequestor) {
// Get the tree owner so we can pass it in as the
// requestor so the child knows not to call back up.
nsCOMPtr<nsIDocShellTreeOwner> rootOwner;
root->GetTreeOwner(getter_AddRefs(rootOwner));
rv = root->FindItemWithName(aName, rootOwner, aOriginalRequestor,
aFoundItem);
if (NS_FAILED(rv) || *aFoundItem)
break;
}
}
}
}