Make _main and _content target the right things when tabs are involved. Bug 277971 and bug 273984, r=bsmedberg, sr=jst, branch181=jst

This commit is contained in:
bzbarsky%mit.edu 2006-03-24 19:38:17 +00:00
Родитель 8c09250cd9
Коммит 0d5aab774b
2 изменённых файлов: 36 добавлений и 9 удалений

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

@ -1964,16 +1964,22 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
else if (name.LowerCaseEqualsLiteral("_top"))
{
GetSameTypeRootTreeItem(getter_AddRefs(foundItem));
if(!foundItem)
foundItem = this;
NS_ASSERTION(foundItem, "Must have this; worst case it's us!");
}
// _main is an IE target which should be case-insensitive but isn't
// see bug 217886 for details
else if (name.LowerCaseEqualsLiteral("_content") ||
name.EqualsLiteral("_main"))
{
if (mTreeOwner)
mTreeOwner->GetPrimaryContentShell(getter_AddRefs(foundItem));
// Must pass our same type root as requestor to the
// treeowner to make sure things work right.
nsCOMPtr<nsIDocShellTreeItem> root;
GetSameTypeRootTreeItem(getter_AddRefs(root));
if (mTreeOwner) {
NS_ASSERTION(root, "Must have this; worst case it's us!");
mTreeOwner->FindItemWithName(aName, root, aOriginalRequestor,
getter_AddRefs(foundItem));
}
#ifdef DEBUG
else {
NS_ERROR("Someone isn't setting up the tree owner. "
@ -1983,6 +1989,8 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
// hanging off the treeowner, just create a named window....
// so don't return here, in case we did that and can now find
// it.
// XXXbz should we be using |root| instead of creating
// a new window?
}
#endif
}
@ -2058,11 +2066,7 @@ nsDocShell::FindItemWithName(const PRUnichar * aName,
if (mTreeOwner && mTreeOwner != reqAsTreeOwner) {
return mTreeOwner->
FindItemWithName(aName,
NS_STATIC_CAST(nsIDocShellTreeItem*,
this),
aOriginalRequestor,
_retval);
FindItemWithName(aName, this, aOriginalRequestor, _retval);
}
return NS_OK;

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

@ -200,6 +200,29 @@ NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
// see bug 217886 for details
if (name.LowerCaseEqualsLiteral("_content") ||
name.EqualsLiteral("_main")) {
// If we're being called with an aRequestor and it's targetable, just
// return it -- _main and _content from inside targetable content shells
// should just be that content shell. Note that we don't have to worry
// about the case when it's not targetable because it's primary -- that
// will Just Work when we call GetPrimaryContentShell.
if (aRequestor) {
// This better be the root item!
#ifdef DEBUG
nsCOMPtr<nsIDocShellTreeItem> debugRoot;
aRequestor->GetSameTypeRootTreeItem(getter_AddRefs(debugRoot));
NS_ASSERTION(SameCOMIdentity(debugRoot, aRequestor),
"Bogus aRequestor");
#endif
PRInt32 count = mXULWindow->mTargetableShells.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item =
do_QueryReferent(mXULWindow->mTargetableShells[i]);
if (SameCOMIdentity(item, aRequestor)) {
NS_ADDREF(*aFoundItem = aRequestor);
return NS_OK;
}
}
}
mXULWindow->GetPrimaryContentShell(aFoundItem);
if(*aFoundItem)
return NS_OK;