Skip to content

Name a side tab without reading every document, and arm the page for ⌥ without restyling it in Firefox - #6227

Merged
max-sixty merged 8 commits into
mainfrom
grind/keys
Nov 17, 2026
Merged

max-sixty merged 8 commits into
mainfrom
grind/keys

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

On #4781's page, a side list of tabs holding thirty large text documents, three
gestures still cost what the page holds:

  • A Tab in the target picker onto a side tab, in Design mode, and a Design mode
    press on a side tab
    . Each named the tab by asking whether another control in its
    owner, the tabs widget, shares its name, and namedParts answered with a query of
    everything the widget holds, every tab's document included. A CPU profile of a
    picker Tab onto a side tab on documents at 256 put 17.8 of its ms in
    namedParts, 16.6 of them in querySelectorAll. A press spent 17.5 ms there.
  • Holding ⌥ in Firefox. The arm was an attribute on body, and four cursor rules
    read it through a descendant combinator, so each ⌥ down and each ⌥ up made Firefox
    walk every element of the page. A Gecko profile shows a style flush of about 55 ms
    that restyled 0 to 14 elements. With the four rules deleted, the gesture fell from
    62–70 ms to 11–14 ms.

Change

  • namedParts (anchor-resolution.js) walks down the owner's own tree and the declared
    roots in it, and steps over each addressable it meets, with everything that
    addressable holds. The controls it skips belong to those addressables, so the result
    is the set the old filter on addressableAt kept, and naming a part costs what its
    owner holds as its own. The picker's announcement and the press share this capture
    (captured), so one change fixes both. Counting names once per picker inventory
    would have fixed only the picker.
  • The hand over a mark comes only from [data-lf-over-mark], which anchor-paint.js
    paints from the same hit test a press uses (markAt is markHit). That hit test
    leaves out controls, the chrome and hidden annotations. .lf-mark-el { cursor: pointer } repeated it for whole marked elements, and four rules undid it again: on
    a drafted element, with the annotations hidden, in the chrome's @scope, and in the
    chrome while armed. All five are gone, and with them every rule that read the arm
    or Design mode from body.
  • aim.js no longer writes data-lf-aiming on body, and the paint vocabulary loses
    it. design.js no longer writes data-lf-design-mode there, whose only readers were
    tests. A body[…] … rule on either would make Firefox walk the page again, and the
    restyle-count guard reads only Chromium's trace, so the tests now wait for Design
    mode's legend (expect_design_mode, render_harness.py).
  • The aim's hand is body [data-lf-over-item] { cursor: pointer !important; }, as the
    crosshair, its sibling paint from the same writer, is. Only an armed page or Design
    mode paints it, and where the aim's press takes an item the hand covers whatever
    cursor the page gives that item.
  • leaf-dev bench gains three inputs. aim holds ⌥ down and lets it up, the pointer
    resting on the page's content. pick, in Design mode, walks the picker up from the
    last hint in view and back; on documents those hints are the side list's last tabs.
    part is a Design mode press on the first side tab, its empty comment closed after.
    The daily documents run reads pick and part.

Calls Max may reverse

Four cursors change, each to match what a press there does:

  • A tab stop or other control inside a marked item reads auto at rest, where it
    read pointer. A press there focuses or works the control and opens no thread
    (markAt leaves out controls), so the hand promised a press nothing takes.
  • A mark in the chrome reads auto under ⌥, where it read default. The aim never
    takes anything in the chrome, so it keeps the same cursor the rest of the armed page
    has shown since Arm the page and open the target picker without restyling or laying out what it holds #6037, where a press takes nothing.
  • A mark in the chrome reads auto in Design mode, where it read default. Design
    mode leaves the chrome working as it does outside the mode, so a press there is the
    chrome's own, and the mark keeps the cursor it has at rest. The rule that drew the
    arrow read body[data-lf-design-mode], the Firefox walk this change removes.
  • The aim's hand covers a cursor the page gives an item, at any weight. On main a
    page rule heavier than the hand's 0-2-1, such as #items #helped { cursor: help },
    showed its own cursor while ⌥ took the press. The aim's press takes the item whatever the
    page says about its cursor, so the hand says so.

Cursors

test_an_armed_page_shows_each_place_the_cursor_its_press_keeps
(threads/test_targets.py) reads the cursor where the pointer rests, in Chromium and in
Firefox. Each place matches main except the four above:

Pointer over At rest ⌥ held Design mode
words in an item auto pointer pointer
beside the column, in no item auto auto auto
words in a marked item pointer pointer pointer
a tab stop inside a marked item auto (main: pointer) auto auto
a marked passage in an item pointer pointer pointer
a link in an item pointer pointer pointer
an item the page gives cursor: help (#items #helped) help pointer (main: help) pointer (main: help)
an item a draft stands on auto pointer
a marked ask in a reply, in the panel auto auto (main: default) auto (main: default)

With main's runtime and main's cells in those four places, the test passes, which
reads main's side of the table. Each of these fails it in both engines:

  • .lf-mark-el's pointer rule added back: the tab stop reads pointer in all three
    columns.
  • The aim's hand without !important: the help item reads help under ⌥ and in
    Design mode.
  • A hand that reaches chrome marks, body ~ .lf-chrome .lf-mark-el { cursor: pointer }: the panel's ask reads pointer in all three columns.

Painting the over-mark hand on chrome marks too (paintHand) shows no hand there, and
the test can't see it: the chrome guard (styles/chrome-guard.css) keeps a rule of one
attribute's weight off chrome elements, behind markHit's own refusal of the chrome.

Evidence

Measured at 028adab. The commits after it remove an attribute no selector read and
make one declaration important.

uv run leaf-dev bench documents --sizes 64,128,256 --input aim --input hover --input design --input inspect --input pick --input part --read cpu --rounds 2 --base,
Chromium, main-thread CPU in ms per input, the lowest of two rounds, host load average
11–14:

                 8 base   8 head  64 base  64 head 128 base 128 head 256 base 256 head
pick cpu ms        16.7     16.1     23.3     18.6     29.8     22.5     40.6     25.5
part cpu ms        30.3     30.6     34.8     30.9     47.2     35.7     54.5     38.0
aim cpu ms          4.1      3.3      3.8      3.7      5.7      4.5      4.5      4.4
inspect cpu ms      6.1      5.9      6.2      6.3      7.1      7.6      7.3      7.7
design cpu ms      16.2     15.4     19.2     19.5     18.3     20.2     26.1     22.6
hover cpu ms        0.3      0.3      0.2      0.4      0.6      0.7      0.4      0.7

part no longer grows with the page. pick still rises from 16 to 26 ms (exponent
0.56 against main's 0.92), with the hints in view, not the documents: each Tab repaints
every chip ("Left as it was").

Firefox, on #4781's shape: a script (not committed) that builds the bench's
side_documents(224) with DOCUMENT_STEPS = 25000, 1.51 million elements, serves it
from each arm, and rests the pointer halfway down the open document. It holds ⌥ down
and lets it up eight times each, 300 ms apart, and enters and leaves Design mode four
times each, 800 ms apart. Content-process main-thread CPU per gesture, as the bench
reads Firefox's (ContentClock), less the idle rate, load average 5–13:

main this branch
⌥ down 67–73 ms 11–16 ms, one 52
⌥ up 68–73 ms, one 113 11–12 ms
Design mode in 77–106 ms 26–30 ms, the first two 53 and 66
Design mode out 75–114 ms 21–26 ms

On the bench's own documents page at 256, about 71,000 elements, Firefox's aim reads
3 to 7 ms on both arms, too small a page to show the walk.

namedParts on an owner with many elements of its own

The walk asks matches(WORKS) of each element the owner holds as its own, which is
slower than one native query over the same elements. In the review's measurement, a
section holding 50,000 elements of its own, with no addressable inside it, took 15.8 ms
against 11.4 in Chromium and 37 against 14 in Firefox. The trade still favours the walk.
The old query read everything under the owner, its members' contents included, so a
tabs widget holding #4781's 1.5 million rows read all of them on every press and every
announcement, where the walk reads its own hundred or so. An owner with tens of
thousands of controls of its own is rare, its cost stays well under the 100 ms a press
has, and those elements are the ones the part's name is counted among.

Tests

  • test_a_design_part_is_a_repeat_only_among_its_own_owner_s_parts
    (test_render_aim.py): a control inside an item the owner holds leaves the owner's
    same-named control unrepeated, and two of the owner's own are repeats. It passes on
    main's namedParts, and fails when the walk doesn't step over addressables.
  • The cursor test above.
  • test_a_mark_in_the_layer_promises_no_press_the_layer_will_not_take becomes
    test_a_press_on_a_mark_in_the_layer_opens_no_thread and keeps its press. Its cursor
    half read each chrome mark's own computed cursor, which no rule sets now, so it
    checked nothing; the cursor test reads that mark where the pointer rests.
  • The 33 waits on body[data-lf-design-mode], in seven test files, wait for Design
    mode's legend.

Ran pnpm run test:runtime (998 passed), pnpm run check:browser, and pre-commit on
the changed files. In each browser test file below, the tests that press ⌥, s or l,
read a cursor, capture a Design mode target, read the hand's paints or wait for Design
mode, selected by name: test_render_aim.py (80 passed, 46 subtests, and the 11 that wait
for Design mode), threads/test_targets.py (6, and 3), test_chrome_contracts.py (9),
test_render_drawing.py (12), test_render_anchors.py (26), threads/test_media.py with
-k "design or part or capture" (9), navigation/test_key_scopes.py (2),
margin/test_opening_threads.py (2), threads/test_composing.py (4),
controls/test_rings.py (2), margin/test_entries.py (2), drafts/test_draft_editing.py
(1), test_render_options.py (2), widgets/test_lifecycle_and_controls.py (1),
widgets/test_contents_and_glosses.py (1), margin/test_status.py (1),
drafts/test_sending.py (1); the journeys that read the page's markup, arm it or wait
for Design mode, in journeys/test_render_aim.py (7 with parameters),
journeys/test_render_semantic_selection.py (1) and journeys/test_render_threads.py
(1); and journeys/test_render_gate.py's
test_the_layer_holds_its_whole_page_rules_on_the_corpus, which reads whether the
adopted sheet's order decides anything.

Not run: the whole suite, WebKit, and the daily bench in CI. Not checked: a desktop
Firefox other than Playwright's, and Max's own #4781 page rather than its generated
shape.

Left as it was

  • Every picker Tab repaints each hint's chip (paintTargetPickerHints, which reads
    targetBounds and makes a hit test for each hint), which keeps a picker Tab at
    17–24 ms of main-thread CPU on documents whatever hint it lands on, over the 8 ms a
    keystroke has.

Part of #5194.

…⌥ without restyling it in Firefox

On #4781's page, a side list of tabs holding thirty large text documents, three
gestures still cost what the page holds:

- **A Tab in the target picker onto a side tab**, in Design mode, and **a Design mode
  press on a side tab**. Each named the tab by asking whether another control in its
  owner, the tabs widget, shares its name, and `namedParts` answered with a query of
  everything the widget holds, every tab's document included. A CPU profile of a
  picker Tab onto a side tab on `documents` at 256 put 17.8 of its ms in
  `namedParts`, 16.6 of them in `querySelectorAll`. A press spent 17.5 ms there.
- **Holding ⌥ in Firefox.** The arm was an attribute on `body`, and four cursor rules
  read it through a descendant combinator, so each ⌥ down and each ⌥ up made Firefox
  walk every element of the page. A Gecko profile shows a style flush of about 55 ms
  that restyled 0 to 14 elements. With the four rules deleted, the gesture fell from
  62–70 ms to 11–14 ms.

## Change

- `namedParts` (anchor-resolution.js) walks down the owner's own tree and the declared
  roots in it, and steps over each addressable it meets, with everything that
  addressable holds. The controls it skips belong to those addressables, so the result
  is the set the old filter on `addressableAt` kept, and naming a part costs what its
  owner holds as its own. The picker's announcement and the press share this capture
  (`captured`), so one change fixes both. Counting names once per picker inventory,
  as the #6203 review suggested, would have fixed only the picker.
- ⌥'s arm (⌥ or the open picker) is painted on the element under the pointer as
  `data-lf-armed`, by the writer that already paints the aim's hand and the crosshair
  there (`refreshAim`, page-geometry.js), in place of `data-lf-aiming` on `body`. The
  four rules read it on that element, or, for a mark element holding it, through
  `:has([data-lf-armed])`. The cursor that shows is the one under the pointer, so every
  place keeps the cursor it had (below). The aim's hand keeps its specificity, (0,2,1),
  which is what lets it stand over a drafted comment's own `cursor: auto`.
- Design mode keeps its arm on `body`. Any `:has([data-lf-armed])` costs Chromium about
  1.5 ms each time the paint moves (`documents` at 256, Design mode moves between two
  side tabs: 6.2–7.6 ms a move with the `:has()` rules, 5.0–5.5 without; Firefox showed
  no difference). Design mode would move the paint on every crossing, while ⌥ moves it
  only while held.
- `refreshAim` takes the element under the pointer from the hit test it already made,
  and writes the cursor's paints after the aim's box and name have read their geometry,
  so the paints don't force a layout.
- `leaf-dev bench` gains three inputs. `aim` holds ⌥ down and lets it up, the pointer
  resting on the page's content. `pick`, in Design mode, walks the picker up from the
  last hint in view and back; on `documents` those hints are the side list's last tabs.
  `part` is a Design mode press on the first side tab, its empty comment closed
  after. The daily `documents` run reads `pick` and `part`.

## Cursors

`test_an_armed_page_shows_each_place_the_cursor_its_press_keeps`
(threads/test_targets.py) reads the cursor where the pointer rests, in Chromium and in
Firefox. It passes on main's runtime and on this branch:

| Pointer over | At rest | ⌥ held | Design mode |
|---|---|---|---|
| words in an item | auto | pointer | pointer |
| beside the column, in no item | auto | auto | auto |
| words in a marked item | pointer | pointer | pointer |
| a tab stop inside a marked item | pointer | auto | auto |
| a marked passage in an item | pointer | pointer | pointer |
| a link in an item | pointer | pointer | pointer |
| an item a draft stands on | auto | pointer | |
| a marked ask in a reply, in the panel | auto | default | |

Each of three flips of the new rules fails it. Without its specificity the hand loses
to the draft (the drafted item reads `auto` under ⌥); a mark that keeps its hand while
armed makes the tab stop read `pointer`; and with the chrome's arrow dropped the ask
reads `auto`. The first is the look the #6062 notes said a single cursor writer would
change.

## Evidence

`uv run leaf-dev bench documents --sizes 64,128,256 --input aim --input hover --input design --input inspect --input pick --input part --read cpu --rounds 2 --base`,
Chromium, main-thread CPU in ms per input, the lowest of two rounds, host load average
about 29:

```
                 8 base   8 head  64 base  64 head 128 base 128 head 256 base 256 head
pick cpu ms        18.5     17.4     24.1     19.3     32.9     23.8     41.6     24.7
part cpu ms        31.5     32.9     36.3     31.5     46.3     35.7     55.0     38.1
aim cpu ms          4.4      4.4      4.0      4.2      5.3      5.6      5.2      6.4
inspect cpu ms      6.4      6.5      6.7      6.9      7.2      7.3      7.7      7.5
design cpu ms      16.9     16.8     19.1     20.1     20.1     21.0     23.0     23.0
hover cpu ms        0.3      0.3      0.2      0.2      0.6      0.7      0.7      0.7
```

The fit marks `pick` (exponent 1.03) and `part` (0.67) as growing on main, and neither
on this branch. It marks this branch's `aim` (0.77) on one reading at 256. Back to
back, 32 ⌥ toggles with the pointer resting on the open document read 5.3 and 6.0 ms
a toggle on main at 64 and 256, and 5.4 and 6.3–6.6 on this branch.

Firefox, ⌥ on #4781's shape: a script (not committed) that builds the bench's
`side_documents(224)` with `DOCUMENT_STEPS = 25000`, 1.51 million elements, serves it
from each arm, rests the pointer halfway down the open document, and holds ⌥ down and
lets it up eight times each, 300 ms apart. Content-process main-thread CPU per
gesture, as the bench reads Firefox's (`ContentClock`), less the idle rate, load
average 24–26:

| | ⌥ down | ⌥ up |
|---|---|---|
| main | 67–111 ms, median 72 | 65–72 ms |
| this branch | 13–21 ms, median 13.5 | 12–13 ms, one 47 |

On the bench's own `documents` page at 256, about 71,000 elements, Firefox's `aim` reads
3 to 7 ms on both arms, too small a page to show the walk.

## Tests

- `test_a_design_part_is_a_repeat_only_among_its_own_owner_s_parts`
  (test_render_aim.py): a control inside an item the owner holds leaves the owner's
  same-named control unrepeated, and two of the owner's own are repeats. It passes on
  main's `namedParts`, and fails when the walk doesn't step over addressables.
- The cursor test above.
- `PAGE_MARKUP` (render_cases_layout.py) strips `data-lf-armed` with the other paints.

Ran `pnpm run test:runtime` (995 passed), `pnpm run check:browser`, and pre-commit over
the branch. In each browser test file below, the tests that press ⌥, `s` or `l`, read a
cursor, capture a Design mode target or read the hand's paints, selected by name:
test_render_aim.py (80 passed, 46 subtests), threads/test_targets.py (7),
test_chrome_contracts.py (9), test_render_drawing.py (12), test_render_anchors.py
(21), threads/test_media.py with `-k "design or part or capture"` (9),
navigation/test_key_scopes.py (2), margin/test_opening_threads.py (2),
threads/test_composing.py (4), controls/test_rings.py (2), margin/test_entries.py (2),
and the four journeys in journeys/test_render_aim.py that read the page's markup or
arm it (7 with parameters).

Not run: the whole suite, WebKit, and the daily bench in CI. Not checked: a desktop
Firefox other than Playwright's, and Max's own #4781 page rather than its generated
shape.

## Left as it was

- Entering and leaving Design mode still make Firefox walk the page, as ⌥ did, since
  the four rules read `body[data-lf-design-mode]`. Moving it to the pointer would cost
  Chromium about 1.5 ms on every crossing in the mode.
- Every picker Tab repaints each hint's chip (`paintTargetPickerHints`, which reads
  `targetBounds` and makes a hit test for each hint), which keeps a picker Tab at
  17–24 ms of main-thread CPU on `documents` whatever hint it lands on, over the 8 ms a
  keystroke has.

Part of #4781.
…ge for ⌥ with no mark on body

Review of #6227: the arm paint and its :has() rules existed only to undo
.lf-mark-el's pointer, which duplicates [data-lf-over-mark]. Delete that
rule and the four that undo it, the arm paint, aim.armed and the armed
paint entry. A tab stop inside a marked item now reads auto at rest, and a
marked ask in the panel reads auto under ⌥.
…ts legend rather than a mark on body

Re-review of #6227: the aim's hand is important, as the crosshair is, so a
page rule of any weight no longer shows over a press the aim takes.
body[data-lf-design-mode] had no reader but tests; they now wait for the
legend. The chrome mark's press test keeps only its press; the armed-cursor
test reads the chrome mark in Design mode and a page cursor the hand covers.
@max-sixty
max-sixty marked this pull request as ready for review November 17, 2026 01:39
@max-sixty
max-sixty merged commit c50d839 into main Nov 17, 2026
6 checks passed
@max-sixty
max-sixty deleted the grind/keys branch November 17, 2026 01:58
leaf-agent pushed a commit that referenced this pull request Nov 17, 2026
Hiding or showing annotations (`o`) restyled every element of the page.
`annotation-layer.js` stated the hidden layer on `html`, and two rules
read it there. One set a custom property on `html`, `--lf-change-bar:
transparent`, which every element inherits; the margin's change bars and
the contents map's changed stretches read it. The other hid the margin's
pins through a descendant combinator from `html`, which makes Firefox
visit every element to find them. On #4781's shape, 1.5 million
elements, each `o` took 2 to 3 s of Firefox's main thread. The attribute
now stands on the chrome's root, which holds the margin's pins and bars.
The contents map, which stands in the page, reads it there through
`:root:has()`.

## Change

- `setAnnotationsHidden` (annotation-layer.js) toggles
`data-lf-annotations-hidden` on the chrome's root (`chromeRoot`,
chrome.js) instead of writing `data-lf-annotations="hidden"` on `html`.
- The margin's change bars hide by a rule in the chrome's scope,
`:scope[data-lf-annotations-hidden] .lf-change-bar` (chrome.css), and
the pins' rule (annotation-theme.css) reads
`.lf-chrome[data-lf-annotations-hidden]`. `--lf-change-bar` goes: it
existed only as the switch.
- The contents map's changed stretch reads `var(--lf-change)`, and
`:root:has(> .lf-chrome[data-lf-annotations-hidden]) lf-toc
…[data-lf-toc-changed]::after` makes it transparent, so it still hides
with annotations, as its margin bar does. toc.css's header records that
the stretch is a change mark.

Firefox now visits only the chrome's elements for the margin's rules,
and Chromium restyles only the pins, the bars and the stretches.

## No look change

Each pair below is pixel-identical between main and this branch, at rest
and after `o`, in Chromium and Firefox: `contents-marks-changes` at
1440×900 (the side map), 900×700, and 600×900 (the column outline), from
`uv run leaf-dev probe --state contents-marks-changes [--do press:o]
--base --shot --browser B --viewport V`. With annotations hidden, the
map's changed stretches are transparent on both arms, and the spine's
rule shows through them unbroken. `uv run leaf-dev stills --base` on
`contents-marks-changes`, `contents-marks`, `margin-gallery` and
`margin-reaction-mark`: unchanged in Chromium and Firefox.

## Call Max could take instead

`o` could leave change marks to `v`, keeping both the margin's bars and
the map's stretches drawn while annotations are hidden. That would drop
the map's `:has()` rule and the bars' rule, but it reverses #4890, which
made a change's bar an annotation.

## Evidence

A scratch script (not committed) builds the bench's
`side_documents(224)` with `DOCUMENT_STEPS = 25000`, 1,512,344 elements,
as #6227 did, serves it from each arm, rests the pointer halfway down
the open document, and presses `o` eight times, 400 ms apart.
Main-thread CPU per press, as the bench reads it (`main_thread_clock`),
less the idle rate:

| | main (2685a32) | this branch |
|---|---|---|
| Firefox, Playwright's build | 2,059–2,949 ms | 10.4–17.8 ms |
| Chromium | 64–74 ms, one recalc of 5,326 elements in 54 ms | 10.1–19.4
ms, the largest recalc 7 elements |

With only the custom property removed, Firefox read 38–45 ms, so the
pins' descendant rule from `html` cost about 25 ms of it. The map's
`:has()` rule adds no cost these readings separate from noise: without
it Firefox read 8.6–18.3 ms. Chromium's recalc on main counted 5,326 of
the 1.5 million elements, which suggests it leaves the closed tabs'
documents unstyled, where Firefox's 2 to 3 s suggests it restyled them
all; no Gecko profile was taken to confirm that.

## Tests

- `test_hiding_and_showing_annotations_restyles_only_the_chrome`
(tests/browser/test_chrome_contracts.py) counts the elements Chromium
restyles as `o` hides and shows the layer, and requires under a quarter
of what a custom property changed on `html` restyles. It guards against
`o` setting an inherited property on `html` again. Run against main's
code it fails earlier, on waiting for the chrome root's attribute, which
main never writes. Firefox visiting the page for a rule read through a
descendant combinator restyles nothing, so no count here sees it.
-
`test_each_contents_row_marks_where_its_section_s_threads_on_me_and_changes_stand`
(widgets/test_contents_and_glosses.py) now presses `o` with the changes
view on and reads a changed row's stretch transparent, then drawn again
after a second `o`. It fails without the map's rule.
- The tests that waited for `html[data-lf-annotations="hidden"]` wait
for `CHROME_ROOT`'s (render_harness.py) `data-lf-annotations-hidden`:
test_draft_editing.py, test_comment_marks.py, test_composing.py,
margin/test_pins.py, and journeys/margin/test_pins.py. Their absence
checks read any value (`re.compile(".*")`) or the empty value, so each
fails while the attribute stands.

Ran `pnpm run test:runtime` (997 passed), `pnpm run check:browser`,
pre-commit on the changed files; every browser and journey test that
presses `o`, reads the annotations attribute or a change bar (20 passed,
test_changes_in_place.py's three included); and the contents widget's
browser tests (34 passed).

Not run: the whole suite, WebKit. Not checked: Max's own #4781 page
rather than its generated shape, and a desktop Firefox other than
Playwright's.

Part of #5194.
max-sixty added a commit that referenced this pull request Nov 17, 2026
Each Tab in the target picker, and each paint of an armed Go-to map,
measured every hint's target again to find out whether any had moved:
its visible parts, its clipped box and a hit test per chip. On
`documents`, #4781's shape, that was the part of a picker Tab that grew
with the side tabs in view. Now the map measures its targets when it
reads them, and a paint between readings draws only the chips' faces.

## Change

- `createHintSession` (keyboard/hints.js) takes each member's box from
`read`, which both callers already measured there, and its `layout` no
longer measures: it turns a member into its face and the corner it asks
for. The `scene` option goes, and the seating keeps no copy of the
targets' boxes.
- The map is read and seated again once a scroll settles, on a resize,
when the chrome comes to cover other boxes, when a member leaves the
document, and when the caller invalidates it. The chrome changes what it
covers when the user opens a panel view, such as the Menu or On me, so
that reading follows the user's own press, as a scroll's or a resize's
does: a target the panel now hides leaves the map, and the others may
take new letters. Between readings each chip rides its target by its
anchor (chip-seats.js), so a page that moves under the map, as a
revision or an opening disclosure does, moves the chips with their
targets and changes no letter, as on main.
- On main, a paint that found a heard target no longer laid out retired
the walk. A target now leaves the map only on a reading, so that branch
goes; the reading itself retires the walk when the target it heard is
gone, as before.

## What differs from main between readings

- **A target the chrome comes to cover leaves the map by a reading.** On
main each paint dropped its chip and kept every other letter. Now the
map is read again, so the covered target goes, the walk retires if it
stood there, and the remaining targets may take new letters.
- **A target a layout moves without a scroll keeps its seat relative to
it.** Its chip follows it by its anchor, where main seated it again on
the next paint. A CSS transform on a target leaves its chip behind in
Firefox between readings, the gap `notes/browser-support.md` records
under "An anchor's transforms in Firefox". No gesture transforms a
target while a map is armed.

## Evidence

`uv run leaf-dev bench documents --sizes 8,64,128,256 --input pick
--read cpu --rounds 3 --base origin/main`, Chromium, main-thread CPU per
picker Tab, the lowest of three rounds, host load average 20 to 40 (an
earlier run at load 10 read 11.9/13.9/16.8/18.5 against
10.9/11.7/14.2/14.9):

```
                 8 base   8 head  64 base  64 head 128 base 128 head 256 base 256 head
pick cpu ms        13.1     11.7     15.8     13.5     19.3     15.0     21.4     16.4
```

A V8 profile of 16 Tabs at 256 (`--profile`) put 4.7 ms per Tab in
`paintTargetPickerHints` on main, 3.5 of it in `elementFromPoint`
through `exposes`; on this branch the hint paint no longer appears among
the top frames. The independent review counted 8–9 box reads and no hit
tests per Tab here, against 178 reads and 56 hit tests on main.

What remains of a Tab, about 11 ms at 8 and 15 ms at 256, is outside the
chips: the panel's Lit updates, the key dispatch's scope walk
(`currentLocation`, `pageSelection`), the command hints
(`unclaimedScopes`) and the document layout read
(`readDocumentHeaders`), each 1 to 3.5 ms of a profiled Tab. The growth
left from 8 to 256 is mostly `namedParts` naming a side tab among its
owner's 34 tabs (#6227), and a forced layout the selection read pays.

## Tests

- `test_a_revision_under_an_armed_go_to_keeps_its_letters_and_walk`
(tests/browser/navigation/test_go_to.py): with Go-to armed and the walk
on the third of five links, a revision adds a paragraph and a link above
them; every link keeps its letter, the third stays current, and the next
Tab reaches the fourth. It fails on this PR's earlier version, which
read the map again on each page layout move and relabelled it.
- `a walk redraws the chips it moves between and reads no target's box`
(tests/runtime/hint-session.test.mjs): two Tabs and their paints read no
member's box. It fails when every paint reads the scene again.
- `a page that moves under the map keeps every letter and the walk`
replaces the case that asserted a re-seat on a layout move. `a target
the chrome comes to cover leaves the map` covers a target with the
harness's chrome and reads it gone from the map and from the chips
shown; it fails without the re-read on a chrome change.

Ran `pnpm run test:runtime` (999 passed), `pnpm run check:browser`,
pre-commit on the changed files,
`tests/browser/navigation/test_go_to.py` and
`tests/browser/test_render_semantic_selection.py` whole together with
the 28 browser tests that read a chip, its seat or its code, or comment
through a hint, and the 12 journey tests that do (104 passed).

Not run: the whole suite, Firefox and WebKit benches.

Part of #5194.
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