Bug 1699682 - Consistently initialize UI state to hide focusrings by default. r=mhowell

UIS_INITIALIZE does something like setting the flag if the last input event was
a mouse event or clearing it if it was a keyboard event. Unfortunately, if this
is initialized to always show focus rings we start always showing outlines for
all content, all the time, which is both undesired and confusing.

It's also not clear from the docs _which_ event it looks at specially at
startup, but anyhow the result we get is clearly flaky, from my testing.

Explicitly clear the flag. It's not clear to me if other applications can cause
the state to change... but otherwise maybe we can just remove the code dealing
with these flags?

Differential Revision: https://phabricator.services.mozilla.com/D109086
This commit is contained in:
Emilio Cobos Alvarez 2021-03-20 01:28:20 +00:00
Родитель 423e4b6902
Коммит d1e5b2d2ed
2 изменённых файлов: 7 добавлений и 13 удалений

Просмотреть файл

@ -1006,15 +1006,10 @@
# Whether focus rings are always shown by default.
#
# This is the initial value of nsWindowRoot::mShowFocusRings, but it can be
# overridden by system preferences. For Windows, we start with default-true,
# and by default the UISF_HIDEFOCUS message comes by and sets it to false.
# overridden by system preferences.
- name: browser.display.show_focus_rings
type: bool
#ifndef XP_WIN
value: false
#else
value: true
#endif
mirror: always
# Whether we should always enable focus rings after focus was moved by keyboard.

Просмотреть файл

@ -1596,8 +1596,7 @@ void nsWindow::Show(bool bState) {
// Initialize the UI state - this would normally happen below, but since
// we're actually already showing, we won't hit it in the normal way.
::SendMessageW(mWnd, WM_CHANGEUISTATE,
MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS | UISF_HIDEACCEL),
0);
MAKEWPARAM(UIS_SET, UISF_HIDEFOCUS | UISF_HIDEACCEL), 0);
}
if (mWindowType == eWindowType_popup) {
@ -1702,10 +1701,9 @@ void nsWindow::Show(bool bState) {
if (!wasVisible && (mWindowType == eWindowType_toplevel ||
mWindowType == eWindowType_dialog)) {
// when a toplevel window or dialog is shown, initialize the UI state
::SendMessageW(
mWnd, WM_CHANGEUISTATE,
MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS | UISF_HIDEACCEL), 0);
// When a toplevel window or dialog is shown, initialize the UI state
::SendMessageW(mWnd, WM_CHANGEUISTATE,
MAKEWPARAM(UIS_SET, UISF_HIDEFOCUS | UISF_HIDEACCEL), 0);
}
} else {
// Clear contents to avoid ghosting of old content if we display
@ -6215,9 +6213,10 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
if (action == UIS_SET || action == UIS_CLEAR) {
int32_t flags = HIWORD(wParam);
UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
if (flags & UISF_HIDEFOCUS)
if (flags & UISF_HIDEFOCUS) {
showFocusRings = (action == UIS_SET) ? UIStateChangeType_Clear
: UIStateChangeType_Set;
}
NotifyUIStateChanged(showFocusRings);
}
}