mirror of
https://github.com/servo/servo
synced 2026-05-12 18:06:32 +02:00
DOM APIs for interacting with selection and text in text inputs `<input type=text>` and `<textarea>` all accept offsets and lengths in UTF-16 code units. Servo was not converting all of these offsets into UTF-8 code units. This change makes it so that this conversion is done more thoroughly and makes it clear when the code is dealing with UTF-8 offsets and UTF-16 offsets. Helper functions are added for doing this conversion in both directions as it is necessary. In addition, a `char` iterator is added for `TextInput` as it is useful for doing this conversion. It will be used more completely in the future when a `Rope` data structure is extracted from `TextInput`. Finally, specification text is added to all of the DOM implementation touched here. Testing: This change includes a new WPT crash test as well as a series of unit tests to verify conversion between UTF-8 and UTF-16 offsets. Fixes #36719. Fixes #20028. Fixes #39184. Signed-off-by: Martin Robinson <mrobinson@igalia.com>