Repository navigation
Keep a reader's line still across restores: aim each from the last aim, not where rounding left the box - #2877
Merged
Merged
Conversation
…the box A scroll offset is a whole pixel: Chromium rounds a fractional one to the nearest, WebKit rounds it down (measured for scrollBy and scrollTo, in a box and the page, at device pixel ratios 1 and 2). Words stand at fractions of a pixel, so each restore lands up to a pixel short of its aim. A place captured afterwards read that shortfall as the reader's place, so the next restore added its own: under repeated revisions the reader's line crept down the screen, 0.28px per revision in both engines on a page whose paragraphs stand 36.28px apart. The same compounding was the "about 5px" WebKit offset in the split-drag test (#2560): before #2562 each frame's restore re-recorded the place it had just left, and WebKit's rounding always went one way (101.1px aimed, 105.9px landed). #2562's holds stopped that for shifts; revisions, which capture afresh, still compounded. moveScrollerBy now remembers its aim while the box stands where the move left it (`aimedTop`), and capturePlace reads from that aim. Behavior change: a reader who doesn't scroll stays within one rounding of their line across any number of revisions. The split-drag test's tolerance goes from 8px to 1px. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…creep placeKeeper corrected with `scrollTop += delta` and then took its new baseline in content coordinates, so it never recovered the fraction the engine's rounding lost. A fold above the reader corrects every frame: stepped through 30 frames, a Threads-list fold left the card below 2px off in Chromium and 10px off in WebKit. correct() now moves through moveScrollerBy from `aimedTop`, so each frame aims from the last frame's aim; the card stays on its pixel. The move is now explicitly instant, where the assignment followed any `scroll-behavior: smooth` on the box. The comments say "off its aim" rather than "short": Chromium rounds to the nearest pixel and can land past it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 14, 2026
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.
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/scrollToto 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.mainthe drag lands 0.75px off in WebKit.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.placeKeeper.correct()setscrollTop += deltaand 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).capturePlacemeasures 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 throughmoveScrollerBygets this, as does every place capture: revisions, region shifts, and the subjects and tabs a region shows.placeKeeper.correct()now moves throughmoveScrollerByand 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. Onmainit 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. Onmainthe 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)
scrolling.js,reading-place.js,user-place.js).