Skip to content

Commit

Permalink
Bug 1667081 - Part 2: Remove windowRaised in nsIFocusManager; r=hsivonen
Browse files Browse the repository at this point in the history
And make nsFocusManager::WindowRaised just returning void given all caller
doesn't actaully check the return value.

Differential Revision: https://phabricator.services.mozilla.com/D91288
  • Loading branch information
EdgarChen committed Sep 29, 2020
1 parent 3af8ce6 commit 6bf9a2e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
22 changes: 12 additions & 10 deletions dom/base/nsFocusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,11 @@ nsFocusManager::MoveCaretToFocus(mozIDOMWindowProxy* aWindow) {
return NS_OK;
}

NS_IMETHODIMP
nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
NS_ENSURE_TRUE(aWindow, NS_ERROR_INVALID_ARG);
void nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
if (!aWindow) {
return;
}

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

if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
Expand Down Expand Up @@ -679,7 +681,7 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
// what the focus manager thinks should be the current widget is actually
// focused.
EnsureCurrentWidgetFocused(CallerType::System);
return NS_OK;
return;
}

// lower the existing window, if any. This shouldn't happen usually.
Expand All @@ -693,7 +695,7 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
if (active == bc && !mActiveBrowsingContextInContentSetFromOtherProcess) {
// EnsureCurrentWidgetFocused() should not be necessary with
// PuppetWidget.
return NS_OK;
return;
}

if (active && active != bc) {
Expand All @@ -711,7 +713,9 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = window->GetDocShell();
// If there's no docShellAsItem, this window must have been closed,
// in that case there is no tree owner.
NS_ENSURE_TRUE(docShellAsItem, NS_OK);
if (!docShellAsItem) {
return;
}

// set this as the active window
if (XRE_IsParentProcess()) {
Expand All @@ -730,7 +734,7 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {
if (baseWindow) {
bool isEnabled = true;
if (NS_SUCCEEDED(baseWindow->GetEnabled(&isEnabled)) && !isEnabled) {
return NS_ERROR_FAILURE;
return;
}

baseWindow->SetVisibility(true);
Expand Down Expand Up @@ -767,14 +771,12 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) {

NS_ASSERTION(currentWindow, "window raised with no window current");
if (!currentWindow) {
return NS_OK;
return;
}

nsCOMPtr<nsIAppWindow> appWin(do_GetInterface(baseWindow));
Focus(currentWindow, currentFocus, 0, true, false, appWin != nullptr, true,
focusInOtherContentProcess);

return NS_OK;
}

NS_IMETHODIMP
Expand Down
5 changes: 5 additions & 0 deletions dom/base/nsFocusManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ class nsFocusManager final : public nsIFocusManager,
void RaiseWindow(nsPIDOMWindowOuter* aWindow,
mozilla::dom::CallerType aCallerType);

/**
* Called when a window has been raised.
*/
void WindowRaised(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 raised.
*/
[noscript] void windowRaised(in mozIDOMWindowProxy aWindow);

/**
* Called when a window has been lowered.
*/
Expand Down
4 changes: 3 additions & 1 deletion xpfe/appshell/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2846,7 +2846,9 @@ void AppWindow::WindowActivated() {
nsCOMPtr<nsPIDOMWindowOuter> window =
mDocShell ? mDocShell->GetWindow() : nullptr;
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm && window) fm->WindowRaised(window);
if (fm && window) {
fm->WindowRaised(window);
}

if (mChromeLoaded) {
PersistentAttributesDirty(PAD_POSITION | PAD_SIZE | PAD_MISC);
Expand Down

0 comments on commit 6bf9a2e

Please sign in to comment.