Repository navigation
Lend a heading one of two anchor names while its link shows, so reaching a heading runs no margin pass - #5379
Merged
Merged
Conversation
…ing a heading runs no margin pass The first time the pointer reached a heading, by a move or by a wheel step that scrolled one under it, the heading's link wrote an anchor name into the heading's inline style (`anchor-name: --lf-aN`). The margin's page observer hears every `style` change on a page box as a possible geometry change, so each such heading ran a full margin layout pass, about 108 ms at 512 sections of the `asks` page. ## What changes **A shown link's heading borrows one of two constant names.** marks.css names a box carrying `data-lf-heading-link="1"` or `"2"` as `--lf-heading-link-1` or `--lf-heading-link-2`, and the link's control stands by that name. The attribute joins the runtime's paint attributes (`page-paint.js`), outside the margin observer's `attributeFilter`, so writing it restyles the heading alone. A link shows for two headings at most, the one under the pointer and the one the user is on, and nothing fades, so two names suffice: a link takes a free one as it shows and gives it back as it hides. A hidden link's control has no anchor, where before it stayed anchored to its heading at opacity 0. **Focus in a link's control counts as being on its heading.** A press focuses the control's button in Chromium and Firefox, and the theme keeps a focused control shown after the pointer leaves. That showing now holds the heading's name too, so the control stays beside its heading. **A heading named already keeps its names.** A rule can't add a name to the ones a box has, so a heading its author named, or one another owner named in its style, takes the link's name through its style as before (`anchorReading`), one heard write on its first showing, as on main. When another owner names a heading while it holds a lent name, as the anchored comment box does for words selected in it, `anchorReading` merges the lent name into the heading's style; giving the name back takes it out again. Without that, the next heading lent the same name could anchor to the earlier one. `block-controls.js` splits `watchNear`, the near-window watch, out of `anchorControl`, so the heading's link watches its block without naming it. ## Evidence Margin passes, counted with a breakpoint on `layoutMountedRows` that never pauses, on the `asks` scaling page; main is 0da1f29. | input | main 64 | head 64 | main 512 | head 512 | |---|---|---|---|---| | 10 wheel steps, each bringing a new `h2` under the pointer | 10 | 0 | 10 | 0 | | 10 hovers over headings not reached before | 6 | 0 | 6 | 0 | | words selected in a paragraph | 1 | 1 | 1 | 1 | | words selected in a heading the pointer is on | 1 | 2 | 1 | 2 | The last row is the merged name being taken out of the heading's style when the pointer leaves; a paragraph's row is the comment box naming the paragraph, on both. Main-thread CPU per wheel step (threadTicks, less the page's idle rate), four rounds alternating main and head under `taskpolicy -c utility`, pooled: | wheel | size | main median / max | head median / max | |---|---|---|---| | `leaf-dev scaling`'s steps (height/30, pointer at 400,400), 120 | 64 | 4.8 / 37.9 ms | 5.2 / 15.6 ms | | same | 512 | 12.5 / 202.1 ms, 13 over 60 ms | 11.7 / 82.2 ms, 2 over 60 ms | | a new `h2` under the pointer each step, 40 | 64 | 27.4 / 44.4 ms | 8.8 / 20.4 ms | | same | 512 | 121.0 / 206.8 ms | 20.4 / 55.1 ms | ## Checks - Each shown link's box equals main's in 25 states (hovers over `h2`, `h3`, a wrapped heading, an author-named and an inline-named heading, each again after its link exists; the user on one heading with the pointer on another; a press then the pointer away; another owner naming a shown heading), in Chromium, Firefox and WebKit at 1440 px, and in Chromium and Firefox at 700 px, where the link stands at the heading's far end. The author's box anchored to the named heading stays put throughout. - `test_each_shown_link_stands_by_its_heading` covers two links at once, a press, an author-named heading and a box anchored to a shown heading. It fails with one name, with focus in the control not counted, with the author's name ignored, and without taking the merged name back out. - The heading-link tests pass, `test_a_heading_copies_the_link_to_the_section_it_opens` included, which also passes on main at 0da1f29. The code copy anchor tests, `test_render_code_reading.py`, the recording bar tests and the margin's authored-anchor-name pin tests pass. - `pnpm run test:runtime` passes 812 tests, and `pnpm run check:browser` passes.
The link read once, as its control was made, whether its heading had an anchor name. A heading the author's stylesheet started naming later, through a class, a media query or a revision, was then lent `--lf-heading-link-1`, and the author's more specific rule won, so the control stood by a name nothing carried and fell to its -9999px fallback. The link now reads the heading's names each time it starts to show, with no name lent, and a heading named by then keeps its names and takes the link's beside them in its style. A link that asks for a name while both are lent now throws, where it overwrote the second borrower; no path reaches it, since a link shows for two headings at most. On the stylesheet case, Chromium and Firefox put the link where main does. Main also loses the author's later name, because the link's inline name outranks it; the author's box anchored to that name stands by the heading here and at its fallback on main. `test_each_shown_link_stands_by_its_heading` adds the case, which fails on the previous commit. The heading-link tests, `pnpm run test:runtime` and `pnpm run check:browser` pass.
leaf-agent
approved these changes
Nov 4, 2026
This was referenced Nov 7, 2026
max-sixty
pushed a commit
that referenced
this pull request
Nov 7, 2026
…pares page markup (#5690) `test_an_aimed_press_does_only_what_the_outline_promised` compares the page's markup before and after each ⌥-click, with runtime paint removed. #5379 moved a heading's link anchor name out of inline `anchor-name` and into a `data-lf-heading-link` attribute, which a heading wears only while the pointer is over it or focus sits on its link. The test still removed inline `anchor-name` but not the new attribute. The press doesn't reach the widget: in release-notes an `<h2>` dropped `data-lf-heading-link="1"` between the two readings, and in ship-review an `<h3>` gained it. Those were the only differences in either case. `PAGE_MARKUP` (`tests/render_cases_layout.py`) now removes `data-lf-heading-link` beside the inline anchor name it already removed. The assertion still catches any widget state an aimed press changes, and the log check after the sweep still catches a decision the press sends. Verification: with `--run-nightly`, the release-notes and ship-review cases fail on main at `754d6e3f0` and pass with this change, as do the other cases of that journey test and the rest of `tests/browser/test_render_aim.py`. The one exception, `test_design_mode_leaves_the_chrome_working`, times out waiting for the "Exit Design mode" button the same way on main without this change. It doesn't read `PAGE_MARKUP`. Closes #5681 — 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.
The first time the pointer reached a heading, by a move or by a wheel step that scrolled one under it, the heading's link wrote an anchor name into the heading's inline style (
anchor-name: --lf-aN). The margin's page observer hears everystylechange on a page box as a possible geometry change, so each such heading ran a full margin layout pass, about 108 ms at 512 sections of theaskspage.What changes
A shown link's heading borrows one of two constant names. marks.css names a box carrying
data-lf-heading-link="1"or"2"as--lf-heading-link-1or--lf-heading-link-2, and the link's control stands by that name. The attribute joins the runtime's paint attributes (page-paint.js), outside the margin observer'sattributeFilter, so writing it restyles the heading alone. A link shows for two headings at most, the one under the pointer and the one the user is on, and nothing fades, so two names suffice: a link takes a free one as it shows and gives it back as it hides. A hidden link's control has no anchor, where before it stayed anchored to its heading at opacity 0.Focus in a link's control counts as being on its heading. A press focuses the control's button in Chromium and Firefox, and the theme keeps a focused control shown after the pointer leaves. That showing now holds the heading's name too, so the control stays beside its heading.
A heading named already keeps its names. A rule can't add a name to the ones a box has, so a heading its author named, or one another owner named in its style, takes the link's name through its style as before (
anchorReading), one heard write on its first showing, as on main. When another owner names a heading while it holds a lent name, as the anchored comment box does for words selected in it,anchorReadingmerges the lent name into the heading's style; giving the name back takes it out again. Without that, the next heading lent the same name could anchor to the earlier one.A heading's names are read each time its link starts to show, not once when the control is made, so a heading a stylesheet starts naming later (a media query, a revision) keeps the author's name and the link adds its own beside it, where on main the link's inline name hid the author's. A third request for a lent name throws rather than taking a held one; no path reaches it.
block-controls.jssplitswatchNear, the near-window watch, out ofanchorControl, so the heading's link watches its block without naming it.Evidence
Margin passes, counted with a breakpoint on
layoutMountedRowsthat never pauses, on theasksscaling page; main is 0da1f29.h2under the pointerThe last row is the merged name being taken out of the heading's style when the pointer leaves; a paragraph's row is the comment box naming the paragraph, on both.
Main-thread CPU per wheel step (threadTicks, less the page's idle rate), four rounds alternating main and head under
taskpolicy -c utility, pooled:leaf-dev scaling's steps (height/30, pointer at 400,400), 120h2under the pointer each step, 40Checks
h2,h3, a wrapped heading, an author-named and an inline-named heading, each again after its link exists; the user on one heading with the pointer on another; a press then the pointer away; another owner naming a shown heading), in Chromium, Firefox and WebKit at 1440 px, and in Chromium and Firefox at 700 px, where the link stands at the heading's far end. The author's box anchored to the named heading stays put throughout.test_each_shown_link_stands_by_its_headingcovers two links at once, a press, an author-named heading and a box anchored to a shown heading. It fails with one name, with focus in the control not counted, with the author's name ignored, and without taking the merged name back out.test_a_heading_copies_the_link_to_the_section_it_opensincluded, which also passes on main at 0da1f29. The code copy anchor tests,test_render_code_reading.py, the recording bar tests and the margin's authored-anchor-name pin tests pass.pnpm run test:runtimepasses 812 tests, andpnpm run check:browserpasses.A Codex review found the two-name pool sound; its one finding, the read-once ownership above, is fixed with a test.