Skip to content

Enter Design mode, Draw mode and Capture area at a cost the window sets, not the page's size - #6062

Merged
max-sixty merged 11 commits into
mainfrom
grind/modes
Nov 15, 2026
Merged

max-sixty merged 11 commits into
mainfrom
grind/modes

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

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.

  • Design mode's legend read the corners of every element the page names.
    paintLegend read getComputedStyle(addressable).borderRadius as it made each box,
    closed tabs included. Chromium answers a style read inside a content-visibility: hidden panel by styling everything the panel holds. At 248,000 elements, 5.8 s of
    the 6.4 s a first entry sampled ran in paintLegend itself, nearly all on that line.
    The styles stay computed, so a second entry was cheap.
  • Design mode's name for what the pointer is over read the whole document. Over a
    text document, Design mode aims at the document's view, a figure, which it reads
    as a picture, and controlContext read the picture's block and the picture's own
    words in full for the name the target picker speaks. refreshAim resolves that
    target on entry and at every move of the pointer, so each read the document twice.
  • Draw mode's and Capture area's crosshair restyled every element. Draw mode set
    --lf-draw-mode and cursor: crosshair on the root and a style query set the
    crosshair on every element; Capture area set it on html, body and every element
    in body. Firefox styles what content-visibility skips, so each change restyled
    all of it: at 248,000 elements one Styles marker of 256,306 elements and 400 to
    575 ms each way for Draw mode.

Change

  • paintLegend reads an element's corners once the element shows, before it places
    the box. A closed tab's elements take theirs when the tab opens.
  • controlContext says a part's block's words on each side of it, at most AROUND
    (28) characters a side, the window contextAround already 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 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.
  • The crosshair of Draw mode and Capture area stands on the element under the
    pointer (data-lf-crosshair), painted by refreshCrosshair in 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 as body between
    blocks, restyles only its children; Chromium restyles what the box holds either way,
    past what content-visibility skips. Chrome and Firefox show the cursor of the
    element 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 the
    press landed in its tree. --lf-draw-mode, its style query and the root's and
    body's crosshairs are gone.
  • Each mode's touch-action stands on html alone. The same rule for body, beneath
    the 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.md records it with the
    reason the rule doesn't wait for (any-pointer: coarse).
  • keepsOnOne writes its flag only where the element lacks it, since an element can
    arrive wearing it, as a copy of the one that wore it does.
  • leaf-dev bench gains design, draw and capture inputs, each mode entered and
    left 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: grab box, a summary, a heading,
an lf-option, the panel's field, the leaf and the gap beside the column (a script
serving one page holding each from both arms). In Draw mode each reads crosshair
but 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) with DOCUMENT_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:

Engine Gesture main this branch
Chromium Design mode, first entry 37,678 to 40,272 83 to 100
Chromium Design mode, second entry 642, 675 35, 45
Chromium Design mode, the pointer down a line 291 to 313 3 to 6
Chromium Draw mode, in and out 39 to 65 30 to 49
Chromium Capture area, in and out 39, 93 48 to 103
Firefox Design mode, first entry 1,490 to 1,882 98 to 115
Firefox Design mode, second entry 895, 959 78, 90
Firefox Design mode, the pointer down a line 306 to 424 3 to 11
Firefox Design mode, leaving 69 to 106 73 to 103
Firefox Draw mode, in 2,109 to 3,655 80 to 116
Firefox Draw mode, out 2,061 to 3,016 79 to 92
Firefox Capture area, in 3,560, 4,790 123, 173
Firefox Capture area, out 3,463, 4,414 161, 215
Firefox ⌥ down and up 67 to 88 62 to 75

Leaving Design mode and ⌥ are unchanged code.

leaf-dev bench's documents page (34 documents of 2,048 lines at 256), main-thread CPU
per press, entering and leaving each mode:

uv run leaf-dev bench documents --input design --input draw --input capture --sizes 64,128,256 --read cpu --base
                   8 base     8 head    64 base    64 head   128 base   128 head   256 base   256 head
design cpu ms       102.0       25.4      283.4       21.7      501.0       25.8      963.6       25.0
draw cpu ms          26.7       24.3       37.6       31.8       32.6       34.7       37.7       48.1
capture cpu ms       37.7       51.7       43.9       56.7       45.5       60.4       57.3       68.7

uv run leaf-dev bench documents --input design --input draw --input capture --sizes 64,128,256 --base --browser firefox
design cpu ms        63.3       15.7       44.3       13.8       39.6       25.5       45.4       20.6
draw cpu ms          28.8       13.3       46.1        9.9       68.4       20.2      126.7       15.8
capture cpu ms       42.0       35.7       86.9       34.1      107.0       45.2      186.1       45.8

Chromium's head draw at 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 above
is one noisy reading.

Tests

  • test_the_legend_reads_no_style_in_a_closed_tab: entering Design mode reads no
    style 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 400
    words 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 from
    test_arming_the_page_restyles_only_what_the_pointer_is_over, adds Draw mode and
    Capture 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.
  • The Draw mode tests read the cursor where the pointer is (cursor_at,
    cursor_over in render_harness.py), since only the element under the pointer
    wears 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_it failed under load and passes alone;
test_the_leaf_paints_inside_its_focus_ring_after_folding fails on main's runtime
too, where PIL can't read the theme's oklab() colour. The journey files that enter
them (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 this
branch'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.

…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.
@max-sixty max-sixty changed the title Enter Design and Draw mode at a cost the window sets, not the page's size Enter Design mode, Draw mode and Capture area at a cost the window sets, not the page's size Nov 15, 2026
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
max-sixty marked this pull request as ready for review November 15, 2026 21:37
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