Skip to content

Commit 27267cd

Browse files
jnjaeschkemoz-wptsync-bot
authored andcommitted
Fix CSS highlights not rendering on inserted text nodes.
Allow detached ranges through the document check in highlight selection population. Added two WPT reftests verifying highlights paint after inserting a text node and after inserting a subtree containing a highlighted range. Differential Revision: https://phabricator.services.mozilla.com/D297898 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2035083 gecko-commit: 597b1c2d66fd9b47739d163a89bdcd0043104ff5 gecko-commit-git: 2ab73e6e95890d16b5e4d7d457faf5809873924c gecko-reviewers: layout-reviewers, emilio
1 parent 44735f0 commit 27267cd

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<pre>Hello <span style="color: red;">world</span></pre>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html class="reftest-wait">
3+
<meta charset="utf-8">
4+
<title>CSS Highlight API Test: highlight renders on text node inserted after highlight registration</title>
5+
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
6+
<link rel="match" href="custom-highlight-painting-insert-node-001-ref.html">
7+
<meta name="assert" content="Highlights on ranges of detached text nodes are painted after the text node is inserted into the document.">
8+
<script src="/common/reftest-wait.js"></script>
9+
<style>
10+
::highlight(example) {
11+
color: red;
12+
}
13+
</style>
14+
<body>
15+
<pre></pre>
16+
<script>
17+
const pre = document.querySelector('pre');
18+
const text = document.createTextNode('Hello world');
19+
const range = new Range();
20+
range.setStart(text, 6);
21+
range.setEnd(text, 11);
22+
CSS.highlights.set('example', new Highlight(range));
23+
pre.append(text);
24+
requestAnimationFrame(() => requestAnimationFrame(() => takeScreenshot()));
25+
</script>
26+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html class="reftest-wait">
3+
<meta charset="utf-8">
4+
<title>CSS Highlight API Test: highlight renders when subtree containing highlighted range is inserted</title>
5+
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
6+
<link rel="match" href="custom-highlight-painting-insert-node-001-ref.html">
7+
<meta name="assert" content="Highlights on ranges inside a detached subtree are painted after the subtree root is inserted into the document.">
8+
<script src="/common/reftest-wait.js"></script>
9+
<style>
10+
::highlight(example) {
11+
color: red;
12+
}
13+
</style>
14+
<body>
15+
<script>
16+
const pre = document.createElement('pre');
17+
const text = document.createTextNode('Hello world');
18+
pre.append(text);
19+
const range = new Range();
20+
range.setStart(text, 6);
21+
range.setEnd(text, 11);
22+
CSS.highlights.set('example', new Highlight(range));
23+
document.body.append(pre);
24+
requestAnimationFrame(() => requestAnimationFrame(() => takeScreenshot()));
25+
</script>
26+
</html>

0 commit comments

Comments
 (0)