Bug 327412
| Summary: | [GTK][WPE] Input method delete-surrounding is documented in characters but counts UTF-16 code units | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Simon Pena <spena> |
| Component: | WPE WebKit | Assignee: | Fujii Hironori <fujii> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | alex, aperez, bugs-noreply, cgarcia, fujii |
| Priority: | P2 | ||
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=205716 https://bugs.webkit.org/show_bug.cgi?id=326818 https://bugs.webkit.org/show_bug.cgi?id=326817 https://bugs.webkit.org/show_bug.cgi?id=250208 https://bugs.webkit.org/show_bug.cgi?id=327414 https://bugs.webkit.org/show_bug.cgi?id=327694 |
||
Simon Pena
The delete-surrounding signal of WebKitInputMethodContext and WPEInputMethodContext documents offset and n_chars as characters. WebPage::deleteSurrounding() counts UTF-16 code units, and has done since the signal was added (bug 205716). The two only differ outside the Basic Multilingual Plane, for example with emoji. With the caret after "a😀":
- delete-surrounding(-1, 1) deletes nothing: it covers half of the emoji's surrogate pair.
- delete-surrounding(-2, 2) deletes the emoji.
A delete that would start before the text depends on the code units too: after "a😀", (-4, 4) deletes nothing; after "aa😀", it deletes everything.
Two more behaviours are not documented, and input methods rely on them:
- The offset is counted from the start of the selection, and the delete can reach into the selection.
- A count of 0 moves the caret by offset.
Input method code in use counts in different units. wpe-android forwards Android's counts, which are UTF-16 code units, and we know of at least one other embedder that counts UTF-16 code units. The Wayland text-input-v1 backend converts to code points. The text-input-v3 backend passes bytes (bug 326818).
Proposal: document UTF-16 code units, the selection start and the zero-count caret move. That matches what WebKit does today and changes no behaviour. Then make the Wayland backends convert to UTF-16 code units. Changing the behaviour to code points would break the embedders that count UTF-16 code units.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Fujii Hironori
Pull request: https://github.com/WebKit/WebKit/pull/77486
EWS
Committed 324121@main (c8f1f0f55c5f): <https://commits.webkit.org/324121@main>
Reviewed commits have been landed. Closing PR #77486 and removing active labels.