Caret affinity is lost during mouse dragging |
||
Issue descriptionChrome Version: 73.0.3642.0 (Official Build) dev (64-bit) OS: Linux What steps will reproduce the problem? (1) Create a contenteditable div with content "abc-def" where line wrap happens after '-' (2) Mouse down at the right side of '-' and hold the mouse button (3) Without releasing, move the mouse by a little bit, but don't enter any text or the second line What is the expected result? After (2), caret should be at "abc-|" After (3), caret should be still be at "abc-|" What happens instead? After (3), caret is moved to the second line at "|def" as long as the mouse moves by a tiny bit
,
Jan 4
Test case attached. Also available at http://jsfiddle.net/b6x0nyjs/
,
Jan 7
A related bug: After setting caret at the end of first line, shift+click also moves caret to the next line.
,
Jan 7
Seems that both bugs have the same root cause.
,
Jan 8
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9c1ee116579e4a3f36ddc93bc258cfce98d5fa9a commit 9c1ee116579e4a3f36ddc93bc258cfce98d5fa9a Author: Xiaocheng Hu <xiaochengh@chromium.org> Date: Tue Jan 08 23:31:53 2019 Don't lose target position affinity in mouse drag When handling a mouse drag, if the result selection remains a caret, we should preserve the text affinity to ensure that the caret shows up in the correct line. This patch makes the implementation follow that. Bug: 919146 Change-Id: I12b40818acfc96fe1aa871cbeb40b6f45ac8a048 Reviewed-on: https://chromium-review.googlesource.com/c/1396438 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Yoshifumi Inoue <yosin@chromium.org> Reviewed-by: Yoichi Osato <yoichio@chromium.org> Cr-Commit-Position: refs/heads/master@{#620930} [modify] https://crrev.com/9c1ee116579e4a3f36ddc93bc258cfce98d5fa9a/third_party/blink/renderer/core/editing/selection_controller.cc [add] https://crrev.com/9c1ee116579e4a3f36ddc93bc258cfce98d5fa9a/third_party/blink/web_tests/editing/caret/caret_affinity_mouse_perturbation.html
,
Jan 9
|
||
►
Sign in to add a comment |
||
Comment 1 by xiaoche...@chromium.org
, Jan 4Root cause: caret affinity is lost when handling the mouse drag In SelectionController::UpdateSelectionForMouseDrag: // TextAffinity is lost in adjusted_position const PositionInFlatTree& adjusted_position = AdjustPositionRespectUserSelectAll(target, visible_selection.Start(), visible_selection.End(), target_position.DeepEquivalent()); const SelectionInFlatTree& adjusted_selection = should_extend_selection ? ExtendSelectionAsDirectional(adjusted_position, visible_selection.AsSelection(), Selection().Granularity()) : SelectionInFlatTree::Builder().Collapse(adjusted_position).Build();