Repository navigation
Stand anchored marks on scaled slides in Firefox - #5058
Merged
Merged
Conversation
In Firefox, every box Leaf anchors to content inside a scaled box stood away from what it marked. reveal.js translates and scales its `.slides` box to fit its stage. With reveal.js 5.1 in a `layout-workspace` page at 1280x800, a quoted comment's pin stood 315px below the passage, under the slide and outside the window. In a fixture scaled to 0.6, the comment's row stood 262px below where Chromium puts it, the thread card opened past the window's right edge, the Alt outline stood 312px right of and 262px below its words, a link's Go-to chip stood about as far from the link, and Copy stood about 650px right of and 300px below its code block's corner. Firefox 157 resolves `anchor()` and `anchor-size()` against the box layout gave the anchor, leaving out every transform on it and its ancestors. Chromium 156 and WebKit 27.2 read the transformed bounding box. Firefox keeps CSS zoom. `anchorBox` (css-anchors.js) is the one measurement every inset starts from, and it corrected only translations: where an ancestor scaled or rotated, it kept the box as shown. `anchorBox` now reads the laid-out box itself in that engine (`laidOut`). Each box from the anchor up to the outermost transform stands at its offset from its offset parent's laid-out box. The walk ends at the first box no transform moves, whose client rectangle is exact. One walk covers translation, scale, rotation and nested transforms, and it replaces the translation-only path (`translationOf`, `movement`). A scroller's first words or an SVG drawing has no offsets, so it maps through its nearest HTML box in proportion, which holds for a translation or a scale. Copy, a heading's link and a recording's bar read their block's far edges and size in CSS (`anchor(right)`, `anchor(bottom)`, `anchor-size(width)`). A scale moves those differently from the corner, so `readInsets` also writes the size difference, `--lf-block-control-dw` and `-dh`, which those rules add. Both are zero except in Firefox under a transform, so other engines write nothing new. `test_marks_stand_on_a_scaled_slide_in_every_engine` runs in Chromium, Firefox and WebKit. It holds a quoted comment's row level with its words on a slide translated and scaled to 0.6, through a 120px scroll, and checks that the Alt outline stands on the words and Copy inside its block's corner. On the merge base it fails in Firefox, with the row 257px below its words. With `anchorBox` fixed but no size insets, it fails at Copy, 380px past the block. The outline and Copy assertions it shares with the widened-table test move into one helper. Two effects remain, recorded in notes/browser-support.md. A scroll inside a scaled box moves its marks at the unscaled rate until the next margin pass: scrolling 60px in a pane scaled to 0.6 left a row 24px off. Offsets are whole pixels, so a mark can stand up to a pixel off. The work runs only in Firefox. Timing copies of both versions on the fixture's DOM in Playwright Firefox, one `anchorBox` call took 2.4 us against 3.0 to 3.3 us on main for an anchor under no transform, and 5.1 to 6.2 us against 3.3 to 3.6 us for one in the scaled box, where main returned the wrong box. A margin pass makes one call per carrier, frame level and shown control. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
reviewed
Nov 2, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The scaled-slide test fails in WebKit because it compares the quoted passage's row with the paragraph box rather than its text (inline suggestion below).
leaf-agent
pushed a commit
that referenced
this pull request
Nov 2, 2026
) A comment on a reveal.js fragment now gets its margin row as soon as the fragment appears. Before, the row stayed withheld after the fragment showed, until some unrelated layout pass happened to run. ## Why the row stayed withheld reveal.js hides a fragment still to come with `visibility: hidden` and shows it by adding a class that starts a transition. The margin runs its pass when that class changes. At that moment the transition hasn't started, and `visibility` turns visible only after the transition's first frame, so the pass reads the fragment as hidden and withholds its row. Nothing afterwards resizes or mutates, so nothing runs the pass again. The same timing affects a slide moved out of the box that clips it by a transform transition: its row keeps standing after the slide has gone. ## What changed The margin now treats `transitionend` and `animationend` on page content as it already treats a scroll inside a pane. Once a frame, it reads again whether the rows under the box whose transition or animation ended have somewhere to stand, and runs the whole pass only where a row's answer changed (`margin-layout.js`, `hearTargetChanges`). This is the existing scroll re-read, renamed from `scheduleScrollReading` to `scheduleStirReading`. It filters on whether a row's target sits under that box, not on a list of properties, so the fragment's `visibility` and the slide's `transform` are both covered. Leaf's own chrome is skipped. `targetShown` also stops calling `checkVisibility()` on each part, since every part `visibleTargetParts` returns has already passed a stricter check. ## What #5024 described The issue blames reveal.js slides that keep the `hidden` attribute while staying laid out. That didn't reproduce. Under Leaf, those slides compute to `display: none`, because Leaf's `[hidden]:not([hidden="until-found"]) { display: none !important }` (base.css) beats reveal's inline `style.display = "block"`, so their rows were already withheld. In Firefox, the *showing* slide's pin and at-work bar reproduce the issue's picture, misplaced by reveal's scaled `.slides` box (#5058, open). Hence **Part of #5024**. ## Evidence - The browser test `test_rows_follow_slides_a_transition_shows_and_hides` (tests/browser/margin/test_scrollers.py) uses a deck whose next slide is hidden by a `visibility` transition, as reveal hides a fragment, and whose previous slide moves out of the deck's clipping box. A closed disclosure on the same page is the control. With the re-read reverted, it fails two frames after both transitions end, with `{'one': False, 'two': True}`: the gone slide's row still stands and the shown slide's row is still withheld. With the re-read, it passes. - With real reveal.js 5.1 and horizontal slides with a fragment on the first, `leaf-dev probe --base` steps `next()` twice. On main the fragment's row stays withheld after the fragment shows. On this branch it stands, and it is withheld again once its slide becomes `past`. - A paragraph shown and faded in with `Element.animate`, which fires neither event, behaves the same on main and on this branch: its row stands 1.5 s after the fade. ## Checks run - `uv run pytest tests/browser/margin/test_scrollers.py tests/browser/margin/test_card_placement.py tests/browser/margin/test_opening_threads.py tests/browser/margin/test_pins.py tests/browser/test_render_aim.py -k "slides_a_transition or withheld or inactive_tab or escapes or clip or quoted_passage_scrolled or pane or shadow or widened_table or constrained_target or user_scrolls or keyboard_arrival or carries or carried or hidden or closed_tab or observes_visibility"`: 67 passed, including the scroll re-read's cases in Firefox and WebKit - `pnpm run test:runtime`: 739 passed - `pnpm run build:browser` and `pnpm run check:browser` after merging main ## Not verified - The new test runs in Chromium only. - Animations a script plays with `Element.animate` fire neither event, so one that changes a target's `visibility` or moves it out of a clip isn't re-read. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
A scroll inside a scaled box left a comment's row off its words in Firefox and WebKit until something unrelated ran a margin pass. reveal.js makes every long `pre code` a scroller inside its scaled slides, so this is the everyday case on a deck. Scrolling 60px in a box scaled to 0.6 left the row 24px off in Firefox 157 and in WebKit 27.2. Both carry an anchored box by the scroll's layout pixels, not the smaller distance the words move on screen; Chromium 156 follows the words. Firefox's own transform support has the same drift (bug 2055371), so it is separate from the transforms `anchorBox` corrects. The margin already hears every scroll in capture. It now also hears `scrollend`, and runs a pass where the box that scrolled shows a layout pixel as more or less than a screen pixel (`scrollMisplacesAnchors` in css-anchors.js: its client width differs from its offset width). Rows drift while the scroll runs and stand on their words a frame after it ends. The check reads the box's scale on screen rather than the engine, so it covers WebKit, which `anchorDropsTransforms()` doesn't flag; Chromium runs one pass at each such scroll's end that changes nothing. The css-anchors.js header's record of the rejected scroll re-measure now says where this pass runs and why. `test_marks_stand_on_a_scaled_slide_in_every_engine` now puts the quoted words in a scrolling box holding only words, so the row anchors to the box's first words and exercises `anchorBox`'s proportional mapping. After the page scroll it scrolls that box 60px, waits for `scrollend` without announcing a layout change, and checks the row stands on its words. With the `scrollend` listener disabled it fails in Firefox and WebKit, each 24px off; Chromium passes either way. notes/browser-support.md records the inner-scroll gap, release Firefox 159 still dropping transforms, bugs 2059840 and 2059841, and when to delete the offset walk, the size insets and this pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # browser/runtime/annotation-overlay/margin-layout.js # dist/kernel/kernel.json # dist/kernel/runtime/bundle-comment-placement.js # dist/kernel/runtime/bundle-content-layout.js
`scrollMisplacesAnchors` compared a box's on-screen width with its `offsetWidth`, so a box under a CSS zoom looked scaled: reveal.js scales up with `zoom` in Chromium on a 1x display, and review measured 720px on screen against an `offsetWidth` of 960. A zoom resizes layout, which anchors follow, so it now compares against `offsetWidth` times `currentCSSZoom`. Under `zoom: 0.6`, a 60px scroll inside the slide now runs no pass in Chromium 156, Firefox 157 or WebKit 27.2, and the row stays on its words in each. The pass also ran for a scaled scroller that carries no row. It now runs only where a row's carrier is anchored inside the box that scrolled. With one comment elsewhere on the scaled slide, scrolling the box beside it runs no pass; with the comment's words in that box, Firefox, WebKit and Chromium each run one and keep the row on its words. Where it runs in Chromium, the pass isn't a no-op for a row whose carrier scrolls with something its target doesn't, such as a pin on a `pre` whose `code` scrolled: it moves that pin back to where a fresh pass puts it. The css-anchors.js header says so. notes/browser-support.md now says to recheck the engines with the `scrollend` listener removed, since the test passes whatever they do while the pass is in place. Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
marked this pull request as ready for review
November 2, 2026 06:42
leaf-agent
reviewed
Nov 2, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The WebKit scroll-end correction never runs because currentCSSZoom is unavailable in that engine; the inline suggestion fixes the failing scaled-slide case.
…pass WebKit 27.2's Linux build (Playwright build 2370, which CI runs) has no `currentCSSZoom`, though its macOS build of the same number does. There `offsetWidth * box.currentCSSZoom` was NaN, `scrollMisplacesAnchors` always answered false, and the scroll-end pass never ran: `test_marks_stand_on_a_scaled_slide_in_every_engine[webkit_browser]` failed in CI with the row 24px off its words after the inner scroll. A missing zoom now counts as 1. Evaluated in Playwright 1.64.1's Linux browsers, a scroller under `scale(0.6)` now reads as scaled in WebKit, as it does in Chromium and Firefox; a scroller under `zoom: 0.6` also reads as scaled in Linux WebKit, which costs one pass at the scroll's end that leaves the rows where they stood. Chromium, Firefox and macOS WebKit read the same as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # dist/kernel/kernel.json
leaf-agent
approved these changes
Nov 2, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 2, 2026
…#5097) A comment on a line of a code block whose `code` scrolls, as reveal.js's theme makes every long one (`pre code { overflow: auto; max-height: 400px }`), stood its pin in one of two places. A layout pass put it above the block's top-right corner; a scroll of the code then carried it away with the lines, 40px for a 40px scroll, until the next pass put it back. The row also stayed shown while its line was scrolled out of the code's view. This happens only where pins are placed by the block: workspace pages, so every reveal deck, and column pages narrower than the rail needs. On a desktop column page the row stands in the rail, level with its line, and the only change there is that it hides while its line is scrolled out of the code's view. ## The cause The carrier was right: since #3091 a passage's row is carried by its words (`anchorFor`), so it moves with the code's scroll. The pass measured the row against its target instead. The target is the `pre`, which the code's scroll doesn't move, so the block seats (the `pre`'s corner), the words' visibility (clipped by the `pre`'s ancestors, not by the `code` inside it) and the offsets the scroll reading and `paintedBox` find the row by all disagreed with the carrier. And a passage in code took the seats built for prose: the seat level with the line fails whenever the next line reaches as far right, the raised fallback hangs off the end of the line above, and the slide-left fallback crosses every word to the window's edge. The pass reached the block's corner because the margin counted the keyboard stop reach.js lends the `pre` (claimed by Copy) as a control, so no seat inside a code block was clear. ## What changed - **Visibility.** `wordsShown` answers what shows of each quoted line through every box holding it, the `code` included, in the pass and in the scroll reading, which also hears a scroll of a box inside the target. The row shows while one quoted line does, and comes back with it. - **One seat on a block of preformatted lines.** A block whose text keeps its spaces and doesn't wrap its lines (`white-space-collapse: preserve`, `text-wrap-mode: nowrap`, as reveal's `pre` and Leaf's document code blocks compute) has one seat per pin, at the right edge of what shows of it (`preformattedBlock`): a line's pin inside the block, its centre on what shows of the passage's first line still in view, and the block's own pin above its top-right corner, where main stood it. A scroll carries a line's pin with its line; once that carries its middle past the quoted lines that show, the scroll reading brings a pass in the next frame that seats it by the first line still in view. `seatRow` keeps such a pin `level`: it takes that seat whatever words it covers, or slides left past a control or a pin already seated there, never up, down or past words. A line's carrier follows the line down the block but not sideways (`axes: "y"`, as a rail row's), so a sideways scroll of a long line leaves the pin at the edge. Wrapped text that keeps its spaces, such as a `pre-wrap` paragraph or `lf-code`'s lines, keeps prose seats. - **Block controls are controls.** `coverIn` never counts a lent reach stop as a control, as control-selectors.js already says of it. It counts instead the box of every control block-controls.js stands over a block (`blockControlBoxes`), at rest as when shown, so no pin stands on Copy or a recording's bar. `blockControlBoxes` reads each control's transform insets from its block first, every block before any control is written, since a deck moves and scales its slides with no resize to say so; on a reveal slide reached after load in Firefox, Copy's box at rest had been read from before the move. A heading's link, made only when it shows, has no footprint, since counting it would move pins on hover. - **Prose fallback in the words' frame.** `passageBlock`, the block a prose passage's pin falls back to, is the outermost box from the words to the target that every scroll moving them moves too. - **Where a row stands between passes.** `standsBy` records each row's offsets from its carrier's anchor, on the axes the carrier follows (or from the document's origin in the root lane). `standsNow` reads where the row stands now for the scroll reading, `paintedBox` and a held pin, which replaces the separate record of a held pin's seat. In Chromium, #5058's `scrollend` pass inside a scaled box now writes the insets the scroll left for such a row instead of moving it back to the block's corner. Firefox and WebKit still need it for the scale drift. ## Visible changes - A line's pin in a code block, where pins are placed by the block, stands level with its line at the block's right edge rather than above the block's corner (main). On a phone it covers the last visible characters of a line that reaches the edge, as Copy does on line 1. Still pair (760px, main | this branch): `~/.tmp/leaf.agent-a531589747ffee0ab/line-pin.png`. - A first-line pin that meets Copy slides left of Copy, level with its line, over the line's last words (pair: `~/.tmp/leaf.agent-a531589747ffee0ab/first-line-pin.png`). Accepted cost: a first-line pin beside Copy can cover the last characters of its own passage when that line reaches Copy's column, as `nam` of `profile_name)` at 760 (pair: `~/.tmp/leaf.agent-a531589747ffee0ab/first-line-at-copy.png`). - An element comment's pin on a code block stands above the block's top-right corner, as on main (pair: `~/.tmp/leaf.agent-a531589747ffee0ab/element-pin.png`; the pin inside main's block belongs to the scrolling block above it, which main stands 247px below its line after a pass). ## Evidence Real reveal.js 5.1 deck (`embedded`, scale 1.22) in a `layout-workspace` page at 1440x900, `leaf-dev probe --base`. Slide 1: comments on `step_05` (the code's line 7) and on the whole `pre`. Slide 2, reached with `Reveal.next()` after load: comments on the whole `pre`, on line 1 and on `step_03`. dy is the pin's top less its line's top (its centre at +16 lies inside the line); right is the pin's right edge less the `pre`'s: | | main | this branch | | --- | --- | --- | | Slide 1, `step_05` | dy +321 to +322, right −9 (below the block) | dy +3, right −28, all three engines | | Slide 1, the `pre` | 30px above the block's top, right −9 | 29–30px above, right −10 | | Slide 2, line 1 | dy +408, right −9 | dy +2 to +4, right −28 (ends where Copy begins) | | Slide 2, `step_03` | dy −1 to 0, right −1103 | dy +3 to +4, right −28 | | Slide 2, the `pre` | pin bottom 4px above the block | 3px above | | Slide 2, Copy | pressable | pressable, `elementFromPoint` at its centre is Copy, all three engines | On slide 1, scrolling the code 200px hides the `step_05` row in all three engines (main kept it shown, from a line out of view) and scrolling back shows it at the same place. At `d5c51bb0d`, the review found Firefox's slide-2 element pin standing on Copy and a click on Copy timing out. Column page at 760 and 390 in Chromium and 760 in Firefox (the review's states), this branch: - A line in a short block, in a scrolling block, and beside an element comment: dy −4 or −5 (centred on the line), right −10, or −24 in the scrolling block, whose `code` box sits inside the `pre`. main: −93, −173 then +247 after a pass, and +0 from a line scrolled out of view. - The block's own pin: 29px above the block's top, right −10 (main −30, −9). - The first line beside Copy: dy −5, right −37, slid left of Copy. A long first line ending under Copy: pin at x673–699 over `nam` of the commented `profile_name)`, Copy at x708–732 and pressable. - A line wider than its block: level at right −10; after scrolling the block sideways, the start's row hides and the tail's shows at right −10. - Two comments on adjacent lines: the second slides left of the first (right −45). At 390 a scrolling block's line reaching the edge: right −24, inside the code box (main: 273px above the line; this PR's first head: x4, at the window's edge). - A prose passage, and `lf-code` lines with neighbours as long as the commented one (at 1280, 760 and 390): the same seats as main. A `pre-wrap` paragraph's pin stands where the same paragraph's does without `pre-wrap` (the test below). The new tests fail on the head before each fix and pass now, in Chromium, Firefox and WebKit: - `test_a_pin_on_a_line_of_a_scrolling_code_block_marks_that_line` (short neighbours, long neighbours, 390px): the pin's vertical centre lies inside its line's box and the pin inside the code box; a 40px scroll carries it with no layout pass and a forced pass leaves it there; it hides while the line is out of view. `290fcb8cb` failed it (30px high; x4 at 390). - `test_a_pin_on_a_code_block_s_first_line_leaves_copy_pressable` (column, and a slide moved after load): no overlap with where Copy shows, and a Playwright click on Copy. `290fcb8cb` failed the column case; `d5c51bb0d` failed the moved slide in Firefox. - `test_a_pin_on_lines_partly_scrolled_away_stands_by_one_still_shown` (a quote of eight lines with two and a half scrolled past the code box's top, and one with 6px of its first line at the box's foot): the pin's middle lies beside a quoted line in view, after the scroll and after a forced pass, and the row hides once none shows. `fa60f4806` failed all six cases (the pin above the box, or below it), as Tend's review found with lines 4–11 and the code scrolled 180px. - `test_a_code_block_s_own_pin_stands_above_its_corner`: `d5c51bb0d` failed it (the pin stood inside the block, under Copy). - `test_wrapped_prose_that_keeps_its_spaces_seats_its_pin_as_prose`: `d5c51bb0d` failed it (the `pre-wrap` pin stood at the right edge). - A runtime case for the `level` seat in `seatRow`. ## Checks run - `uv run pytest` on `test_scrollers.py`, `test_pins.py`, `test_clusters.py`, `test_card_placement.py`, `test_entries.py`, `test_render_margin.py`, `test_rail.py`, `test_status.py`, `test_render_heading_links.py`, `test_render_code_reading.py`, `controls/test_recording_bar.py`, `test_opening_threads.py`, and the passage and Copy tests of `test_render_send_placement.py` and `test_render_anchors.py`: all pass but five that fail the same way on main: `test_release_notes_pins_under_a_finger_stand_by_the_words_they_decide`, `test_a_finger_hides_the_annotations_from_the_leaf_s_menu`, `test_suggestion_actions_stay_reachable_through_a_decision_and_its_undo` (an unchanged style write at teardown, in earlier runs only), `test_a_new_anchored_comment_keeps_the_users_thread_view[760-False]` and `test_a_quoted_passage_keeps_its_inline_attachment_before_and_after_send[pointer-900]` (the thread card never opens after the send). - `test_scrollers.py` at the head (58 passed, the new cases in all three engines), `pnpm run test:runtime` (747 passed), `pnpm run build:browser`, `pnpm run check:browser`, pre-commit on the changed files. ## Not verified - After reveal's animated slide change in Firefox, the reading taken on slide 2 still shows Copy's box at rest at its unscaled place: the last pass ran while Copy was still `hidden` (its block's near-window observer had not fired), and nothing reads it again once Copy shows. On that slide no pin needed to keep off Copy and Copy stayed pressable; a line-1 pin whose seat met Copy there would stand on it until the next pass. A slide moved without a transition is covered by the test above. - A code block inside a box that scrolls sideways around it: a line's pin follows its line down the block only, so that outer scroll leaves it where the window holds it until the next pass, as it does a rail row. Accepted. - A passage in a scroller inside a widget's shadow tree inside the target, and a real trackpad scroll (probes and tests set `scrollTop`). ## Calls Max may reverse - A line's pin follows the line's scroll down the block but not sideways, which keeps it at the edge through a sideways scroll of a long line. Part of #5024 > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[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.
In Firefox, every box Leaf anchors to content inside a scaled box stood away from what it marked: comment pins and rows, the thread card, the Alt outline, Go-to chips and Copy. reveal.js translates and scales its
.slidesbox to fit its stage, so marks on a deck's slides hit this. A scroll inside a scaled box, such as the longpre codereveal's theme makes a scroller, then carried rows off their words in Firefox and WebKit. An agent found the first while working on #5024, and #5042 recorded it as the part of #5024 that PR left open.Part of #5024
The cause
Firefox resolves
anchor()andanchor-size()against the box layout gave the anchor, leaving out every transform on it and its ancestors: Playwright's Firefox 157, and release Firefox 159. It keeps CSS zoom. Chromium 156 and WebKit 27.2 read the transformed bounding box.anchorBox(css-anchors.js) is the one measurement every anchored inset starts from. It corrected only translations, added for widened tables in #3113; where an ancestor scaled or rotated, it kept the box as shown.A scroll inside a scaled box is a separate gap. Firefox 157 and WebKit 27.2 carry an anchored box by the scroll's layout pixels, not the smaller or larger distance the words move on screen. Chromium 156 follows the words. Firefox's bug is 2055371, and it remains with Firefox's own transform support on.
What changed
anchorBoxreads the laid-out box where the engine drops transforms. Each box from the anchor up to the outermost transform stands at its offset from its offset parent's laid-out box (laidOut). The walk ends at the first box no transform moves, whose client rectangle is exact. One walk covers translation, scale, rotation and nested transforms, and it replaces the translation-only path (translationOf,movement). A scroller's first words or an SVG drawing has no offsets, so it maps through its nearest HTML box in proportion, which holds for a translation or a scale. Other engines take the early return they took before. That includes Firefox Nightly 160 withlayout.css.anchor-positioning.follows-transforms.enabledon, sinceanchorDropsTransforms()then finds transforms kept.Block controls add the size difference. Copy, a heading's link and a recording's bar read their block's far edges and size in CSS (
anchor(right),anchor(bottom),anchor-size(width)). A scale moves those differently from the corner, soreadInsetsalso writes--lf-block-control-dwand-dh, which those three rules add. Both are zero except in Firefox under a transform, so other engines write nothing new.The margin runs a pass when a scroll inside a scaled box ends. The margin already hears every scroll in capture. It now also hears
scrollend, and runs a pass where a row's carrier is anchored inside the box that scrolled and that box shows a layout pixel as more or less than a screen pixel (scrollMisplacesAnchors: its on-screen width differs fromoffsetWidth×currentCSSZoom, so a CSS zoom, which anchors follow, doesn't count). WebKit 27.2's Linux build (Playwright build 2370, which CI runs) has nocurrentCSSZoom, unlike its macOS build of the same number, so a missing zoom counts as 1: a zoomed box there reads as scaled and costs one pass that leaves the rows where they stood. Rows drift while the scroll runs and stand on their words a frame after it ends. The check reads the box's scale on screen rather than the engine, so it covers WebKit, whichanchorDropsTransforms()doesn't flag. In Chromium, where it runs, the pass also moves a row whose carrier scrolls with something its target doesn't back to where a fresh pass puts it: review found a pin on aprewhosecodescrolled carried 45px with the code without the pass, a mismatch older than this PR, and the pass snaps it back to the block's corner. The css-anchors.js header, which rejects a script that places boxes again after each scroll, now says where this pass runs and why.notes/browser-support.mdrewrites "An anchor's transforms in Firefox": the engines, bugs 2059840 (the pref, on in Nightly 160) and 2059841 (enabling it in release: no milestone, blocked on 2055371, 2057633 and 2060883), the inner-scroll gap, and when to delete each part.Evidence
Real reveal.js 5.1 (vendored into
.tmp/for the probe only) in alayout-workspacepage at 1280x800,leaf-dev probe --browser firefox --base: the quoted comment's pin stood at[974, 913]on the merge base, 315px below its passage and outside the window, and stands at[714, 566]on this branch. Chromium puts it at[714, 567]. Review drove the same deck in Firefox 157 through slide changes, resizes, narrow windows and reveal's overview mode (scale 0.19, 3D transforms), and every mark landed within 1–3px of Chromium.A fixture with the same transform at 0.6 (
translate(-50%, -50%) scale(0.6)), at 1440x900, each mark's top-left corner:A scroll of 60px inside a box scaled to 0.6, holding the quoted words, measured as the row's offset from its words after
scrollend: Firefox moved from 0 to −24px and WebKit from 0 to −24px with no pass after the scroll; with thescrollendpass all three engines stay at 0, after one pass each.test_marks_stand_on_a_scaled_slide_in_every_engine(tests/browser/margin/test_scrollers.py) runs in Chromium, Firefox and WebKit. On a slide translated and scaled to 0.6, the quoted words stand in a scrolling box holding only words, so the row anchors to the box's first words and exercisesanchorBox's proportional mapping. The test holds the row level with its words through a 120px page scroll, then through a 60px scroll of that box, afterscrollendand without announcing a layout change, and checks that the Alt outline stands on the box and Copy inside its block's corner. On the merge base it fails in Firefox, with the row 257px below its words. WithanchorBoxfixed but no size insets, it fails at Copy, 380px past the block. With thescrollendlistener disabled, it fails in Firefox and WebKit, each row 24px off. Its outline and Copy assertions, shared with the widened-table test, move into one helper.Cost: in Firefox, timing copies of both versions on the fixture's DOM, one
anchorBoxcall took 2.4 µs against 3.0–3.3 µs on main for an anchor under no transform, and 5.1–6.2 µs against 3.3–3.6 µs for one in the scaled box, where main returned the wrong box. A margin pass makes one call per carrier, frame level and shown control. In every engine, a scroll's end checks the margin's carriers against the box that scrolled, reads that box's width only where one stands in it, and runs one margin pass only where the box is scaled by a transform, not a zoom. Underzoom: 0.6, a 60px scroll in the slide ran no pass in any of the three engines and the row stayed on its words; with one comment elsewhere on the scaled slide, scrolling the box beside it ran no pass in Firefox.Before/after screenshots are in the worktree's
.tmp/evidence/(firefox-*-before.png,firefox-*-after.png,chromium-*.png).What remains
scrollendpass can go once release Firefox and WebKit both keep a row on its words through that scroll. The test passes whatever the engines do while the pass is in place, so recheck with thescrollendlistener removed (Firefox 157 left the row −24.1px from its words that way, WebKit 27.2 −24.0px), or by reading the row in the frame after the scroll, beforescrollend.Calls Max may reverse
DOMMatrixes from computed transforms. Offsets already leave transforms out, so one walk handles every transform kind without parsingtransform,translate,rotate,scale, origins or perspective; the price is the whole-pixel rounding above.scrollendpass keys on the scrolled box's scale on screen, not onanchorDropsTransforms(), because WebKit drifts the same way and keeps transforms at rest. Chromium pays one pass at the end of each scroll inside a scaled box that carries a row.Checks run
uv run pytest tests/browser/margin/test_scrollers.py -k "scaled_slide or widened_table or every_engine or pane or slide_the_reader or carrier" -n 2: 16 passed, all three engines of both transformed-box tests included, after merging main at a300990 (which brought Show a reveal.js fragment's comment row once the fragment appears #5042's stir reading beside the new listener). Evaluated in Playwright 1.64.1's Linux browsers (Docker), the check reads ascale(0.6)scroller as scaled in WebKit, Chromium and Firefox, where WebKit read it as unscaled before the?? 1default; CI's WebKit case had failed that way, the row 24px off. With thescrollendlistener disabled, the scaled-slide test fails in Firefox and WebKit.test_tabs.py,test_rings.py,test_focus.py,threads/test_layout.py,test_comment_marks.py,test_render_drawing.py,test_suggestions.py,test_send_corner.py,test_render_pages.py(-k "firefox or webkit" -n 2): 43 passed, 2 failed. The two aretest_words_scrolled_past_a_card_head_show_nowhere_above_it[firefox_browser-*], which fail the same way with current main'sbrowser/anddist/(travel246, wants over 300).test_render_heading_links.py,test_render_code_reading.py,test_render_anchors.py), run before thescrollendcommit: 109 passed. Eight failed and four errored, all intest_render_anchors.py:test_thread_travel_keeps_its_passage_above_the_bottom_reading_clearanceand thelf-diffcases (deferred_diff_renders_only_opened_files,native_file_metadata_without_empty_disclosures,inline_version_diff_indexes_astral_text,hunk_step_waiting_on_a_file, which throwCannot read properties of null (reading 'path')inlf-diff.js). The same eight fail and the same four error with main'sbrowser/anddist/at 1f49b64.pnpm run test:runtime: 742 passed.pnpm run build:browser(type check and kernel rebuild),pnpm run check:browser, pre-commit on the changed files.Not verified
pre code; the test and probes scroll by settingscrollTop.