Repository navigation
Anchor target paint in panes so it paints in the frame its target scrolls - #1944
Merged
Merged
Conversation
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]>
…olls The aim, the target trace and visual marks over a target inside a scrolling pane followed the pane's scroll through scroll-driven motion layers, which Chrome can paint a frame before or after the content they carry. A new frame test, which reads the compositor's own frames while a pane scrolls under a held aim, failed 9 of 40 runs on CI's Linux runner under load with layers (the outline a full 40px wheel step off its target for a frame) and 0 of 20 with this change; the nested-pane and shadow-host paint tests also passed 20 of 20 each. A paint stand now anchors where anchors reach: each frame is fixed and anchored to the scroller whose band it cuts, cutting with `clip-path`, which clips the fixed boxes inside it without becoming their containing block, and the box is fixed and anchored to its surface. Every inset is measured from its anchor, so a scroll writes nothing. Where an anchor does not reach what a stand holds (a scroller between a box in a shadow tree and the host it anchors through, an anchor after the stand or in the top layer, or no anchor support), the stand stands whole in motion layers as before. Motions are now computed only for those stands. `scrollsWith` in anchor-names.js is the one rule for "every scroll that moves this node moves what that box holds": margin-layout's `rigidIn` moves there, and target paint uses it for its anchors. Tests: `assert_follows_in_every_frame` in render_harness.py wheels a scroller and checks every compositor frame; the margin pin test and the new `test_a_held_aim_in_a_pane_paints_in_the_frame_its_target_scrolls` share it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…chors Review of the anchored stand found two cases still on motion layers: a diagram node in a pane (its drawing's `<svg>` clips, so the old check read it as a scroller and rejected the anchor through it) and a margin pin inside any clipping box that scrolls nothing between its target and the pane, which #1935 had anchored and the shared `scrollsWith` dropped. `scrollsContent` in scroll-motion.js is now the one reading of "this box scrolls what it holds": a scrollport, `hidden` included, holding more than it shows, and never an inline SVG drawing. margin-layout's `scrollSources`, `scrollsWith` and the paint stand's anchor check all read it. The stand's top-layer check walks the flat tree, so an anchor slotted into an open popover or modal falls back to layers rather than paint off screen. Tests: `test_an_aim_in_a_pane_stands_anchored_to_what_it_outlines` (words and a diagram node) and `test_a_pin_in_a_pane_rides_an_anchored_carrier_through_boxes_that_scroll_nothing` (bare, `overflow: hidden`, a fitting `overflow-x: auto` wrapper) assert the anchored structure, which a dev machine's frames cannot tell apart from layers; each fails with the old scroller check. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A `scroll` event is not composed, so a scroller inside a widget's shadow stage reached none of the page's capture listeners on `document`, and page geometry never placed its paint again. Review found the case: an aim over a part in a shadow-stage box that begins to overflow after the aim stands, anchored through the widget, stayed 40px off its part once that box scrolled, with motion layers as without. `watchScrolls` in arrivals.js, the stages' registry, hears the document's scrolls and each stage's own, including stages built later: each stage holds one listener that calls every watcher, so nothing but the stage's own listener list refers to it. Page geometry's `pageShifted`, the command hints and the page search's match mark, the listeners that repaint geometry on any scroll, listen through it, so the next shadow scroll places the paint again (and the stand, now under a scroller, moves to motion layers). Test: `test_an_aim_follows_a_scroll_inside_a_widgets_shadow_stage`, with a new `lf-test-shadow-scroller` fixture widget; it fails with the stage listener disabled. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 7, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 7, 2026
…e moves them (#1953) The runtime's scroller sweep (`reachScrollers`, `runtime/reach.js`) decides which boxes scroll from their computed overflow. Three things depend on that answer: a keyboard tab stop, the edge marks that say more is off to one side, and the restart of the sticky-header slot `--lf-top`. Three defects found while landing #1902 and #1903 came from that answer, and this PR fixes all three. ## A box that starts scrolling after it arrives The sweep read each box's overflow only when the box arrived or was first drawn. A box that a media query, a container query or a script turned into a scroller later got no stop, no edge marks and no restart until reload. A side-list queue narrowed from a desktop window to a phone's width showed no edge arrows on its row of tabs. The sweep now reads a box again when an input to its computed style moves: - the whole page when the window resizes; - a size container's subtree when the size its queries read changes; - a subtree a module announces with `layoutChanged`, which is how a class a page script adds reaches it. Residency (`content-layout.js`) now announces `main` when it seats a resident, because the Layout makes a seated sidebar scroll. A sidebar loaded in the margin had no stop. A re-read waits until what asked for it holds still, per box, then sweeps the outermost due boxes once. A window drag therefore reads the page once when it stops rather than every frame (a sweep is about 28ms on the corpus). No sweep runs inside a size delivery, where it raised ResizeObserver loops. The settled reading counts a box's wait. A container that keeps moving for longer than a second is the exception, whatever moves it. It is playing, as a meter that pulses while work runs is, so it stops holding the page and waits 100ms still on a timer. For this, `sizeObserver` (`rendering.js`) gained `counted: false`. A box that stops scrolling gives back its stop and its restart. A style that moves with none of these inputs, such as a rule on `:checked`, is read only at the next one, because the browser announces nothing when it applies. ## A page tab panel the page makes scroll The tab strip stacked its height onto its panel's `--lf-top` with a selector that outranked the runtime's restart, so a diff in a panel the page made scroll pinned 113px down. The restart (`[data-lf-scrolls]`) moves from `shadow.css`, where it sat in the packages' layer at no specificity, to `state.css`, above packages and Layouts. A box whose slot starts somewhere other than 0 says so in `--lf-top-start`, which the restart reads. The workspace pane body and the thread list do this. `module-authoring.md` now tells package authors about `--lf-top-start` and `overflow: clip`. Two eval cases score that paragraph: - `package-scroller-headers-stand-on-its-edge`: base 0/3, candidate 3/3 (Claude Code). - `package-card-keeps-its-headers-pinned`: 3/3 on both arms, so it guards. ## An `overflow: hidden` box `geometry.js` counted `hidden` as a scroller when reading what sticky headers cover, and the sweep did not. The sweep, `scroll-motion.js`'s `scrollContainer` and `scrollsContent` (#1944), and geometry's header reading now share one predicate, `scrollsBy` with its per-axis `scrollport`. The undecided option card and a hidden page tab panel used `hidden` only to clip. That made the card the scroller a diff's file header in an option stuck in, so the header scrolled off with the page. Both now say `overflow: clip`, and the header pins under the banner. ## Behavior that changed - A box that starts scrolling at a shorter window, a narrower container, or after a module's `layoutChanged` takes a stop, edge marks and the restart once the layout settles. One that stops gives all three back. - A column sidebar loaded seated in the margin takes its tab stop. - A diff in a page tab panel the page makes scroll pins at the panel's content edge. - A diff in an undecided option pins under the banner as the page scrolls past. - A page that moves a size container for longer than a second reads as settled about a second later than on main. ## Is there a more underlying fix? Yes, and this PR makes it. The first version answered the reported cases. Review then ran other routes to the same answer, and each one failed until fixed here: - a sidebar seated by residency, which announced nothing; - a box a script inserts and announces; - a `layoutChanged` sent from inside a ResizeObserver callback; - an endlessly animating container that starved every re-read and kept the page from settling; - a finite transition that read settled before its sweep; - an animating sibling that resized a container. Merging main exposed a third copy of the scroller predicate in #1944's `scrollsContent`, which now reads the shared one. Still open, each run and confirmed: - a style flipped by a pseudo-class, or a class a script adds without `layoutChanged`, waits for the next resize or announcement; - a padded scroller that doesn't state `--lf-top-start` pins its headers below its padding. ## Tests - `test_a_box_that_starts_scrolling_after_it_arrives_takes_a_stop` replaces #1903's strict xfail. It covers each route above, a table drawn when its disclosure opens, a sidebar loaded seated in the margin, and a size container animating from load that a script announces, after which the page still settles. - `test_any_box_that_scrolls_starts_the_sticky_header_slot_again` gains an `overflow: hidden` box. - `test_a_diff_pins_to_its_page_tab_panel_or_past_an_option_card` is new. - Each fails with its part of the change taken out. That holds for all 15 parts tried, from the three re-read routes to the card's `clip`. - A render selection across the scroller, slot, tab, pane, option, margin and aim tests (926 tests): the only failures also fail on main. `npm run test:runtime` passes. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
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
target-paint-geometry.js). Each clipping frame is now fixed and anchored to the scroller whose band it cuts, and cuts withclip-path; the paint box is fixed and anchored to its surface.clip-pathclips the fixed boxes inside a frame without becoming their containing block, whichoverflowand 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:scrollsContentinscroll-motion.js): a scrollport,hiddenincluded, 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" (scrollsWithinanchor-names.js) builds on it. margin-layout's oldrigidInmoves 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 Carry margin rows through inner scrolls with anchored carriers #1935 carrier.watchScrollsinarrivals.js). Ascrollevent 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 insort-aim-cutsits 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 newtest_a_held_aim_in_a_pane_paints_in_the_frame_its_target_scrollsshare it.test_an_aim_in_a_pane_stands_anchored_to_what_it_outlinescovers words and a diagram node.test_a_pin_in_a_pane_rides_an_anchored_carrier_through_boxes_that_scroll_nothingcovers a bare target, anoverflow: hiddenwrapper and a fittingoverflow-x: autowrapper.test_an_aim_follows_a_scroll_inside_a_widgets_shadow_stageuses a newlf-test-shadow-scrollerfixture 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/mainfails too. The runtime tests pass.