Allow obtaining the mouse button for menuitem clicks from the command event
Categories
(Core :: DOM: Events, task)
Tracking
()
People
(Reporter: mstange, Assigned: mstange)
References
Details
(Whiteboard: [proton-uplift])
Attachments
(6 files, 1 obsolete file)
Bug 1469148 added a click event listener to WebExtension context menu items, which manually fires a command event and closes the menu. This click event listener has two purposes:
- It allows the menu item to be clicked with middle clicks. By default, probably for no good reason, menu items only respond to left and right button clicks.
- The click event has the information about the mouse button that was used for the event.
Native context menus will not fire a click event. If the mouse button is needed, it will somehow need to be delivered via the command event.
I can think of two ways to do this:
- We could add a
button
property toXULCommandEvent
. - Or we could create a DOM mouse event with the right button and put it into the command event's
sourceEvent
attribute.
Smaug, Masayuki, which solution would you prefer?
This problem is currently preventing native context menus from being enabled by default (bug 1700679), because doing so would make the test browser_ext_menus_capture_secondary_click.js
fail. (There are other test failures too, this is just one of them.)
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
At the moment, WebExtension menu items are special cased to allow this, by using
a click event listener which manually fires command and closes the menu.
I would like to remove the click listener, because native menus won't fire click.
Assignee | ||
Comment 2•4 years ago
|
||
Depends on D111954
Assignee | ||
Comment 3•4 years ago
|
||
Depends on D111955
Assignee | ||
Comment 4•4 years ago
|
||
Depends on D111954
Assignee | ||
Comment 5•4 years ago
|
||
This problem isn't exclusive to ext-menus.js; we also have the same setup for the content area context menu:
https://searchfox.org/mozilla-central/search?q=checkForMiddleClick&path=
The menu items have a click handler which calls checkForMiddleClick, which, for middle clicks, dispatches a command event and closes the menu.
Comment 6•4 years ago
|
||
I like adding button
better since otherwise and if events are stored outside event listeners, source events are also copied into the heap.
Comment 7•4 years ago
|
||
Do we need to dispatch command events for non-primary clicks? Usually only left click triggers command.
...
oh, I see https://searchfox.org/mozilla-central/rev/759872688df15a5d6ab305ffe39d90450590bfec/browser/base/content/utilityOverlay.js#712 is bizarre. Doing something against platform convention.
But yeah, .button property would be fine.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 8•4 years ago
|
||
Comment hidden (obsolete) |
Assignee | ||
Comment 10•4 years ago
|
||
Assignee | ||
Comment 11•4 years ago
|
||
Now that there is no more click handler, we need to go one level lower to keepthis test passing.
At this point in the patch series, activateItem does not yet support the button property.
Later on in this series, I will replace this with an activateItem call so that the test works with native context menus as well.
Assignee | ||
Comment 12•4 years ago
|
||
Comment 13•4 years ago
|
||
Comment 14•4 years ago
|
||
Backed out for bc failures on browser_ext_menus_capture_secondary_click.js
Backout link: https://hg.mozilla.org/integration/autoland/rev/c16907689a746b031581c59c45a508163d8a3252
Log link: https://treeherder.mozilla.org/logviewer?job_id=336564952&repo=autoland&lineNumber=15385
Comment 15•4 years ago
|
||
Please also check failures on browser_contextmenu_whereToOpenLink.js -> https://treeherder.mozilla.org/logviewer?job_id=336573344&repo=autoland&lineNumber=4939
Updated•4 years ago
|
Assignee | ||
Comment 16•4 years ago
|
||
In the past, menus stayed open when an item was middle-clicked. Now that menus
fire command on middle-click, they automatically close when middle-clicked.
So this code now needs to handle middle clicks on menus like left clicks on
menus, and manually keep the menu open (rather than rely on them staying open
by default).
This functionality is covered by browser_stayopenmenu.js.
Depends on D112073
Assignee | ||
Comment 17•4 years ago
|
||
Comment 18•4 years ago
|
||
Comment 19•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/196422b73904
https://hg.mozilla.org/mozilla-central/rev/2b505afdf0ff
https://hg.mozilla.org/mozilla-central/rev/673588cfb191
https://hg.mozilla.org/mozilla-central/rev/8c46cf21aba8
https://hg.mozilla.org/mozilla-central/rev/c28ff25f8047
https://hg.mozilla.org/mozilla-central/rev/fd72fcc0fa52
Comment 20•4 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-beta/rev/293e266ee29b
https://hg.mozilla.org/releases/mozilla-beta/rev/96a00e46c8dd
https://hg.mozilla.org/releases/mozilla-beta/rev/34a4398b67fe
https://hg.mozilla.org/releases/mozilla-beta/rev/5ab5ccb0459c
https://hg.mozilla.org/releases/mozilla-beta/rev/dbaa28b321be
https://hg.mozilla.org/releases/mozilla-beta/rev/986f7739ea86
Updated•4 years ago
|
Updated•3 years ago
|
Description
•