Fix line-box content detection for negative-height boxes, NBSP width handling and inline box quantization - #22
Closed
nicoburns wants to merge 3 commits into
Conversation
- An in-flow inline box with a negative reserved height (e.g. an atomic inline with a large negative margin-top) is still content: the strut must apply and the line must not be treated as empty. Only out-of-flow boxes (infinitely negative extents) are ignored. - Only ordinary spaces (U+0020) are collapsible/hangable whitespace for the purposes of min/max content widths and line-end trimming; no-break spaces are preserved (css-text-3 §4.1.1, §4.1.3).
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Inline box extents are exact sizes supplied by the caller; rounding the ascent and descent independently could reserve one more pixel than the box's height, producing an off-by-one line height (WPT floats-141).
Only the content-width calculation should stop trimming NBSP; changing the line-break-time handling regresses line-break: anywhere tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Contributions: This PR was produced with Devin (an LLM tool) under the direction of the requester; the follow-up regression triage of Blitz #832 is documented on that PR.
Three fixes for regressions found while triaging the WPT diff of DioxusLabs/blitz#832 (which consumes #18).
LineBoxMetrics::add_inline_box(parley/src/layout/line_break.rs) treated an inline box withascent + descent <= 0as "no content", so a line containing only an atomic inline with a large negativemargin-top(reserved height negative but finite) was laid out as an empty/invisible line with no strut. Now any finite non-zero extents count as content; only out-of-flow boxes (which Blitz passes withNEG_INFINITYextents) are still skipped.add_inline_boxalso roundedascentanddescentindependently whenquantizeis set. For a box whose baseline splits it into two.5halves this reserves one more pixel than the box's (already integral) height, e.g. 82px for an 81px box. Inline box extents are exact sizes from the caller, not font metrics, so they are no longer rounded (the box height and the resulting line coords are still quantized as before). Together with (1) this fixescss/CSS2/floats-clear/floats-141.xht.calculate_content_widths(parley/src/layout/data.rs) subtracted NBSP advances as "trailing whitespace" when computing min/max content widths. NBSP is neither collapsible nor hangable (css-text-3 §4.1.1, §4.1.3), so a shrink-to-fit inline-block containing only collapsed to zero width. Only U+0020 is trimmed now. Fixesinline-block-zorder-004/005.xhtandt41-html4-keywords-a.xhtin Blitz WPT. The line-breaker's ownis_spacecheck at line-break time is intentionally left asis_space_or_nbsp(): changing it made 8 justify/trailing-space tests pass but regressedline-break-anywhere-overrides-uax-behavior-004/006, so that is left for a separate change.Regression tests added in
parley/src/tests/test_style_metrics.rs:line_with_negative_height_inline_box_is_not_invisiblequantized_inline_box_extents_are_not_rounded_separatelyno_break_spaces_are_not_hanging_whitespaceChangelog: None
Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/5c4401ef6292427a952400c36ae85272
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/5c4401ef6292427a952400c36ae85272?variant=devin-insiders
Requested by: @nicoburns