Intent to Prototype: EditContext On-Demand Text & Selection Updates (invalidate() and contextrequest)

17 views
Skip to first unread message

Gary Klassen

unread,
Oct 20, 2026, 7:02:46 PM (yesterday) Oct 20
to blin...@chromium.org, David Bokan, Igor Kopylov, dan...@microsoft.com
Contact emails:
gkla...@google.com, bo...@chromium.org

Explainer:
https://github.com/w3c/edit-context/issues/156

Specification:
https://w3c.github.io/edit-context/

Summary:
Adds a pull-on-demand context update mechanism (`editContext.invalidate()` and the `contextrequest` event via `ContextRequestEvent`) to `EditContext`. Large-document canvas/custom editors (such as Google Docs and Slides) have non-trivial serialization costs when computing multi-paragraph plain-text buffers and selection offsets on every keystroke or cursor movement. `editContext.invalidate()` allows web editors to notify the user agent in O(1) time that the document text or selection has changed (and cleanly cancel any active IME composition), while deferring actual `updateText()` / `updateSelection()` serialization until an IME, OS text service, or browser AI/voice dictation feature dispatches a `ContextRequestEvent` (`scope: "local" | "extended"`, with optional `waitUntil(promise)` support for asynchronous document models).

Blink component:
Blink>Editing>IME

Motivation:
Currently, `EditContext` requires authors to eagerly call `updateText()` and `updateSelection()` on every document mutation or selection change so the browser cache stays warm—even when no IME or OS text consumer is reading it. Furthermore, resetting an active IME composition on external selection changes currently requires a synthetic DOM `blur()`/`focus()` workaround (which causes virtual keyboard flicker on mobile). `invalidate()` + `contextrequest` brings the same pull-on-demand ergonomics to text and selection that `characterboundsupdate` already provides for geometry.

Initial public proposal:
https://github.com/w3c/edit-context/issues/156

Prototype CL:
https://chromium-review.googlesource.com/c/chromium/src/+/8608668

TAG review:
N/A (incremental addition to the existing EditContext API; will file if requested by API owners)

Risks:
- Interoperability and Compatibility: Low. Additive method (`invalidate()`) and event (`contextrequest`) on `EditContext`, guarded behind the `EditContextOnDemand` runtime feature. Existing eager `updateText()` / `updateSelection()` callers are completely unaffected.
- Gecko: No signal
- WebKit: No signal
- Web developers: some positive signal from Google Workspace Editors.

Debuggability:
Standard DevTools Event Listener breakpoints and DOM/Event inspection apply to `contextrequest`.

Is this feature fully tested by web-platform-tests?
Will add WPT coverage under `editing/edit-context/` alongside the prototype.

Flag name on about://flags:
--enable-blink-features=EditContextOnDemand (or experimental web platform features)

Requires code in //chrome?
No (Blink renderer `core/editing/ime` and `modules/content_extraction`).

Tracking bug:
https://crbug.com/574145399

--
Gary
Reply all
Reply to author
Forward
0 new messages