Middle click-hold-release fires paste event after autoscrolling
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox89 | --- | fixed |
People
(Reporter: gwarser, Assigned: masayuki)
References
Details
Attachments
(4 files, 3 obsolete files)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
Steps to reproduce:
- open facebook.com
- open chat window with someone you chatted earlier (to have scrollback history)
- select some text on page to fill middle click clipboard
- middle click and hold on old message in chat window and move mouse a bit to autoscroll
- release mouse button
Actual results:
middle click clipboard content is pasted into text area on the bottom of the chat window
Expected results:
- paste should not happen
Note:
- paste does not happen if I simply middle-click once, without moving mouse
- paste does not happen if I middle-click to enter auto-scroll mode, perform autoscrolling and then middle-click again to exit auto-scroll
Related:
https://bugzilla.mozilla.org/show_bug.cgi?id=1461708
https://bugzilla.mozilla.org/show_bug.cgi?id=1521396
Updated•6 years ago
|
Updated•6 years ago
|
| Assignee | ||
Comment 1•6 years ago
|
||
Sorry for the delay.
I got it. If I move selection at middle-mousedown, I see same behavior as Chrome.
| Assignee | ||
Comment 2•6 years ago
|
||
Hmm, even if I change our "paste" event behavior exactly same as Chromium on Linux, Facebook handles the "paste" event. So, I guess that pasting issue on Facebook is not caused by this incompatibility.
| Assignee | ||
Comment 3•6 years ago
|
||
I think that we should stop dispatching eClick, eAuxClick and ePaste event when mouseup event is fired during auto-scroll. Perhaps, from AutoScrollController.jsm, we need to make ESM not dispatch them. However, I think that there is no good API to do that because we fire eClick and eAuxClick events even when eMouseUp is consumed, and "prevent multiple actions" is not useful because we've already used it for preventing double action of middle mouse paste.
Can I add new chrome API for MouseEvent?
Comment 4•6 years ago
|
||
Yeah, I agree we should stop dispatching those events when user is using the rarely used auto scrolling.
What kind of API would you need? Can it be something generic which might be useful with some other events too (and then add it as [ChromeOnly] to Event, and not just MouseEvent)?
| Assignee | ||
Comment 5•6 years ago
|
||
Thanks, I'm thinking about [ChormeOnly] method of MouseEvent, e.g.,MouseEvent.preventFollowingClickEvent() or something. I think that it's really complicated if we add new generic API to Event since there are already Event.peventDefault() and Event.preventMultipleActions(). So, adding specific name API can avoid to make them more complicated.
Comment 6•6 years ago
|
||
I see. Could there be cases when key event initiated click should be prevented? If so, perhaps the API could live in UIEvent? But also, the API can be easily moved there later, if there is actual use case.
Updated•6 years ago
|
| Assignee | ||
Comment 7•6 years ago
|
||
Ah, sorry, I misunderstood. All mouse events are propagated from auto-scroll popup to main window intentionally with using mousethrough="always". I'm investigating how can I prevent only click event in this case (mouseup event is propagated even on Chrome, but does not cause click/auxclick event).
| Assignee | ||
Comment 8•6 years ago
|
||
Ah, okay. Anyway, the new API is necessary. I'll try to write an automated test, but I'm not sure whether I can write it since the autoscroll popup is the main process's, but content is the content process's...
Because of this bug, imgur constantly nags me about "URL failed to upload".
- Linux, autoscroll enabled
- copy https://imgur.com/a/TwY6q to clipboard
- open https://imgur.com/a/TwY6q
- autoscroll by press middle mouse button on the page margin -> hold and move -> release
- small "bubble" appears on top with "URL Failed to Upload" message
I did not associated this behavior with this issue at first, but now I wonder how many text snippets from my clipboard has been sent to imgur.
I will be better with middlemouse.paste turned off.
| Assignee | ||
Comment 10•5 years ago
|
||
Resetting assignee which I don't work on in this several months.
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 11•4 years ago
|
||
Chrome and Safari move selection at middle button down and does not modify the
range at middle button up. However, they handle middle button down with
Shift key is "continue selection". So, we should handle selection in
nsIFrame when mousedown event for middle mouse button is fired, but ignore
multiple selection, drag and drop and maintaining selection for aligning the
behavior to the other browsers.
This patch splits nsIFrame::HandlePress() and calls new method which
moves selection from nsIFrame::HandleEvent() when middle button is pressed.
(Note that this patch does not check whether middle click paste is enabled
because Chrome moves selection even on Windows which Chrome always disable
middle click paste on.)
With this change, "paste" event target is changed. Previously, we used target
of the preceding mouseup event, but we start to use the target of the
preceding mousedown event.
Note that even with this patch, we still behave differently from Chrome even
in the following cases:
- middle mouse button down in selected range, we collapse it, but Chrome keeps
the selection. - middle mouse button click in selected range, we dispatch "paste" event, but
Chrome collapse selection and not dispatch "paste" event. - middle mouse button down in selected range and up in different element,
Chrome does not modify the range nor dispatch "paste" event. - Shift + middle mouse button in editable
<table>works as non-editable
in Chrome, but our editor handles it with special path. Therefore, we
don't modify the range but dispatch "paste" event in the selected range.
Changing them requires bigger change and probably requires some other features'
behavior changes. Therefore, we shouldn't touch these issues until they are
actually reported as web-compat issues.
Depends on D103996
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 12•4 years ago
|
||
Chrome behaves like this:
- When user starts autoscroll with a middle click,
mousedownandmouseup
are fired, butauxclicknorpasteevent is not fired. - When user ends autoscroll with a left click, only
mouseupevent is fired.
I.e,mousedownnorclickevent is not fired. - When user ends autoscroll with a middle click, only
mouseupevent is fired.
I.e.,mousedown,auxclicknorpasteevents is not fired. - When user ends autoscroll with a right click,
mouseupandcontextmenu
events are fired, butmousedownandauxclickevents are not fired.
This patch emulates these Chrome's behavior as far as possible. However,
unfortunately, we cannot do exactly same behavior without some big patches
because each widget (nsWindow or nsChildView) discards a mouse event
which rolled up a widget before dispatching it into the DOM. Therefore,
for now, this patch does not fix the following issues:
mousedownevent is not fired in content when clicking outside the
autoscroller to close it except when pressing the secondary button or on any
buttons on Linux.mouseupevent is not fired in content when clicking outside the
autoscroller to close it except when pressing the primary button macOS.clickevent andauxclickevents are fired when clicking outside the
autoscroller with the secondary button.
So, the middle button click/auxclick events and paste event which is
reported to the bug won't be fired with this patch. I'll file follow up bugs.
Depends on D103997
Updated•4 years ago
|
Comment 13•4 years ago
|
||
Comment 15•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/be5cf87707f9
https://hg.mozilla.org/mozilla-central/rev/33c7b633ada2
Comment 16•4 years ago
|
||
This has been backed out for for breaking navigation with clicks after the user scrolled by clicking with middle mouse button:
https://hg.mozilla.org/mozilla-central/rev/c7e489f5759a6dc1e0dabdab8772339410e5e12b
Steps to reproduce:
- Click with the mouse wheel / middle mouse button.
- Move the mouse up and down to scroll.
- Click on the page to stop the scrolling.
- Try to click a link with the left mouse button (behavior: expected navigation doesn't happen).
Comment 17•4 years ago
|
||
Backed out changeset 33c7b633ada2 (bug 1528289)
Backed out changeset be5cf87707f9 (bug 1528289)
Updated•4 years ago
|
Comment 18•4 years ago
|
||
Backed out changeset 33c7b633ada2 (bug 1528289)
Backed out changeset be5cf87707f9 (bug 1528289)
Updated•4 years ago
|
Comment 19•4 years ago
|
||
Backed out changeset 33c7b633ada2 (bug 1528289)
Backed out changeset be5cf87707f9 (bug 1528289)
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 20•4 years ago
|
||
I was confused by the old flag this._ignoreMouseEvents. It's now set to
true by startAutoscroll, but stopScroll does not set it to false.
Instead, this._scrollable is available for this purpose.
Then, the test does not pass only on 32bit Windows and macOS. The failure is,
when clicking on left mouse button, click event is fired in the content.
The difference from the other platforms, the click is handled by APZ on them.
Therefore, there is no chance to consume click event in AutoScrollParent,
AutoScrollChild nor browser-custom-element.
Depends on D104652
| Assignee | ||
Comment 21•4 years ago
|
||
The automated tests become orange only in macOS and 32bit Windows builds. It
fails when left mouse button down is synthesized in the autoscroller (a XUL
<panel> element). Although I'm not sure why that depends on the platform,
APZ cancels active autoscrolling before dispatching mousedown event.
Therefore, AutoScrollParent nor AutoScrollChild cannot block the following
click event.
Therefore, this patch adds new field into APZEventResult and set it to true
when autoscroll is synchronously canceled by a mouse input. Then,
nsBaseWidget can prevent following click event of eMouseDown and eMouseUp
events as expected before dispatching them into the DOM tree. (FYI: Preventing
click event of either eMouseDown or eMouseUp can prevent the following
click event, etc.)
Depends on D107324
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 22•4 years ago
|
||
botond: ping for review.
Comment 23•4 years ago
|
||
Sorry, a bit backed up with reviews. I hope to look at it tomorrow.
| Assignee | ||
Comment 24•4 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #23)
Sorry, a bit backed up with reviews. I hope to look at it tomorrow.
No problem, thanks in advance!
Comment 26•4 years ago
|
||
Comment 27•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/b537cd918f2d
https://hg.mozilla.org/mozilla-central/rev/6b4c18f087b7
https://hg.mozilla.org/mozilla-central/rev/f315d81e17f9
https://hg.mozilla.org/mozilla-central/rev/889132330748
Description
•