Open Bug 1720538 Opened 5 years ago Updated 7 days ago

Dispatch mouse events for X1 / X2 mouse buttons, and implement back/forward navigation as the default action

Categories

(Core :: DOM: Events, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: mstange, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

The current implementation of X1 / X2 mouse button clicks skips the mouse event dispatch entirely, and dispatches a WindowCommandEvent instead.
This means that web pages do not have the ability to handle these mouse buttons.

In Chrome, at least on macOS, web pages receive mouse events for X1 / X2 mouse buttons. It seems like back/forward navigation is handled as the default handling for the click event (but this should be investigated some more).

I think we should do the same, where possible. For example, on Windows, it looks like back/forward navigation from these buttons is done via a WM_APPCOMMAND message, and depending on the driver, this message is only sent based on the status we return for the WM_(NC)XBUTTONDOWN/UP messages.

IIRC, both Microsoft and Logitech interupt the button messages before focused app... I'll check it later.

Severity: -- → N/A
Priority: -- → P3
Attached file testcase (obsolete) —

(In reply to Markus Stange [:mstange] from comment #0)

It seems like back/forward navigation is handled as the default handling for the click event (but this should be investigated some more).

The testcase shows that there is no click event; in Chrome, the navigation is done as the default handling of the mouseup event. Calling preventDefault() on mouseup prevents the navigation.

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #1)

IIRC, both Microsoft and Logitech interupt the button messages before focused app... I'll check it later.

No problem about Logitech's mouse. I'll check Microsoft's mouse tomorrow.

click is for the primary button only. auxclick is for other buttons.

Attached file testcase

Added auxclick support. Calling preventDefault() on auxclick does not prevent back/forward navigation in Chrome.

Attachment #9231257 - Attachment is obsolete: true

I confirmed that both Microsoft's Mouse-KeyboardCenter and Logitech Options work equally. They sent x button messages first, then, WM_APPCOMMAND is sent. And on Chrome, only mouseup can prevent the default.

Any technical difficulties adding this feature?

The MDN browser compatibility table of MouseEvent.button and MouseEvent.buttons says Firefox has full support, but it's not true, because Firefox doesn't dispatch mousedown/pointerdown events for back/forward buttons, it's time to fix it or we should add an implementation note to that compatibility table.

Currently Alt + MouseWheel behaves as back/forward in Firefox, that behavior may easily cause unwanted page navigation but fortunately can be prevented by canceling keyup event of Alt key, while I cannot prevent back/forward behaviors triggered by mouse x-buttons.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: