commit 823923c44a6928efad1b75e1dbf490ae39434c4e
parent d743f5f24fa1f54abb963e6216de65e030ff9f58
Author: Martin Robinson <mrobinson@igalia.com>
Date: Mon, 5 Jan 2026 10:23:01 +0000
Bug 2008011 [wpt PR 56945] - script: More thoroughly convert between UTF-16 and UTF-8 offsets in text inputs, a=testonly
Automatic update from web-platform-tests
script: More thoroughly convert between UTF-16 and UTF-8 offsets in text inputs
DOM APIs for interacting with selection and text in text inputs
`<input type=text>` and `<textarea>` all accept offsets and lenghths 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.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
--
wpt-commits: 78ebe5a82f362d69e24a30a06c994c7425bf4552
wpt-pr: 56945
Diffstat:
3 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/css/css-ruby/ruby-annotation-with-margin-ref.html b/testing/web-platform/tests/css/css-ruby/ruby-annotation-with-margin-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<link rel="stylesheet" href="/fonts/ahem.css">
+<style>
+body {
+ display: flow-root;
+ font-family: Ahem;
+ font-size: 10px;
+}
+
+ruby {
+ color: transparent;
+}
+
+rt {
+ color: green;
+}
+</style>
+<div style="margin: 10px 0px 20px 10px;"><ruby>base<rt>annotation</rt></ruby></div>
+<div style="margin-top: 10px;"><ruby>base<rt>annotation</rt></ruby></div>
+<div style="margin-bottom: 30px;"><ruby>base<rt>annotation</rt></ruby></div>
+<div style="margin: 20px 0px 10px 10px"><ruby>base<rt>annotation</rt></ruby></div>
+<div style="margin: 20px 0px 0px 0px"><ruby>base<rt>annotation</rt></ruby></div>
+<div style="margin: 0px 0px 10px 0px"><ruby>base<rt>annotation</rt></ruby></div>
+
+<div style="writing-mode: vertical-lr">
+ <div style="margin: 0px 0px 0px 10px"><ruby>base<rt>annotation</rt></ruby></div>
+ <div style="margin: 0px 0px 0px 10px"><ruby>base<rt>annotation</rt></ruby></div>
+ <div style="margin: -10px 0px 0px 0px"><ruby>base<rt>annotation</rt></ruby></div>
+</div>
diff --git a/testing/web-platform/tests/css/css-ruby/ruby-annotation-with-margin.html b/testing/web-platform/tests/css/css-ruby/ruby-annotation-with-margin.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<title>Interlinear ruby annotation box with margin</title>
+<link rel="match" href="ruby-annotation-with-margin-ref.html">
+<link rel="help" href="https://drafts.csswg.org/css-ruby-1/#interlinear-layout">
+<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
+<style>
+body {
+ font-family: Ahem;
+ font-size: 10px;
+}
+
+ruby {
+ color: transparent;
+}
+
+rt {
+ color: green;
+}
+
+.under ruby {
+ ruby-position: under;
+}
+</style>
+<div><ruby>base<rt style="margin: 10px;">annotation</rt></ruby></div>
+<div><ruby>base<rt style="margin-top: 10px;">annotation</rt></ruby></div>
+<div><ruby>base<rt style="margin-bottom: 10px;">annotation</rt></ruby></div>
+
+<div class=under>
+ <div><ruby>base<rt style="margin: 10px;">annotation</rt></ruby></div>
+ <div><ruby>base<rt style="margin-top: 10px;">annotation</rt></ruby></div>
+ <div><ruby>base<rt style="margin-bottom: 10px;">annotation</rt></ruby></div>
+</div>
+
+<div style="writing-mode: vertical-lr">
+ <div><ruby>base<rt style="margin: 10px;">annotation</rt></ruby></div>
+ <div><ruby>base<rt style="margin-top: 10px;">annotation</rt></ruby></div>
+ <div><ruby>base<rt style="margin-bottom: 10px;">annotation</rt></ruby></div>
+</div>
diff --git a/testing/web-platform/tests/html/semantics/forms/textfieldselection/textarea-setRangeText-utf16-code-unit-crash.html b/testing/web-platform/tests/html/semantics/forms/textfieldselection/textarea-setRangeText-utf16-code-unit-crash.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<title>setRangeText: Should not crash when setting text range intersects UTF-16 code units</title>
+<link rel="help" href="https://github.com/servo/servo/issues/36719">
+<script>
+ textarea = document.createElement("textarea");
+ textarea.defaultValue = String.fromCodePoint(806453);
+ textarea.setRangeText("", 0, 1);
+</script>