Skip to content

Carry margin rows through inner scrolls with anchored carriers - #1935

Merged
max-sixty merged 1 commit into
mainfrom
wheel-return-flake
Oct 6, 2026
Merged

max-sixty merged 1 commit into
mainfrom
wheel-return-flake

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A margin pin whose target scrolls inside a pane followed that scroll
through a ScrollTimeline motion layer, which Chrome can paint a frame
before or after the scrolled content, as #1916 found for the comment
box. On CI's Linux runner under load, 6 of 20 runs of a pane pin drew a
frame with the pin a wheel step (40px) off its target, and three
tripped the suite's shift watch ("span.lf-margin-marker moved without
input by (0, 40)px").

A row whose target scrolls inside a box short of the document now
stands in a carrier: a fixed box anchored to an element that box's
scroll carries (carriedAnchor), so CSS anchor positioning moves it
with the target in the frame that scrolls. With the change the same
job showed 0 of 20 desynced and no shift-watch reports. Rows share a
carrier per anchor, axis set and run, not one per row, which keeps the
layout cost #1890 removed: rows still name no anchor of their own. A
rail row's carrier follows only the block axis, as the rail does not
follow a region's sideways scroll, and a sideways page scroll places
those rows again. A carrier takes a row only where every box between
its target and the scroller is in flow: a sticky, fixed or absolute box
there moves the target other than the scroll does. Motion layers remain
where no anchor reaches, as inside a shadow tree, or when the lane
itself rides one. Each pass names the carrier's anchor again, since a
revision that rewrites the anchor's style takes the name away. A
carrier holds one run of consecutive rows and stands in its lane where
that run comes, so rows keep document order across carriers.

carriedAnchor (anchor-names.js) is now the one rule for "an element a
scroller's scroll carries"; the comment box's anchor (#1916) uses it.
The scroll reading that withholds a row as its target leaves no longer
reads the row's box, which a carried row reports a frame late after a
scroll, but the offset from its target recorded at placement.

Tests: test_a_pin_in_a_pane_paints_in_the_frame_its_target_scrolls
reads Chrome's compositor frames through a pane scroll. It passes
locally on either mechanism; the desync shows on CI's Linux runner
under load. The trace helper behind it (compositor_trace, with
frame_image and marked_tops) is shared with the wheel-return test
and records only the categories it names: Chrome otherwise adds its
default ones, and the forced-layout events the suite's own watchers
cause made a two-second idle trace 2.9 million events long, so the
trace often outlasted its wait under load.

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

A margin pin whose target scrolls inside a pane followed that scroll
through a ScrollTimeline motion layer, which Chrome can paint a frame
before or after the scrolled content, as #1916 found for the comment
box. On CI's Linux runner under load, 6 of 20 runs of a pane pin drew a
frame with the pin a wheel step (40px) off its target, and three
tripped the suite's shift watch ("span.lf-margin-marker moved without
input by (0, 40)px").

A row whose target scrolls inside a box short of the document now
stands in a carrier: a fixed box anchored to an element that box's
scroll carries (`carriedAnchor`), so CSS anchor positioning moves it
with the target in the frame that scrolls. With the change the same
job showed 0 of 20 desynced and no shift-watch reports. Rows share a
carrier per anchor, axis set and run, not one per row, which keeps the
layout cost #1890 removed: rows still name no anchor of their own. A
rail row's carrier follows only the block axis, as the rail does not
follow a region's sideways scroll, and a sideways page scroll places
those rows again. A carrier takes a row only where every box between
its target and the scroller is in flow: a sticky, fixed or absolute box
there moves the target other than the scroll does. Motion layers remain
where no anchor reaches, as inside a shadow tree, or when the lane
itself rides one. Each pass names the carrier's anchor again, since a
revision that rewrites the anchor's style takes the name away. A
carrier holds one run of consecutive rows and stands in its lane where
that run comes, so rows keep document order across carriers.

`carriedAnchor` (anchor-names.js) is now the one rule for "an element a
scroller's scroll carries"; the comment box's anchor (#1916) uses it.
The scroll reading that withholds a row as its target leaves no longer
reads the row's box, which a carried row reports a frame late after a
scroll, but the offset from its target recorded at placement.

Tests: `test_a_pin_in_a_pane_paints_in_the_frame_its_target_scrolls`
reads Chrome's compositor frames through a pane scroll. It passes
locally on either mechanism; the desync shows on CI's Linux runner
under load. The trace helper behind it (`compositor_trace`, with
`frame_image` and `marked_tops`) is shared with the wheel-return test
and records only the categories it names: Chrome otherwise adds its
default ones, and the forced-layout events the suite's own watchers
cause made a two-second idle trace 2.9 million events long, so the
trace often outlasted its wait under load.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit d19d162 into main Oct 6, 2026
4 checks passed
@max-sixty
max-sixty deleted the wheel-return-flake branch October 6, 2026 23:43
max-sixty added a commit that referenced this pull request Oct 7, 2026
…olls (#1944)

Target paint over content in a scrolling pane (the aim, the target trace
and visual marks) now moves with the pane's scroll in the frame Chrome
paints that scroll, instead of trailing or leading it by a frame. This
finishes the move #1935 made for margin pins.

## Why

The paint followed pane scrolls through scroll-driven animation layers
(`scroll-motion.js`), which Chrome can paint a frame before or after the
content they carry. A frame test reads the compositor's own frames while
a pane scrolls under a held aim. On CI's Linux runner under load, the
aim outline sat a full 40px wheel step off its target in 9 of 40 runs
with layers and in 0 of 20 with this change. The nested-pane and
shadow-host paint tests passed 20 of 20 each.

## What changed

- **Anchored paint stands** (`target-paint-geometry.js`). Each clipping
frame is now fixed and anchored to the scroller whose band it cuts, and
cuts with `clip-path`; the paint box is fixed and anchored to its
surface. `clip-path` clips the fixed boxes inside a frame without
becoming their containing block, which `overflow` and a transform would.
Every inset is measured from its anchor, so a scroll writes nothing.
Where an anchor can't reach what a stand holds, the whole stand falls
back to motion layers as before:
- a scroller between a box in a shadow tree and the host it anchors
through
  - an anchor that comes after the stand, or sits in the top layer
  - a browser without anchor support
- **One rule for "this box scrolls what it holds"** (`scrollsContent` in
`scroll-motion.js`): a scrollport, `hidden` included, that holds more
than it shows, and never an inline SVG drawing. The rule for "every
scroll that moves this node moves what that box holds" (`scrollsWith` in
`anchor-names.js`) builds on it. margin-layout's old `rigidIn` moves
there, and both margin pins and paint stands now read these rules.
Diagram nodes in panes therefore anchor too, and a pin inside a clipping
wrapper that scrolls nothing keeps its #1935 carrier.
- **One scroll door across shadow stages** (`watchScrolls` in
`arrivals.js`). A `scroll` event isn't composed, so scrolls inside a
widget's shadow stage never reached page geometry. Review measured an
aim staying 40px off a part inside a stage scroller that began to
overflow after the aim stood; that bug was already on main. Three
listeners now go through the door: page geometry, the command hints and
the page search's match mark. Each stage holds one listener of its own,
so nothing else retains a stage.

## Visible change

None intended. In `leaf-dev stills`, the one difference in a
target-paint state is that the aim's bottom border in `sort-aim-cut`
sits half a CSS pixel lower, because it is now positioned from an
anchor. The other states that differ change from one capture to the next
(a build hash, a text field's inner scroll offset).

## Tests

- `assert_follows_in_every_frame` (`tests/render_harness.py`) wheels a
scroller and checks every compositor frame. The pin frame test and the
new `test_a_held_aim_in_a_pane_paints_in_the_frame_its_target_scrolls`
share it.
- A dev machine's frames can't tell anchored from layered, so these
structural tests pin the anchoring. Each fails with the old scroller
check:
- `test_an_aim_in_a_pane_stands_anchored_to_what_it_outlines` covers
words and a diagram node.
-
`test_a_pin_in_a_pane_rides_an_anchored_carrier_through_boxes_that_scroll_nothing`
covers a bare target, an `overflow: hidden` wrapper and a fitting
`overflow-x: auto` wrapper.
- `test_an_aim_follows_a_scroll_inside_a_widgets_shadow_stage` uses a
new `lf-test-shadow-scroller` fixture widget. It fails with the stage
listener disabled.

Local runs of the margin, aim, pages, send-placement, chrome-contract,
shift-watch, navigation, commands, drafts, drawing, widgets and threads
files fail only where `origin/main` fails too. The runtime tests pass.

> _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