Put more recently focused tabs in a window at the beginning of the named item search order. Bug 407421, r+sr=jst, a=schrep

This commit is contained in:
bzbarsky@mit.edu 2007-12-14 09:32:41 -08:00
parent b3acc391de
commit 964f9412f2

View File

@ -1632,8 +1632,23 @@ nsresult nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
}
#endif
NS_ENSURE_TRUE(mTargetableShells.AppendObject(contentShellWeak),
NS_ERROR_OUT_OF_MEMORY);
// put the new shell at the start of the targetable shells list if either
// it's the new primary shell or there is no existing primary shell (which
// means that chances are this one just stopped being primary). If we
// really cared, we could keep track of the "last no longer primary shell"
// explicitly, but it probably doesn't matter enough: the difference would
// only be felt in a situation where all shells were non-primary, which
// doesn't happen much. In a situation where there is one and only one
// primary shell, and in which shells get unmarked as primary before some
// other shell gets marked as primary, this effectively stores the list of
// targetable shells in "most recently primary first" order.
PRBool inserted;
if (aPrimary || !mPrimaryContentShell) {
inserted = mTargetableShells.InsertObjectAt(contentShellWeak, 0);
} else {
inserted = mTargetableShells.AppendObject(contentShellWeak);
}
NS_ENSURE_TRUE(inserted, NS_ERROR_OUT_OF_MEMORY);
}
return NS_OK;