Commit Graph

805 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
a705793753 Bug 1895229 - Remove nsIWebBrowserChromeFocus. r=hsivonen,dom-core
It's only implemented by BrowserChild, we can do this more directly.

Differential Revision: https://phabricator.services.mozilla.com/D209534
2024-05-06 11:30:34 +00:00
Emilio Cobos Álvarez
45b669a6a7 Bug 1036966 - Make accessibility.tabfocus default to 7 on macOS too. r=morgan,settings-reviewers,mac-reviewers,mstange
Stop supporting following the system preference, but keep macOS users
able to switch to just text controls (accessibility.tabfocus=1) in the
settings.

Change the meaning of the "Use the tab key to move focus between form
controls and links" checkbox in the Firefox settings, which was
introduced in bug 1628476 to override the system setting.

The intention, I think was that this checkbox being off resulted in
"follow the system" behavior, but that didn't quite happen due to a bug
in the preferences code (this[1] won't unset the pref, because of
this[2], which means we'll just return 0).

This patch changes it so that the checkbox instead always ignores the
system setting. There will no longer be a Firefox setting (neither in
the UI nor on about:config) that means "follow system setting".

This allows us to somewhat simplify the approach compared to the
previous patch in D196110, and keep the accessibility.tabfocus working
as the source of truth without a migration.

In the future, we can think of migrating accessibility.tabfocus to a
boolean pref, which would allow us to do the cleanups to the preferences
code that D196110 did.

[1]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/browser/components/preferences/main.js#2252
[2]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/toolkit/content/preferencesBindings.js#450,483

Differential Revision: https://phabricator.services.mozilla.com/D208602
2024-05-03 23:10:47 +00:00
Tamas Szentpeteri
453ac165cb Backed out changeset 644738c3ccfe (bug 1036966) for causing mochitest failures in test_tabindex.html. CLOSED TREE 2024-05-03 04:18:36 +03:00
Emilio Cobos Álvarez
87eeb156af Bug 1036966 - Make accessibility.tabfocus default to 7 on macOS too. r=morgan,settings-reviewers,mac-reviewers,mstange
Stop supporting following the system preference, but keep macOS users
able to switch to just text controls (accessibility.tabfocus=1) in the
settings.

Change the meaning of the "Use the tab key to move focus between form
controls and links" checkbox in the Firefox settings, which was
introduced in bug 1628476 to override the system setting.

The intention, I think was that this checkbox being off resulted in
"follow the system" behavior, but that didn't quite happen due to a bug
in the preferences code (this[1] won't unset the pref, because of
this[2], which means we'll just return 0).

This patch changes it so that the checkbox instead always ignores the
system setting. There will no longer be a Firefox setting (neither in
the UI nor on about:config) that means "follow system setting".

This allows us to somewhat simplify the approach compared to the
previous patch in D196110, and keep the accessibility.tabfocus working
as the source of truth without a migration.

In the future, we can think of migrating accessibility.tabfocus to a
boolean pref, which would allow us to do the cleanups to the preferences
code that D196110 did.

[1]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/browser/components/preferences/main.js#2252
[2]: https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/toolkit/content/preferencesBindings.js#450,483

Differential Revision: https://phabricator.services.mozilla.com/D208602
2024-05-02 22:19:53 +00:00
Ziran Sun
1229476ae0 Bug 1891934 - [popover] Handling focus naviagtion when invoker is not focusable. r=smaug
At popover navigation bug 1856539, we left the case that when invoker is not focusable to its default behaviour.
At https://github.com/web-platform-tests/wpt/pull/45391, it is suggested that we should another element next to
the invoker to focus.

Differential Revision: https://phabricator.services.mozilla.com/D207693
2024-05-02 08:51:13 +00:00
Tamas Szentpeteri
a9d1e792f2 Backed out changeset 977bf4319b43 (bug 1891934) for causing wpt failures in nsFocusManager.cpp. CLOSED TREE 2024-04-24 16:40:18 +03:00
Ziran Sun
8eea0c4e75 Bug 1891934 - [popover] Handling focus naviagtion when invoker is not focusable. r=smaug
At popover navigation bug 1856539, we left the case that when invoker is not focusable to its default behaviour.
At https://github.com/web-platform-tests/wpt/pull/45391, it is suggested that we should another element next to
the invoker to focus.

Differential Revision: https://phabricator.services.mozilla.com/D207693
2024-04-24 10:23:58 +00:00
Sean Feng
0f45ff8550 Bug 1884870: Clear ancestors' focus when child document loses the focus r=hsivonen,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D205135
2024-03-27 20:48:28 +00:00
Olli Pettay
3bca61d1e9 Bug 1887621 - Micro-optimize nsFocusManager::ContentRemoved, r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D205551
2024-03-25 14:02:28 +00:00
Sean Feng
684a2f7a04 Bug 1483828 - [Part 4] Ensure KEY_F6 still works properly for chrome document navigation r=smaug
KEY_F6 has a special requirement for chrome document navigation
such that if the focus algorithm has reached to the end of the
top-level chrome document, it expects to focus first element of
this chrome document, because the root element of chrome document
is not focusable. This patch is to ensure this behaviour is still
working.

dom/tests/mochitest/chrome/test_focus_docnav.xhtml is used to test this.

Differential Revision: https://phabricator.services.mozilla.com/D200864
2024-03-04 14:16:32 +00:00
Sean Feng
d7254ccf1b Bug 1483828 - [Part 1] Disallow <tab> to move focus to root element r=smaug
Brings us on-par with Chrome and Safari

Differential Revision: https://phabricator.services.mozilla.com/D198436
2024-03-04 14:16:30 +00:00
Emilio Cobos Álvarez
3107f02299 Bug 1879607 - Rename nsINode::GetPreviousContent to nsINode::GetPrevNode. r=smaug
For parallelism with GetNextNode.

Differential Revision: https://phabricator.services.mozilla.com/D201264
2024-02-09 20:42:39 +00:00
Sean Feng
faf28dc59b Bug 1878753 - Fix focus gets incorrectly cleared by PresShell::FixUpFocus if the focus is on area element r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D200950
2024-02-08 16:35:02 +00:00
Emilio Cobos Álvarez
5a714b595c Bug 1875100 - Propagate top level activeness automatically to top descendants. r=nika,tabbrowser-reviewers,mconley,extension-reviewers,robwu,geckoview-reviewers,owlish,kaya
For that, opt in tabbrowser and the shopping sidebar to manual
activeness management.

Differential Revision: https://phabricator.services.mozilla.com/D198942
2024-02-07 10:58:15 +00:00
Cristian Tuns
77579088f3 Backed out changeset ecd780688279 (bug 1875100) for causing mochitest failures in test_suspend_media_by_inactive_docshell.html 2024-02-07 01:25:21 -05:00
Emilio Cobos Álvarez
a6a14d3ed6 Bug 1875100 - Propagate top level activeness automatically to top descendants. r=nika,tabbrowser-reviewers,mconley,extension-reviewers,robwu,geckoview-reviewers,owlish
For that, opt in tabbrowser and the shopping sidebar to manual
activeness management.

Differential Revision: https://phabricator.services.mozilla.com/D198942
2024-02-06 21:47:37 +00:00
Emilio Cobos Álvarez
8b123421cc Bug 1877672 - Simplify some uses of FunctionRef that now can use lambdas. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D200158
2024-02-02 19:21:20 +00:00
Emilio Cobos Álvarez
ca8e85e34b Bug 1877242 - Avoid some unnecessary refcounting churn when accessing parent-cross-chrome-boundary. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D199901
2024-01-30 23:24:43 +00:00
Masayuki Nakano
5e49db6103 Bug 1872301 - Make nsFocusManager::GetSelectionLocation never fail when found text node has no frame r=NeilDeakin
In the test case, `nsFocusManager::GetSelectionLocation` is called with
collapsed selection at end of the `<svg>` which ends with collapsible
white-spaces.  Therefore, it reaches the white-space only text node and it
does not have a primary frame due to invisible.

Previously, creating `nsFrameIterator` failed and then the method returned
error, but after bug 779684, `nsFrameIterator` constructor wants non-nullptr
frame avoiding crash.  Therefore, I added the `MOZ_ASSERT` there to get a
way to reproduce the case and now we got it.

I think that just removing `MOZ_ASSERT` and keeping returning error is not
correct. The text can be invisible with the other reasons and it does not
collapsed at end of invisible text, this does not return error.  Therefore,
this patch makes just returning the text in the case without error.

Differential Revision: https://phabricator.services.mozilla.com/D198128
2024-01-17 00:25:04 +00:00
Masayuki Nakano
2ac7025389 Bug 1872000 - Make nsFocusManager::GetSelectionLocation check whether the text frame is nullptr before creating nsFrameIterator r=emilio
See the comment in the bug, this is not a new crash.  The old factory method
did the null-check and returned.  Therefore, before using `MOZ_TRY`, calling
a method of `nsFrameIterator` with `nullptr` caused a crash.

I tried to reproduce this bug with creating empty text nodes or invisible
text nodes, but I couldn't reproduce this.  Therefore, this patch does not
contain crash tests.

Differential Revision: https://phabricator.services.mozilla.com/D197317
2023-12-27 07:48:25 +00:00
Masayuki Nakano
099c05f33c Bug 779684 - part 3: Make nsFrameIterator non-refcountable r=emilio
Nobody shares an instance of `nsFrameIterator`.  Therefore, we can make it
non-refcountable.  Additionally, `nsVisualIterator` is not required because
it overrides only 4 methods which are really simple.  So, once we merge it
into `nsFrameIterator`, we can allocate it in the stack.

Differential Revision: https://phabricator.services.mozilla.com/D197144
2023-12-24 06:01:19 +00:00
Masayuki Nakano
0c98adaa6f Bug 779684 - part 2: Get rid of nsFrameTraversal and nsIFrameTraversal r=emilio
The class is used only for creating `nsFrameIterator`, but it's unnecessary
so that we can get rid of it and its interface.

Differential Revision: https://phabricator.services.mozilla.com/D197143
2023-12-24 06:01:19 +00:00
Masayuki Nakano
ff15a98ea7 Bug 779684 - part 1: Get rid of nsIFrameEnumerator interface r=emilio
It's inherited only by `nsFrameIterator`, and `nsFrameIterator` can be declared
in a header file. So, the interface is not required and removing it can avoid
virtual calls.

Differential Revision: https://phabricator.services.mozilla.com/D197142
2023-12-24 06:01:19 +00:00
Stanca Serban
3651b1ac9c Backed out 3 changesets (bug 779684) for causing nsFrameIterator related mochitests failures.
Backed out changeset 8b92fb4e3f41 (bug 779684)
Backed out changeset f357b2287591 (bug 779684)
Backed out changeset 738fe6bbf913 (bug 779684)
2023-12-23 10:32:48 +02:00
Masayuki Nakano
bf4e6a40b9 Bug 779684 - part 3: Make nsFrameIterator non-refcountable r=emilio
Nobody shares an instance of `nsFrameIterator`.  Therefore, we can make it
non-refcountable.  Additionally, `nsVisualIterator` is not required because
it overrides only 4 methods which are really simple.  So, once we merge it
into `nsFrameIterator`, we can allocate it in the stack.

Differential Revision: https://phabricator.services.mozilla.com/D197144
2023-12-23 05:39:39 +00:00
Masayuki Nakano
dc9647c07e Bug 779684 - part 2: Get rid of nsFrameTraversal and nsIFrameTraversal r=emilio
The class is used only for creating `nsFrameIterator`, but it's unnecessary
so that we can get rid of it and its interface.

Differential Revision: https://phabricator.services.mozilla.com/D197143
2023-12-23 05:39:38 +00:00
Masayuki Nakano
8cc40d3b31 Bug 779684 - part 1: Get rid of nsIFrameEnumerator interface r=emilio
It's inherited only by `nsFrameIterator`, and `nsFrameIterator` can be declared
in a header file. So, the interface is not required and removing it can avoid
virtual calls.

Differential Revision: https://phabricator.services.mozilla.com/D197142
2023-12-23 05:39:38 +00:00
Emilio Cobos Álvarez
71e771518b Bug 1868552 - Refactor nsIContent::IsFocusable for clarity. r=masayuki
Make it be output-only, not having that confusing in-out tab-index
parameter that is special for XUL to become focusable with
-moz-user-focus: normal. Instead, do that explicitly in
nsIFrame::IsFocusable().

Also, call it IsFocusableWithoutStyle(), since that's what it is.

Differential Revision: https://phabricator.services.mozilla.com/D195644
2023-12-08 11:34:06 +00:00
Ziran Sun
bed8737ffd Bug 1856539 - Add focus navigation support for popover. r=emilio,smaug,edgar
This implements the focus behavior described in [1]:

 1. Moves focus from an invoking element to its invoked popover,
    regardless of where in the DOM that popover lives.
 2. Moves focus back to the next focusable element after the
    invoking element once focus leaves the invoked popover.
 3. Skips over an open invoked popover otherwise.

[1] https://html.spec.whatwg.org/#focus-navigation-scope-owner

Differential Revision: https://phabricator.services.mozilla.com/D190560
2023-11-16 15:25:54 +00:00
Norisz Fay
44ea06c342 Backed out changeset d3fec9e5f456 (bug 1856539) for causing bustage on nsFrameTraversal.cpp CLOSED TREE 2023-11-16 16:05:55 +02:00
Ziran Sun
cd63bb5e85 Bug 1856539 - Add focus navigation support for popover. r=emilio,smaug,edgar
This implements the focus behavior described in [1]:

 1. Moves focus from an invoking element to its invoked popover,
    regardless of where in the DOM that popover lives.
 2. Moves focus back to the next focusable element after the
    invoking element once focus leaves the invoked popover.
 3. Skips over an open invoked popover otherwise.

[1] https://html.spec.whatwg.org/#focus-navigation-scope-owner

Differential Revision: https://phabricator.services.mozilla.com/D190560
2023-11-16 10:57:14 +00:00
Narcis Beleuzu
3d36a651dc Backed out changeset bc6c5c88423b (bug 1856539) for bustages on nsFrameTraversal.cpp . CLOSED TREE 2023-11-16 00:44:04 +02:00
Ziran Sun
d5806368ef Bug 1856539 - Add focus navigation support for popover. r=emilio,smaug,edgar
This implements the focus behavior described in [1]:

 1. Moves focus from an invoking element to its invoked popover,
    regardless of where in the DOM that popover lives.
 2. Moves focus back to the next focusable element after the
    invoking element once focus leaves the invoked popover.
 3. Skips over an open invoked popover otherwise.

[1] https://html.spec.whatwg.org/#focus-navigation-scope-owner

Differential Revision: https://phabricator.services.mozilla.com/D190560
2023-11-15 18:51:36 +00:00
Sandor Molnar
f20c834438 Backed out changeset 58fc056d5652 (bug 1856539) for causing build bustages at layout/base/nsFrameTraversal.cpp CLOSED TREE 2023-11-15 18:09:47 +02:00
Ziran Sun
009a5623dd Bug 1856539 - Add focus navigation support for popover. r=emilio,smaug,edgar
This implements the focus behavior described in [1]:

 1. Moves focus from an invoking element to its invoked popover,
    regardless of where in the DOM that popover lives.
 2. Moves focus back to the next focusable element after the
    invoking element once focus leaves the invoked popover.
 3. Skips over an open invoked popover otherwise.

[1] https://html.spec.whatwg.org/#focus-navigation-scope-owner

Differential Revision: https://phabricator.services.mozilla.com/D190560
2023-11-15 09:46:35 +00:00
Noemi Erli
aff86dfd0c Backed out changeset 4267cbd5b7f5 (bug 1856539) for causing bustages in nsFocusManager.cpp 2023-11-14 12:38:50 +02:00
Ziran Sun
abb1cc1e1b Bug 1856539 - Add focus navigation support for popover. r=emilio,smaug,edgar
This implements the focus behavior described in [1]:

 1. Moves focus from an invoking element to its invoked popover,
    regardless of where in the DOM that popover lives.
 2. Moves focus back to the next focusable element after the
    invoking element once focus leaves the invoked popover.
 3. Skips over an open invoked popover otherwise.

[1] https://html.spec.whatwg.org/#focus-navigation-scope-owner

Differential Revision: https://phabricator.services.mozilla.com/D190560
2023-11-14 09:07:38 +00:00
Jan Varga
272327b326 Bug 1855134 - Move existing MOZ_TRY macros to a dedicated header file; r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D189226
2023-09-28 20:46:07 +00:00
pommicket
58155264eb Bug 1248186 - prevent focus loss at end of [contenteditable] r=masayuki
Adjust nsFocusManager::GetSelectionLocation so that
it never moves the selection outside of the "ancestor limiter".

Differential Revision: https://phabricator.services.mozilla.com/D186864
2023-09-26 07:45:20 +00:00
Emilio Cobos Álvarez
e76308530f Bug 1248186 - Preliminary clean-up of nsFocusManager::GetSelectionLocation. r=masayuki
This patch shouldn't change behavior. It just removes a lot of noise
from that function.

In particular, it simplifies various conditions that can't happen, like
startNode being a text-node but a form control at the same time, or a
text-node and the root element.

Differential Revision: https://phabricator.services.mozilla.com/D186964
2023-08-29 09:45:52 +00:00
Markus Stange
51a7e874f7 Bug 1843484 - Use EventTarget* instead of nsISupports* in some nsFocusManager methods. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D186978
2023-08-28 23:38:43 +00:00
Markus Stange
a4e2816d54 Bug 1843484 - Use EventTarget* instead of nsISupports* for the event target parameter of the EventDispatcher::Dispatch methods. r=smaug
This saves a few QueryInterface calls on the hot path.

Differential Revision: https://phabricator.services.mozilla.com/D186977
2023-08-28 23:38:43 +00:00
Markus Stange
70bd936589 Bug 1843484 - Use EventTarget* instead of nsISupports* for the event target parameter of the nsContentUtils::Dispatch methods. r=smaug
This saves a few queryInterface calls on the hot path.

Differential Revision: https://phabricator.services.mozilla.com/D186976
2023-08-28 23:38:42 +00:00
Logan Rosen
847ac3aef0 Bug 1091187 - remove unused arguments and check from UpdateCommands r=dom-core,webidl,masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D185385
2023-08-10 04:09:08 +00:00
Peter Van der Beken
c10814e75a Bug 1846277 - Remove nsGlobalWindow.h. r=dom-core,necko-reviewers,jesup,farre
Differential Revision: https://phabricator.services.mozilla.com/D184973
2023-08-02 20:41:48 +00:00
Emilio Cobos Álvarez
64833c7584 Bug 1842679 - Consistently scroll to center for focus. r=dlrobertson
Differential Revision: https://phabricator.services.mozilla.com/D183512
2023-07-16 21:27:22 +00:00
Masayuki Nakano
9eee09202f Bug 1841689 - Make nsFocusManager::ContentRemoved let IMEStateManager of focus change when focused element is removed from the tree r=emilio
When an element in the shadow DOM of UA widget of `<input>` gets focus,
`IMEStateManger` let know the element instead of `<input>`.  Then, when
`HTMLInputElement` destroys the shadow DOM at changing type attribute,
`IMEStateManager` may not let know the focus change until `TextEditor`
is created.  Then, `IMEContentObserver` is created by `UpdateIMEState`
notification from `EditorBase::PostCreateInternal`, but
`TextControlState::GetIMEContentObserver()` fails to check whether it's
observed by an `IMEContentObserver` instance (*1).  Therefore,
`TextControlState` fails to notify `IMEContentObserver` of the value change
while `TextEditor` is not ready (*2).  Then, `IMEContentObserver` will let
IME know only a selection change without text change.  Therefore,
`ContentCacheInChild` will get invalid data due to outdated `mText` value
and latest `mSelection` value (*3).

For solving this issue, this patch makes `nsFocusManager::ContentRemoved`
let `IMEStateManager` know the focus change synchronously because `TextEditor`
may be initialized for some API calls of `HTMLInputElement` before
`nsFocusManager` handles the focus change.

1. https://searchfox.org/mozilla-central/rev/1bcef85eb36da6de8fab890bc724e214dde68ecb/dom/html/TextControlState.cpp#3055
2. https://searchfox.org/mozilla-central/rev/1bcef85eb36da6de8fab890bc724e214dde68ecb/dom/html/TextControlState.cpp#2959
3. https://searchfox.org/mozilla-central/rev/1bcef85eb36da6de8fab890bc724e214dde68ecb/widget/ContentCache.cpp#54

Differential Revision: https://phabricator.services.mozilla.com/D183080
2023-07-14 00:30:25 +00:00
Emilio Cobos Álvarez
c05407a221 Bug 1843277 - Remove nsContentUtils::HasPluginWithUncontrolledEventDispatch. r=peterv
Always false.

Differential Revision: https://phabricator.services.mozilla.com/D183495
2023-07-13 14:35:12 +00:00
Dan Robertson
f10f43b3d7 Bug 1818126: Use WhereToScroll::Center when tab scrolling. r=hiro,credential-management-reviewers,sgalich
When scrolling the next element into view for a tab scroll, scroll the
element to the center.

Differential Revision: https://phabricator.services.mozilla.com/D182930
2023-07-12 13:20:09 +00:00
Emilio Cobos Álvarez
529c9ee321 Bug 1839922 - Remove usage of {Has,Get}Attr(kNameSpaceID_None, ..). r=edgar
We have more readable and faster versions (that just omit the namespace
arg).

Mostly done via sed, with a couple helpers to use the faster lookups
where possible.

Differential Revision: https://phabricator.services.mozilla.com/D181795
2023-06-23 10:01:32 +00:00