Repository navigation
Conversation
…espace content widths Line breaking: when hanging whitespace overflows the line width, keep scanning instead of immediately starting a new line. Hanging whitespace does not end a line on its own: a following forced break (e.g. a newline) terminates the line normally, and following non-whitespace content that doesn't fit breaks at the opportunity marked after the hanging whitespace. Previously every overflowing whitespace atom appended to the line and then immediately broke, producing spurious empty lines (e.g. "X<space>\n<space><space>" in a 1ch-wide box produced 4 lines instead of 2). calculate_content_widths: a max-content line never wraps, so nothing can hang off it — stop subtracting the running hanging whitespace from max-width candidates. Also only accumulate hanging whitespace when wrapping is enabled (text_wrap_mode == Wrap): under a nowrap mode such as white-space:pre, trailing preserved whitespace is part of the line's width and must not hang (CSS Text 4 § 4.3.2), matching the updated line-break hanging advance computation.
tomcur
left a comment
There was a problem hiding this comment.
This is targeting the same as #790, but differs in that this does not implement the spec's conditional hanging of whitespace when it is followed by a newline or the end of the layout (see CSS Text 4 § 4.3.2 Step 4). This leaves the line breaker hanging whitespace unconditionally.
That then means this is internally inconsistent, as the max-content width can be greater than the layout's calculated width when it's broken to that width (the trailing whitespace should not hang in that case).
We also decided in #790 to wait until WhiteSpaceCollapse is available as a style in the layout, as these rules should only be applied in case of WhiteSpaceCollapse::Preserve.
| running_max_width += advance; | ||
|
|
||
| if !can_hang { | ||
| if !can_hang || text_wrap_mode != TextWrapMode::Wrap { |
There was a problem hiding this comment.
The branches below check the same thing, so this is technically superfluous. If this condition stays, perhaps the other branches should be updated to remove their checks.
(The cluster branch actually checks this per character of the cluster, which may matter if the wrap mode changes inside the cluster, though I don't know if that matches browsers.)
|
Superceded by #790 |
LLM Contributions: Generated with Fable 5.1 Low.
A few hanging whitespace fixups. Followups for #785 needed to mitigate Blitz WPT test regressions.