Closed Bug 1696176 Opened 3 years ago Closed 3 years ago

Broken behavior in nsIFrame::SelectByTypeAtPoint

Categories

(Core :: Layout, defect)

defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(1 file)

The method nsIFrame::SelectByTypeAtPoint is supposed to select content at the given position, based on the nsSelectionAmount parameters to determine the types of boundary to respect in each direction.

The only reasonable expectation would be, for example, that if the given point falls in the middle of a simple glyph, and the requested amount is "character", the individual character at that position should be selected.

However, in this situation SelectByTypeAtPoint will in fact select two characters, the real "target" of the point and an additional character before or after it.

This behavior is reflected in the expectations of the nsIDOMWindowUtils.selectAtPoint testcase at https://searchfox.org/mozilla-central/rev/3f97afc8db535f9b0232222cb48cc4cbf8334c76/dom/tests/mochitest/chrome/selectAtPoint.html#113-119, where individual "character" or "cluster" selections apparently expect to select a pair of characters. I believe this expectation is incorrect/illogical.

A similar selecting-two-units-instead-of-one effect can also be demonstrated in Firefox on macOS (or presumably on other platforms if layout.word_select.eat_space_to_next_word is false; note that on Windows it is true by default).

STR:
In Firefox on macOS, load the trivial testcase

data:text/html,<h1>one two three
  • Try double-clicking within a word. The individual target word is selected, as expected.

  • Try double-clicking at the left-hand edge of the word "two". Again, the individual target word is selected, as expected.

  • Now try double-clicking at the right-hand edge of "two". This time, Firefox selects "two three" -- it incorrectly extends the selection to include the following word. This happens if the double-click occurs within the right-hand half of the "o" or the left-hand half of the inter-word space.

It may be debatable whether double-clicking within inter-word space should in fact select the space instead of the adjacent word (this is what other browsers seem to do), but it certainly should not select both the preceding and following words.

This also prevents incorrectly selecting two words when double-clicking at
the end of the first word (before the inter-word space).

We also update the selectAtPoint testcase to target more widely-spread glyphs,
to check that it is behaving accurately across a larger distance.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #9207073 - Attachment description: Bug 1696176 - Fix nsIFrame::PeekBackwardAndForward so that selectAtPoint correctly selects a single character or cluster rather than two adjacent characters. r?dholbert → Bug 1696176 - Fix nsIFrame::PeekBackwardAndForward so that selectAtPoint correctly selects a single character or cluster rather than two adjacent characters. r=dholbert
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a7ceef946175
Fix nsIFrame::PeekBackwardAndForward so that selectAtPoint correctly selects a single character or cluster rather than two adjacent characters. r=dholbert,emilio
Flags: needinfo?(jfkthame)
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d7e50a94db5b
Fix nsIFrame::PeekBackwardAndForward so that selectAtPoint correctly selects a single character or cluster rather than two adjacent characters. r=dholbert,emilio
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ad40c13d6a3d
Fix nsIFrame::PeekBackwardAndForward so that selectAtPoint correctly selects a single character or cluster rather than two adjacent characters. r=dholbert,emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
Regressions: 1706990
Flags: needinfo?(jfkthame)
No longer regressions: 1706990
See Also: → 1706990
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: