Open Bug 1666851 Opened 4 years ago Updated 5 months ago

'pointerout', 'pointerenter' and 'pointerleave' events incorrectly fired during pointer capture

Categories

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

80 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: aleksandar.xyz, Assigned: edgar)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36

Steps to reproduce:

Capture pointer using setPointerCapture on pointerdown event. For example:

let capturing;

element.addEventListener( 'pointerdown', ( event ) => {
element.setPointerCapture( event.pointerId );
}, false );

Here is a working demonstration:

https://jsbin.com/vaxiruhapi/4/edit?js,output

It could be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1078327 but in regards to pointer leaving the window.

Actual results:

I you move the cursor while dragging out of the browser window, 'pointerout', 'pointerenter' and 'pointerleave' will incorrectly fire.

Expected results:

The events should not fire until the mouse/pen button is released

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → DOM: Events
Product: Firefox → Core
Component: DOM: Events → DOM: UI Events & Focus Handling

This isn't reproducible on Windows nor Ubuntu. Anne, could you try reproducing this on macOS?

Flags: needinfo?(annevk)

I can reproduce (I have Fission enabled though). If I hold the pointer down in the orange square, then drag it outside the window, the number keeps updating until I'm outside the window at which point it logs pointerleave.

Flags: needinfo?(annevk)

I think Edgar has worked on similar issue:

Flags: needinfo?(echen)

I can reproduce on Mac, too. The pointer capture stops after mouse moves outside the browser window, I guess it might be a bug on widget code, or Mac have a different behavior than other platform.

Note that neither Chrome (on macOS) nor Safari behave like Firefox, so it does not seem like a platform difference in that sense.

(In reply to Anne (:annevk) from comment #6)

Note that neither Chrome (on macOS) nor Safari behave like Firefox, so it does not seem like a platform difference in that sense.

I meant our code for event handling is generic for all platforms, but the issue happens on Mac only, so it might because Mac has some different behavior at the widget layer, e.g. the widget event order/timing is different or such, and we don't handle it well. But it is just a guess, I need to take a look closely.

In Mac OS, while mouse leaves tracking area it would generate eMouseExitFromWidget even during the drag, and we don't do any special handle for that, so you would see those event bubble up to the web content. Chrome seems only handle mouse left button correct, if you test with mouse right button, you would see same issue on Chrome. I tested various cases on Safari, all of them works well.

In Window platform, we would setup capture while mouse button is pressed, see https://searchfox.org/mozilla-central/rev/35245411b9e8a911fe3f5adb0632c3394f8b4ccb/widget/windows/nsWindow.cpp#4454-4471.

Not sure how Linux platform works.

(In reply to Edgar Chen [:edgar] from comment #8)

Not sure how Linux platform works.

Linux seems to have the same issue.

Not sure if we should handle this in Widget, like Chrome does, https://source.chromium.org/chromium/chromium/src/+/master:ui/base/cocoa/base_view.mm;l=166-172;drc=3930cf3f0e2404a517b4580b21e598a3fc648ff0. But this seems to also happen on Linux, I guess we could try to handle this on EventStateManager, for example, ignore eMouseExitFromWidget or convert it to eMouseMove during pointer capture.

Assignee: nobody → echen
Flags: needinfo?(echen)
Severity: -- → S3
Priority: -- → P2
Blocks: 822898
Blocks: pointerevent
No longer blocks: 822898
You need to log in before you can comment on or make changes to this bug.