Skip to content

Grid: resolve named lines once (before the grid size estimate) - #1259

Merged
nicoburns merged 9 commits into
mainfrom
devin/1791249287-grid-size-estimate-named-lines
Oct 8, 2026
Merged

nicoburns merged 9 commits into
mainfrom
devin/1791249287-grid-size-estimate-named-lines

Conversation

@nicoburns

@nicoburns nicoburns commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Objective

compute_grid_size_estimate treated every named-line placement as auto (into_origin_zero_ignoring_named), but its negative implicit track count is used as exact, and its positive count as a lower bound. Items placed with named lines therefore created implicit tracks that nothing occupies:

  • grid-column: foo / 1 (unknown foo, resolves to 1 / 4 in a 2-column grid) was estimated as auto / 1, adding an implicit column before the grid.
  • grid-row: span 5 / last was estimated as a fully auto-placed span of 5, adding implicit rows after the grid as well as the ones the item really needs before it.

The estimate now works on each child's grid-row/grid-column with named lines already resolved. To avoid resolving names twice (once for the estimate, once in place_grid_items), name resolution is moved ahead of both: compute_grid_layout resolves every in-flow child's named lines exactly once and hands the results to both the estimate and place_grid_items.

This fixes 2 WPT subtests in Blitz (grid-placement-unknown-named-grid-line-001.html, grid-placement-negative-position-resolution-001.html), with no regressions in css/css-grid.

Blitz PR: DioxusLabs/blitz#1072

Context

compute_grid_layout builds items and placements: Vec<ItemPlacement> (InBothAbsAxis<Line<OriginZeroGridPlacement>> — the grid-row/grid-column styles with named lines resolved, in origin-zero coordinates; previously built inside place_grid_items step 0) in one walk over the in-flow children, then:

compute_grid_size_estimate(explicit_col_count, explicit_row_count, &placements)
place_grid_items(&mut cell_occupancy_matrix, &mut items, &placements, grid_auto_flow)
  • compute_grid_size_estimate / get_known_child_positions take &[ItemPlacement] instead of a style iterator (no generics, no resolver); child_min_line_max_line_span takes the Line<OriginZeroGridPlacement> and is otherwise unchanged, so negative implicit tracks are still pre-sized by the estimate.
  • place_grid_items loses step 0 and the children_iter/align_items/justify_items/named_line_resolver parameters; steps 1–4 are unchanged.
  • ItemPlacement stays in placement.rs, now pub(super) and re-exported through the grid module for implicit_grid.rs.
  • util::test_helpers gains resolve_named_lines (resolve test styles the same way) and grid_items (build test GridItems), used by the implicit_grid/placement unit tests.

Memory is unchanged (placements was already allocated by place_grid_items; items is reserved from child_count as before). main walked the children twice (estimate, then placement), calling grid_row()/grid_column() — which clone the placement — on each walk; the single walk is measurably faster.

Benchmarks vs the merge-base d7cb4642 (release, interleaved rounds pinned to one core, min of per-round Criterion medians; 15 rounds for named, 5 for the others; named layouts bit-identical): grid/named/lines 63.8µs → 54.1µs (−15%), grid/named/areas 66.6µs → 57.0µs (−14%), grid/named/unnamed 28.4µs → 26.0µs (−8%); items extending before the explicit grid via negative integer lines −6%, via negative named lines (-2 foo) −7%; grid/wide 31×31 / 100×100 / 316×316: −3% / −10% / −5%; grid/deep −4.5% / −8% / −5%; grid/superdeep −2% / +2%. The named benchmark (12×12 grid, 144 items placed by <integer> <ident> + span <ident>, by area name, or by negative lines) is not part of this PR.

Tests: new generated fixtures grid_implicit_tracks_named_line_placement (row flow) and grid_implicit_tracks_named_line_placement_auto_flow_column (column flow, so the estimate's role in the flow axis is covered for both axes); both fail on main.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/2530fd358d4f4736bec3c4ac9accefdb
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/2530fd358d4f4736bec3c4ac9accefdb?variant=devin-insiders
Requested by: @nicoburns

@staging-devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1791249287-grid-size-estimate-named-lines branch from 201b768 to 5bc0fde Compare October 8, 2026 03:03
@staging-devin-ai-integration staging-devin-ai-integration Bot changed the title Grid: resolve named lines in grid size estimate Grid: resolve each item's placement once and use it in the grid size estimate Oct 8, 2026
@staging-devin-ai-integration staging-devin-ai-integration Bot changed the title Grid: resolve each item's placement once and use it in the grid size estimate Grid: resolve named lines once, before the grid size estimate Oct 8, 2026
@nicoburns nicoburns changed the title Grid: resolve named lines once, before the grid size estimate Grid: resolve named lines once (before the grid size estimate) Oct 8, 2026
@nicoburns
nicoburns merged commit 4f18a82 into main Oct 8, 2026
28 checks passed
@nicoburns
nicoburns deleted the devin/1791249287-grid-size-estimate-named-lines branch October 8, 2026 14:26
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