Browser extension: highlights are misplaced inside a zoomed element
Describe the bug
When a text field is inside an element with CSS zoom, Harper finds the errors but draws the highlights in the wrong place: below and to the right of the words, and larger than them. When the page also scales a container with the scale property, the highlights are still off, and in a textarea they drift further from the text the further along the line the mistake is. Fields outside such elements on the same page are fine.
To Reproduce
- Open a page with a textarea inside a zoomed container, for example
<div style="zoom: 1.2"><textarea></textarea></div> - Type a sentence with a spelling mistake into the textarea
- See the highlight appear below and to the right of the misspelled word
Expected behavior The highlight covers the misspelled word, as it does in a textarea without such an ancestor.
Platform Browser extension in Firefox 156 and Chrome 154 on Linux.
Additional context
I ran into this in the web client of an ERP system, which sets scale: 0.9 on its main container and zoom: 1.2 on its forms, so it is not only a synthetic case.
I think there are two causes. The render box is inserted next to the text field, inside the zoomed or scaled subtree, so the position: fixed highlights get moved and scaled a second time. isContainingBlock() also does not check individual transform properties such as scale. Separately, the mirror that measures text in a textarea is appended to <body>, with the field's own font size but its on-screen width, so its text is laid out smaller than in the real field.
This may be related to #3868, which is about font-size scaling, but I have not verified that.
I'll open a pull request with a fix and Playwright tests.
Text of this issue was prepared with an LLM agent (Claude Code); I reviewed it and edited where appropriate before posting.
Source: Automattic/harper