Repository navigation
Give a heading's gap to the column item it opens, so the item's box starts at the heading - #4858
Merged
Merged
Conversation
Evidence for the section-focus-frame decision. elementBox reads a box that draws nothing of its own (no background, border, shadow, clip, generated content, text or shadow tree) as its children's extent in the block axis, and shownExtent and two margin-row reads take it. On a copy of the reported page in Firefox, the keyboard focus ring and margin entry on a column section match the pre-#4724 layout pixel for pixel, and the card and a #how landing stand at the heading again. Known wrong, from an independent review: elementBorderFrame takes the trimmed top with the full height, so drawing coordinates move; a transparent button's padding reads as blank; a section wrapped once more keeps its band. The recommended design gives marks their own reading and leaves elementBox alone.
# Conflicts: # dist/kernel/kernel.json
The fix chosen for the section focus frame changes the reading theme's spacing instead, so elementBox and the margin rows read the box as before.
…tarts at the heading An item of a reading column or flow is a grid item, so the top margin of a heading that opens it stayed inside its box: a section's box began 48px above its heading, and the focus ring, margin entry, thread card and landing Leaf places by that box all stood in the band. The reading sheet now gives an item that opens with a heading (or an eyebrow or hgroup over one) the heading's gap as its own margin and declares its start edge, so the existing edge trim clears the heading's margin; a list in the column trims its first item, whose margin block flow collapsed into the list's. Text stays where it was. Adds the stills state section-ring-keyboard: a section thread resolved by keyboard, which rings the section.
The padded-box case of the frame-edge test now stands inside a plain wrapper: as a direct column item opening with a heading it takes the heading's gap outside its border, so its heading no longer keeps the margin inside its inset there.
page-layout.md's Document flow now says where that gap stands and that page CSS sets it through --h2-start and --h3-start rather than the heading's own margin.
Stills of review-a-plan showed the list trim also clearing a step's opening h3, moving it 32px up: block flow had collapsed that heading's margin out through the item and the list. Such a list now takes the heading's gap, as any column item does.
Text positions on nine examples showed two faults in the first rule. A heading-led section that is itself a frame's first child, such as a tab panel's first section, took the heading's gap over the edge trim, moving the panel's text 48px down; the rules now carry the trim's specificity and stand before it, so the trim wins there. And trimming a plain list's first item moved every list 6px up, and a step list (margin 0, items 10px) up to the text above it; lists now keep their first item's margin, except one whose first item opens with a heading.
leaf-agent
reviewed
Oct 31, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The new Layout-dependent selectors break the existing ownership boundary and fail tests/model/test_interact_layer.py::test_layout_style_and_widgets_never_read_each_other. The heading-box correction is useful, but this coupling needs resolving before approval.
…margin The heading rules named `.layout-column` and `.layout-flow` in reading.css, which `test_layout_style_and_widgets_never_read_each_other` refuses: a style may not read a Layout. The column and a flow inside a reading measure now declare `--lf-items-keep-margins: 1` (registered in base.css beside the other frame tokens), and the rules match an item of any box that declares it, so a page's own grid can declare it too. The rules now weigh nothing. At their old weight they replaced a frame's own margin: a callout or panel in the column opening with a heading moved down by the difference between the heading's gap and the frame's margin (30px for a callout). Now a frame's margin, a margin page CSS gives the item, and the edge trim each outrank them. The eyebrow case moves to the reading package beside the eyebrow's own gap rule, since core may not name a package's class. The case of a list whose first item opens with a heading is dropped: at zero weight a step list's own margin would win while the edge still cleared the heading, losing its gap, so the list keeps its band as other lists do.
leaf-agent
reviewed
Oct 31, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The heading-gap transfer changes spacing even when the reading face is off; it needs to respect that opt-in before approval.
The rules that give a column item its heading's gap ran whatever the page's face, so a page that turns the reading face off (`--lf-reading-face: 0`), or a theme of its own on the same Layout, had its sections take a 48px gap and lose their headings' browser margins. The heading margins they move belong to the reading face, so the rules now stand in its layer and its `style(--lf-reading-face: 1)` query. In that layer every other rule of the tier outranks them, as zero specificity alone did before: a frame's own margin, the edge trim, and the face's margins for other elements. The eyebrow rule in the reading package stays outside the face, as the eyebrow's own gap does.
leaf-agent
approved these changes
Oct 31, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 3, 2026
…ule (#5056) 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 #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 #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 #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 #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 #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_
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.
Since #4724 a section in a
layout-columnis a grid item, so its heading's top margin stayed inside the section's box: the box began 48px above the heading, and everything Leaf places by that box stood in the band. After a thread on a section was resolved by keyboard, the focus ring's top edge ran through the caption of the figure above, and the thread's margin entry, its card and the landing on the section stood in the same band.The column, and a flow inside a reading measure, now declare
--lf-items-keep-margins: 1: their items are grid items, each keeping its children's margins inside its box. The reading theme gives an item of such a box that opens with a heading (or an hgroup, or an eyebrow over one) the heading's gap as the item's own top margin, and declares its start edge so the existing edge trim clears the heading's margin. The box moves onto the heading; Leaf's runtime is unchanged. The token is registered beside the other frame tokens inbase.css, so the theme reads a fact about a box rather than a Layout class, and a page's own grid can declare it too.The heading rules belong to the reading face, so a page that turns it off keeps the browser's spacing. They stand in the face's own cascade layer with zero specificity, so the gap is the item's margin only where nothing else sets one:
An item that opens any other way, such as a list or a paragraph, keeps its first child's margin inside, because moving it out would move the text.
Checks: on the reported page in Firefox, the ring and the margin entry match the layout before #4724 pixel for pixel. Each of the 36 example pages was opened by itself in Firefox. On main, 91 regions there have a band of 6px or more inside their box; with this change 32 still do:
h4.No region gained a band. On nine of those pages, 288 headings, paragraphs, list items and figures stand where they do on main. A Firefox fixture shows that callouts, panels and asks opening with a heading keep their text where it was, and that with
--lf-reading-face: 0nothing moves. The catalogue stills, run on the first version of this change, showed only the moved rings, and scroll offsets where a state scrolls to a section; this version moves a subset of those boxes.Pages whose own CSS styles a column section or its heading do move. In 341 stored pages, about ten do this. Each affected section moves by the heading's gap (48px for an
h2):section { margin-block: 2.5rem }, so the gap above each section falls from 88px to 40px (block flow before Use one browser rendering lifecycle and native document layout #4724 gave 48px);h2top margin, so that heading's gap is added to the item's;Also in this change:
test_a_column_item_opening_with_a_heading_starts_at_the_heading;section-ring-keyboard, that resolves a section's thread by keyboard;page-layout.mdtells authors to set the gap with--h2-startand--h3-start;package-themes.mdandpackages.mddescribe the new token.