Open Bug 294844 Opened 20 years ago Updated 2 years ago

Html elements can still be dragged when mouse is outside the window

Categories

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

x86
Windows XP
defect

Tracking

()

REOPENED

People

(Reporter: martijn.martijn, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: testcase)

Attachments

(1 file)

See upcoming testcase.
Afaik, you should not be able to interact with the content area, when the mouse
is outside the window.
So the draggable div in this testcase should not be dragging on when the mouse
is moved outside the content area.
This only happens when there is at least some text in the draggable div, with no
text at all, the bug doesn't happen.
Attached file testcase
Blocks: 301255
FYI: Adding "-moz-user-select: none;" to the style for #sun fixes the problem.
I believe this is the correct behavior, and certainly it's what I want. When the mouse is pressed, mouse capture is engaged so that you can get mousemove and mouseup events that occur outside the window. Once the mouseup occurs, mouse capture is turned off. If this didn't happen then DHTML dragging scripts don't get the mouseup to end the drag if the mouse is released when the cursor is outside the window. This can cause all sorts of strange behavior.
It may be what you want, until you try to implement a cross-frame drag and drop application. ;)
Yeah, there are probably scenarios where this is desired, but I think it would be better if it would happen in a controllable way, rather than by accident.
Frank: yeah, making something unselectable will "fix" this since that causes the function that does the mouse grabbing to return early:

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/generic/nsFrame.cpp&rev=3.667&mark=1781,1785-1786,1792-1793#1776

Note that capturing mouse events from outside the window is not necessarily the same thing as capturing events from outside a frame. I wonder if I would be happy if mouse events that occur outside the window caused an equivalent DOM event to be dispatched to the top level content document with the document object as the event's target, regardless of whether the capture-activating mousedown occurred in a subframe or not.

Martijn: I agree it would be nice if this was more controllable. I doubt it is possible to have this behavior happen automatically and still allow everyone to meet their use cases. Do you have any suggestions on how this might be done?
Blocks: 357679
Assignee: events → nobody
QA Contact: ian → events
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
Component: Event Handling → User events and focus handling
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: