Skip to content

Lay out the reading column as block flow, replacing #4858's heading rule - #5056

Merged
max-sixty merged 18 commits into
mainfrom
section-focus-frame
Nov 3, 2026
Merged

max-sixty merged 18 commits into
mainfrom
section-focus-frame

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Since #4724 the reading column has been a CSS grid. A grid item never collapses margins with its children, so a section's box began in the empty band above its first child's top margin, and every mark Leaf places by that box (the focus ring, the margin entry, the thread card, a fragment's landing) stood in that band. #4858 moved a heading's gap onto the item that opens with it; lists, asks and widgets kept their bands. This puts the column and every layout-flow back in ordinary block flow, where a first child's margin collapses out through its parent's box, and deletes #4858's rule and its --lf-items-keep-margins token.

How the column works

  • Prose and room. The column is a box with the measure (--col) inside its gutters, centred by auto margins, as before Use one browser rendering lifecycle and native document layout #4724, and a page's CSS sizes it as any box. On the Layout's box, the room past the gutter on each side is the shell's width (100cqi) less the column's own content, kept as a percentage that each breakout resolves against its own containing block (--lf-free-start, --lf-free-end), so the room follows whatever width the page gives the column, as long as the column stands centred in its shell. A column nested in another box has no room.
  • Breakouts. wide keeps the prose's start edge and grows to min(--wide, 100% + --lf-free-end). available, and a sidebar Layout standing in the column's flow, take both sides, moved there by a relative offset chosen by the holder's direction, so a page's own margins can't undo it. An available table is centred on the room's axis with left and translate, since Firefox lacks justify-self on a block. On paper every block keeps the prose's measure, and a failed exhibit, or an undrawn widget on a page whose runtime could not start, returns to it. A flow's box grows into the room as far as the blocks in it break out, by padding matched with a negative margin, so its focus ring and every mark drawn round it enclose them while its content box, and so its blocks' room, stays at the prose.
  • Sidebar pages. The body column pads its end by the width the flex row leaves past the prose, so auto margins and floats work against the prose rather than the whole body.
  • Runtime and checks. The runtime finds the prose from --lf-prose-measure, which the column declares, instead of parsing grid track names (content-layout.js, margin-layout.js). The render check drops its subgrid flow-tracks advice. It reads spills against the page's room, the shell's content box less a gutter each side, as it read them against the grid's window-wide box, and judges what stands in the margin against the column's content box, so a page's own furniture beside the column still answers for itself.
  • Author instructions. page-layout.md's "Document flow" now describes ordinary block flow and drops the grid caveats: margins that add, floats that don't float, and auto margins that shrink a block. Authors write the same markup as before.

Measured in Firefox

  • Bands of 6px or more at the top of a region's box on the 36 examples, each opened alone: 12, against 32 on main and 91 before Give a heading's gap to the column item it opens, so the item's box starts at the heading #4858, with none added. The 12 are sidebar rails, sections in a page's own grid, flex lanes a page lays out, and two widgets that reserve room. On 37 stored pages that built on both versions: 56 to 11, none added.
  • Horizontal geometry: block edges on 41 example and site pages at 1600, 1280, 900 and 390px match main (5,005 readings; 27 of the pages rerun on the final column in Firefox, 3,884 readings, and the feature gallery in Chromium and WebKit too), except that the column's own box is as wide as the prose, a layout-flow's box stands round what it holds where main's spans the window, and floats float. On ten example pages at 1600, 1000 and 390px in all three engines, no flow's box is crossed by a block inside it.
  • Vertical gaps: a block's bottom margin counts again, so 32 gaps on nine example pages change, mostly by 3–4px and by up to 17px under the feature gallery's title. On the three pages also compared with the column before Use one browser rendering lifecycle and native document layout #4724, every gap matches it.

Costs

  • A flow holding a table that declares a width rings the table's whole room, since the table's columns set its width.
  • Page CSS on the column box itself acts on a plain box, as before Use one browser rendering lifecycle and native document layout #4724, where the grid's tracks absorbed it. A page that widens the column, such as main { max-width: 960px }, gets that box with its text at the measure from the box's start edge, where the grid centred a 720px text track inside it. A page that moves the column off centre (a margin or padding on one side, a grid track of its own beside a nav, a universal margin: 0 reset) or sets direction: rtl in CSS rather than dir gets breakouts placed for a centred column: they can cover the nav or leave the window, which the render check reports as past-room. A universal box-sizing: border-box reset narrows the prose to 672px, where the grid kept 720px. None of 261 stored column pages sizes the column, and of 145 real column pages under ~/.tmp none offsets or resets it; --col is the documented way to change the measure.
  • A section that is its own formatting context (display: flow-root, flex) keeps its band, which Give a heading's gap to the column item it opens, so the item's box starts at the heading #4858's rule covered.
  • Two engine gaps are worked around and recorded in notes/browser-support.md: the available table's translate, and WebKit leaving a non-inheriting registered length stale after a container resize, which is why the room tokens inherit.

Tests

test_a_column_block_starts_at_its_first_line replaces #4858's heading test and holds heading-, eyebrow-, prose-, list- and flow-led blocks at a band of 0. The subgrid flow-tracks test goes. Tests main had adapted to the grid return to block-flow expectations: the view-geometry reading no longer lists the column as an arrangement, the column-loss journey gets a column with no room by narrowing body, the drawing tests read the room from the shell's width, and the obligation test holds boxes pulled past the prose to the shell's room rather than to main's box. Locally, the focused layout, rail, pane, tab, drawing and gate tests pass (369), apart from eight that fail on main too, among them test_an_obligation_and_a_callout_keep_the_column_and_widen_to_what_they_hold, which main's latest CI run fails on the same #padded assertion. The 745 runtime tests pass.

This was written by Claude Code on behalf of max-sixty

Since #4724 the column has been a grid, and a grid item keeps its first child's
margin inside its box, so a section's box began in the gap above its heading and
every mark Leaf places by that box stood in the gap. #4858 lifted a heading's gap
onto the item; lists, widgets and asks kept their bands. This puts the column and
every layout-flow back in block flow, where that margin collapses out through the
box, and deletes #4858's heading rule and its token.

The column's content box is the prose, centred by its padding. On the Layout's box
the room past the gutter is computed from the shell's 100cqi into --lf-free-start
and --lf-free-end, which the column pads by and its flows inherit; a nested column
centres by percentage padding and gives none. A wide block keeps the prose's start
edge and takes --wide or the room; an available block, and a sidebar Layout in the
column's flow, take both sides, moved by a relative offset so a page's own margins
can't undo it; an available table is centred on the room's axis with a translate.
A sidebar's body column pads its end by the width the flex row leaves past the prose.
The runtime finds the prose by --lf-prose-measure instead of parsing grid track
names, and the render check's subgrid advice goes. The room tokens inherit: WebKit
left a non-inheriting one, passed down with `inherit`, stale after a resize.

Measured in Firefox on the 36 examples, each opened alone: 12 regions keep a band of
6px or more, against 32 on main and 91 before #4858, and none gains one. The rest
are sidebar rails and boxes a page lays out itself. Horizontal geometry matches
main at 1600, 1280, 900 and 390 on 39 pages, except that flow boxes are now as wide
as the prose and floats float. Vertical gaps change where a block's bottom margin
exceeds the next one's top: 32 of the gaps on nine pages, and on the three also run
against the column before #4724 every gap matches that layout.
Firefox 157 lacks justify-self on a block, so an available table is centred by an
offset and a translate; WebKit 27.2 left a non-inheriting room length passed down
with inherit stale after a resize, so the room inherits.
# Conflicts:
#	browser/layouts.css
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-comment-placement.js
#	dist/kernel/runtime/bundle-content-layout.js
#	src/leaf/render-checks/layout.js
Merging main brought tests and fixtures adapted to the grid. In block flow
the view-geometry reading lists only the page's own rows, since the column
is no grid; the column-loss probe needs only a 720px column with no room
beside it; and the drawing tests measure the room a breakout may take as the
prose plus the room the column pads.

The margin reading counts as room only what the column pads beside its prose,
so a page whose own padding replaces the column's keeps its spills reported.
A page whose runtime could not start shows each undrawn widget's source at
the prose's measure again, as the column did before #4724.
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
# Conflicts:
#	browser/layouts.css
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-comment-placement.js
#	dist/kernel/runtime/bundle-content-layout.js
#	skills/leaf/references/page-layout.md
A page that sized the column itself, such as a catalog's
main { box-sizing: border-box; max-width: var(--wide) }, lost its prose in
block flow: the column padded by the room computed from the shell's width, so
at 1720px nothing was left inside a 907px box (test_rail's catalog case).

The column is now a box --col wide, centred by auto margins, as before #4724.
The room each side is the shell's width less the column's own content, kept as
a percentage that each block in the flow resolves against its own 100%, so it
follows whatever width the page gives the column. Text keeps the measure from
the box's start edge, as base.css already says.

The render check reads the column's content box as the column again, as it
did before #4724, and counts note rows and sidebar Layouts in the flow among
the breakouts it holds to the room. So a box the page pulls past the prose by
its own margins is reported again, and the column-loss probe needs no
fixture CSS. The drawing tests read the room from the shell's width.
# Conflicts:
#	dist/kernel/runtime/bundle-content-layout.js
@leaf-agent

Copy link
Copy Markdown
Collaborator

This also removes a reproduced shift-watch failure in #3990. A held-fold probe fails both resolved-diff reopening routes on main 5daa30285cd6bb019c766009c1a1bf479c2ee440 and passes both on this PR's 6ed58e9e695eb3a0b851349bda12e4716f7d9863, with the watch unchanged. The fold's measured shrinkage reaches each ancestor and matches the paragraph movement, but the watch rejects propagation at the column's display:grid; your return to block flow removes that rejection.

The issue comment preserves the deciding geometry and the exact probe. This verifies the current failure; older recorded failures remain unconfirmed, so #3990 stays open. No changes to this branch or shift tolerances were made.

… at the measure

A review of the centred column found the render check now refused a breakout
table's own scrolled rows (outside-part on Linux's wider fonts), since a clip
counted only when inside the narrow column. The check again reads spills
against the page's room, the shell less a gutter each side, while what stands
in the margin is still judged against the column's content box, so a page's
own furniture beside the column answers for itself. The column-loss probe
narrows its shell to get a column with no room.

The column is border-box at the measure plus its gutters, so a page's universal
box-sizing reset no longer narrows the prose to 672px, and a Layout main is
never its own size container, so a sidebar nested in the column measures the
shell as before. Note rows are no longer counted as breakouts.
…ent-box

A second review found the render check's room read main's auto margins, which
Chromium reports as 0px after a tab switch, so note rows and scrolling board
columns came back as spills. The room is now the shell's content box less a
gutter each side, which misplacedBoxes already measures.

The column goes back to content-box at --col: border-box narrowed the prose of
any page that caps main itself, as two of 145 real column pages do with
max-width: var(--col), to fix a universal box-sizing reset that none of them
uses. A notes column's room is the shell less the column's actual content, as a
plain column's is, so padding on main or a padded flow no longer pushes a note
row out of the window, and a page that makes the column a grid keeps one track
the column's width.
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
In block flow a `layout-flow`'s box was as wide as the prose, so a wide or
available block inside it crossed the flow's focus ring, and every mark Leaf
draws round the flow's box. On main the flow spanned the window, which enclosed
the block but also the empty margins beside it.

A flow in the column's flow now pads itself into the room by as much as the
blocks in it break out on each side, with an equal negative margin, so its
border box reaches the widest block's edges and its content box, which its
blocks resolve their room against, stays at the prose. A flow holding only
prose is unchanged. A table's reach is its whole room, since its columns set its
width.

Measured on ten example pages at 1600, 1000 and 390px in Firefox, Chromium and
WebKit: no flow's box is crossed by a block inside it, and every block's edges
match the previous commit. No stored or real page pads a flow in a column.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A flow containing both a sidenote and a wide exhibit can still leave part of its content outside its focus outline; the two reach calculations need to compose.

Comment thread browser/layouts.css Resolved
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-comment-placement.js
#	dist/kernel/runtime/bundle-content-layout.js
A flow holding both a note row and a wide block took the wide block's reach,
the later rule, though a note row reaches farther at the default tokens
(720 + 384px against about 908px), so the note crossed the flow's focus ring.
Each kind now states the width it reaches from the prose's start edge, and the
flow takes the larger, within the room. A fixture flow holding both encloses
both at 1600, 900 and 390px in Firefox, Chromium and WebKit.
@max-sixty
max-sixty merged commit 65ac1a0 into main Nov 3, 2026
5 of 6 checks passed
@max-sixty
max-sixty deleted the section-focus-frame branch November 3, 2026 04:13
max-sixty added a commit that referenced this pull request Nov 4, 2026
…page in Firefox (#5281)

In Firefox, resolving a thread left the page scrollable sideways: 456px
past a 1728px window on the On me alternatives page. Closing the thread
card hands focus to the paragraph beside the thread's subject (`letGo`
in `browser/runtime/focus.js`), so the paragraph briefly wears a focus
ring. Firefox then recomputes the overflow of the ring's holder without
laying it out again, and that recomputation counts a child moved by a
relative offset or a translate at its place in flow as well as where it
is drawn. Since #5056 an `available` block, and a sidebar Layout in the
column's flow, reached the room's start by `left`, so its place in flow
ran from the prose's start to 456px past the window, and the page kept
that width until the column next laid out. Chromium doesn't count it. A
plain HTML page with no Leaf reproduces it in Playwright Firefox 157
(`notes/browser-support.md`, "A moved box's place in flow in Firefox's
scroll size").

## Change

- An `available` block or sidebar reaches the room's start by a negative
margin on its holder's start side, so its place in flow is where it is
drawn. It stays `position: relative`, with no offset, so its absolutely
positioned descendants keep it as their containing block.
- An `available` table starts at the room's start by the same margin,
and `left` and `translate` centre it on the room's axis from there, so
its place in flow stays inside the room.
- The failed-exhibit reset also clears the inline margin.
- The margin is an ordinary `lf-layouts` declaration, which gives up
#5056's reason for the offset: a page rule that sets the block's inline
margins, such as `margin: 1rem 0`, now replaces it, and the block spills
past the window by the room it would have taken, in every engine. `page
check --render` reports that as `page-scrolls` and names the block
`past-room`, and `page-layout.md` tells authors to space a `data-width`
block with `margin-block`. By a selector-name scan, 12 of 252 distinct
authored pages with a breakout had a margin rule that may reach one.

## Behavior

- Drawn boxes are unchanged: available blocks, full-room and narrower
available tables, and breakouts directly in the column or in a flow read
the same edges on main and here, in Firefox and Chromium, left-to-right
and right-to-left, at 1728 and 1100px. Stills of twelve breakout states
show no pixel change.
- On the reported page, resolving a thread leaves the root's scroll
width at 1728 in Firefox, against 2184 on main, whether the thread is
anchored on a playground control or on a paragraph.
- An available table in a holder whose direction differs from the
page's, such as `<main dir="rtl">` on a left-to-right page, still widens
the page after a ring in Firefox, by up to half the table's width, more
than on main, because Firefox applies the table's translate to its place
in flow. `notes/browser-support.md` records it with the ways to close
it.

## Tests

`test_a_breakout_grows_only_from_a_holder_that_spans_the_column` and
`test_a_table_granted_room_stands_on_the_prose_axis` now ring a
paragraph beside the breakouts and hold the page's sideways scroll at 0.
The first fails on main in Firefox, left-to-right. Both pass in
Chromium, Firefox and WebKit on this branch merged with main.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 5, 2026
… made it (#5499)

`test_available_space_is_a_generic_package_capacity` has failed in every
nightly run since #5056. That change made the reading column a box at
the prose measure, and an `available` block now breaks out of it into
the shell's room. #5056 updated the browser-tier
`test_a_drawing_the_room_can_hold_is_shown_whole` to read that room as
`--lf-shell-width` less a `--col-pad` gutter on each side. This journey
runs only nightly, so #5056's CI never ran it, and it still read the
room as its holder's content box, which is now the 720px prose. The
surface itself was correct: it spanned 1714px of a 1762px window, with
two equal 845px children and no sideways scroll.

The test now reads the room the same way the drawing test does. Its
other expectations are unchanged, and no layout or runtime code changes.
Locally on Linux, `uv run pytest
tests/journeys/test_render_pages.py::test_available_space_is_a_generic_package_capacity
--run-nightly` fails on main with the reported `994 <= 1` and passes
with this change.

<details><summary>When it started</summary>

The test passed in scheduled run 41432142330 (`72afa89ec2`) on Linux and
macOS. It failed in 41622727492 (`19757c94c5`), the first run after
#5056 (`65ac1a06a`) merged. #5281 later changed how the breakout is
offset, but it landed after the first failure and doesn't change the
box's width.

</details>

Closes #5462 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 5, 2026
…ding (#5502)

`test_page_fixture_renders[dynamic-widgets]` has failed in the nightly
journeys since #5056 made the reading column block flow. A grid item
never traps its children's margins, but a block does. So `main`'s 96px
bottom padding now traps the margin of its last child,
`lf-widget-builder`. The shared edge trim does reach the builder
(`--lf-frame-end: 1`), but the page's own `margin-block: 28px 48px`
outranks it, so the probe reports 48px of margin beside a 96px drawn
edge. The page now gives the builder only its 28px top margin, and
`main`'s padding alone spaces the page's foot.

The only visible change is at the page's foot: the space below the
builder's last help paragraph drops from 144px to 96px. At rest at the
top of the page nothing moves. `leaf-dev stills --state dynamic-widgets`
at 1280×2000 reports the state unchanged, since the page fits that
window. A shorter window just stops scrolling 48px sooner.

The focused
`tests/journeys/test_render_gate.py::test_page_fixture_renders[dynamic-widgets]`
(`--run-nightly`) fails on main `f8808301f` with the one framing finding
and passes on this branch.

Closes #5466 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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.

2 participants