Repository navigation
Description
Problem
Clicking inside a scrolled Chromium textarea in the background puts the caret on the wrong line, and the engine answers success. The column is right; the line is the one under the point as if the field were scrolled to the top.
Measured in #290's hosted A/B (run https://github.com/SSFSKIM/cua/actions/runs/42560301611), on both main and the #290 branch:
- The 3,074-character field: the screenshot shows lines 32–35. The unfocused character boxes put the click at offset 1,408. After the click, the page reads offset 96 (line 2, column 14). This happened in 12 of 12 cells.
- The 20k field (macOS engine: the focus route's caret scan searches a field's character boxes by line, then x, instead of linearly #290's branch): the screenshot shows lines 230–233, and the boxes put the click at offset 9,526. The page again reads offset 96, in 12 of 12 cells.
The cause is in focusPlacingCaret (WebAreaFocus.swift). By #283's design it reads the character boxes only after setting AXFocused, so that the boxes exist. But focusing a Chromium textarea scrolls it to its existing caret, offset 0. The boxes are then read in the scrolled-to-top layout, and the clicked point maps to a different line.
Impact: every scrolled textarea in background Chrome. Text typed after the click goes to the wrong place, with no error.
Intent
The caret lands at the clicked character in a scrolled field. Candidates:
- read the boxes before focusing, where they exist;
- after focus, re-derive the point from the field's scroll change, using the before and after frames of a reference character box;
- restore the field's scroll before reading.
Keep #283's rules: never a guessed offset, a line end only where established, no inference across empty boxes, and secure fields never scanned. Measure first. The #290 kit (probe/290-measure, the long textarea cells) reproduces it.
Constraints
- Applies to Chromium. Check whether Safari and Firefox focus-scroll too.
- Lives in WebAreaFocus.swift, which macOS engine: the focus route's caret scan searches a field's character boxes by line, then x, instead of linearly #290 changes. Build it after macOS engine: the focus route's caret scan searches a field's character boxes by line, then x, instead of linearly #290 merges.
- Spawned by macOS engine: the focus route's caret scan searches a field's character boxes by line, then x, instead of linearly #290 (found in its A/B). Not blocked by macOS engine: the focus route's caret scan searches a field's character boxes by line, then x, instead of linearly #290 itself; no parent (consciously N/A).
Success criteria
- In a textarea scrolled to show lines 32–35 and 230–233, a click places the caret at the offset the unfocused boxes give for the point, on Chrome for Testing, in both shared and dedicated mode.
- No regression on macOS engine: a background Chrome text-field click in shared mode focuses the field through AXFocused, and says the caret was not placed #283's and macOS engine: the focus route's caret scan searches a field's character boxes by line, then x, instead of linearly #290's cells.
Activity
Docs: #290's Decision Log entry, its stated limits and #341, the host…
Probe 341: the page fits Chrome for Testing's viewport (three-line fi…
Engine: the caret's offset searched by line, then x, with #283's line…
Engine: the focus route's comments state #341's order, the caret's wr…
Merge origin/main (#303 merged as e31bb1f) into fix/341-scrolled-care…
Docs: #341's Decision Log entry (the caret's write first, AXFocused t…
Docs: #341's test count after main's merge (refs #341)
Docs: #341's layoutMoved false negative stated as shipped (finer proof …
Engine: an empty field's exemption from the reference box is re-check…
Engine: the reference box is waived only for a field empty before the…
Merge origin/main (#347 at 95ed66e, 0.27.21) into fix/341-scrolled-ca…
Plugin: #341 takes 0.27.22, after #347's 0.27.21; the test count with…
SSFSKIM commentedon Nov 9, 2026
[board] in-review: PR #349: caret written before any focus, placed only with the reference-box proof; A/B 42578081142 (main 59 of 72 placed claims false, branch 0 of 63); reviewer-high 3 rounds clean; ci-gate GREEN 42592550254 at 0.27.22
Engine: a Chromium click writes the caret before any focus, and answe…
SSFSKIM commentedon Nov 9, 2026
[board] done: Landed via PR #349 (0.27.22)
Merge origin/fix/330-new-element-over-point (#330's evidence; main's #…
Probe #359: qualify paired unmodified engines and forced tails [skip ci]
macOS engine: AX text actions wait for a foreground click to land, an…