The caret marker span's box: origin (viewport space) + its line-box height (the caret height).
The mirror's border-box origin, viewport space.
textarea.scrollLeft — the caret shifts left as the field scrolls right.
textarea.scrollTop.
The textarea's border-box origin, viewport space (textarea.getBoundingClientRect()).
Compose the viewport-space caret rect from the three measured boxes — the pure core of the caret geometry, split out so it can be unit-tested without a layout engine (jsdom does no layout).
The caret's offset within the content is
marker.left/top − mirror.left/top: because the mirror copies the textarea's border + padding, that delta measured from the mirror's border-box corner equals the same offset from the textarea's border-box corner. Add the textarea's viewport position and subtract its scroll to land on the on-screen caret.