Commit Graph

736 Commits

Author SHA1 Message Date
Sean Feng
3630c2abf3 Bug 1741936 - Implement focus delegate algorithm r=emilio
Spec: https://html.spec.whatwg.org/multipage/interaction.html#focus-delegate

Differential Revision: https://phabricator.services.mozilla.com/D153689
2022-10-14 01:20:08 +00:00
Emilio Cobos Álvarez
dbe028afb1 Bug 1794777 - Make elementIsFocusable not lie with ShadowRoot.delegatesFocus and an already-focused element. r=smaug
FlushAndCheckIfFocusable was returning false, when the real thing that's
going on is that the element _is_ focusable, but it's already focused.

Improve handling of FlushAndCheckIfFocusable elsewhere, though I don't
think that can change behavior since we get the delegated focus at that
point already. Still seems like the right thing to do.

Differential Revision: https://phabricator.services.mozilla.com/D158935
2022-10-12 10:35:58 +00:00
Csoregi Natalia
d8d093364f Backed out changeset 4edc81a94eaa (bug 1792057) for causing multiple failures. CLOSED TREE 2022-10-05 21:53:02 +03:00
Emilio Cobos Álvarez
01538095ba Bug 1792057 - Make sure to focus inner text field when creating / rebuilding edit fields in datetime widget. r=smaug
The blur is a regression from bug 1740989, but it's really uncovering a
regression from bug 1729342, sorta. Before that, we used to focus the
inner text field on rebuild via focusInnerTextBox().

One could argue that the focus fixup rule should really deal with this,
but I guess since content can't really unattach shadow DOM, it's less of
a general issue and more of an implementation detail.

The test uncovers another pre-existing issue (switching from date ->
test was also broken, and we left a bogus ElementState::FOCUS state in
the element).

Differential Revision: https://phabricator.services.mozilla.com/D158167
2022-10-05 17:31:51 +00:00
Emilio Cobos Álvarez
12f31c86d8 Bug 1689816 - Flush style in moveFocus. r=smaug
This is callable from JS, and nothing guarantees that style has been
updated properly before. Without this, my previous patch causes failures
in browser/base/content/test/tabdialogs/browser_tabdialogbox_focus.js,
because the nsDeckFrame used to listen to attribute changes
synchronously and now it's style-based, so if you moveFocus right after
revealing it we'd end up with the wrong answer.

Differential Revision: https://phabricator.services.mozilla.com/D157886
2022-09-22 18:10:50 +00:00
Emilio Cobos Álvarez
65467ff64a Bug 1740989 - Implement focus fixup rule. r=smaug
This implements the proposal in the linked spec issue, and makes
it nightly-only pending resolution + edits.

Differential Revision: https://phabricator.services.mozilla.com/D155970
2022-09-01 11:28:47 +00:00
Iulian Moraru
5c4c8e97c7 Backed out changeset d8f983951128 (bug 1740989) for causing mochitest-chrome failures on test_modal_prompts.html. CLOSED TREE 2022-09-01 01:03:29 +03:00
Emilio Cobos Álvarez
be87a9cbef Bug 1740989 - Implement focus fixup rule. r=smaug
This implements the proposal in the linked spec issue, and makes
it nightly-only pending resolution + edits.

Differential Revision: https://phabricator.services.mozilla.com/D155970
2022-08-31 17:10:17 +00:00
Emilio Cobos Álvarez
aa13814e76 Bug 1765083 - Introduce FocusOptions.focusVisible. r=smaug,pip-reviewers
As per:

 * https://github.com/whatwg/html/issues/7830
 * https://github.com/whatwg/html/pull/8087

Replace the internal preventFocusRing with the new flag.

Differential Revision: https://phabricator.services.mozilla.com/D151326
2022-07-11 22:04:34 +00:00
Emilio Cobos Álvarez
f2056542cb Bug 1775451 - Scroll into view after changing focus state, not before. r=smaug
This matches other browsers.

The scroll event is dispatched async, so
the test would mostly pass without the patch, actually, except for the
fact that we wouldn't scroll. So without the patch the test times out.

Differential Revision: https://phabricator.services.mozilla.com/D150237
2022-06-28 12:58:01 +00:00
Cristian Tuns
10bda96f9c Backed out changeset 0a4ba27058a9 (bug 1775451) for causing mochitest failures on test_imestate.html CLOSED TREE 2022-06-27 07:33:08 -04:00
Emilio Cobos Álvarez
1bf671d8d5 Bug 1775451 - Scroll into view after changing focus state, not before. r=smaug
This matches other browsers.

The scroll event is dispatched async, so
the test would mostly pass without the patch, actually, except for the
fact that we wouldn't scroll. So without the patch the test times out.

Differential Revision: https://phabricator.services.mozilla.com/D150237
2022-06-27 10:56:15 +00:00
Emilio Cobos Álvarez
fb118ad24e Bug 1773070 - Rename/remove some eventState/s variables. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D148558
2022-06-07 23:09:54 +00:00
Emilio Cobos Álvarez
1c58e2a928 Bug 1773070 - Unify Gecko and Servo EventState/ElementState bits. r=smaug
Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
2022-06-07 23:09:52 +00:00
Masayuki Nakano
4c27cacfce Bug 1770133 - part 2: Make IMEStateManager::sFocusedContent store it as Element r=m_kato
`nsFocusManager` defines that focused content is at least `dom::Element`.
So `IMEStateManager` can handle focused content with `dom::Element` too.

Additionally, this patch makes `IMEStateManager` methods take references instead
of pointers as far as possible if they just return error for `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D147133
2022-05-26 07:03:19 +00:00
Masayuki Nakano
8a7f413128 Bug 1770684 - Mark IMEStateManager::SetIMEState and its callers in IMEStateManager as MOZ_CAN_RUN_SCRIPT r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147071
2022-05-26 04:37:21 +00:00
Masayuki Nakano
2f0b6cd4d9 Bug 1680611 - part 10: Mark nsFocusManager::Flush*() and their callers in nsFocusManager r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147069
2022-05-26 04:37:21 +00:00
Masayuki Nakano
60e856a8ab Bug 1680611 - part 8: Mark nsFocusManager::Blur and its callers in nsFocusManager as MOZ_CAN_RUN_SCRIPT r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147067
2022-05-26 04:37:20 +00:00
Masayuki Nakano
96fe8a653c Bug 1680611 - part 6: Mark nsFocusManager::MoveCaretToFocus() and its callers in nsFocusManager as MOZ_CAN_RUN_SCRIPT r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147065
2022-05-26 04:37:19 +00:00
Masayuki Nakano
e50d6cff45 Bug 1680611 - part 5: Get rid of nsFocusManager::FocusPlugin() because of unused r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147064
2022-05-26 04:37:19 +00:00
Masayuki Nakano
26e31d62cf Bug 1680611 - part 3: Mark nsFocusManager::WindowLowered() and its callers in nsFocusManager as MOZ_CAN_RUN_SCRIPT r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147062
2022-05-26 04:37:18 +00:00
Masayuki Nakano
6763b09ad9 Bug 1680611 - part 2: Mark nsFocusManager::SetFocusedWindowWithCallerType and its callers in nsFocusManager as MOZ_CAN_RUN_SCRIPT r=smaug,media-playback-reviewers,chunmin
Differential Revision: https://phabricator.services.mozilla.com/D147061
2022-05-26 04:37:18 +00:00
Masayuki Nakano
e872cfa146 Bug 1680611 - part 1: Mark all nsFocusManager methods whose names explain that they may dispatch events as MOZ_CAN_RUN_SCRIPT r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147060
2022-05-26 04:37:17 +00:00
Sean Feng
482f4b298e Bug 1738777 - Check whether we need to ignore tabindex again when doing sequential navigation r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D140406
2022-04-01 15:52:38 +00:00
Emilio Cobos Álvarez
e4291f8aba Bug 1761493 - Make Gecko internally consistent wrt what a link is. r=smaug
This is mostly edge-casey, but see bug 1757156 for an example where it's
causing some issues (granted, they could use `href="#"` or something
instead of an empty href).

It feels weird if a link looks like a link (because the CSS definition
of a link matches, which is "has an href") but then mostly doesn't
behave as a link.

We can't navigate anywhere if we don't have a valid URI but maybe JS
handles the relevant events as in bug 1757156.

Use the CSS definition (has href) since that's interoperable across
browsers. This should also make some stuff much faster (since checking
'is link' is now just a bit check instead of a virtual call).

(Awaiting try results, if no tests need adjustments then I need to write
some)

Differential Revision: https://phabricator.services.mozilla.com/D142107
2022-03-30 17:34:31 +00:00
Edgar Chen
400be57297 Bug 1761374 - Check action id for focus adjustment; r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D142012
2022-03-28 08:36:18 +00:00
Edgar Chen
8b92674e1c Bug 1756233 - Ensure docShellBeingHidden is not null; r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D141515
2022-03-21 09:58:00 +00:00
Sean Feng
5497f1d6f6 Bug 1739154 - Fix a bug where focus delegate step may be run when it shouldn't be r=emilio
According to the spec, focus delegate step should be run unless
the focus target is a shadow-including-ancestor of the current focus.
Our code didn't do this correctly.

Differential Revision: https://phabricator.services.mozilla.com/D138072
2022-02-08 01:04:23 +00:00
Kagami Sascha Rosylight
4e00478aaf Bug 1697256 - Check docshell existence in SetFocusInner r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D111950
2022-01-21 21:49:39 +00:00
Sandor Molnar
93b06b670c Backed out changeset a428c4aa428e (bug 1697256) for causing crashtest failures in dom/base/crashtests/1697256.html CLOSED TREE 2022-01-21 20:20:17 +02:00
Kagami Sascha Rosylight
ef8e66366c Bug 1697256 - Check docshell existence in SetFocusInner r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D111950
2022-01-21 16:31:36 +00:00
Emilio Cobos Álvarez
8b56890b85 Bug 1735076 - Use ProgrammaticFocusFlags from nsXULCommandDispatcher. r=smaug
Relevant calls are here:

  https://searchfox.org/mozilla-central/rev/21a9b72545da06681db97c4b3a2a6be761f4aae5/toolkit/content/widgets/button.js#42-68

This makes sure to set the FLAG_BYKEY properly if needed, instead of passing
down raw flags to nsFocusManager. Clean up a bit while at it.

Let me know if you want a test for this, but we have tests for programmatic
focus and :focus-visible already, so my gut feeling is that testing this
particular XUL-specific change is not super-worth-it...

Differential Revision: https://phabricator.services.mozilla.com/D133690
2021-12-23 18:34:05 +00:00
Kagami Sascha Rosylight
10a1504c02 Bug 1539884 - Part 37: Add strong references for arguments in callers r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D134475
2021-12-23 16:27:26 +00:00
Noemi Erli
bbc247e24d Backed out changeset 93b9da069dde (bug 1735076) for causing failures in browser_searchbar_openpopup.js CLOSED TREE 2021-12-21 21:53:42 +02:00
Emilio Cobos Álvarez
b25df9b5ea Bug 1735076 - Use ProgrammaticFocusFlags from nsXULCommandDispatcher. r=smaug
Relevant calls are here:

  https://searchfox.org/mozilla-central/rev/21a9b72545da06681db97c4b3a2a6be761f4aae5/toolkit/content/widgets/button.js#42-68

This makes sure to set the FLAG_BYKEY properly if needed, instead of passing
down raw flags to nsFocusManager. Clean up a bit while at it.

Let me know if you want a test for this, but we have tests for programmatic
focus and :focus-visible already, so my gut feeling is that testing this
particular XUL-specific change is not super-worth-it...

Differential Revision: https://phabricator.services.mozilla.com/D133690
2021-12-21 18:22:30 +00:00
Kagami Sascha Rosylight
ad72a8a6a9 Bug 1539884 - Part 5: Mark Focus*Event::Run as CAN_RUN_SCRIPT_BOUNDARY r=masayuki
Depends on D133914

Differential Revision: https://phabricator.services.mozilla.com/D133915
2021-12-16 17:17:06 +00:00
Butkovits Atila
0f55d2ea96 Backed out 8 changesets (bug 1539884) for causing build bustages at Document.cpp. CLOSED TREE
Backed out changeset ad65ce9208ce (bug 1539884)
Backed out changeset 15d728ef97ca (bug 1539884)
Backed out changeset de9e2829d42a (bug 1539884)
Backed out changeset a8cfa2201751 (bug 1539884)
Backed out changeset ca21c5838f37 (bug 1539884)
Backed out changeset 3d3019f61b5a (bug 1539884)
Backed out changeset ca7c808621d6 (bug 1539884)
Backed out changeset 57068a40f3c9 (bug 1539884)
2021-12-16 08:12:15 +02:00
Kagami Sascha Rosylight
3211e473cf Bug 1539884 - Part 5: Mark Focus*Event::Run as CAN_RUN_SCRIPT_BOUNDARY r=masayuki
Depends on D133914

Differential Revision: https://phabricator.services.mozilla.com/D133915
2021-12-16 02:58:45 +00:00
Masayuki Nakano
7a52e41ff0 Bug 1741148 - part 3: Make users of nsINode::ComputeIndexOf_Deprecated() use nsINode::ComputeIndexOf() if the result is not set to int32_t nor return as int32_t r=smaug
This patch fixes only the cases if the result of `ComputeIndexOf_Deprecated()`
is used as unsigned integer with implicit or explicit cast.

Differential Revision: https://phabricator.services.mozilla.com/D131336
2021-12-09 11:55:36 +00:00
Masayuki Nakano
41d6e516dc Bug 1741148 - part 1: Rename nsINode::ComputeIndexOf to ComputeIndexOf_Deprecated r=smaug
It's hard to fix some callers.  Therefore, in this bug, we should fix only
simple cases.  Therefore, we should rename existing API first.

Differential Revision: https://phabricator.services.mozilla.com/D131334
2021-12-09 08:32:30 +00:00
Mike Hommey
b9b2736d16 Bug 1744877 - Remove --disable-xul. r=Gijs
Building with --disable-xul has been busted since _at least_ bug
1082579, for more than 7 years (I didn't try to track that down
further). It's time to recognize that the option serves no purpose.

Differential Revision: https://phabricator.services.mozilla.com/D133161
2021-12-08 21:37:11 +00:00
Masayuki Nakano
1748af94ea Bug 1455514 - part 2: Add accessors and static helper methods to retrieve nsPIDOMWindowInner, nsPIDOMWindowOuter and nsPIWindowRoot r=smaug
Similar to the previous patch, there are a lot of QI from `EventTarget` to
window interfaces.  This patch adds them, but unfortunately,
`nsPIDOMWindowInner` and `nsPIDOMWindowOuter` do not inherit `EventTarget`
directly, and they are in a public header instead of their concrete classes
(`nsGlobalWindowInner` and `nsGlobalWindowOuter`).  So we cannot cast them
in `nsPIDOMWindow.h`, and it causes it's impossible to use the macros added
by the previous patch.

Differential Revision: https://phabricator.services.mozilla.com/D129782
2021-11-02 13:03:43 +00:00
Masayuki Nakano
628f3ba93c Bug 1455514 - part 1: Add accessors and static helper methods to retrieve nsINode or its concrete classes from EventTarget r=smaug
Currently, checking whether an `EventTarget` is `nsINode` (or its concrete
classes) or not requires a QI, but it's expensive and used a lot while we
handle each event.  Therefore, it'd be nicer for creating a virtual method,
`EventTarget::IsNode()` and use it for the check.

If trying to convert `EventTarget` to a concrete class, it may require two
virtual method calls.  I'm not sure whether it's cheaper than a QI, but at
least, it won't depend on the UUID check order of `QueryInterface()` when
multiple interfaces are implemented.

Differential Revision: https://phabricator.services.mozilla.com/D129781
2021-11-02 13:03:43 +00:00
Emilio Cobos Álvarez
fe23d2f6a3 Bug 1737020 - Update delegatesFocus to use its shadow tree rather than the flat tree. r=smaug,sefeng
This behavior is much more reasonable and aligns with developers
expectations better, see https://github.com/whatwg/html/issues/7207.

Differential Revision: https://phabricator.services.mozilla.com/D129146
2021-10-21 16:09:00 +00:00
Masayuki Nakano
ffa5244e07 Bug 1732845 - Add nsINode::IsInDesignMode() to check whether the node is directly in design mode r=smaug
There are a lot of check of `Document`'s editable state **with** comments. This
means that it's unclear for developers that only `Document` node is editable in
design mode.

Additionally, there are some points which use composed document rather than
uncomposed document even though the raw API uses uncomposed document. Comparing
with the other browsers, checking uncomposed document is compatible behavior,
i.e., nodes in shadow trees are not editable unless `contenteditable`.

Therefore, `nsINode` should have a method to check whether it's in design mode
or not.

Note that it may be called with a node in UA widget.  Therefore, this patch
adds new checks if it's in UA widget subtree or native anonymous subtree,
checking whether it's in design mode with its host.

Differential Revision: https://phabricator.services.mozilla.com/D126764
2021-10-12 03:14:43 +00:00
Daniel Holbert
f6ff9635d0 Bug 1733465 part 2: Modernize nsViewManager::GetRootWidget() to use already_AddRefed return value, instead of requiring getter_AddRefs at callsite. r=tnikkel
This patch shouldn't change behavior at all.

This patch replaces a manual NS_ADDREF call with typesafe code that manages the
reference count for us.  This reduces repeated boilerplate code, in the
implementation as well as the callsites.

Differential Revision: https://phabricator.services.mozilla.com/D127179
2021-10-01 20:38:09 +00:00
Sandor Molnar
cd907dc1bb Backed out 5 changesets (bug 1733465) for causing android build bustages in android/SessionAccessibility.cpp. CLOSED TREE
Backed out changeset 4c5b28b66740 (bug 1733465)
Backed out changeset 3db0452b185c (bug 1733465)
Backed out changeset d7460c9c6acb (bug 1733465)
Backed out changeset 3cee3f595e45 (bug 1733465)
Backed out changeset 267d5fc92f12 (bug 1733465)
2021-10-01 19:13:59 +03:00
Daniel Holbert
10092c7ff4 Bug 1733465 part 2: Modernize nsViewManager::GetWidget() to use already_AddRefed return value, instead of requiring getter_AddRefs at callsite. r=tnikkel
This patch shouldn't change behavior at all.

This patch replaces a manual NS_ADDREF call with typesafe code that manages the
reference count for us.  This reduces repeated boilerplate code, in the
implementation as well as the callsites.

Differential Revision: https://phabricator.services.mozilla.com/D127179
2021-10-01 14:37:05 +00:00
Karl Tomlinson
c01798fe8e Bug 1733301 generate action ID for focusmanager.testmode WindowRaised() at time of call r=hsivonen
for consistency with OS-triggered calls
https://searchfox.org/mozilla-central/rev/b022ae1fc071ad7a29f64f281bc19b7b093df538/xpfe/appshell/AppWindow.cpp#3005
and so that interleaved element-focus actions don't make the active toplevel
window change notification (and its associated content window focus changes)
stale.

Differential Revision: https://phabricator.services.mozilla.com/D127029
2021-09-30 06:48:37 +00:00
Peter Van der Beken
8863f3d134 Bug 1720990 - Clear mActiveBrowsingContextInContent when a page goes into the BFCache. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D123941
2021-09-13 16:57:15 +00:00