Skip to content

Break a block out of the column only down block flow, and keep it off the page's own arrangement - #2635

Merged
max-sixty merged 5 commits into
mainfrom
breakout-only-down-block-flow
Oct 12, 2026
Merged

max-sixty merged 5 commits into
mainfrom
breakout-only-down-block-flow

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A block given data-width now breaks out of the prose column only down a chain of block flow from the column. Where it, or a box between it and the column, is something the page arranged itself (a grid or flex item, a table cell, one of a multi-column holder's columns, an inline-block, a float, a positioned box), it keeps to the box it is laid out in. Inside such a box the room beside it is the page's own content, such as a sibling cell's text. A review of #2529 and #2553 as they sit together on main found these cases; each is a test that fails on main.

  • A table in a page's own grid (1fr 1fr, the table in the right cell): the table widened its track and crushed the left cell to 30px, and the page scrolled sideways (scrollWidth 1516 at 1440). Now it stays in its cell (728..1080) and scrolls its columns there, as before Retire layout-wide; a table granted room keeps its columns' natural width #2529.
  • A wide block that is itself a grid or flex item: it centred on its cell and lay across the sibling's text. Now it takes its cell's width.
  • A table whose direction differs from its holder's (dir="rtl" data in an English page): it landed at 555..1664 and the page overflowed by 224px. Placement now follows the holder's direction, because the browser anchors an over-wide box by its holder's.
  • Firefox scrolled sideways: by 10px at phone width and by 63px at 1440 on a page with an indented table. Firefox counts a translated table at its untranslated position when it works out what the page can scroll. The table is now laid out by a margin to the start of its span, and a translation moves it the rest of the way, so its untranslated box stays inside the window.
  • A holder moved by something Leaf didn't cause (a class adding a margin, a display: none class removed): its breakout stayed off the axis until the next resize. Each breakout is now watched by an IntersectionObserver rooted at main, sized to the breakout's horizontal extent, which fires when the breakout moves sideways or its edge moves outward, never on scroll. Leaf's own triggers still correct its own changes before paint.
  • A block wrapped in a link or span, such as a chart in a link, is laid out in the link's holder's flow and breaks out as on main.

prepaint.js classifies each breakout once per holder per reading by walking to main and reading display, float, position and the column properties, skipping display: contents and inline wrappers. An arranged breakout wears the runtime attribute data-lf-arranged (a page-paint attribute, so revision diffs ignore it) and takes --lf-room: 100%. The natural-width table rules skip it. This replaces an end-margin trick and a table carve-out, which this branch tried and deleted. page-authoring.md ("Bounds and widths") says a block the page places itself stays in the box it is given.

A breakout in a holder that gives it no width (a flex row with no width, an inline-block, a table cell sized to its content) is as wide as that box, which can be 0. A plain table there already behaved this way, and main does the same for blocks.

Leaf's 32 example and docs pages, compared with main at 1440 and 390 and with every tab and disclosure open: every breakout's geometry and every page scrollWidth is identical. Six breakouts are now marked arranged without moving. Firefox and WebKit match Chromium within 1px. Cost on the corpus is the same number of readings as main, none from scrolling.

Not covered: a holder that switches how it lays out its children (block to grid) while nothing in it moves or resizes is re-read at the next margin pass, not at once.

Tests: test_a_table_granted_room_stands_on_the_prose_axis (grid cell, grid item, opposite direction; Firefox and WebKit), test_a_breakout_in_an_indented_holder_measures_its_room_from_the_column (grid and flex items, inline-block, link, span, multi-column; even and phone postures in all three engines, both directions), and the new test_a_breakout_whose_block_moves_re_lands.

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

max-sixty and others added 4 commits October 12, 2026 09:43
…irection and containing block, and re-read it when that block moves

Four defects in how a block that breaks out of the column is placed, found by
review of #2529 and #2553 and measured in Chromium at 1440x900 (prose 360..1080,
axis 720).

## What changed

- **A table asks nothing of its holder** (layouts.css). A table granted room
  takes its columns' natural width, so it had dropped the size containment that
  keeps every other breakout's width out of its holder's. In a cell of a page's
  own `1fr 1fr` grid its natural width became the track's minimum: the left
  cell shrank to 30px and the page scrolled sideways (scrollWidth 1516). The
  table now carries a margin at its holder's inline end equal to the most it can
  be wide (`--lf-table-span`). Block layout ignores an over-constrained box's end
  margin when placing it, and a holder sizing itself to its content counts it,
  so the table contributes nothing and overflows into its room. Same result in
  Chromium, Firefox and WebKit. Trade-off: as an item of a flex row, where an
  end margin does place the next item, the table would stand under its sibling.
- **Translation and margins follow the holder's direction** (layouts.css). The
  browser keeps an over-constrained box at its holder's inline start, but the
  sign of the table's translation was keyed to the table's own `:dir(rtl)`. A
  `dir="rtl"` table in a left-to-right page stood at 555..1664 (224px of page
  overflow), and the mirror case at -224..885. The rules now match
  `:dir(rtl) > table`, on the holder.
- **The indent is read from the breakout's containing block** (prepaint.js).
  `indents` took the parent's content box as the block a breakout is laid out
  in. For a breakout that is itself a grid or flex item, that block is the grid
  area, so a `wide` block in the second track of a `1fr 1fr` grid centred on its
  cell (392..1416, centre 904). A breakout whose width follows its block spans
  that block exactly once its resolved margins are counted back, in flow, in a
  grid area or on a flex line, and its margins never move it. So that box is now
  what gets read (180..1260). A table's width is its own, so its box says
  nothing of the block's far edge, and it still reads its holder's content box.
- **A moved block is noticed, whatever moved it** (content-layout.js).
  Re-reading ran only on a fixed set of triggers: resize, toggle, chrome layout,
  insertion, `data-lf-space`/`hidden`/`open`, and a holder's width. A
  fixed-width holder that a class gave `margin-left: 80px` left its breakout
  80px off indefinitely. A holder revealed by removing a `display: none` class
  left its breakout as if its block were the column. Each breakout now has an
  IntersectionObserver rooted at `main`. Its root is cut to the breakout's
  current horizontal extent and reaches 1e6px above and below, so scrolling and
  growth above it report nothing. Moving sideways by a pixel, an edge moving
  outward, or being drawn for the first time changes the reported ratio and
  takes a reading, which re-arms the watch. The watch is rebuilt from every
  reading and dropped on removal, like the holder record. The existing triggers
  stay as the before-paint path for the causes Leaf and revisions produce. The
  observer reports after the frame that moved the block, so anything else lands
  one frame late. Still uncovered: a block whose one edge moves inward while its
  holder keeps its width, as when a sibling's content takes from an `auto`
  track. An IntersectionObserver cannot see that, and the holder's
  ResizeObserver does not fire.

## Measured (Chromium, 1440x900, main to this change)

| Case | main | this change |
|---|---|---|
| 8-column `available` table in right cell of `1fr 1fr` grid | cells 360..390 / 406..1516, page scrollWidth 1516 | cells 360..712 / 728..1080, table 165..1275, scrollWidth 1440 |
| `<table dir=rtl>` in LTR page | 555..1664, scrollWidth 1664 | 165..1275 |
| `<table dir=ltr>` in RTL page | -224..885 | 165..1275 |
| `wide` div as second grid item | 392..1416 | 180..1260 |
| fixed holder gains `margin-left: 80px` | 260..1340 after 1s | 180..1260 |
| holder revealed by class removal | 192..1272 after 1s | 180..1260 |

Cost on the corpus page (35 breakouts) over a scroll down and back, 12 tab
choices, 8 disclosures and a resize: same number of readings as main
(residency 21, indents 7, none from scrolling), 12.3ms in all against 10.3ms.
The margin pass after a body style change has a median of 17ms against 16ms on
a host at load average about 30. The difference is within noise there.

## Tests

- `test_a_table_granted_room_stands_on_the_prose_axis` adds a table in the
  other direction and one in a cell of the page's own two-track grid. Both must
  stand where the flow's table does, with the grid's tracks even. Fails on main
  in all 8 cases in Chromium, and in Firefox and WebKit; passes in all three.
- `test_a_breakout_in_an_indented_holder_measures_its_room_from_the_column`
  adds wide and available blocks that are themselves items of the page's grid.
  Fails on main and passes here.
- `test_a_breakout_whose_block_moves_re_lands` (new) holds frame callbacks,
  moves a holder by a class margin or reveals it by class removal, and waits
  for the breakout to return to the prose axis with no margin pass run. Times
  out on main and passes here, in Chromium, Firefox and WebKit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… out where Firefox cannot count it past the window

A review of the previous commit found that letting a breakout overflow into
"the breakout room" fails inside a page's own grid or flex arrangement. There,
that room is a sibling's content. Measured in Chromium at 1440x900:

- The end-margin trick stopped a table widening its track, but the table
  (165..1275) and a wide block (180..1260) still covered the left cell's text.
- A table alone in an `auto` track shrank the track to 227px and covered the
  neighbouring track.
- A table in an inline-block shrank the block to 0.
- A table directly in a flex row pulled the next item onto it (250..448).
- A table that is itself a grid item stood at 533..1643 (scrollWidth 1643).
- A wide flex item stood over its sibling by 344px.

Decision (Max's coordinator): `data-width` breaks out of the prose column only
where the block sits in block flow down from the column. Where the page arranged
the block, or a box between it and the column, the block keeps to its box.

## What changed

- **Arranged, read once per holder** (prepaint.js, `indents`). For each
  breakout, the reading walks from the breakout to `main` and asks of each box
  whether it stands in its holder's block flow. Each box must be block-level,
  not floated or out of flow, in a holder whose inner display is flow or
  flow-root, read from `display`. The verdict for a holder is cached for the
  reading, so the walk costs one style read per box however many breakouts
  share it. A breakout that fails wears `data-lf-arranged` (a runtime root
  attribute, listed in page-paint.js) and gets no indent.
- **An arranged breakout keeps to its box** (layouts.css). `[data-lf-arranged]`
  takes `--lf-room: 100%`, as a breakout inside another does, so `wide` and
  `available` take the box's width. The natural-width table rules exclude it,
  so such a table is the contained table reading.css makes it and scrolls its
  columns inside its box, as before #2529.
- **Deleted.** The end-margin trick and the previous commit's margin-box
  reading are gone, along with the table exception to that reading. Every
  breakout that still grows stands in block flow, where its holder's content
  box is its block and nothing up the chain sizes itself to its content.
- **Firefox sideways scroll, from #2553.** Firefox counts a translated box's
  untranslated place in what the page scrolls. A table laid out at its
  holder's start and translated back hung past the window: 400 against 390 on a
  phone for a table in a step list, and 1503 (LTR) and 1469 (RTL) at 1440 when
  the timing fell that way. The table now carries a margin, keyed to the
  holder's direction, that lays it out at the start of its span. That span is
  even about the prose axis, or starts at the prose's left edge beside a
  sidebar. The translation moves it the rest of the way, so it lands where it
  did, and its untranslated box lies inside the span, which lies inside the
  window.
- **One ownership mechanism for the watch** (content-layout.js). The holder
  record held its breakouts through WeakRefs while the move watch held them
  strongly. Both records now hold what they watch, and a removal releases it
  from both, holders' breakout lists included. The header no longer claims a
  gap for a grid track a sibling's content takes from, since a breakout in a
  grid is no longer read. What stays uncovered is a holder that changes how it
  arranges what it holds while nothing in it moves or resizes.
- page-authoring.md, "Bounds and widths", says a block the page places itself
  keeps to its box.

## Measured, Chromium 1440x900 unless noted (previous commit to this one)

The same numbers in Firefox and WebKit, within 1px.

| Case | previous commit | this commit |
|---|---|---|
| table that is the second item of a `1fr 1fr` grid | 533..1643, scrollWidth 1643 | 728..1080 (its track), 1440 |
| table and wide block in a cell, long text in the other cell (360..712) | 165..1275 and 180..1260, over the text | both 728..1080 |
| table alone in an `auto` track beside another (603..1080) | 165..1275, over it | 360..587, its track |
| wide block that is a `flex: 1` item beside a sibling | 548..1080, sibling 360..892 | 728..1080, sibling 360..712 |
| table directly in a flex row | 322..1431, next item pulled to 250..448 | 0 wide at 517, next item 533..731 |
| table in an inline-block | holder 0 wide, table 165..1275 | holder and table 0 wide |
| step-list page, Firefox, scrollWidth (390 / 1440 LTR / 1440 RTL) | 400 / 1503 / 1469 | 390 / 1440 / 1440 (as at 48d21ba~1) |

In a flex row or an inline-block that nothing else gives a width, the table
takes the width it is given, which is none. That is the same as any plain table
there, since reading.css contains every table's width.

Every breakout on the indented-holder pages, LTR and RTL, at 390 and 1440 in all
three engines, stands where it did at the previous commit. On Leaf's 32 pages
(examples, examples/developer, docs), every drawn breakout at 1440 and 390 stands
where it does on main, with the same scrollWidth. With every tab panel and
disclosure revealed at 1440, the geometry is also unchanged. Six breakouts that
already filled their box now wear `data-lf-arranged`: five in the corpus's
alert-review queue and workspace panes, and the how-it-works board.

## Tests

- `test_a_table_granted_room_stands_on_the_prose_axis` now expects a table in a
  cell of the page's grid, and one that is itself a grid item, to stand in that
  cell's box. It runs the even posture in Firefox and WebKit too. It fails on
  the previous commit and passes here.
- `test_a_breakout_in_an_indented_holder_measures_its_room_from_the_column` now
  expects grid-item blocks to take their track, a wide flex item to take its
  share beside its sibling, and a table in an inline-block to stay inside it.
  It runs the even and phone postures in Firefox and WebKit, both directions,
  so the Firefox sideways scroll fails it. It fails on the previous commit and
  passes here.
- The existing breakout, table, width and residency tests, the move test and
  `test_joined_option_cells_share_edges_and_text_column` pass (83).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n a column to its column

Review of 90adbc0 found two classification mistakes in `indents`
(prepaint.js).

- **A block inside an inline holder was marked arranged** (a regression against
  main). `<a href><div data-width="wide">`, a `<span>`, or an unknown custom
  element (inline by default) around a block failed the block-flow test, so the
  block kept to the column at 360..1080. The browser sets a block inside an
  inline in an anonymous block of the inline's own holder's flow, which is why
  main grew it to 180..1260. `holderOf` now steps past an inline ancestor as it
  steps past a `display: contents` one. The step reaches the box the block is
  laid out in, for the arrangement walk and for the measured indent alike. A
  chart or figure wrapped in a link is the realistic case.
- **A block in a multi-column holder broke out across the other column** (main
  did the same). A `columns: 2` holder computes as `display: block`, so a wide
  block in its second column stood at 393..1416, over the first column's text
  (360..712). A holder whose `column-count` or `column-width` is not `auto` now
  counts as one the page arranged, so the block keeps to its column (729..1080).

Chromium, Firefox and WebKit at 1440 give the same numbers. The reviewer's
classification fixtures, main / 90adbc0 / this commit:

| Holder | main | 90adbc0 | this commit |
|---|---|---|---|
| `<a href>` around a wide block | 180..1260 | 360..1080 | 180..1260 |
| `<span>` around a wide block | 180..1260 | 360..1080 | 180..1260 |
| unknown custom element | 180..1260 | 360..1080 | 180..1260 |
| wide block in a `columns: 2` holder's second column | 393..1416 | 393..1416 | 729..1080 |

Every other holder in those fixtures is unchanged from 90adbc0:
`display: contents`, flow-root, list item, section, an `lf-tabs` panel, `lf-ask`,
details, blockquote, callout, and the float, absolute and table-cell holders.

## Tests

`test_a_breakout_in_an_indented_holder_measures_its_room_from_the_column` adds a
wide block wrapped in a link and one in a span, which must stand where the
flow's does, and a wide block in the second column of a two-column holder,
which must keep to a column's width inside the holder. Before this change the
link case failed in Chromium, Firefox and WebKit at 1440 in both directions,
and the column case failed once the link case was fixed. They pass now. The
four breakout tests (35) and the focused breakout, table, width and residency
selection (83) pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
…and drop an unused noqa

Formatting only: ruff 0.16.1 format of test_render_pages.py, prettier 3.9.6 of
prepaint.js and content-layout.js, and the `# noqa: E731` that RUF100 reports as
unused. `pre-commit run --files` over the branch's six changed files passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 3b178e3 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the breakout-only-down-block-flow branch October 12, 2026 18:34
leaf-agent added a commit that referenced this pull request Oct 12, 2026
…2651)

The [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38291812775) failed
three browser tests after #2635. #2639 already repaired the Threads
dialog visibility assertion. This PR repairs the other two tests while
preserving the behaviors they check.

The selection test clicked a heading that brought the page back toward
the top, then dragged toward text outside the viewport. The browser
extended that selection into the next paragraph. The test now brings the
target paragraph into view before dragging. The wide Ask test assumed
its answer list stood mostly under the open Threads panel; the breakout
change placed it in the Ask's wide span instead. Its fixture now
positions the list on the panel side, so pressing `q` still has to
reveal a covered answer list.

All five focused cases pass on this branch: the selection test, all
three Ask postures, and the Threads naming test (`uv run pytest -q -n0`
with those node IDs). The two changed assertions each failed on current
main before the fixture changes.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 15, 2026
Removes the per-holder ResizeObserver and per-breakout
IntersectionObserver that re-read a breakout's (`data-lf-space`)
placement when page script restyled its holder after load
(`watchHolders`, `watchMoves`, `observeMove`, `releaseHolders` in
`content-layout.js`, and the holder bookkeeping `prepaint.js`'s
`indents` returned for them). They arrived in #2553 and #2635.

What users lose: when page script restyles a breakout's holder after
load, the breakout keeps its last placement until the next resize,
toggle, chrome layout or revision. Indent measurement itself, and
re-reads on insertion or a `hidden`/`open` change, stay.

The re-landing tests go with the watchers except the insert case, kept
as `test_a_breakout_a_revision_inserts_deeper_lands_before_it_paints`.
It fails with the MutationObserver's read disabled. `LeafIndents` in
`runtime-globals.d.ts` now declares only `changed`, and the kernel is
rebuilt.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[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