Closed Bug 1958985 Opened 3 months ago Closed 2 months ago

Can't use arrow up/down keys to land on an empty list item in contenteditable div

Categories

(Core :: Layout: Generated Content, Lists, and Counters, defect)

defect

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
firefox139 --- fixed

People

(Reporter: dshin, Assigned: jfkthame)

Details

Attachments

(2 files)

Attached file Reduced testcase

Noticed this on Slack.

STR:

  1. Load attached test case
  2. Put caret on upper "test" by clicking on it
  3. Press down arrow, observe where the caret moves to
  4. Put caret on lower "test" by clicking on it
  5. Press up arrow, observe where the caret moves to
  6. Put caret on middle bullet
  7. Press either up/down arrow, observe where the caret moves to

Expected:

  • Step 3: Moves to the first bullet
  • Step 5: Moves to the last bullet
  • Step 7: Moves to the first (up)/last (down) bullet

Actual:

  • Step 3: Moves to the upper test
  • Step 5: Moves to the lower test
  • Step 7: Moves to the upper (up)/lower (down) bullet

It's not purely about empty list items, even:

  1. Load the testcase
  2. Click to the caret on each bullet in turn, and insert the words "one", "two", "three" on the respective lines
  3. Click to put the caret in the middle of the upper word "test"
  4. Press down-arrow

Expected: caret moves to the beginning of the first list item
Actual: caret jumps past the list items to the lower "test"

  1. Now add text to the top line so that it reads "test for caret movement with arrow keys"
  2. Click in the middle of the word "keys"
  3. Press down-arrow

Expected: caret moves to the end of the first list item (maintaining its horizontal position, as far as possible within the line)
Actual: works as expected

So the problem occurs when the horizontal offset of the caret is before the start of the list-item text.

And it only occurs when the list-item's ::marker has display: inline-block; changing it to display: inline resolves the issue.

Similar behavior can be reproduced with other kinds of generated content having inline-block display, e.g. with

data:text/html,<style>blockquote::before{content:"*";display:inline-block}</style>
    <div contenteditable>test<blockquote>quote</blockquote>test</div>

up/down arrows will move the caret directly between the two "test" lines, skipping the indented blockquote.

The same thing happens if the "target" caret position is past the end of a line, and it ends with generated content having display: inline-block. Example:

data:text/html,<style>blockquote::after{content:"*";display:inline-block}</style>
    <div contenteditable>test for caret movement<blockquote>quote</blockquote>test</div>

Put the caret at the end of the word "movement" and press down-arrow; it skips past the "quote" to end of the third line.

Severity: -- → S3

What's happening seems to be that the search in nsIFrame::PeekOffsetForLine ends up descending into the inline-block frame found at the beginning or end of the potential target line; but then it determines that it's not a valid result because it is generated content; so the search fails on that line, and moves on to the next.

We should prevent the search descending into the generated-content block, and let it try the next (or previous) frame on the line instead.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #9479641 - Attachment description: Bug 1958985 - Don't recurse into generated-content block within GetNextPrevLineFromBlockFrame. r=#layout → Bug 1958985 - Don't allow a generated-content block as a "result frame" in GetNextPrevLineFromBlockFrame. r=#layout
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/82da936a0e11 Don't allow a generated-content block as a "result frame" in GetNextPrevLineFromBlockFrame. r=layout-reviewers,emilio
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/52089 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-triage-done-c140/b139]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: