Implemented the nsIBaseWindow::FocusAvailable. Hooked up the old nsIWebShellContainer::FocusAvailable to go through the new one.

This commit is contained in:
tbogard@aol.net
1999-12-02 10:11:38 +00:00
parent 7002b3d1a9
commit 1513ba792b
2 changed files with 80 additions and 54 deletions

View File

@@ -2413,33 +2413,8 @@ nsWebShell::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult)
NS_IMETHODIMP
nsWebShell::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken)
{
//If the WebShell with focus is us, pass this up to container
if (this == aFocusedWebShell && nsnull != mContainer) {
mContainer->FocusAvailable(this, aFocusTaken);
}
nsIDocShell* shell = nsnull;
//Other wise, check children and move focus to next one
PRInt32 i, n = mChildren.Count();
for (i = 0; i < n; i++) {
shell = (nsIDocShell*)mChildren.ElementAt(i);
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(shell));
if (webShell.get() == aFocusedWebShell) {
if (++i < n) {
shell = (nsIDocShell*)mChildren.ElementAt(i);
nsCOMPtr<nsIBaseWindow> shellWin(do_QueryInterface(shell));
shellWin->SetFocus();
break;
}
else if (nsnull != mContainer) {
mContainer->FocusAvailable(this, aFocusTaken);
break;
}
}
}
return NS_OK;
nsCOMPtr<nsIBaseWindow> webShellAsWin(do_QueryInterface(aFocusedWebShell));
return FocusAvailable(webShellAsWin, &aFocusTaken);
}
NS_IMETHODIMP
@@ -4075,6 +4050,44 @@ NS_IMETHODIMP
nsWebShell::FocusAvailable(nsIBaseWindow* aCurrentFocus, PRBool* aTookFocus)
{
NS_ENSURE_ARG_POINTER(aTookFocus);
// Next person we should call is first the parent otherwise the
// docshell tree owner.
nsCOMPtr<nsIBaseWindow> nextCallWin(do_QueryInterface(mParent));
if(!nextCallWin)
{//XXX Enable this when docShellTreeOwner is added
//nextCallWin = do_QueryInterface(mDocShellTreeOwner);
}
//If the current focus is us, offer it to the next owner.
if(aCurrentFocus == NS_STATIC_CAST(nsIBaseWindow*, this))
{
if(nextCallWin)
return nextCallWin->FocusAvailable(aCurrentFocus, aTookFocus);
return NS_OK;
}
//Otherwise, check the chilren and offer it to the next sibling.
PRInt32 i;
PRInt32 n = mChildren.Count();
for(i = 0; i < n; i++)
{
nsCOMPtr<nsIBaseWindow>
child(do_QueryInterface((nsISupports*)mChildren.ElementAt(i)));
if(child.get() == aCurrentFocus)
{
while(++i < n)
{
child = do_QueryInterface((nsISupports*)mChildren.ElementAt(i));
if(NS_SUCCEEDED(child->SetFocus()))
{
*aTookFocus = PR_TRUE;
return NS_OK;
}
}
}
}
if(nextCallWin)
return nextCallWin->FocusAvailable(aCurrentFocus, aTookFocus);
return NS_OK;
}