Bug 1618204 - DeCOMtaminate GetActiveWindow in nsWindow::BringToFront(). r=snorp

Differential Revision: https://phabricator.services.mozilla.com/D64372

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2020-02-26 22:34:57 +00:00
parent ec996a7e9d
commit 2339507e78

View File

@ -1814,14 +1814,15 @@ void nsWindow::SetFocus(Raise, mozilla::dom::CallerType aCallerType) {
}
void nsWindow::BringToFront() {
MOZ_ASSERT(XRE_IsParentProcess());
// If the window to be raised is the same as the currently raised one,
// do nothing. We need to check the focus manager as well, as the first
// window that is created will be first in the window list but won't yet
// be focused.
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
nsCOMPtr<mozIDOMWindowProxy> existingTopWindow;
fm->GetActiveWindow(getter_AddRefs(existingTopWindow));
if (existingTopWindow && FindTopLevel() == nsWindow::TopWindow()) return;
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm && fm->GetActiveWindow() && FindTopLevel() == nsWindow::TopWindow()) {
return;
}
if (!IsTopLevel()) {
FindTopLevel()->BringToFront();