Skip to content

refactor: drop page-sheets.js and guard the chrome with one CSS rule - #4480

Merged
max-sixty merged 3 commits into
mainfrom
fix-diff-formatting
Oct 27, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix-diff-formatting

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

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. The chrome isolation audit exempts lf-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 @scope instead 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-controls layer name that orders nothing, and a leftover data-controls attribute 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-controls passes 3/3 on each arm with the rewritten rubric.

test_response_and_message_reading_keep_their_face_across_shadow_seating (forced-colors outline) and test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame fail on main as well.

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

[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
leaf-agent previously approved these changes Oct 27, 2026
# Conflicts:
#	dist/kernel/leaf.js
#	dist/kernel/runtime/bundle-data.js
@max-sixty
max-sixty merged commit ec2280f into main Oct 27, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the fix-diff-formatting branch October 27, 2026 18:19
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]>
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