Repository navigation
Follow the pointer in Design mode at a cost the control sets, not the page's size - #6203
Merged
Merged
Conversation
… page's size In Design mode, each move of the pointer onto a control part, such as a tab in a side tab list, captured the part's durable anchor only to paint its box and name. The capture asks `namedParts` whether another control in the same owner has the part's name, and `controlPassages` which controls nest inside the part. Both filtered `pageQueryAll(WORKS)`, a query of every element on the page. On #4781's page (30 tabs of large text documents) that cost about 0.7 s a move. ## Change - `aimTargetAt(node, {design: true})` returns the target's inventory reading, as `aimTargets` already does for the target picker. The box and name a hovering pointer paints read only the element, its surface and the part's name, so a move no longer captures. - Whoever commits a target captures it, through one helper, `captured` (anchor-resolution.js). A press captures what it claims in `claimPress` (aim.js), once for the press and any continuation, so the composer opens on the same anchor as before. The picker's choice and Capture area already captured at their choice and now call the same helper. - The capture's two queries ask only the owner and the part (`queryAllUnder`, shadow.js: `root`'s tree and the declared shadow roots under it). `pageQueryAll` and the projection's two copies of the same query (`projectedDescendants`, `markedDatums`) and the page-words watcher's `idsUnder` now call it. ## Evidence `leaf-dev bench` gains an `inspect` input: in Design mode, the pointer moves between the page's first two tab controls 16 times. It needs `[role=tab]`, so it reads on `documents` (#4781's shape) and `asktabs`. `Input` gains `leave`, which takes back the mode `ready` entered, so the inputs after it start from the same page. The daily bench's `documents` step now reads it. `uv run leaf-dev bench documents --sizes 64,256 --input inspect --read cpu --base`, CPU ms a move, one round, load average 6–9: | | 8 | 64 | 256 | exponent | |---|---|---|---|---| | main | 7.3 | 14.3 | 38.6 | 1.08 (marked growing) | | this branch | 4.0 | 3.8 | 4.7 | level | A CPU profile of eight moves between two tab controls on the 64 page (`leaf-dev probe --journey`): main spent 11.2 of 13.9 ms a move in `querySelectorAll` under `namedParts` and `controlPassages`; this branch spends 2.1 ms a move, none of it in either. ## Tests The check API exports `captured`. The `test_render_aim.py` reads of the target a press carries now capture it as the press does; what they assert is unchanged. Ran: `test_render_aim.py` in two `-k` selections that together cover the file (45 and 87 passed), `test_render_projection.py` and `threads/test_media.py` (22 passed), the design, aim and picker tests of `test_chrome_contracts`, `test_render_drawing`, `test_render_reactions`, `margin/test_opening_threads`, `navigation/test_key_scopes`, `controls/test_rings`, `threads/test_targets`, `margin/test_scrollers` and `widgets/test_playgrounds` (9 passed), `pnpm run test:runtime` (993 passed), `pnpm run check:browser`, and pre-commit on the changed files. Not run: the whole suite, journeys, Firefox and WebKit. ## Left as it was - A press on a part still queries the part's owner. On #4781's page a press on a side tab queries the tabs widget, which holds every document, so the press that opens the composer still costs about what one move did on main. Walking down from the owner and skipping each addressable it holds would make it cost what the owner holds directly. - On `asks` at 256 sections, a Design mode move over an option (an addressable, so no part and no capture) spends about 8 ms in two forced layouts (`labelAim` → `shownParts`), each about 7 ms for 2 to 14 dirty objects, and grows with the page on main and on this branch. Part of #5194.
…h its capture `captured` returned the capture's own object, which leaves out the point `pointedTarget` (aim.js) adds to a press in Design mode with the picker open. It now carries the fields the caller added beside the captured anchor and label, as main did when the target arrived captured.
max-sixty
marked this pull request as ready for review
November 16, 2026 20:11
leaf-agent
approved these changes
Nov 16, 2026
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.
In Design mode, each move of the pointer onto a control part, such as a tab in a
side tab list, captured the part's durable anchor only to paint its box and name.
The capture asks
namedPartswhether another control in the same owner has thepart's name, and
controlPassageswhich controls nest inside the part. Bothfiltered
pageQueryAll(WORKS), a query of every element on the page. On #4781'spage (30 tabs of large text documents) that cost about 0.7 s a move.
Change
aimTargetAt(node, {design: true})returns the target's inventory reading,as
aimTargetsalready does for the target picker. The box and name ahovering pointer paints read only the element, its surface and the part's
name, so a move no longer captures.
captured(anchor-resolution.js). A press captures what it claims in
claimPress(aim.js), once for the press and any continuation, so the composer opens on
the same anchor as before. The picker's choice and Capture area already
captured at their choice and now call the same helper. The helper keeps what
the caller added to the target, such as the point a press landed on.
(
queryAllUnder, shadow.js:root's tree and the declared shadow rootsunder it).
pageQueryAlland the projection's two copies of the same query(
projectedDescendants,markedDatums) and the page-words watcher'sidsUndernow call it.Evidence
leaf-dev benchgains aninspectinput: in Design mode, the pointer movesbetween the page's first two tab controls 16 times. It needs
[role=tab], soit reads on
documents(#4781's shape) andasktabs.Inputgainsleave,which takes back the mode
readyentered, so the inputs after it start fromthe same page. The daily bench's
documentsstep now reads it.uv run leaf-dev bench documents --sizes 64,256 --input inspect --read cpu --base,CPU ms a move, one round, load average 6–9:
A CPU profile of eight moves between two tab controls on the 64 page
(
leaf-dev probe --journey): main spent 11.2 of 13.9 ms a move inquerySelectorAllundernamedPartsandcontrolPassages; this branch spends2.1 ms a move, none of it in either.
Tests
The check API exports
captured. Thetest_render_aim.pyreads of the targeta press carries now capture it as the press does; what they assert is
unchanged.
Ran: after the last commit,
test_render_aim.pyandthreads/test_media.pyunder
-k "design or picker or capture or hint or repeated or part or pointed"(59 passed); before it,
test_render_aim.pyin two-kselections that together cover the file(45 and 87 passed),
test_render_projection.pyandthreads/test_media.py(22passed),
the design, aim and picker tests of
test_chrome_contracts,test_render_drawing,test_render_reactions,margin/test_opening_threads,navigation/test_key_scopes,controls/test_rings,threads/test_targets,margin/test_scrollersandwidgets/test_playgrounds(9 passed),pnpm run test:runtime(993 passed),pnpm run check:browser, and pre-commit on the changed files. Not run: thewhole suite, journeys, Firefox and WebKit.
Left as it was
a side tab queries the tabs widget, which holds every document, so the press
that opens the composer still costs about what one move did on main. Walking
down from the owner and skipping each addressable it holds would make it cost
what the owner holds directly.
asksat 256 sections, a Design mode move over an option (an addressable,so no part and no capture) spends about 8 ms in two forced layouts
(
labelAim→shownParts), each about 7 ms for 2 to 14 dirty objects, andgrows with the page on main and on this branch.
Part of #5194.