Skip to content

Keep each scroller's reading place across width changes, moved only by the user - #2562

Merged
max-sixty merged 23 commits into
mainfrom
keep-reading-place-across-widths
Oct 12, 2026
Merged

max-sixty merged 23 commits into
mainfrom
keep-reading-place-across-widths

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Width and posture changes now preserve the passage the reader was reading in each scroller. The page and each bounded reading region record their own place when the reader acts. When a region moves between a pane and the page, the runtime restores the newest place whose landmark belongs in the destination scroller. This fixes the heading and pane drift seen in the feature gallery, alert review, and source pane examples.

A restore holds its place while the resulting layout settles, with a one-second limit per settling window. Input aimed at that scroller, a scroll that carries its landmark, navigation, or a revision releases the hold. The screen reading still includes words drawn outside their block's box and responds to style-only changes. Chart drawings retain their declared height until a redraw lands, avoiding a transient shift during width changes.

Focused browser checks passed for a late script scroll, an indefinitely changing chart layout, wheels in contained and ordinary panes, and a pane flowing into the page. The runtime suite passed (372 tests). CI remains the landing gate.

max-sixty and others added 8 commits October 11, 2026 23:10
A page holding a flowing reading region, such as the feature gallery's side
queue below its section heading, lost the reader's place when the window
changed width. The heading the reader had landed on moved 230px down on
narrow -> wide and stayed displaced on the way back (scroll 3150 -> 1812 ->
2692); a single wide -> narrow step put it 197px above the landing band, under
the banner.

Cause: on a shift, version.js restored every flowing region the page carries
from its own record, led by the "active" region. With no focus or gesture
naming a region, active was the region whose first on-screen line stood
highest, so a queue starting lower in the window took the page scroller and
moved the page to put its own first line back, overriding the browser's
anchoring of the heading above it.

- The fallback for the region the user works is now the deepest region standing
  across the top of the page's landing band, the line the page measures its own
  place from. A line in the page's own words names no region.
- Each record of the page scroller notes which flowing region stood for it
  (`pageReader`), and a shift restores a flowing region that only rewrapped in
  the page only when it was that reader. A region handed to another scroller
  (a posture change) restores from its record as before.

Behavior change: a heading or paragraph above a flowing pane or side queue
keeps its distance below the banner as the window narrows and widens; reading
inside the flowing region keeps its passage as before.

Test: a heading above a flowing pane keeps its place at 390 and back at 1280
(fails on the old code at -189 vs 4.5).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…s height until it redraws

On alert-review at 390px, a reader of the first alert who widened the window
and narrowed it again came back 409px lower than they left: the passage at
202px below the banner returned at 611px. Two causes, each fixed at its owner.

- version.js: widened, the alert's panel scrolls on its own and is already at
  its top, so its restore could not put the passage where it stood (164px,
  the best the panel's range allows). The record taken after the restore, and
  any scroll the restore raised, then replaced the reader's place with that
  clamped one, which the next narrowing restored. A restore is the runtime's
  move, not the user's: what it restored now stays the region's reading until
  the user next acts (`restoredReadings`, keyed by the input count), so only a
  user's own scroll or a restore that landed updates the record.
- lf-chart (styles/chart.css): for the frame between a width change and its
  redraw, Plot's sheet scaled the old drawing's height with the width (200px
  drew as 108px), moving everything below the chart under the restore that
  measured the page then. The drawing now keeps the height it was drawn at,
  as the x-height contract says it does.

Behavior change: narrowing, widening and narrowing again returns a reader in a
workspace pane to the passage where they left it (alert-review: 202 -> 164 ->
202 -> 164 -> 202, was 202 -> 164 -> 611 -> 164 -> 611). Either fix alone
leaves it short: the hold alone ends at 294, the chart alone at 611.

Tests: a restore cut short by a pane keeps the reader's place for the return
(fails without the hold: 14 vs 367); a chart keeps its stated height when its
room narrows before it redraws (fails without the rule).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… user moves it

Width and posture continuity arbitrated which region's record stood for a
scroller (`active`, `pageReader`, a line rule, a per-region hold), and each
arbitration had a case it got wrong. A wheel or touch over the feature
gallery's open queue panel made the panel the recent region, so the next
shift restored the panel's first line and the heading the reader was on moved
25 -> 255 -> 586. A flowing region inside a bounded pane was restored from
its own rarely recorded reading. On a page with no regions the browser's
anchoring held another element than the reader's.

Now each scroller has one place, read from the words it carries:
- the page's from every word outside a box that scrolls on its own, flowing
  regions included (`blocksOnScreen` now skips a block by the scroller
  carrying it rather than by its own region's posture, so a flowing region
  inside a bounded pane belongs to the pane), and each bounded region's from
  its body. A place is recorded on the first frame a scroll stops in that
  scroller, and where the user stands or steps.
- After a shift each scroller it touched takes the newest place speaking for
  it: its own, one from the scroller that carried its words before, or one
  whose landmark it now carries (`placeNode`). A newer place that lands
  nowhere there supersedes an older one rather than letting it win.
- Only the user moves a place. A box the runtime restored holds that place
  until an input, Back/Forward/fragment travel, or a scroll no layout change
  explains; nothing records over it, and it is applied again whenever the
  layout under it changes, so a widget drawing a frame late no longer moves
  the reader in any browser.
- A composition (`preserveReadingRegions`) restores its own bounded scrollers
  from what it captured, which no longer counts as a place the user recorded.

Deleted: `pageReader`, `restoredReadings`/`keepReading`, `regionViews`,
`recordRegions`, `restoreRegions`, and the landing-line fallback in
`activeReadingRegion`, which reverts to main's and now serves only the
revision handoff.

Behavior changes (probe, main vs this): gallery heading through four width
changes holds at 25 or 33 after a fragment, wheel over the queue, the open
panel or the guide, in both directions (main drifts to 483 or -205);
alert-review's first alert returns to 202 (main 611); release-notes at its
end returns to 169 (main 179); review-a-plan holds -87 at every width (main
-60 when wide); rust-sort's source pane keeps its passage at 47 when narrow
(main 1316, off screen).

Tests: the heading-above-a-pane test gains a wheel-over-pane variant (fails
on main and on the previous commit: -181 vs 12.5).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
version.js takes this branch's continuity; the next commit carries main's
landedSince rule (#2546) into it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ar it, and carry main's landing rule

Review fixes to per-scroller continuity (de2c5fe).

- One predicate (`held`) says whether a held box still keeps the place the
  runtime gave it: no input, no landing (`landedSince`, carried from main's
  #2546) and no scroll from where the runtime or the last layout change left
  it. The re-application now asks it too. A scroll a page script made the frame
  after a layout change used to be undone and pinned the reader (gallery:
  2442 back to 2098); it now stands (2442). The resize observer's delivery,
  which follows layout and anchoring, is where the layout leaves a box.
- A shift leaves a box a landing has moved since its place was recorded, as
  main's shift restore did; without it the lf-trace Moment test fails under
  reduced motion.
- `restoreView` drops holds, so a revision's own handoff is not overwritten by a
  place held from an earlier resize.
- Recording costs the blocks near the screen: `renderedBlocks` passes over a
  block whose own box lies wholly outside the band before measuring its words,
  after the skipped-content check so hidden panels are never laid out (doing it
  before moved an embedded tab set's page 24px on a switch). capturePlace on a
  3,000-paragraph page with the reader 86% down: 24.5ms -> 1.3ms; feature
  gallery at 95%: 2.7ms -> 0.24ms. The same landmarks are chosen.

Tests: a scroll the frame after a layout change moves a held page (fails on
de2c5fe: 2000 vs 2400); a box holding a restored place still follows a
script scroll, fragment travel and Back. The cut-short test now shares its
setup with them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

The new block-box shortcut misses visible words positioned outside their containing block; see the inline finding.

PR #2560 also changes restoreShifted and scroll ownership, replacing landedSince with chosenSince. Please reconcile these two ownership rules before both PRs land.

max-sixty and others added 3 commits October 12, 2026 02:15
…third review's fixes

#2560 counts a scroll as the reader's when it ends (`chosenSince`), and has a
place keeper's write say where it left a box (`placeKept`). This branch now
answers "did the reader move this box" with that rule alone:

- A hold releases on the reader's next input or a scroll they chose there,
  not on an offset inferred from the resize observer. A script that grows the
  layout and scrolls in the same frame, or the frame after, keeps its scroll
  (gallery: 2450, was snapped back to 2050).
- A held place is applied again only while the shift's layout settles: until
  two frames pass with no layout delivery, at most 12 deliveries. That is what
  re-application is for (a widget drawing a frame late), and past it a place
  put back could undo someone's move.
- A shift leaves a box the reader chose a scroll in since its place was
  recorded, replacing main's `landedSince`; places record on `scrollend` too.
- Subject readings (`showReadingSubject`) are kept per subject in the
  per-scroller places. A region returning from concealment, as a closed tree
  opening, takes only its own place, not one from the box that carried it
  (`reading-regions.js` marks such a shift `returned`). The box a region left
  is no longer restored: its own words moved only as layout moves them.
- Focus on a container that holds the passage, as a section a fragment landed
  on, names that passage rather than itself, so PageDown from a landed section
  keeps the paged passage (gallery 5, 5, 5; was 5, 285, 542).
- A screen reading skips a block below or above the band only when its words
  are drawn inside its box: no positioned or transformed element between the
  words and the block, read once per page reading. capturePlace on 3,000
  paragraphs 86% down: 1.4ms warm, 2.0ms first; gallery 0.25ms.
- The drawers reading-keys test reads the page's position once rendering has
  rested after the drawer opens beside the page.

Tests: script scrolls in the same frame, the first frame and the next move a
held page; paging down from a landed section keeps the passage; a reading finds
words a positioned child draws outside its block's box. Each fails on the
previous commit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

The new screen-reading shortcut can miss visible words after a style-only layout change; see the inline finding.

max-sixty and others added 2 commits October 12, 2026 03:39
… Leaf's settled reading

A place nobody chose could outrank the reader's. When wt-merge's panes flowed
back into the page, the page took the newest place by when it was read, and a
record taken after layout moved a box (a clamp, anchoring, the order places
were first read in) beat the passage the reader read at 390: 81 came back as
555. Recording now follows #2560's rule for whose a scroll is:

- A place is recorded only when the reader chose a scroll in its box since its
  last record (`chosenSince`), acted since (a wheel before its scroll ends), or
  stood there. Only those records rank; a box's first place, read as the page
  arrives, ranks below all of them. wt-merge: 81 -> 66 -> 81 from 390, and
  66 -> 81 -> 66 from 1200 (main 554 both ways).
- scrolling.js: a sequence a place keeper wrote in stays the keeper's when it
  ends elsewhere with no input since the write, since layout settling after a
  resize moves the box on before the sequence ends; that end otherwise read as
  the reader's choice and released the hold. A keep no scroll follows within
  two frames lapses, so a later script scroll is still the reader's.
- The re-application window closes when Leaf's rendering reads settled
  (`renderingState`), at most 12 deliveries.
- The scroll-rest and scrollend records no longer both run for one gesture:
  the second finds no choice since the first. 1.6ms per gesture on a 207,000px
  report page.
- A screen reading checks whether a block's words are drawn outside its box
  fresh each time rather than per page reading, so a breakpoint or stylesheet
  that moves a child is seen (1.56ms vs 1.43 on 3,000 paragraphs).

Tests: a passage read in a flowing wt-merge pane returns after the panes scroll
alone (fails on the previous head); the out-of-box reading test adds a
breakpoint-moved child (fails on the previous head).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
version.js conflicted only in its imports: this branch's rendering and
arrivals imports for continuity, and #2568's readingPaint for comparison
watchers. Both kept; the rest merged cleanly.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

Two scroll ownership paths can still replace a place the reader chose; see the inline findings.

Comment thread skills/leaf/assets/runtime/version.js Resolved
Comment thread skills/leaf/assets/runtime/scrolling.js Resolved
max-sixty and others added 6 commits October 12, 2026 04:01
The keeper's-sequence rule in scrolling.js gave a page script's scroll in the
frames after a resize to the keeper, so the hold stayed and re-application
undid it (gallery: 2050 where the script left 2450). scrolling.js is back to
#2560's rule: a sequence ending away from the kept offset is a choice. Whose a
move was is now read in version.js:

- A hold ends when the reader aims input at its box, or when a scroll carries
  the held landmark with the box: the box and the landmark moved by the same
  distance. Layout moves the landmark under a box that stays or that anchoring
  moves to keep something else still, and re-application puts it back. Such a
  scroll records the place it left as the reader's; input in a box the restore
  put the reader in makes the held place theirs, as if recorded before the act.
  A landmark another box now carries ends the hold.
- The end of a scroll a restore started is the runtime's, wherever layout
  carried the box before it ended (`writing`), unless the reader aimed input at
  the box meanwhile; continuity reads choices through that (`readerChose`).
- Input counts for the box it scrolls: a wheel for the first box in its chain
  that can still move its way, a wheel nothing can follow and every other input
  for the innermost box. A wheel in a pane no longer counts as a choice on the
  page around it.
- Re-application skips a place whose landmark still stands, and
  `moveScrollerBy` writes no move under half a pixel: a zero write stopped a
  smooth scroll under way (gallery: 2050 -> 2850, as main).
- reading-place.js gives `placeNode` and the new `placeOffset` one landmark
  reading (`landmarkOf`).

Journeys vs main: wt-merge 81/66 both ways (main 554); gallery fragment,
wheel and panel cases hold 25 or 33; alert-review returns to 202; a script
scroll 1 or 2 frames after a resize, smooth with growth, or a frame after the
first scroll stands. A script scroll in the same task as the resize's first
scroll is undone here as on main: it lands in the frame layout settles in.

Tests: script-scroll variants added (1 and 2 frames after the resize, smooth
with growth, a frame after the first scroll); a wheel in a box is no choice of
the page around it. Each new case fails on the previous head.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A hold keeps the place a width change restored until someone moves it. A
box that scrolls while its landmark moves by another distance is ambiguous:
anchoring answering the shift's own layout looks like that, and so does a
page script that scrolls in the frame content grows above the reader. The
hold read every such move as layout, at any time, so the script's scroll
stood until the next width change put the held place back over it
(feature-gallery, `raf-grow-above`: the heading returned to 282 on main
instead of staying where the script left it).

The layout reading is now bounded to the re-apply window. While the shift's
layout settles, an ambiguous move is layout's and the hold stays; after it,
the move is someone's, the hold ends, and the place it left is recorded.
Inside the window the reading stays a guess: a script that scrolls as
content grows while the shift settles is still undone, as on main, and a
script scroll in the same task as the resize's first scroll is lost, also as
on main.

The window now spans successive shifts: a shift's announcement no longer
closes it, the restore reopens it and then prunes holds under it, and it
closes only when rendering reads settled and every region stands where it
was last seen (`regionsSettled`), or after 12 deliveries. A landmark missing
inside the window, as a widget repainting its text, waits rather than ending
the hold; the re-application skips it until it returns.

A wheel in a pane at its end chained to the page in `inputBox` even where
the pane sets `overscroll-behavior: contain`, so the page's clamp could end
the page's hold. The chain now stops at a box whose computed
`overscroll-behavior-y` is not `auto`, as the browser's does.

Leaving the window or opening find is not counted as ending a hold: it moves
nothing, and find's own scroll is read like any other scroll.

Tests: `test_a_script_scroll_as_content_grows_above_ends_the_hold` (new);
`test_a_wheel_in_a_box_is_no_choice_of_the_page_around_it` gains the
contained-overscroll case.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
max-sixty and others added 2 commits October 12, 2026 07:20
…sion

The window in which an ambiguous move reads as layout closed when Leaf's
rendering read settled and every region stood still, or after 12 resize
deliveries. Deliveries come only from what the window observes, so on a page
whose rendering never settles, such as a chart whose box animates forever
or a live sample held open before presenting, the window never closed: a
script's scroll seconds later was undone, and the next width change put
the held place back. The window now also closes `SETTLING_MS` (1s) after it
opens, whatever happens. One timer bounds it in time; a frame count would
stretch on a slow or throttled page and close early on a fast display.

A revision patched in place restored the view only where the reader's
intent allowed, and the holds were cleared inside that restore, so a reader
who acted elsewhere kept holds on boxes across the revision. The landing
now releases every hold first, whatever the intent; hash and history travel
use the same release.

Test: `test_a_page_that_never_settles_lets_the_held_place_go_after_a_while`
breathes an lf-chart forever after the page opens, widens, waits 1.5s, then
grows content above and scrolls by script; the script's place survives the
next narrowing. Without the time bound it fails with the scroll undone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
A fresh document lands its handoff or saved view through restoreView after
presentation, with reading continuity already listening, so a shift during
startup, as a region's width settles while widgets upgrade, could leave a
hold whose re-apply put the startup place back over the landed view within
the window. Every whole-view restore is a runtime handoff that supersedes
what a shift was holding, so restoreView releases holds itself; the in-place
revision keeps its earlier release ahead of its intent check.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
# Conflicts:
#	tests/browser/test_render_navigation.py
@max-sixty
max-sixty merged commit a81350c into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the keep-reading-place-across-widths branch October 12, 2026 15:17
max-sixty added a commit that referenced this pull request Oct 12, 2026
…der's column (#2624)

A reading place is now what stands at the landing edge, in the column
the reader is using, rather than the first text block in document order
plus a pixel offset from that block's start. That offset held only while
nothing between the block's start and what the reader saw changed
height, so a width change or a revision moved the reader whenever it
did. A review of #2562 and #2574 as they sit together on main found the
cases below; each became a test that fails on main.

What a place stands on, in order:
- a drawing the edge cuts (an `img`, `svg`, `canvas`, `video`,
`picture`, `iframe`, `object`, `embed`, or a custom element holding no
text block), or a box that scrolls on its own and is no reading region
of its own, kept as how far through its height the edge cuts it. The
browser's hit test names it, at the reader's column or the middle of the
content. The line below it is recorded too, and stands in when a
revision replaces the drawing's node.
- otherwise the first line at or below the edge, quoted from its first
character with the prefix and suffix a comment's anchor takes
(`anchorForPassage`, split out of `anchorForRange`), measured from that
line. Lines above it in the same paragraph can rewrap or be rewritten
without moving what the reader sees. Text in a stuck sticky box, and
runs under 24 characters (a nav of labels), name no place.
- the reader's column (the pointer's last x over the box, else focus's)
only decides between blocks standing side by side at that line's row.
- a raw scroll offset is restored only in the same scroller, at the same
width, in the same revision; elsewhere the browser's anchoring keeps the
box.

Memory: a place holds its focused node and body through WeakRefs, and
`retainUserIntent` holds its source weakly, so a revision that removes
the section the reader focused or clicked in frees it (#2574's
guarantee, which #2562's `places` broke). Holds are keyed by scroller id
with a WeakRef to the box; `writing` is a WeakMap.

Also fixed: every bounded region's hold was dropped the first time it
was read, because the hold compared region records with `===` and
`readingRegions()` builds fresh records each call, so since #2562 a pane
did not re-apply its restored place while its layout settled.

Behavior changes (main → this, 1440×900 unless stated):
- a paragraph partly under the banner, reader's line: 1200→600 +84px →
+2.1px; 600→1200 −79px (under the banner) → +2.95px; a revision
rewriting words above the line +84px → +2.1px.
- a 2160px figure, reader 40% through: 1200→600 the figure's top landed
451px below the edge → stays 40% through at every width; a same-width
revision inserting paragraphs above it threw the reader ~2000px back →
−864 → −864.5.
- a figure with its caption lower on screen: 22%/54% → 40% both ways.
- two columns stacking at 800, reading the right one: 1255px → 4.45px.
- a nav of short items stacking above the text, keyboard reader: 40px
drift → line kept.
- the shipped `layout-column` sticky sidebar: main threw the reader
2353px → paragraph kept.
- a scrolling div that is no reading region: 47% → 60%/34% → 47.5% both
ways.
- a bounded pane whose content grows two frames after a resize: +200px →
held.

Known limits, shared with main: with scroll anchoring off (Safari), an
image that loads late after a revision still moves the reader (21% →
22%), because a revision's restore is applied once rather than held;
holding it would reverse the rule that a revision ends every hold.
focus.js `stood`/`published` keep a removed focused node until the next
input, and history.js keeps a clicked `#` link's focus for its entry's
life.

Tests: `test_a_width_change_keeps_what_stands_at_the_landing_edge` (new,
nine shapes),
`test_a_bounded_box_holds_its_place_while_its_layout_settles` (new);
`inside` and `figure` cases on
`test_live_revision_keeps_the_visible_semantic_reading`;
`test_paging_down_from_a_landed_section_keeps_the_paged_passage`
measures the word at the edge;
`test_a_revision_releases_the_served_markup_it_removes` focuses a link
in the removed section.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 12, 2026
The [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38275653575) failed
because
`test_a_reaction_list_opens_from_a_trigger_under_the_thread_panel`
assumed a reply would remain in the viewport after a resize.
[#2562](#2562) intentionally
preserves the page's reading position across width changes; at the
failed assertion, the reaction trigger was above the viewport, so the
panel could not cover it. The test now places the trigger under the
panel before checking that `e` opens its reaction list and keeps it
open.

The original test passes on the commit before #2562 and fails on #2562.
The corrected test passes on this branch with `uv run pytest -q -n0
tests/browser/test_render_threads.py::test_a_reaction_list_opens_from_a_trigger_under_the_thread_panel`.
No runtime behavior changes.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 14, 2026
…m, not where rounding left the box (#2877)

A reader who doesn't scroll now stays within one pixel of their line
across any number of revisions, and a card stays on its pixel while a
Threads-list fold corrects for it frame after frame. Before this, each
correction added its rounding to the last one's, so what the reader
looked at crept across the screen. It settles item 65 of the Lit
follow-up review, "WebKit place restores land about 5px off".

## Cause

A scroll offset is a whole pixel. Chromium rounds a fractional
`scrollBy`/`scrollTo` to the nearest pixel and WebKit rounds it down. I
measured both for a box and for the page, at device pixel ratios 1 and
2. Words stand at fractions of a pixel, so a restore lands up to a pixel
off its aim. A place captured afterwards took that error as part of the
reader's place, and the next restore added its own on top.

- **The reported 5px.** At #2560's commit I logged each frame of the
split drag. WebKit's landmark crept down by about half a pixel to a
pixel per frame, from 101.75px to 105.875px, because each frame's
restore re-recorded the place it had just left and WebKit always rounds
the same way. Chromium's errors went both ways and stayed under a pixel.
#2562 stopped this for layout shifts: its holds keep the reader's own
reading and don't re-record a box the runtime restored. On `main` the
drag lands 0.75px off in WebKit.
- **What #2562 left: revisions.** Revision continuity (`captureView`)
reads a fresh place at every revision, from wherever the last restore
left the box. On a page whose paragraphs stand 36.28px apart, both
engines scroll 36px for each paragraph added above, and the reader's
line drifts 0.28px per revision.
- **The same in `placeKeeper`.** `correct()` set `scrollTop += delta`
and then took its new baseline in content coordinates, so it never
recovered what the rounding lost. A fold above the reader corrects once
per frame. When I stepped a Threads-list fold through 30 frames, the
card below drifted 2px in Chromium and 10px in WebKit.

## Change

`moveScrollerBy` (`scrolling.js`) remembers the fractional offset it
aimed at for as long as the box stays at the offset the move left it
(`aimedTop`). `capturePlace` measures from that aim. The aim isn't kept
when the move was smooth, or when the box landed a pixel or more off,
since a box clamped at its range doesn't stand at its aim. Every restore
that moves through `moveScrollerBy` gets this, as does every place
capture: revisions, region shifts, and the subjects and tabs a region
shows. `placeKeeper.correct()` now moves through `moveScrollerBy` and
aims from where its last correction aimed.

## Tests

- `test_revision_after_revision_keeps_the_reader_on_the_same_line` (new,
Chromium and WebKit): six revisions each add a paragraph above the
reader. On `main` it fails in both engines (259.66px → 261.34px). With
the fix it lands at −0.31px in Chromium and +0.69px in WebKit.
- `test_a_fold_frame_by_frame_keeps_the_card_below_on_its_pixel` (new,
Chromium and WebKit): a held fold steps through 30 frames above the card
the reader looks at. On `main` the card drifts 2px in Chromium and 10px
in WebKit. With the fix it doesn't move.
- `test_a_split_drag_keeps_a_panes_reading`: the tolerance goes from 8px
to 1px, the most one rounding can leave.

## Line deltas (item 65)

- Hand-written source: +36 / −5 (`scrolling.js`, `reading-place.js`,
`user-place.js`).
- Tests: +89 / −3.

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