Closed Bug 1691622 Opened 4 years ago Closed 4 years ago

Cannot synthesize native middle/right mouse button event via `nsIDOMWindowUtils::SendNativeMouseEvent()` on Linux

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

Desktop
Linux
defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(13 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

The API was defined with assuming that a native event is mapped to a mouse button down and up. However, on Linux and Android (and 4th or later buttons on Windows) do not so. They just have "mousedown" or "mouseup" message and specifies additional information of mouse button ID.

I'll fix this only for Linux for now.

OS: All → Linux
Summary: Cannot synthesize native middle/right mouse button event via `nsIDOMWindowUtils::SendNativeMouseEvent()` on Linux and Anroid → Cannot synthesize native middle/right mouse button event via `nsIDOMWindowUtils::SendNativeMouseEvent()` on Linux

In these days, API should take an Object instead of multiple arguments
since the callers look like using "named" arguments and this allows to
add new optional arguments with changing not all callers.

This patch also changes similar API for APZ aware tests for keeping
consistent style for their users.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED

With adding new feild to the aParam, synthesizeNativeMouseClick can
work as synthesizenativeMouseClickAtCenter too. Therefore, we can get
rid of the redundant API.

Additionally, this patch makes synthesizeNativeMouseClickWithAPZ can
take the new field for consistency between them.

Depends on D105755

Some tests want to specify screen position directly. Therefore, they should
have additional fields in the Object param to take offset in screen.

Depends on D105756

Surprisingly, they don't take modifiers, and
nsIWidget::SynthesizeNativeMouseEvent() which are implementations of
nsIDOMWindowUtils::SendNativeMouseEvent() treat given modifier flags
are native's ones, and handle modifiers only on macOS. Therefore, this
patch makes them handle native modifiers of Gecko.

Unfortunately, I'm not so familiar with Android API, and in the short
term, I don't need the support on Android. Therefore, this patch just
adds a TODO comment on Android widget.

Additionally, we don't have a simple way to set modifier only while
posting a mouse input on Windows too. It requires complicated code.
Therefore, I don't add the support for it on Windows too.

Depends on D105757

Let's make synthesizeNativeMouseClick* take an event type, and only when
it's click, it should send native mouse event twice.

Then, we can all them synthesizeNativeMouseEvent*.

Depends on D105758

Now, there are no users of this API. However,
nsIWidget::SynthesizeNativeMouseMove() is still used by EventStateManager.
Even though it's just redirected to nsIWidget::SynthesizeNativeMouseEvent(),
but it hides the native event message from EventStateManager. Therefore,
this patch keeps the widget API for now.

Depends on D105761

Currently, it takes a raw native message value, but it makes JS content too
complicated. And on Linux, it cannot synthesize non-primary button events
because GDK has only button press and release messages which dont' include
mouse button information.

For solving these problems, this patch creates a new abstract native message
as nsIWidget::NativeMouseMessage and makes each widget converts it to
a platform native message.

Additionally, this patch adds an argument to make it possible its callers
to specify pressing or releasing mouse button with a DOM mouse button value.

Note that the following patch adds new argument to
synthesizeNativeEventMouse* for mochitests and which will be tested by
new tests.

Depends on D105762

Now, it should take button argument whose default value is 0 (primary
button).

Depends on D105763

For making the test framework/API change easier, such raw API shouldn't be
used directly. Therefore, this patch makes tests using it directly stop
using it and use synthesizeNativeMouseEvent instead.

However, this patch does not fix browser_touch_event_iframes.js because
it accesses the API from ContentTask. So, EventUtils.js isn't available
without larger change.

Depends on D105764

For minimizing the previous patch changes, scale's default value for
screenX/Y is treated as 1.0. It means that screenX/Y are device
pixels by default, but offsetX/Y are in CSS pixels by default. This
difference may make developers confused. Therefore, we should align the
default unit of them to screenPixelsPerCSSPixel. I.e., their default
unit becomes CSS pixels.

Depends on D105765

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/e649d8ff7787 part 1: Make `synthesizeNativeMouseClick` take an `Object` instead of multiple arguments for synthesizing events r=smaug https://hg.mozilla.org/integration/autoland/rev/301ce838d678 part 2: Merge `synthesizeNativeMouseClickAtCenter` with `synthesizeNativeMouseClick` r=smaug https://hg.mozilla.org/integration/autoland/rev/54b426637c32 part 3: Make `synthesizeNativeMouseClick` take screenX/Y r=smaug https://hg.mozilla.org/integration/autoland/rev/727097623436 part 4: Make `synthesizeNativeMouseClick*()` aware of modifiers r=smaug,geckoview-reviewers,m_kato https://hg.mozilla.org/integration/autoland/rev/d21beb190305 part 5: Make `synthesizeNativeMouseClick*` take an event type r=smaug https://hg.mozilla.org/integration/autoland/rev/dc5e230ba557 part 6: Merge `synthesizeNativeMouseClick*` with `synthesizeNativeMouseEvent*` r=smaug https://hg.mozilla.org/integration/autoland/rev/6af85d93a7f2 part 7: Merge `synthesizeNativeMouseMove*` with `synthesizeNativeMouseEvent*` r=smaug https://hg.mozilla.org/integration/autoland/rev/b3e0851f5cec part 8: Get rid of `nsIDOMWindowUtils::SendNativeMouseMove()` r=smaug https://hg.mozilla.org/integration/autoland/rev/1008909e3dde part 9: Make `nsIWidget::SynthesizeNativeMouseEvent` take an XP button ID and abstract message value r=smaug,geckoview-reviewers,agi,m_kato https://hg.mozilla.org/integration/autoland/rev/5fc38c58de82 part 10: Make `synthesizeNativeMouseEvent` take a button argument r=smaug https://hg.mozilla.org/integration/autoland/rev/da33e4b8fa18 part 11: Make mochitests stop using `nsIDOMWindowUtils.sendNativeMouseEvent` directly as far as possible r=smaug https://hg.mozilla.org/integration/autoland/rev/ed9c8bd8966c part 12: Change the default unit of `screenX/Y` of `synthesizeNativeMouseEvent` from device pixels to CSS pixels r=smaug
Pushed by dluca@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f3050f40efe5 part 13: Make `helper_scrollbarbutton_repeat.html` use new API to synthesize native mouse click. r=fix CLOSED TREE
Regressions: 1694567
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: