Closed Bug 1933769 Opened 3 months ago Closed 3 months ago

Remove some focus calls in the front-end which shouldn't have an effect.

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

defect

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

Details

Attachments

(3 files)

I tried to do this in bug 1933119 but got backed out due to a test failure.

I think the test failure is legit and uncovers a bug in nsFocusManager.

We're in a situation where:

  • mActiveWindow = the top level window
  • mFocusedWindow = nullptr

Front-end calls promiseFocus(), and document.hasFocus() returns false. So it proceeds to call window.focus(), but that bails out in RaiseWindow here:

I think bailing out is wrong and we should ensure the widget becomes focused as well. We already deal with this situation correctly here:

Furthermore, we no longer have the windows special-case of having child windows in the top level, so we can simplify a bit RaiseWindow.

Since bug 1823984, this focus() call has been a no-op on remote frames.

The previous patch also fixes the non-remote frame focus switch.

Windows no longer has child widgets since bug 1870512, where we removed
ShouldAttachToTopLevel() special-cases.

We're in a situation where:

mActiveWindow = the top level window
mFocusedWindow = nullptr

Front-end calls promiseFocus(), and document.hasFocus() returns false
(correctly).

So it proceeds to call window.focus(), but that bails out in RaiseWindow
here:

https://searchfox.org/mozilla-central/rev/234f91a9d3ebef0d514868701cfb022d5f199cb5/dom/base/nsFocusManager.cpp#3022

I think bailing out is wrong and we should ensure the widget becomes
focused as well. We already deal with this situation correctly here:

https://searchfox.org/mozilla-central/rev/234f91a9d3ebef0d514868701cfb022d5f199cb5/dom/base/nsFocusManager.cpp#699-708
Attachment #9440280 - Attachment description: Bug 1933769 - Don't bail out from RaiseWindow if we're not both the active and focused window. r=smaug,edgar,hsivonen → Bug 1933769 - Move focus to window directly if we are already the active window. r=smaug,edgar,hsivonen
Keywords: leave-open
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3f6eb274c4d9 Clean-up a bit nsFocusManager::RaiseWindow. r=smaug
Severity: -- → S3
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d6c7cfdf4e11 Move focus to window directly if we are already the active window. r=smaug

Backed out changeset d6c7cfdf4e11 (Bug 1933769) for causing bv failures at outOfProcess/browser_controller.js

Backout link

Push with failures

Failure log

Flags: needinfo?(emilio)
Attachment #9440280 - Attachment description: Bug 1933769 - Move focus to window directly if we are already the active window. r=smaug,edgar,hsivonen → Bug 1933769 - Move focus to window directly if we are already the active window. r=smaug
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4424a9d13f3f Move focus to window directly if we are already the active window. r=smaug
Keywords: leave-open
Priority: -- → P3
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/842468e46637 Remove no-op focus() calls. r=tabbrowser-reviewers,dao
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: