The caret fades to invisibility or grows fat under transform: scale()

#353556446 Area: Blink>Editing / paint CL 8653958 In Review

What happens

The bar caret width is picked in the editable's local CSS px and then painted through the element's transform chain. A transform: scale(0.1) therefore shrinks the caret to a tenth of a device pixel -- it washes out to nothing -- and scale(10) paints it ten device pixels wide, fat enough to cover the next glyph. Reported in 2024, reproducible since M116.

The CL rescales the caret rect by the inverse of the accumulated transform scale between the painter block and the LayoutView, so the caret keeps its size in viewport space. Only the bar caret is touched, and only when the scale is finite, positive and not 1. Behind the default-on CaretWidthIgnoresTransform kill switch.

SVG text is left alone: it scales its contents with a factor of its own on top of the transform chain and the caret is laid out in those scaled units already, so compensating there produced a barely visible, partially covered caret -- caught by svg/text/text-layout-crash.html on the bots.

The remark on the issue was that this is hard because the transform is not known when the caret is painted. It is known one step earlier: the caret rect is computed in CaretDisplayItemClient::ComputeCaretRectAndPainterBlock(), where LocalToAncestorTransform() is available, and that runs again whenever style or layout changes.

1. transform: scale(0.1) -- caret must not fade away

Before: no caret at all
Without the fix the caret is 0.1 device px wide: not a single caret pixel shows up in any blink phase.
After: caret visible
With the fix the caret is back to one device pixel (two columns of partial coverage).
Diff mask on the caret
46 px differ -- the caret that was missing.
Live: click into either input. The caret is red, the text is grey.

2. transform: scale(10) -- caret must not get fat

Before: 10px wide caret
Without the fix the caret is 10 device px wide and swallows the glyph next to it.
After: thin caret
With the fix it is one device pixel, the same as in an unscaled field.
Diff mask on the caret
270 px differ -- the nine extra columns of caret.

Verification

Links

Issue 353556446 CL 8653958 standalone sampler.html capture_screenshots.py