Skip to content

Stretch multi-row grid tracks with an auto maximum #106

Description

@wieslawsoltes

Problem

A definite-height multi-row grid using the initial align-content: normal does not stretch tracks whose maximum sizing function is auto. This leaves unused block-axis space and places later rows too early.

Code OSS Welcome exposes the bug after named template areas are honored. Its 824px grid uses:

grid-template-rows: 25% minmax(min-content, auto) min-content;

Chromium computes 206px 600px 18px and places the footer at y=888 in the application viewport. The focused AppScene/WebScene package preserves the horizontal named-area geometry but places the footer around y=526 because the middle row remains at its intrinsic height.

Product-neutral reproduction

Use a 700x400 grid with rows 25% minmax(min-content, auto) min-content, a 200px-tall middle item, and an 18px footer.

Chromium 152 geometry:

{"grid":[0,0,700,400],"header":[0,0,700,40],"middle":[0,100,700,200],"footer":[0,382,700,18]}

WebScene native geometry:

{"grid":[0,0,700,400],"header":[0,0,700,40],"middle":[0,100,700,200],"footer":[0,300,700,18]}

The 82px of free space should enlarge the middle track's used size from 200px to 282px. The item itself remains 200px because it has an authored height; the following row moves to y=382.

Root cause

webscene_native_dom_layout.inc only performs row stretching when single_auto_row is true. The column path already distributes remaining inline space across stretchable automatic tracks, but the row path deliberately stops at the one-row compatibility case. It also needs to treat a minmax() track with an auto maximum as stretchable.

The portable arrangement and measurement paths should be audited for the same contract.

Proposed fix

  1. Represent or preserve whether a minmax() maximum is auto; a resolved zero/unspecified length is not enough to distinguish it from other growth limits.
  2. After intrinsic row sizing and fractional-track resolution, compute remaining definite block-axis space.
  3. For align-content: normal/stretch, distribute positive remaining space equally across tracks with an auto maximum, including implicit auto tracks and minmax(<minimum>, auto).
  4. Preserve intrinsic minimums, authored fixed/percentage tracks, gaps, fractional tracks, overflow behavior, and non-stretch alignment modes.
  5. Apply the same rule in intrinsic measurement so measure and arrange cannot disagree.

Acceptance and regression gates

  • Add a WPT-style contract for the exact three-row reduction above and compare exact Chromium/native rectangles.
  • Cover more than one stretchable auto-max track, row gaps, minmax(0, auto), and minmax(min-content, auto).
  • Cover align-content: start, center, space-between, and explicit stretch so the default rule is not applied to non-stretch modes.
  • Cover an indefinite-height grid where no remaining-space stretch occurs.
  • Add mutation tests for container height, row template, content intrinsic height, and align-content; assert synchronous geometry and no stale track cache.
  • Add a bounded benchmark of at least 500 height/template mutations and gate both elapsed time and retained scratch-memory growth.
  • Re-run the packaged Code OSS Welcome+Chat visual comparison. The footer should match the Chromium y=888 placement within the visual geometry tolerance while the horizontal named-area geometry remains unchanged.

Evidence

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions