From aef095fb3d1d8388335b10cf571da17640184043 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Tue, 29 Jan 2002 21:42:07 +0000 Subject: [PATCH] deactivate root focus controller as well as your own while deactivating yourself. bug 122462 / bugscape 11864 code=saari,myself r=bryner,hyatt --- embedding/browser/webBrowser/nsWebBrowser.cpp | 41 +++++++++++-------- xpfe/appshell/src/nsWebShellWindow.cpp | 7 +++- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index b73737a6396..499ffd0aaa2 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -1662,26 +1662,31 @@ NS_IMETHODIMP nsWebBrowser::Activate(void) /* void deactivate (); */ NS_IMETHODIMP nsWebBrowser::Deactivate(void) { - /* At this time we don't clear mWWatch's ActiveWindow; we just allow - the presumed other newly active window to set it when it comes in. - This seems harmless and maybe safer, but we have no real evidence - either way just yet. */ - - NS_ENSURE_STATE(mDocShell); - nsCOMPtr presShell; - mDocShell->GetPresShell(getter_AddRefs(presShell)); - if(!presShell) - return NS_OK; - - nsCOMPtr domWindow; - GetContentDOMWindow(getter_AddRefs(domWindow)); - if (domWindow) { - nsCOMPtr privateDOMWindow = do_QueryInterface(domWindow); - if(privateDOMWindow) - privateDOMWindow->Deactivate(); - } + /* At this time we don't clear mWWatch's ActiveWindow; we just allow + the presumed other newly active window to set it when it comes in. + This seems harmless and maybe safer, but we have no real evidence + either way just yet. */ + NS_ENSURE_STATE(mDocShell); + nsCOMPtr presShell; + mDocShell->GetPresShell(getter_AddRefs(presShell)); + if(!presShell) return NS_OK; + + nsCOMPtr domWindow; + GetContentDOMWindow(getter_AddRefs(domWindow)); + if (domWindow) { + nsCOMPtr privateDOMWindow = do_QueryInterface(domWindow); + if(privateDOMWindow) { + nsCOMPtr focusController; + privateDOMWindow->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) + focusController->SetActive(PR_FALSE); + privateDOMWindow->Deactivate(); + } + } + + return NS_OK; } /* void setFocusAtFirstElement (); */ diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 11395b2cffb..b95f6e571af 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -542,8 +542,13 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent) else */ if (domWindow) { nsCOMPtr privateDOMWindow = do_QueryInterface(domWindow); - if(privateDOMWindow) + if(privateDOMWindow) { + nsCOMPtr focusController; + privateDOMWindow->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) + focusController->SetActive(PR_FALSE); privateDOMWindow->Deactivate(); + } } break; }