Repository navigation
refactor: drop page-sheets.js and guard the chrome with one CSS rule - #4480
Merged
Merged
Conversation
page-sheets.js rewrote every page and theme selector at runtime, through the
CSSOM, so it could not match `.lf-chrome` or `.lf-ui`. It covered revisions,
imported sheets, sheets a framework rewrites, and an iOS WebKit quirk with
adopted sheets. A `data-controls` stylesheet, or a theme package's `controls.css`
in an `lf-controls` tier, opted out. All of that is gone.
Page CSS is now ordinary CSS over the document. A page's `button` rule dresses
the controls widgets build, as it dresses its own. The chrome (panel, thread
cards, composer) keeps its look through one unlayered rule,
`.lf-chrome, .lf-chrome * { all: revert-layer }` (styles/chrome-guard.css, also
covering ::before, ::after and ::placeholder), adopted after the page's sheets.
A page rule as light as one class rolls back to Leaf's layered faces there. A
heavier page selector (`button:hover`) or an `!important` declaration still
reaches the chrome, and so does any layered rule, a page `@layer` rule or a theme
package's `lf-theme` rule, since it outranks the layered faces the chrome's
controls wear.
Behavior that changes:
- Widget controls (`.lf-ui`) take the page's and a theme's element rules. The
feature gallery's control-access demo and the examples' `data-controls`
markers go. page-layout.md now tells authors to name what each rule styles.
- A theme package's bare element rule reaches the chrome. No theme package
exists, bundled or installed; packages.md tells theme authors to name their
content (`main button`), and the theme test uses that form.
- `controls.css` and the `lf-controls` tier no longer exist (PACKAGE_STYLES,
CASCADE_LAYERS).
- PhotoSwipe's styles, which the runtime puts inside the chrome's image viewer,
go in `lf-base`, so the guard rolls back to them rather than past them.
- A page rule written for controls now applies as written, such as the feature
gallery's widget rule hiding its sample margin entries' hover labels, which
page-sheets.js had silently kept off them.
- lf-text-document's line numbers drop Pierre's `data-line-number-content`
attribute, which only page-sheets.js had kept Pierre's inline-block rule off.
Tests: the page-CSS test now asserts the guard (placeholders included) in
Chromium, Firefox and WebKit, and that widget controls take page rules. The iOS
adopted-sheets test and the control-access revision steps go with the code they
covered, and tests drop their `data-controls` markers; the boxless-reply test
names its widget past the guard, as it is inside the chrome.
No protocol bump: an earlier page's vendored theme.css keeps an empty
`lf-controls` layer name that orders nothing, and a leftover `data-controls`
attribute is inert.
leaf-agent
reviewed
Oct 27, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
[P2] The new unscoped guard breaks the chrome-isolation gate. Running uv run pytest -q -n0 tests/browser/threads/test_layout.py::test_a_coined_class_cannot_reach_the_chromes_rules fails with ['lf-chrome']: the selector collector now finds .lf-chrome outside @scope, while chromeSharedClasses in stylesheets.js does not declare it. Reconcile that audit and its declared vocabulary with the intentional guard, preserving the check that private chrome classes cannot style page content. This failure is in the edited browser test file, so the PR's changed-test selection includes it.
The guard stands outside the chrome's @scope and names only `lf-chrome`, the chrome's own root, which no authored element may wear. Scoping the guard instead would let its scope proximity beat the chrome's unscoped shared rules of the same weight; a sweep of the chrome's computed faces showed box-sizing, position and pointer-events changing on the legend, the response bar and the composer.
leaf-agent
previously approved these changes
Oct 27, 2026
# Conflicts: # dist/kernel/leaf.js # dist/kernel/runtime/bundle-data.js
leaf-agent
approved these changes
Oct 27, 2026
This was referenced Oct 27, 2026
This was referenced Oct 28, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 28, 2026
…oom (#4640) Since #4480, `.lf-chrome ::after { all: revert-layer }` crashed Chrome's renderer on load whenever page zoom or device scale wasn't 1. The issue narrowed it to `zoom` and `view-timeline-inset` both reverting on the floating panel's `::after`. No Leaf rule sets `zoom`, so `normal` is the value the revert reached anyway; the guard now restates `zoom: normal` after the reset, which keeps every computed value and stops the crash. Verified in Chrome for Testing 155.0.8059.79 on macOS, serving `ideas-to-implement` with a profile default zoom: before the change the tab crashed at 0.9, 1.1 and 1.5 and rendered at 1; after it, all four render. Stable Chrome 156.0.8078.49 doesn't crash on either side, so no regression test can see this on current Chrome or in the headless shell the suite uses. The guard's existing tests (`test_layout.py -k "stop_at_the_chrome or coined_class"`) pass. Closes #4536 > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Oct 29, 2026
…nd the zoom workaround (#4664) The chrome guard's `::before`, `::after` and `::placeholder` parts came with #4480 as parity with `page-sheets.js`, which excluded the chrome from every page selector, pseudo-elements included. They were the part that crashed Chrome 155's renderer at any zoom but 100% (#4536), which #4640 worked around with `zoom: normal`. Without them the guard needs no workaround: Chrome for Testing 155.0.8059.79 renders at 0.9, 1.1 and 1.5 with `.lf-chrome, .lf-chrome * { all: revert-layer }`, and still crashes with the pseudo parts kept and the zoom line removed. Behavior that changes: a page rule aimed at a pseudo-element with a bare or universal subject now reaches the chrome, such as `::placeholder { font-style: italic }` on the composer's placeholder, `button::after { content }` on its buttons, or a `*::after` margin/padding reset on its hit areas. Inherited faces still stop, since a pseudo-element inherits from its guarded element. `test_a_pages_light_rules_stop_at_the_chrome` no longer asserts the placeholder case. Measured on 2026-10-28 by toggling the guard's selector in place: - The authored CSS of 194 sources (the page directories under `~/.local/state/leaf/pages`, the examples and the docs, those with a `<style>`), laid over review-a-plan's chrome, changes no rendered chrome pseudo-element. Only five have a pseudo-element rule not scoped to the page's own classes, and the one universal rule is `!important`, which the guard never stopped. - Leaf's own rules, with no page CSS, change no rendered chrome pseudo-element across 88 `leaf-dev stills` states covering the panel, cards, composer, menus, image viewer and command reference. > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
added a commit
that referenced
this pull request
Oct 29, 2026
The shift watch treated `all: revert-layer` as a competing inset, so the chrome guard from #4480 prevented it from crediting the peek's native-anchor motion. The watcher now checks the inset alternatives a rollback can expose and uses Typed OM to distinguish `auto` from a resolved pixel position. Panel layout and chrome isolation are unchanged. The regression fails before the fix with 130px of uncredited anchor movement and passes afterward. Independent-offset controls still report movement when the reset loses, when it removes anchoring, and when an important reset exposes numeric insets from a lower tier. The three reported floating-panel cases reproduced before the fix and pass afterward at 6× CPU throttling. Focused native-anchor and inherited-motion checks pass; Ruff, JavaScript syntax and diff checks pass. Closes #4497 — 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.
page-sheets.js rewrote every page and theme selector at runtime, through the CSSOM, so it could not match
.lf-chromeor.lf-ui. It covered revisions, imported sheets, sheets a framework rewrites, and an iOS WebKit quirk with adopted sheets. Adata-controlsstylesheet, or a theme package'scontrols.cssin anlf-controlstier, opted out. All of that is gone.Page CSS is now ordinary CSS over the document. A page's
buttonrule dresses the controls widgets build, as it dresses its own. The chrome (panel, thread cards, composer) keeps its look through one unlayered rule,.lf-chrome, .lf-chrome * { all: revert-layer }(styles/chrome-guard.css, also covering ::before, ::after and ::placeholder), adopted after the page's sheets. A page rule as light as one class rolls back to Leaf's layered faces there. A heavier page selector (button:hover) or an!importantdeclaration still reaches the chrome, and so does any layered rule, a page@layerrule or a theme package'slf-themerule, since it outranks the layered faces the chrome's controls wear.Behavior that changes:
.lf-ui) take the page's and a theme's element rules. The feature gallery's control-access demo and the examples'data-controlsmarkers go. page-layout.md now tells authors to name what each rule styles.main button), and the theme test uses that form.controls.cssand thelf-controlstier no longer exist (PACKAGE_STYLES, CASCADE_LAYERS).lf-base, so the guard rolls back to them rather than past them.data-line-number-contentattribute, which only page-sheets.js had kept Pierre's inline-block rule off.Tests: the page-CSS test now asserts the guard (placeholders included) in Chromium, Firefox and WebKit, and that widget controls take page rules. The iOS adopted-sheets test and the control-access revision steps go with the code they covered, and tests drop their
data-controlsmarkers; the boxless-reply test names its widget past the guard, as it is inside the chrome. The chrome isolation audit exemptslf-chrome, the guard's only class: it is the chrome's own root, which no authored element may wear. Putting the guard in its own@scopeinstead would let its proximity beat the chrome's unscoped shared rules, and a face sweep showed the legend, response bar and composer changing.No protocol bump: an earlier page's vendored theme.css keeps an empty
lf-controlslayer name that orders nothing, and a leftoverdata-controlsattribute is inert.Measured against main: every computed property of 2,459 chrome elements across 7 panel, menu and thread states is unchanged, icon URLs aside. Across 19 examples, the document's computed faces differ in three ways only: by run-to-run noise (corpus, deck, alert-review, review-a-fix differ the same way between two runs of identical code); in code-comparison, rust-sort, wt-merge and github-discoveries, because the base arm read their new source without
data-controls, so main's narrowing dropped their control rules; and in the feature gallery's sample margin labels, now hidden as its widget rule asks.page-css-names-leaf-controlspasses 3/3 on each arm with the rewritten rubric.test_response_and_message_reading_keep_their_face_across_shadow_seating(forced-colors outline) andtest_a_wheel_return_attaches_the_comment_box_in_the_first_visible_framefail on main as well.