While composing a prompt, a few things ran on every keystroke that did work scaling with the size of the whole document, so typing could feel slow on longer prompts. This patch cuts that down:
- Cache the editor's serialized `value` and reuse it while the document hasn't changed, instead of re-serializing it on every read.
- In #dispatchTransaction, only read `value` when the document actually changed, so caret and selection changes don't serialize it.
- Resolve both selection offsets in a single pass (#posFromTextOffsets).
- Cache Mentions.hasMention the same way (by document identity) so it no longer walks the whole document on every call.
- Make _on_keyup synchronous and move the rare deferred-Enter handling into a fire-and-forget #finishDeferredEnter helper, with a guard so a second keyup can't re-enter it while it's still waiting. (also mirrored in UrlbarInputBase).
Differential Revision: https://phabricator.services.mozilla.com/D321755