Skip to content

Output last baselines from all built-in layout algorithms - #1110

Open
nicoburns wants to merge 2 commits into
mainfrom
devin/1786752152-last-baseline-output
Open

Output last baselines from all built-in layout algorithms#1110
nicoburns wants to merge 2 commits into
mainfrom
devin/1786752152-last-baseline-output

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Objective

Compute and output the last baseline of a container (LayoutOutput::baselines.last) from all built-in layout algorithms (flexbox, grid and block), building on the Baselines { first, last } representation introduced in #1107. Last-baseline alignment (align-items: last baseline) is not part of this PR and will follow separately.

Context

Last baselines ride along with the existing layout passes — no additional layout computation is performed. Selection rules (per css-align §9.1 "baseline export" / css-flexbox §8.5):

  • Flexbox: the last baseline is generated from the cross-end-most line (the first line for wrap-reverse containers), from that line's last flex item. Each item's last baseline is captured during the final layout pass, mirroring the existing first-baseline handling:
    item.baseline      = baseline_offset + baselines.first.unwrap_or(size.height)  // existing
    item.last_baseline = baseline_offset + baselines.last.unwrap_or(size.height)   // new
    with both clamped to the item's border box for scroll containers (csswg#7660).
  • Grid: the last baseline is generated from the last row containing items, using the row's first item's last baseline (synthesized from its border box when it has none). align_and_position_item now returns the child's Baselines (clamped for scroll containers), stored on GridItem as last_baseline.
  • Block: the container's last baseline is the last baseline of its last in-flow child that has one (the first baseline is unchanged: the first baseline of the first in-flow child with one). Both are shifted together when align-content offsets the in-flow group.

Since no built-in leaf produces baselines and nothing consumes baselines.last yet, this is only observable via custom trees / measure functions, so coverage is a new hand-written test suite (tests/hand_written/last_baseline.rs) with a minimal custom tree whose leaves report fixed first/last baselines, asserting the root LayoutOutput.baselines for flex row/column/wrap/wrap-reverse, grid multi-row, and block containers.

cargo fmt / clippy / cargo test --workspace all pass.

Feedback wanted

  • Grid's first baseline currently uses the alignment baseline (item.baseline, only set for baseline-aligned items) with a border-box fallback, whereas the new last baseline uses the child's actual reported last baseline. This asymmetry preserves existing first-baseline behaviour; happy to align the first-baseline path with the "actual baseline" approach in a follow-up if desired.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/c0a80d9344d54e918b37cacfb71a2128
Requested by: @nicoburns

@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1786752152-last-baseline-output branch from e8eed57 to 088cecd Compare August 21, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant