Stop setting ill-formed UTF-16 to `KeyboardEvent.key` and `InputEvent.data` when typing a surrogate pair in release builds
Categories
(Core :: DOM: Events, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox154 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
Attachments
(1 file)
Bug 1840519 introduces prefs to control how we expose a typing of a surrogate pair.
dom.event.keypress.dispatch_once_per_surrogate_pair is default to false in all channels because even though Chrome and Safari dispatches only one keypress event for a surrogate pair input on macOS (and probably on Linux and Android too for Chrome), this breaks existing web apps which use String.fromCharCode(event.charCode).
I think that we do not need to change this because of the backward compatibility.
dom.event.keypress.key.allow_lone_surrogate is default to false on early beta builds and earlier. Once we set this to false, first keypress will have a surrogate pair to .key and high-surrogate to .charCode, and second keypress will have empty string to .key and low-surrogate to .charCode. Then, TextEditor and HTMLEditor do not handle surrogates separately. Therefore, InputEvent.data will have a surrogate pair.
I think that this behavior is reasonable for both modern web apps and legacy web apps using String.fromCharCode. However, this is not compatible with the other browsers on any platforms.
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Comment 1•1 month ago
|
||
The pref was added in bug 1840519, 3 years ago. The motivation of the
new behavior is, String.fromCharCode(event.charCode) won't create
ill-formed UTF-16 string only from the high-surrogate or the
low-surrogate.
Unfortunately, this behavior is incompatible with Chrome, but we don't
get any bug reports from our testers in this 3 years. So, I think
shipping this is enough safe and the new behavior is better from the
Unicode spec point of view.
Note that there must be only a few keyboard layouts which can type
non-BMP characters directly. I tried to test it with creating a
custom keyboard layout (attachment 9341661 [details]). So, originally, this bug
affected only a small number of users.
Updated•1 month ago
|
Comment 2•1 month ago
|
||
Comment on attachment 9604608 [details]
Bug 1849790 - Ship the better keypress.charCode behavior when typing a surrogate pair r=smaug!
Revision D310450 was moved to bug 2052478. Setting attachment 9604608 [details] to obsolete.
Updated•1 month ago
|
Comment 4•1 month ago
|
||
| bugherder | ||
Updated•1 month ago
|
Description
•