Open Bug 2021980 Opened 21 days ago Updated 13 days ago

Character reference to a carriage return results in wrapping _before_ the CR

Categories

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

Firefox 148
defect

Tracking

()

UNCONFIRMED

People

(Reporter: waiwai95, Unassigned)

Details

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

Steps to reproduce:

If there is a character reference to a carriage return inside a flex container, Firefox appears to wrap the text before the word immediately before the carriage return even if there is plenty of space and the text does not need to wrap at that point, which is unexpected. By way of comparison, Chrome does not wrap the text.

I believe this is fairly niche but technically uncompliant behavior:

  • A character reference to U+000D is not permitted by 13.1.4 of the HTML spec.
  • However, if the parser encounters a character reference to a carriage return, it becomes a control-character-reference parse error (13.2.5.80).
  • The parser should nonetheless emit U+000D in this scenario (13.2.2) unless it aborts parsing (which Firefox does not).
  • U+000D is then emitted into the DOM in the "in body" insertion mode (13.2.6.4.7)
  • U+000D should be treated identically to a space (U+0020) if encountered by the renderer (CSS Text Module Spec section 4)
    • I appreciate that there has been debate over how a lone CR should be rendered. However, I don't see that there is an argument to be made that there should be a line wrap before the word before the CR.

Repro:

<!DOCTYPE html>
<body>
    <div style="display:flex; border: 1px solid red;">
        <p>
            Some text here &#xD;
        </p>
    </div>
</body>

Actual results:

Firefox renders the text as follows:

Some text
here

Expected results:

Firefox renders the text as follows:

Some text here

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Text and Fonts' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Text and Fonts
Product: Firefox → Core
You need to log in before you can comment on or make changes to this bug.