Skip to content

Commit

Permalink
Bug 1667081 - Part 3: Remove windowLowered in nsIFocusManager; r=hsiv…
Browse files Browse the repository at this point in the history
…onen

This patch also does following changes,
- Assert aWindow instead of early return given all caller passes a non-null window.
- Make it returning void given all caller doesn't actaully check the return value.

Differential Revision: https://phabricator.services.mozilla.com/D91289
  • Loading branch information
EdgarChen committed Sep 28, 2020
1 parent a60331b commit 0a84919
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 5 additions & 7 deletions dom/base/nsFocusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,9 @@ void nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
focusInOtherContentProcess);
}

NS_IMETHODIMP
nsFocusManager::WindowLowered(mozIDOMWindowProxy* aWindow) {
NS_ENSURE_TRUE(aWindow, NS_ERROR_INVALID_ARG);
void nsFocusManager::WindowLowered(mozIDOMWindowProxy* aWindow) {
MOZ_ASSERT(aWindow);

nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);

if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
Expand All @@ -801,13 +801,13 @@ nsFocusManager::WindowLowered(mozIDOMWindowProxy* aWindow) {

if (XRE_IsParentProcess()) {
if (mActiveWindow != window) {
return NS_OK;
return;
}
} else {
BrowsingContext* bc = window->GetBrowsingContext();
BrowsingContext* active = GetActiveBrowsingContext();
if (active != bc->Top()) {
return NS_OK;
return;
}
}

Expand Down Expand Up @@ -856,8 +856,6 @@ nsFocusManager::WindowLowered(mozIDOMWindowProxy* aWindow) {
}

mWindowBeingLowered = nullptr;

return NS_OK;
}

nsresult nsFocusManager::ContentRemoved(Document* aDocument,
Expand Down
5 changes: 5 additions & 0 deletions dom/base/nsFocusManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ class nsFocusManager final : public nsIFocusManager,
*/
void WindowRaised(mozIDOMWindowProxy* aWindow);

/**
* Called when a window has been lowered.
*/
void WindowLowered(mozIDOMWindowProxy* aWindow);

static uint32_t FocusOptionsToFocusManagerFlags(
const mozilla::dom::FocusOptions& aOptions);

Expand Down
5 changes: 0 additions & 5 deletions dom/interfaces/base/nsIFocusManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,6 @@ interface nsIFocusManager : nsISupports
/** move focus to the last focusable document */
const unsigned long MOVEFOCUS_LASTDOC = 10;

/**
* Called when a window has been lowered.
*/
[noscript] void windowLowered(in mozIDOMWindowProxy aWindow);

/**
* Called when a new document in a window is shown.
*
Expand Down
4 changes: 3 additions & 1 deletion xpfe/appshell/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2862,7 +2862,9 @@ void AppWindow::WindowDeactivated() {
nsCOMPtr<nsPIDOMWindowOuter> window =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm && window && !fm->IsTestMode()) fm->WindowLowered(window);
if (fm && window && !fm->IsTestMode()) {
fm->WindowLowered(window);
}
}

#ifdef USE_NATIVE_MENUS
Expand Down

0 comments on commit 0a84919

Please sign in to comment.