Repository navigation
Enter Design mode, Draw mode and Capture area at a cost the window sets, not the page's size - #6062
Merged
Merged
Conversation
…size On #4781's shape (thirty text documents of 50,000 lines in side tabs, 1.51 million elements), entering Design mode the first time took 38 s in Chromium, each move of the pointer over the open document in Design mode 0.3 to 1.7 s, and entering or leaving Draw mode 2.3 to 4.8 s in Firefox. They now take tens of milliseconds. - Design mode's legend read every named element's corners with getComputedStyle, closed tabs included, and Chromium styles everything a closed tab holds to answer one. It now reads them once the element shows. - Design mode's spoken name for a text document's view read the whole document twice on every pointer move. controlContext now reads at most 280 characters of the block and of the control, stepping over controls, through excerpt's new skip. - Draw mode's crosshair stood on every element through an inherited property, and Firefox restyles what content-visibility skips. It now stands on the element under the pointer (data-lf-draw-at, painted by refreshAim), whose children take cursor: auto. Its touch-action stands on html alone, where a coarse pointer can reach the page. - leaf-dev bench gains design and draw inputs, read daily on the documents page. Cursors at the pointer match main in Chromium, Firefox and WebKit in every mode.
# Conflicts: # tests/browser/test_render_drawing.py
An element can arrive wearing the flag, as a copy of the one that wore it does: test_an_active_stroke_re_resolves_a_replaced_target clones the stroke's target, and keepsOnOne's setAttribute then wrote data-lf-crosshair onto an element that already held it, which the write watch fails as an unchanged write.
…alone controlContext read up to 280 characters from its block's start, so a control deep in a long paragraph lost the words beside it, and a text document's view said its excerpt twice, once as its block and once as its own words. It now says the block's words on each side of the part, at most AROUND (28) characters a side, the window contextAround gives search and the picker's captured names, with a control's own words between, cut at LABEL_WORDS as an addressable's label is. A block is still read once per inventory, noting where each control and picture stands in it, with every part's words left out. A picture says none of its own words, since its name describes it, so a text document's view is named by its label and its document is never read.
…ch-action on the root Capture area set its crosshair on html, body and every element in body, which took Firefox 4.4 to 4.8 s to enter or leave on #4781's shape. Draw mode's crosshair attribute becomes data-lf-crosshair, painted by refreshCrosshair in page-geometry.js while Draw mode or Capture area stands; Capture area claims the pointer's moves before the aim hears them, so it asks for the crosshair to follow each move it claims. Chrome and Firefox show the cursor of the element holding the pointer, so a stroke and an area's drag now capture the pointer on the element wearing the crosshair, where Capture area captured on html and Draw mode on a widget's host. Each mode's touch-action stands on html alone, without (any-pointer: coarse): Firefox on Linux can report no touchscreen while it receives touch events (Mozilla bug 1870900), where one finger would pan rather than draw. Firefox's update of every box as the root's touch-action changes is recorded in notes/browser-support.md. leaf-dev bench gains a capture input, read daily on the documents page, and the restyle-count test covers Capture area, with the root's touch-action held by the page since Chromium restyles every drawn element when it changes.
A control whose own words begin with its name, as a tab whose words go on to a count, was named "Canary health check · Canary health check 0 of 47 pages real". controlContext now leaves the name out of the control's own words, so it reads "Canary health check · 0 of 47 pages real". Also: the notes entry on the root's touch-action states Chromium's restyle beside Firefox's, which the restyle-count test holds the page's touch-action against, and a long comment line in bench.py is rewrapped.
max-sixty
marked this pull request as ready for review
November 15, 2026 21:37
leaf-agent
approved these changes
Nov 15, 2026
This was referenced Nov 15, 2026
This was referenced Nov 17, 2026
Open
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.
On #4781's shape (30 text documents of 50,000 lines in side tabs, 1.51 million
elements), entering Design mode the first time took about 40 s in Chromium, and each
move of the pointer over the open document in Design mode 0.3 to 0.4 s in either
engine. Entering or leaving Draw mode took about 3 s in Firefox, and Capture area
4.4 to 4.8 s. Each now takes tens of milliseconds, or about 100 to 200 ms for the
whole-plane modes in Firefox, where the rest is the root's touch-action
(
notes/browser-support.md, "A root's touch-action in Firefox").Causes
Each is named by a CPU profile of the gesture: V8's for Chromium, the Gecko
profiler's for Firefox.
paintLegendreadgetComputedStyle(addressable).borderRadiusas it made each box,closed tabs included. Chromium answers a style read inside a
content-visibility: hiddenpanel by styling everything the panel holds. At 248,000 elements, 5.8 s ofthe 6.4 s a first entry sampled ran in
paintLegenditself, nearly all on that line.The styles stay computed, so a second entry was cheap.
text document, Design mode aims at the document's view, a
figure, which it readsas a picture, and
controlContextread the picture's block and the picture's ownwords in full for the name the target picker speaks.
refreshAimresolves thattarget on entry and at every move of the pointer, so each read the document twice.
--lf-draw-modeandcursor: crosshairon the root and a style query set thecrosshair on every element; Capture area set it on
html,bodyand every elementin
body. Firefox styles whatcontent-visibilityskips, so each change restyledall of it: at 248,000 elements one
Stylesmarker of 256,306 elements and 400 to575 ms each way for Draw mode.
Change
paintLegendreads an element's corners once the element shows, before it placesthe box. A closed tab's elements take theirs when the tab opens.
controlContextsays a part's block's words on each side of it, at mostAROUND(28) characters a side, the window
contextAroundalready gives search and thepicker's captured names, with a control's own words between, cut at
LABEL_WORDSas an addressable's label is and less the control's name where they begin with it,
so a tab reads "Canary health check · 0 of 47 pages real" rather than saying its
name twice. A block is still read once per inventory, which now
notes where each control and picture stands in it, and every control's and
picture's words are left out of it, so a neighbour's label never names this one. A
picture says none of its own words, since its name describes it, so a text
document's view is named by its label alone and its document is never read. A
call Max may reverse: a control's spoken name now says the words beside it, in
their order around its own, rather than its whole block followed by its own words.
pointer (
data-lf-crosshair), painted byrefreshCrosshairin page-geometry.js,inside a widget's tree where the pointer is over one, and never on a Leaf surface.
Capture area claims the pointer's moves before the aim hears them, so it asks for
the crosshair to follow on each move it claims. The crosshair element's children
take
cursor: auto, so in Firefox a box the pointer crosses, such asbodybetweenblocks, restyles only its children; Chromium restyles what the box holds either way,
past what
content-visibilityskips. Chrome and Firefox show the cursor of theelement holding the pointer, as WebKit bug
232339 describes, so a stroke and
an area's drag each capture the pointer on the element wearing the crosshair, which
keeps it until the release; Capture area used to
capture on
html, and Draw mode on the event's target, a widget's host where thepress landed in its tree.
--lf-draw-mode, its style query and the root's andbody's crosshairs are gone.
touch-actionstands onhtmlalone. The same rule forbody, beneaththe root's attribute, cost Firefox 25 to 33 ms a toggle on a page of 900,000 plain
elements, against 8 to 12 ms without it. Firefox still updates every box of the page
as the root's touch-action changes;
notes/browser-support.mdrecords it with thereason the rule doesn't wait for
(any-pointer: coarse).keepsOnOnewrites its flag only where the element lacks it, since an element canarrive wearing it, as a copy of the one that wore it does.
leaf-dev benchgainsdesign,drawandcaptureinputs, each mode entered andleft with the pointer resting halfway down the page's content, or on the menu row
that chose the area, and the daily run reads all three on the documents page.
What the user sees
The cursor at the pointer matches main in Chromium, Firefox and WebKit at rest, in
Draw mode, under ⌥, in Design mode, in Capture area and after each, over words,
emphasis, a link, a button, a text field, a
cursor: grabbox, a summary, a heading,an
lf-option, the panel's field, the leaf and the gap beside the column (a scriptserving one page holding each from both arms). In Draw mode each reads
crosshairbut the panel's field, and in Capture area each but the leaf, as on main.
Measurements
#4781's shape, 1.51 million elements, from a script that builds the bench's
side_documents(224)withDOCUMENT_STEPS = 25000, serves it from each arm(
leaf_dev.arms.serving_source), rests the pointer on a line of the open document,and times each gesture from its key or click to the start of 800 ms with no
main-thread gap over 50 ms. Main is the merge base, arms back to back, a fresh page
for each mode, host load 5 to 15 on 18 cores. Milliseconds, one value per gesture:
Leaving Design mode and ⌥ are unchanged code.
leaf-dev bench's documents page (34 documents of 2,048 lines at 256), main-thread CPUper press, entering and leaving each mode:
Chromium's head
drawat 256 read 33.1 as the lowest of three rounds of--input draw --rounds 3(27.9, 25.2, 30.0 at the smaller sizes), so its 48.1 aboveis one noisy reading.
Tests
test_the_legend_reads_no_style_in_a_closed_tab: entering Design mode reads nostyle inside a closed tab, and the box of the tab's paragraph takes its 6px corners
once the tab opens by keyboard. On main the legend read the closed paragraph's
style.
test_a_design_part_s_spoken_name_says_the_words_beside_it: a button after 400words of its paragraph is named by "beside the Keep after it.", a button named
"Canary check" whose words go on to a count by "Canary check · 0 of 47 real", and a
3,000-line text document's view by its label, each under 300 characters. On main the document's
name held 153,838 characters, the document twice.
test_a_page_mode_restyles_only_what_the_pointer_is_over, renamed fromtest_arming_the_page_restyles_only_what_the_pointer_is_over, adds Draw mode andCapture area in and out, each restyling under a quarter of a whole-page restyle,
with the root's touch-action held by the page. On main a mode restyled up to 696
elements, against 691 for the whole page.
cursor_at,cursor_overinrender_harness.py), since only the element under the pointerwears the crosshair.
Ran, after merging main: every browser test file that enters Draw mode, Design
mode or Capture area (598 tests in 13 files,
-n 4), 596 passing.test_an_open_view_covers_the_page_beneath_itfailed under load and passes alone;test_the_leaf_paints_inside_its_focus_ring_after_foldingfails on main's runtimetoo, where PIL can't read the theme's
oklab()colour. The journey files that enterthem (55 tests in 10 files), 54 passing;
test_trace_moment_lands_its_saved_element_over_the_trees_reading[no-preference]fails on main's runtime too. Also
pnpm run test:runtime(982 passed),pnpm run check:browser, and pre-commit on the changed files. With main's runtime under thisbranch's tests, the three tests above fail as described.
Not verified: a real touch device, WebKit's timings, and the whole suite.
Part of #5194.