Closed Bug 1642223 Opened 5 years ago Closed 5 years ago

Double click to highlight word doesn't highlight first word when cursor is moved left then right

Categories

(Core :: Layout: Text and Fonts, defect, P3)

76 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox-esr68 --- wontfix
firefox77 --- wontfix
firefox78 --- wontfix
firefox79 --- fixed

People

(Reporter: 99jackpearson, Assigned: jfkthame)

References

(Regression, )

Details

(Keywords: parity-chrome, regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0

Steps to reproduce:

  • Navigate to a webpage with plain text (say, https://en.wikipedia.org/wiki/Mozilla).
  • Double click on a word (say, "founded")
  • Hold mouse after second click to continue selecting words
  • Move cursor one word left ("community")
  • Return cursor to original word

Actual results:

The left word ("community") was not highlighted, and the original word ("founded") also was not highlighted.

Expected results:

The left word ("community") was not highlighted, but the original word ("founded") was highlighted.

Steps to reproduce:

  1. open data:text/html,<h1>prev%20this%20next</h1>
  2. Double click on word "this". And do not release mouse button
  3. Move mouse pointer to "prev".
  4. And then move to "this"
  5. Optionally, continue move to "next"

Actual Results:
At step 2: "this " is selected
At step 3: "prev this " is selected
At step 4: nothing is selected --- bug
At step 5: "next" is selected --- bug

Expected Results:
At step 2: "this " is selected
At step 3: "prev this " is selected
At step 4: "this " is selected
At step 5: "this next" is selected

Regression window:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=80eefd4207ce&tochange=0322169bc93e

Has Regression Range: --- → yes
Has STR: --- → yes
Component: Untriaged → Layout
Product: Firefox → Core
Regressed by: 371839

I can confirm this happens on OS X, as well.

Status: UNCONFIRMED → NEW
Component: Layout → Layout: Text and Fonts
Ever confirmed: true

The commits for https://bugzilla.mozilla.org/show_bug.cgi?id=371839 seem a likely cause, given the regression window.

It looks to me like it's running into some kind of confusion regarding the anchor vs focus ends of the selection range, such that the selection incorrectly collapses to the end of the originally-doubleclicked word.

Note that if we continue from the STR in comment 1 with

  1. Continue moving mouse back into "this"

the selection becomes correct again.

Severity: -- → S3
Priority: -- → P3

This also affects selecting with a triple-click (to select a whole paragraph) and drag:

Testcase:

data:text/html,<p>first line<p>second line<p>third line

Triple-click in "second line" to select it; then drag upwards into "first line" to extend the selection; then back down into "second line". Expected: "second line" is selected. Actual result: no selection.

The issue arises because the selection code mishandles the anchor/focus ends of the "maintained range" representing the originally-clicked word (or line). When initially double-clicked, we save the range, with its anchor at the start and focus at the end. When dragging leftwards to the preceding word, we need to swap the ends of the maintained range so that the anchor will be at its end, and the selection will extend to the focus that is being updated as we drag. This much works fine.

However, when the mouse is dragged back into the original word, the anchor of the maintained range is now at its end, and the dynamically-moving focus also jumps to the end of the word, and we end up with an empty selection. To avoid this, when the mouse re-enters the maintained range, its anchor and focus ends need to revert to the original order.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ee15802eedda Fix behavior of AdjustNormalSelection when moving back into the maintained range from before it, to avoid collapsing to the end of the range. r=mbrodesser https://hg.mozilla.org/integration/autoland/rev/d0b8c9d1e237 Add test for multiclick-and-drag selection behavior. r=mbrodesser
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: