mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 08:51:04 +00:00

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. Differential Revision: https://phabricator.services.mozilla.com/D103997
Common testing tools for mozilla codebase projects, test suite definitions for automated test runs, tests that don't fit anywhere else, and other fun stuff