Граф коммитов

1202 Коммитов

Автор SHA1 Сообщение Дата
Emilio Cobos Álvarez 38b10eafda Bug 1824236 - Stop using XUL layout for scrollbars. r=jwatt
This rewrites scrollbar layout to work with regular reflow rather than
box layout.

Overall it's about the same amount of code (mostly because
nsScrollbarFrame::Reflow is sorta hand-rolled), but it cleans up a bit
and it is progress towards removing XUL layout altogether, without
getting into much deeper refactoring.

This also blocks some other performance improvements and refactorings I
want to make in this code.

We make some assumptions to simplify the code that to some extent were
made already before, both explicitly and by virtue of using XUL layout.

In particular, we assume that scrollbar / slider / thumb has no border or
padding and that the writing-mode is horizontal ltr.

Differential Revision: https://phabricator.services.mozilla.com/D173489
2023-03-27 20:54:53 +00:00
Sandor Molnar fcbacc6d6c Backed out changeset 7da2469ac949 (bug 1824236) for causing assertion failures in layout/generic/crashtests/369038-1.xhtml CLOSED TREE 2023-03-27 23:20:35 +03:00
Emilio Cobos Álvarez 914393e83e Bug 1824236 - Stop using XUL layout for scrollbars. r=jwatt
This rewrites scrollbar layout to work with regular reflow rather than
box layout.

Overall it's about the same amount of code (mostly because
nsScrollbarFrame::Reflow is sorta hand-rolled), but it cleans up a bit
and it is progress towards removing XUL layout altogether, without
getting into much deeper refactoring.

This also blocks some other performance improvements and refactorings I
want to make in this code.

We make some assumptions to simplify the code that to some extent were
made already before, both explicitly and by virtue of using XUL layout.

In particular, we assume that scrollbar / slider / thumb has no border or
padding and that the writing-mode is horizontal ltr.

Differential Revision: https://phabricator.services.mozilla.com/D173489
2023-03-27 19:12:52 +00:00
Cristina Horotan 4bb2c7c915 Bug 1784826 - disable test_bug360437.xhtml on all platforms for frequent failures. a=test-only 2023-03-20 16:37:09 +02:00
Cristina Horotan cf36c98aa5 Bug 1784826 - disable test_bug360437.xhtml on win 11 platform for frequent failures. r=intermittent-reviewers,jmaher DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D172991
2023-03-20 14:24:34 +00:00
Dan Robertson 30e2548477 Bug 1168182 - Bind wheel event targets to wheel transactions. r=masayuki,smaug
- Create wheel transactions for wheel events handled by APZ.
 - Group wheel events with the current wheel transaction, so that all
   wheel events in a wheel transaction are fired to the same element.
 - Store the current event target for the first event in a wheel
   transaction to be used for subsequent events.
 - Add the dom.event.wheel-event-groups.enabled preference as a feature
   flag for this behavior.

Differential Revision: https://phabricator.services.mozilla.com/D163484
2023-03-20 12:19:36 +00:00
Emilio Cobos Álvarez da7fa43d4a Bug 1809084 - Stop using XUL layout for menu popups. r=desktop-theme-reviewers,dao,dshin
The underlying issue here is an invalidation bug with XUL layout. When a
popup opens, we try to lay it out at full size, then post a reflow
callback to constrain it.

There's an intermediate step there where the popup might remain at full
size, and the constraining operates directly on mRect, which isn't quite
sound and doesn't update the scrollport of descendants.

Make nsMenuPopupFrame inherit from nsBlockFrame instead, doing
potentially two layout passes when constrained.

This fixes the issue at hand, and removes XUL layout from menu popups,
so it's a win-win.

To make reasoning about it a bit easier, factor out a bunch of the XUL
positioning code to be const. The mutation of mRect etc which was going
on otherwise was pretty hard to reason about.

Differential Revision: https://phabricator.services.mozilla.com/D170368
2023-03-16 19:09:14 +00:00
Emilio Cobos Álvarez ac370758b4 Bug 1822131 - Allow XUL elements to shrink-by-default. r=dholbert
Bug 1821920 and bug 1821871 are instances of an interesting behavior
change from bug 1820534.

The default flex-basis of old XUL was auto instead of max-content,
because of this code:

  https://searchfox.org/mozilla-central/rev/af78418c4b5f2c8721d1a06486cf4cf0b33e1e8d/layout/generic/nsFlexContainerFrame.cpp#1327

So stuff that used to wrap now no longer does, in an horizontal flex
container, since xul.css prevents XUL elements from shrinking.

Per the comment, a few tests relied on this, but I believe it should
generally be safe to shrink the items. This only causes to shrink if
they have an explicit width but no min-width (including min-width:
auto).

Some tests like test_mousescroll.xhtml hit this, because they have
explicit sizes but min-width: auto ends up being 0 effectively, but I
believe we should tweak those tests instead.

Differential Revision: https://phabricator.services.mozilla.com/D172462
2023-03-14 12:22:11 +00:00
Norisz Fay 0eabfe04d0 Backed out changeset e3fb28ffc489 (bug 1822131) for causing reftest failures on 540247-1.xhtml 2023-03-14 01:20:07 +02:00
Emilio Cobos Álvarez f60d745bc2 Bug 1822131 - Allow XUL elements to shrink-by-default. r=dholbert
Bug 1821920 and bug 1821871 are instances of an interesting behavior
change from bug 1820534.

The default flex-basis of old XUL was auto instead of max-content,
because of this code:

  https://searchfox.org/mozilla-central/rev/af78418c4b5f2c8721d1a06486cf4cf0b33e1e8d/layout/generic/nsFlexContainerFrame.cpp#1327

So stuff that used to wrap now no longer does, in an horizontal flex
container, since xul.css prevents XUL elements from shrinking.

Per the comment, a few tests relied on this, but I believe it should
generally be safe to shrink the items. This only causes to shrink if
they have an explicit width but no min-width (including min-width:
auto).

Some tests like test_mousescroll.xhtml hit this, because they have
explicit sizes but min-width: auto ends up being 0 effectively, but I
believe we should tweak those tests instead.

Differential Revision: https://phabricator.services.mozilla.com/D172462
2023-03-13 20:43:34 +00:00
Emilio Cobos Álvarez 097eb3703e Bug 1820534 - Move front-end to modern flexbox. r=Gijs,dao,settings-reviewers,credential-management-reviewers,sgalich,devtools-reviewers,nchevobbe
Done mostly automatically via find/replace following the conversions
specified here:

  https://groups.google.com/a/mozilla.org/g/firefox-dev/c/9sGpF1TNbLk/m/QpU3oTUuAgAJ

For the most part I think the "flex: N N" usage could be simplified to
just "flex: N", but I wanted to preserve behavior (-moz-box-flex sets
both flex-grow and flex-shrink).

I changed legacy layout to also look at the order property rather than
-moz-box-ordinal-group because it made splitters and treecols easier (we
don't need to deal with both orders).

Differential Revision: https://phabricator.services.mozilla.com/D171715
2023-03-08 16:13:57 +00:00
Stanca Serban 923ef223cd Backed out changeset c25af897c9bc (bug 1820534) for causing reftests and mochitests failures. 2023-03-08 17:34:42 +02:00
Emilio Cobos Álvarez 57e476145f Bug 1820534 - Move front-end to modern flexbox. r=Gijs,dao,settings-reviewers,credential-management-reviewers,sgalich,devtools-reviewers,nchevobbe
Done mostly automatically via find/replace following the conversions
specified here:

  https://groups.google.com/a/mozilla.org/g/firefox-dev/c/9sGpF1TNbLk/m/QpU3oTUuAgAJ

For the most part I think the "flex: N N" usage could be simplified to
just "flex: N", but I wanted to preserve behavior (-moz-box-flex sets
both flex-grow and flex-shrink).

I changed legacy layout to also look at the order property rather than
-moz-box-ordinal-group because it made splitters and treecols easier (we
don't need to deal with both orders).

Differential Revision: https://phabricator.services.mozilla.com/D171715
2023-03-08 14:11:35 +00:00
Brad Werth 73c097499a Bug 1631735 Part 4: Make tests that minimize windows wait for size mode change events. r=mstange
Depends on D170841

Differential Revision: https://phabricator.services.mozilla.com/D171626
2023-03-06 19:38:12 +00:00
Iulian Moraru a6d122dc1c Backed out changeset 2ddeecc9100b (bug 1168182) for causing mochitest failures on test_wheel_scroll.html. CLOSED TREE 2023-02-22 21:32:15 +02:00
Dan Robertson e03ea6d72f Bug 1168182 - Bind wheel event targets to wheel transactions. r=masayuki,smaug
- Create wheel transactions for wheel events handled by APZ.
 - Group wheel events with the current wheel transaction, so that all
   wheel events in a wheel transaction are fired to the same element.
 - Store the current event target for the first event in a wheel
   transaction to be used for subsequent events.
 - Add the dom.event.wheel-event-groups.enabled preference as a feature
   flag for this behavior.

Differential Revision: https://phabricator.services.mozilla.com/D163484
2023-02-22 16:57:05 +00:00
Emilio Cobos Álvarez 1f12238611 Bug 1817518 - Try to activate menuitem harder.
This tries to fix some failures on autoland that didn't show up on try
(on linux64 with socket-process enabled).
2023-02-22 12:08:21 -05:00
Emilio Cobos Álvarez 71662660c4 Bug 1817518 - De-select closed menuitems on mouseout. r=mstange
I knew this sounded familiar, see bug 1811466.

The patch is a one-liner, the rest is a test. I'd ask smaug for review
but he's on PTO so... Markus, maybe you can take a look?

Differential Revision: https://phabricator.services.mozilla.com/D170269
2023-02-22 15:58:54 +00:00
Matthias Camenzind a36aa2e14f Bug 1814834 - Maintain client size in SyncAttributesToWidget() depending on the last resize. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D169633
2023-02-13 21:00:02 +00:00
Emilio Cobos Álvarez d28f1e4d47 Bug 1815255 - Fix tests to deal with flexbox emulation. r=Jamie,Gijs
Mostly changing XUL attributes to CSS properties, though there are a few
tricky ones:

 * test_offsets.xhtml expects the scroller to be full-width, while
   modern flexbox would honor width: 200px (so just remove it).

 * window_intrinsic_size.xhtml was relying on the div imposing a XUL
   min-size (the test is for SetSizeConstraints, bug 1447056). Use
   min-height instead as that's what modern flexbox reads. Confirmed
   that bug doesn't regress in any case.

 * object-fit-contain-png-001.xhtml has a float: left which had no
   effect on -moz-box, but which assert with modern layout[1]. In the
   future I think we could remove that assert but anyways, for now just
   keeping behavior.

 * image-size.xhtml has a couple uninvestigated sizing differences. They
   didn't seem problematic.

 * 579323-1-ref.html changes because the other file has a canvas with
   width=100 height=100 which imposes an aspect ratio (which XUL never
   honored).

 * window_largemenu.xhtml shows a regression, but this never worked on
   some platforms (at least Linux+Wayland) and nobody has noticed it in
   the browser area, so I suspect we're fine.

[1]: https://searchfox.org/mozilla-central/rev/08362489086b10de96e7a199b267ea5504c01583/layout/generic/ReflowInput.cpp#2137

Differential Revision: https://phabricator.services.mozilla.com/D169084
2023-02-09 12:24:53 +00:00
Marian-Vasile Laza 7675a138b5 Backed out 2 changesets (bug 1815255) for causing reftest failures. CLOSED TREE
Backed out changeset b1173e8c7497 (bug 1815255)
Backed out changeset bd09cf2a4abb (bug 1815255)
2023-02-09 04:26:01 +02:00
Emilio Cobos Álvarez 656f11b2a0 Bug 1815255 - Fix tests to deal with flexbox emulation. r=Jamie,Gijs
Mostly changing XUL attributes to CSS properties, though there are a few
tricky ones:

 * test_offsets.xhtml expects the scroller to be full-width, while
   modern flexbox would honor width: 200px (so just remove it).

 * window_intrinsic_size.xhtml was relying on the div imposing a XUL
   min-size (the test is for SetSizeConstraints, bug 1447056). Use
   min-height instead as that's what modern flexbox reads. Confirmed
   that bug doesn't regress in any case.

 * object-fit-contain-png-001.xhtml has a float: left which had no
   effect on -moz-box, but which assert with modern layout[1]. In the
   future I think we could remove that assert but anyways, for now just
   keeping behavior.

 * image-size.xhtml has a couple uninvestigated sizing differences. They
   didn't seem problematic.

 * 579323-1-ref.html changes because the other file has a canvas with
   width=100 height=100 which imposes an aspect ratio (which XUL never
   honored).

 * window_largemenu.xhtml shows a regression, but this never worked on
   some platforms (at least Linux+Wayland) and nobody has noticed it in
   the browser area, so I suspect we're fine.

[1]: https://searchfox.org/mozilla-central/rev/08362489086b10de96e7a199b267ea5504c01583/layout/generic/ReflowInput.cpp#2137

Differential Revision: https://phabricator.services.mozilla.com/D169084
2023-02-09 00:55:13 +00:00
Cristina Horotan fbcc0f66b4 Backed out 2 changesets (bug 1815255) for causing chrome failures at test_focus.xhtml on a CLOSED TREE
Backed out changeset 983fe4e70647 (bug 1815255)
Backed out changeset f8c6426c60f9 (bug 1815255)
2023-02-08 19:50:19 +02:00
Emilio Cobos Álvarez 5db814c383 Bug 1815255 - Fix tests to deal with flexbox emulation. r=Jamie,Gijs
Mostly changing XUL attributes to CSS properties, though there are a few
tricky ones:

 * test_offsets.xhtml expects the scroller to be full-width, while
   modern flexbox would honor width: 200px (so just remove it).

 * window_intrinsic_size.xhtml was relying on the div imposing a XUL
   min-size (the test is for SetSizeConstraints, bug 1447056). Use
   min-height instead as that's what modern flexbox reads. Confirmed
   that bug doesn't regress in any case.

 * object-fit-contain-png-001.xhtml has a float: left which had no
   effect on -moz-box, but which assert with modern layout[1]. In the
   future I think we could remove that assert but anyways, for now just
   keeping behavior.

 * image-size.xhtml has a couple uninvestigated sizing differences. They
   didn't seem problematic.

 * 579323-1-ref.html changes because the other file has a canvas with
   width=100 height=100 which imposes an aspect ratio (which XUL never
   honored).

 * window_largemenu.xhtml shows a regression, but this never worked on
   some platforms (at least Linux+Wayland) and nobody has noticed it in
   the browser area, so I suspect we're fine.

[1]: https://searchfox.org/mozilla-central/rev/08362489086b10de96e7a199b267ea5504c01583/layout/generic/ReflowInput.cpp#2137

Differential Revision: https://phabricator.services.mozilla.com/D169084
2023-02-08 16:52:18 +00:00
Emilio Cobos Álvarez 07c34bc2d9 Bug 1815309 - Test. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D169063
2023-02-07 13:49:24 +00:00
Emilio Cobos Álvarez e7174ae731 Bug 1813303 - Test. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D168375
2023-02-03 14:18:53 +00:00
Sandor Molnar 21460758e7 Backed out changeset 32dc2c5f63df (bug 1813303) for causing mochitest failures in toolkit/content/tests/chrome/test_maximized_persist_with_no_titlebar.xhtml CLOSED TREE 2023-02-02 04:21:57 +02:00
Emilio Cobos Álvarez c80ccbf7db Bug 1813303 - Test. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D168375
2023-02-01 23:27:01 +00:00
Mark Banner 99c7240948 Bug 1812973 - Add xulStore interface to ESLint's services.json. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D168042
2023-01-27 10:00:31 +00:00
Gijs Kruitbosch 129735a58b Bug 1811854 - switch remaining tests to BrowserTestUtils.loadURIString from BrowserTestUtils.loadURI, r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D167558
2023-01-24 13:19:11 +00:00
Mark Banner 166d8573cb Bug 1811796 - Automatically replace Cu.reportError with console.error (most of toolkit). r=mossop,credential-management-reviewers,dimi
Depends on D167518

Differential Revision: https://phabricator.services.mozilla.com/D167519
2023-01-23 18:09:03 +00:00
Edgar Chen e5fe0a40c0 Bug 1796548 - Introduce a generic method to check clipboard capabilities in nsIClipboard; r=geckoview-reviewers,nika,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D166475
2023-01-16 19:50:17 +00:00
Nika Layzell 05dc1d3602 Bug 1808630 - Part 1: Clean up after test_edit_contextmenu.html, r=smaug
This fixes the main issue, and makes the test pass by avoiding issues with the
window sticking around after test completion, messing up future runs.

Differential Revision: https://phabricator.services.mozilla.com/D166119
2023-01-09 22:22:05 +00:00
Emilio Cobos Álvarez 8f9e643713 Bug 1809019 - Menulists shouldn't be considered to have a menu parent. r=smaug
This worked pre-patch because IsOnMenu() returned true not for all
popups, but only for <menupopup>. Instead, I think it's clearer to just
treat menulists as never-inside-a-menu.

Differential Revision: https://phabricator.services.mozilla.com/D166247
2023-01-09 07:50:29 +00:00
Emilio Cobos Álvarez 4f1f5e7314 Bug 1805414 - Remove nsMenuFrame and nsMenuParent. r=smaug,Jamie,desktop-theme-reviewers,settings-reviewers,dao
Move most the event handling stuff to the DOM. I've left nsMenuBarFrame
for now, but I will be removing that in the future.

The basic set up is:

  * nsMenuParent becomes XULMenuParentElement (menubar or popup, manages
    the current active menu item)

  * nsMenuFrame -> XULButtonElements that return true for IsMenu().
    Can't use XULMenuElement because of <button type=menu>, which
    behaves like a, well, menu.

This makes the a11y events for menus (DOMMenuItem{Active,Inactive}) make
sense (before that we were firing duplicate Inactive events etc, and the
event order was rather suspicious).

Differential Revision: https://phabricator.services.mozilla.com/D164210
2023-01-04 19:01:13 +00:00
Csoregi Natalia 9807a6e6e8 Backed out changeset f11c529b2407 (bug 1805414) for failures on test_submenuClose.xhtml and nsMenuPopupFrame.cpp. CLOSED TREE 2023-01-04 01:48:30 +02:00
Emilio Cobos Álvarez 3d82727505 Bug 1805414 - Remove nsMenuFrame and nsMenuParent. r=smaug,Jamie,desktop-theme-reviewers,settings-reviewers,dao
Move most the event handling stuff to the DOM. I've left nsMenuBarFrame
for now, but I will be removing that in the future.

The basic set up is:

  * nsMenuParent becomes XULMenuParentElement (menubar or popup, manages
    the current active menu item)

  * nsMenuFrame -> XULButtonElements that return true for IsMenu().
    Can't use XULMenuElement because of <button type=menu>, which
    behaves like a, well, menu.

This makes the a11y events for menus (DOMMenuItem{Active,Inactive}) make
sense (before that we were firing duplicate Inactive events etc, and the
event order was rather suspicious).

Differential Revision: https://phabricator.services.mozilla.com/D164210
2023-01-03 22:06:01 +00:00
Emilio Cobos Álvarez 6913a852ce Bug 1807892 - Fix test_popup_recreate.xhtml on some platforms.
On platforms with scrollbar size > dropmarker width the popup is not
guaranteed to be bigger than the menulist after this patch and
bug 1805694 (given the "menu sizes to popup" behavior changed there).

Ensure the popup is sized to the menulist by widening the later.

MANUAL PUSH: Trivial test fix CLOSED TREE
2022-12-29 22:54:20 +01:00
Stephen A Pohl d704105be4 Bug 1430892: Prevent accidental selection of an item in a dropdown menu and closing the menu on macOS. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D161310
2022-12-20 16:55:44 +00:00
Emilio Cobos Álvarez bbe36d6bf7 Bug 1805694 - Simplify menulist popup layout. r=tnikkel
I decided to split this up from bug 1805414 because it's only
tangentially related to the removal of nsMenuFrame.

We have this sizetopopup attribute and behavior that allows menulists to
be sized to the contents of the popup. The popup also expands to the
menulist rect.

This means that layout is by somewhat cyclic and we need to go out of
our way to support it. However, I think we only care about the first
behavior. We don't have many non-intrinsically-sized menulists, and
if we need we can use HTML <select> instead, which does have that
behavior.

Simplify the setup to make sizetopopup only apply to menulists (we don't
have non-menulist usage anyways), and only work in the "popup depends on
the menulist" direction, not the other way around.

This will allow making the popup a regular out-of-flow element. The
change to test_menulist_paging is not needed (I restored the behavior of
eagerly layout menulists, to fix the <select> popup, but I'd like to fix
that eventually, so I'd rather leave them in, they're harmless).

Differential Revision: https://phabricator.services.mozilla.com/D164693
2022-12-19 16:15:52 +00:00
Emilio Cobos Álvarez b8a0c9a742 Bug 1805500 - Implement panel borders in cocoa using a border rather than shadow. r=mstange,extension-reviewers
My guess is that it was done using shadows to not interfere with the
native look, but actually this just works even with native-looking menus
(like the <select> menulist), because the background-color for those is
set on the menupopup, rather than the ::part(content).

So those have effectively 1px of extra padding (due to the transparent
border), but that seems barely perceptible, and worth the consistency
and simplification.

Differential Revision: https://phabricator.services.mozilla.com/D164716
2022-12-17 01:45:05 +00:00
Cristian Tuns c2f987572a Backed out changeset b9473eda2d5b (bug 1805500) for causing mochitest failures on browser_ext_popup_select_in_oopif.js CLOSED TREE 2022-12-16 19:10:34 -05:00
Emilio Cobos Álvarez 1eb1a7ba94 Bug 1805500 - Implement panel borders in cocoa using a border rather than shadow. r=mstange,extension-reviewers
My guess is that it was done using shadows to not interfere with the
native look, but actually this just works even with native-looking menus
(like the <select> menulist), because the background-color for those is
set on the menupopup, rather than the ::part(content).

So those have effectively 1px of extra padding (due to the transparent
border), but that seems barely perceptible, and worth the consistency
and simplification.

Differential Revision: https://phabricator.services.mozilla.com/D164716
2022-12-16 17:34:48 +00:00
Norisz Fay df7a96cf4a Backed out changeset 48f2dad16e54 (bug 1805694) for causing bc failures on browser_selectpopup.js CLOSED TREE 2022-12-16 19:11:19 +02:00
Norisz Fay 08d4a8b04f Backed out changeset 839fc9d4bfa4 (bug 1805500) for causing mochitest failures on browser_test_select_popup_position.js 2022-12-16 18:11:22 +02:00
Emilio Cobos Álvarez ed57810bcf Bug 1805500 - Implement panel borders in cocoa using a border rather than shadow. r=mstange,extension-reviewers
My guess is that it was done using shadows to not interfere with the
native look, but actually this just works even with native-looking menus
(like the <select> menulist), because the background-color for those is
set on the menupopup, rather than the ::part(content).

So those have effectively 1px of extra padding (due to the transparent
border), but that seems barely perceptible, and worth the consistency
and simplification.

Differential Revision: https://phabricator.services.mozilla.com/D164716
2022-12-16 10:31:33 +00:00
Emilio Cobos Álvarez 51b37cc937 Bug 1805694 - Simplify menulist popup layout. r=tnikkel
I decided to split this up from bug 1805414 because it's only
tangentially related to the removal of nsMenuFrame.

We have this sizetopopup attribute and behavior that allows menulists to
be sized to the contents of the popup. The popup also expands to the
menulist rect.

This means that layout is by somewhat cyclic and we need to go out of
our way to support it. However, I think we only care about the first
behavior. We don't have many non-intrinsically-sized menulists, and
if we need we can use HTML <select> instead, which does have that
behavior.

Simplify the setup to make sizetopopup only apply to menulists (we don't
have non-menulist usage anyways), and only work in the "popup depends on
the menulist" direction, not the other way around.

This will allow making the popup a regular out-of-flow element. The
change to test_menulist_paging is not needed (I restored the behavior of
eagerly layout menulists, to fix the <select> popup, but I'd like to fix
that eventually, so I'd rather leave them in, they're harmless).

Differential Revision: https://phabricator.services.mozilla.com/D164693
2022-12-16 10:23:05 +00:00
Emilio Cobos Álvarez a14c746228 Bug 1805415 - Use activateItem() rather than click() to activate menuitems. r=Gijs,extension-reviewers,pip-reviewers,search-reviewers
Bug 1805414 will move menu event handling to the DOM.

With that change the current synthetic click behavior of XUL menuitems
breaks. On current central, we rely on nsMenuFrame::HandleEvent not
getting called at all for synthetic clicks, and instead we just fire a
command event synchronously here:

  https://searchfox.org/mozilla-central/rev/a0d4f8f112c5c792ae272bf6ce50763ddd23ffa2/dom/xul/nsXULElement.cpp#1071

After my patch the command event is fired properly (potentially
asynchronously too) by the regular menu activation machinery, which is
preferable.

 * They fire a command event synchronously (even though on some
   platforms like macOS activating a context menu item is async).

 * They use a totally different codepath from what a user does.

 * They don't deal with native menus, etc.

We have a proper API for this (activateItem) which takes a much more
closer codepath to what users do, requires that the menu is shown, etc.
Use that API instead for testing.

As a benefit, tests now do not need to close the context menu manually
when clicking on a menu item (because we trigger the same code path as
users clicking the menu).

Differential Revision: https://phabricator.services.mozilla.com/D164567
2022-12-15 03:11:55 +00:00
Cristian Tuns b638ccfac9 Backed out 2 changesets (bug 1805415) for causing dt failures on browser_net_telemetry_throttle_changed.js CLOSED TREE
Backed out changeset 5056d7df9f1e (bug 1805415)
Backed out changeset e13513500184 (bug 1805415)
2022-12-14 08:52:21 -05:00
Emilio Cobos Álvarez be1f057109 Bug 1805415 - Use activateItem() rather than click() to activate menuitems. r=Gijs,extension-reviewers,pip-reviewers,search-reviewers
Bug 1805414 will move menu event handling to the DOM.

With that change the current synthetic click behavior of XUL menuitems
breaks. On current central, we rely on nsMenuFrame::HandleEvent not
getting called at all for synthetic clicks, and instead we just fire a
command event synchronously here:

  https://searchfox.org/mozilla-central/rev/a0d4f8f112c5c792ae272bf6ce50763ddd23ffa2/dom/xul/nsXULElement.cpp#1071

After my patch the command event is fired properly (potentially
asynchronously too) by the regular menu activation machinery, which is
preferable.

 * They fire a command event synchronously (even though on some
   platforms like macOS activating a context menu item is async).

 * They use a totally different codepath from what a user does.

 * They don't deal with native menus, etc.

We have a proper API for this (activateItem) which takes a much more
closer codepath to what users do, requires that the menu is shown, etc.
Use that API instead for testing.

As a benefit, tests now do not need to close the context menu manually
when clicking on a menu item (because we trigger the same code path as
users clicking the menu).

Differential Revision: https://phabricator.services.mozilla.com/D164567
2022-12-14 10:25:17 +00:00