Repository navigation
Hold lf-shot's drawn size from first paint, so the page below doesn't jump - #6142
Merged
Merged
Conversation
…ays put An lf-shot had no box until its module drew it, then grew to its drawn height, moving everything below it on a page already painted. On a page with a shot under its first paragraph (1440x900, a 1800x746 pair), the paragraph painted at y 207 and jumped to 565 when the module drew: 90 ms after first paint in Chromium and 450 ms in Firefox, on a warm reload, before the page presented. Until lf-shot is defined, its ::before now takes the box the first drawing takes: the toolbar (the view chooser's row, `--lf-chooser`, in its padding, and the label row in a narrow shot), then the stage's padding, gutter and the frame's 1px border around the captures at Slider's fitted size. The size comes from the `data-lf-media-width` and `data-lf-media-height` delivery already paints, read with typed attr(): the stage's width at the captures' ratio, never past their own height, nor taller than the screen below the toolbar, as `fitShotGeometry` fits them. That makes package-themes.md's account of those attributes true. The hold is scoped to html[data-lf-interactive], so a page whose runtime won't start holds no room, and a browser without typed attr() holds the toolbar and padding only. The held box matched the drawn one to 0.1 px in Chromium, Firefox and WebKit, at 1440x900, 900x600, 500x800 and 390x844 (touch and mouse), for wide, mixed-height, tall, small and strip captures. The widget-quality check now finds no keeps-first-box change for lf-shot, so its accepted finding goes, and that check fails if the hold drifts from the drawing. A `screenshot-startup` stills state shows release-notes' shot with its runtime held.
…en and with a size Three cases where the room an lf-shot holds before its module draws differed from what it then drew: - The screen bound. The held frame stopped at `100svh`, while the module's fit stopped at `documentElement.clientHeight`, which leaves out a classic horizontal scrollbar. On a page that scrolls sideways under one, a tall shot held 900 px and drew 884, and everything below it moved up 16 px. The screen's height is now the stylesheet's alone: `--lf-shot-screen: 100svh`, registered as a `<length>` so that it computes to pixels, which the held frame reads through `var()` and the fit through `getComputedStyle`. The two read one computed value, so they agree in every engine, scrollbars or not. A shot that the screen bounds, on a page scrolling sideways under a classic scrollbar, now stands up to that bar's thickness taller than the visible window, as the held frame already did. - A shot whose images have no size delivery can read held 68 px, its toolbar and padding, and drew nothing there. It now holds nothing until it draws. - Print during startup kept the held room as blank space, 357 px for a 1800x746 pair; the hold is now for the screen only. Measured on base and head: the tall shot under classic scrollbars in Chromium (900 held, 884 drawn, now 900 and 900); the sizeless shot (68 held, now 0) and print emulation (357, 900 and 68 px held, now 0) in Chromium, Firefox and WebKit; and, unchanged, every shape at 1440x900, 900x600 and phone width.
leaf-agent
approved these changes
Nov 16, 2026
This was referenced Nov 16, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 16, 2026
… size (#6191) Three default-package widgets drew a different box once presented than at first paint, so the content below them moved during startup. `test_bundled_widgets_meet_the_widget_quality_checks[default]` failed on all five findings in #6181. It fails on main `f1b367375` and passes on this branch, as do the other 19 tests in `tests/journeys/test_widget_quality.py`. - **`lf-note` (from #6109).** A docked note's left padding included its line's indent. The module copies that indent only when it docks the note, so a card sized to its words grew by indent × ch (333→365px for the example's 4-space line). The indent is now the note's `margin-inline-start`, and `max-inline-size` subtracts it. The words, card, caret and right edge stand where #6109 put them, and the box keeps its first-paint size. - **`lf-code`'s registry example (from #6157).** HTML drops a newline right after `<pre>` but not after a `<code>` inside it. The example's `<code class="language-python">` was followed by a newline, which painted a blank first row (about 20px) that the module then strips. The example now starts its code on the `<code>` line. - **`lf-shot` (from #6142).** The placeholder frame (`::before`) had the stage's `scrollbar-gutter`. A box's `width` includes its own gutter, so `aspect-ratio` sized the frame from a width 2 × the gutter wider than the frame the module fits. On hosts with classic scrollbars (Linux, Windows) it held 2G/ratio too much: 18.75px for the example, where G is one 15px gutter. #6142 was measured on overlay scrollbars, where G is 0. The gutter now sits on the empty `lf-shot` itself, so the frame inside it takes the stage's content width. Chromium, Firefox and WebKit all give `aspect-ratio` that width-including-gutter behaviour (probed in the Playwright engines). **What the reviewer should weigh** - On classic-scrollbar hosts, the gutter on the empty shot narrows its `lf-shot` container by 2G. A shot whose width is within 30px above the 450px narrow-toolbar breakpoint therefore holds the narrow toolbar's height before upgrade. Before this change, every shot on those hosts was off by 2G/ratio. On overlay-scrollbar hosts nothing changes. - The authoring hazard behind the `lf-code` finding is wider than the example. #6157 wrote `<pre><code class="language-…">` followed by a newline in about 14 places in `examples/` and `docs/how-it-works.html`, and the `lf-code` instruction doesn't warn about the newline (`lf-text-document`'s does). Those pages still paint one blank row before upgrade. Fixing them, and adding the sentence to the instruction (which would need an instruction score), is left out of this repair. **Drawn states** (`leaf-dev stills`, base `f1b367375` vs head): `code-comparison`, `code-reader-feedback` and `screenshot-comparison` are pixel-identical. `walkthrough-code` changes only in text anti-aliasing: the note crops match, and the indent now lands as a fractional margin rather than padding. `screenshot-startup`, the held placeholder, now reserves about 12px less, the gutter error for its 1800×746 shot: | before | after | |---|---| |  |  | Focused checks: the `note`/`shot`/`annot` tests in `test_code_and_documents.py` and both `test_render_commands.py` files (19 passed), and `pnpm run check:browser`. Closes #6181 — automated triage Co-authored-by: leaf-agent <[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.
lf-shotnow holds its drawn size from first paint, so the content below no longer jumps when the shot's module draws. Leaf doesn't hide the page before presentation; it only turns transitions off. So the empty shot painted first and grew once its module drew. On a test page, the paragraph under an 1800×746 shot moved from y 207 to y 565. It was out of place for about 90 ms in Chromium (about 400 ms on a cold load) and about 450 ms in Firefox, and the render check recorded a layout shift of CLS 0.179.Before the module defines the element,
lf-shot:not(:defined)::beforetakes the drawn shot's size. That size is:data-lf-media-widthanddata-lf-media-height, which delivery already writes, using typedattr().The frame follows the drawing's limits: never larger than the captures, no wider than the stage, no taller than the screen. The screen height is one registered property,
--lf-shot-screen: 100svh, read by both the placeholder andfit(), so the two agree. The placeholder applies only on screen, only while the runtime runs (html[data-lf-interactive]), and only when both media attributes are present.What to weigh:
attr()arrives in Chrome 133, Firefox 155 and Safari 27.3, which is still in beta. Current Safari keeps only the toolbar and padding, so it still jumps by the image height.fitShotGeometry's sizing rules. The widget-quality check, which now has no accepted lf-shot resize, fails if they drift apart at desktop width or in a workspace pane, but it doesn't check narrow widths.fit()reads the same100svhthe placeholder does.lf-note(keeps-first-box, from Draw code notes as cards under the key they explain, and let the reader hide them from the block's toolbar #6109), not on lf-shot.Max asked for this after #6127 traced most of the render check's startup shifts to lf-shot. Codex reviewed it and found three cases where the held box differed from the drawn one: the screen-height cap under a horizontal scrollbar, a shot with no media size, and printing during startup. Each is fixed and measured equal.
Tests: held and drawn heights agree in Chromium, Firefox and WebKit, at four window sizes, at phone width, in dark, and for five shot shapes. Stills show no change inside the drawn shot. A new
screenshot-startupstills state holds the runtime. The fourtest_render_commandsshot tests,shot-view.test.mjsandpnpm run check:browserpass.