Skip to content

Commit 47e5adf

Browse files
dandclarkchromium-wpt-export-bot
authored andcommitted
Highlight API: Ignore CSS contain when painting
Per the CSSWG resolution [1], ignore CSS contain boundaries when painting. Update tests, and remove some tests that are no longer interesting now that StaticRange painting no longer needs to take contain boundaries into account. [1] w3c/csswg-drafts#4598 Bug: 1164461 Change-Id: Iad9249867ea704f924827db810816935069363c4
1 parent 893864c commit 47e5adf

7 files changed

+26
-127
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<meta charset="UTF-8">
2+
<title>CSS Highlight API Test: title>
3+
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
4+
<link rel="match" href="custom-highlight-painting-001-ref.html">
5+
<meta name="assert" value="Highlight should be painted even though a Range that crosses a css-contain boundary is a part of it">
6+
<script src="resources/run-after-layout-and-paint.js">script>
7+
<style>
8+
::highlight(example-highlight) {
9+
background-color: yellow;
10+
color: blue;
11+
}
12+
#target {
13+
contain: paint;
14+
}
15+
style>
16+
<body><span>One span><span id="target"><span>two span><span>three…span>span>
17+
<script>
18+
let r = new Range();
19+
r.setStart(document.body, 0);
20+
r.setEnd(document.querySelector("#target"), 1);
21+
CSS.highlights.set("example-highlight", new Highlight(r));
22+
script>

css/css-highlight-api/painting/custom-highlight-painting-staticrange-001.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
<title>CSS Highlight API Test: title>
44
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
55
<link rel="match" href="custom-highlight-painting-staticrange-001-ref.html">
6-
<meta name="assert" value="StaticRanges that are invalid, collapsed or that cross only one boundary of a css-contain node should not be painted when they're in a Highlight">
6+
<meta name="assert" value="StaticRanges that are invalid or collapsed should not be painted when they're in a Highlight">
77
<style>
88
::highlight(example-highlight) {
99
background-color: yellow;
1010
color: blue;
1111
}
12-
#second {
13-
contain: style;
14-
}
1512
style>
1613
<body><span id="first">One span><span id="second">two span><span id="third">three…span>
1714
<script>
@@ -21,7 +18,5 @@
2118
h.add(new StaticRange({startContainer: document.body, startOffset: 1, endContainer: document.body, endOffset: 100}));
2219
h.add(new StaticRange({startContainer: document, startOffset: 0, endContainer: document, endOffset: 1}));
2320
h.add(new StaticRange({startContainer: document.querySelector("#third").firstChild, startOffset: 1, endContainer: document.querySelector("#first").firstChild, endOffset: 2}));
24-
h.add(new StaticRange({startContainer: document.querySelector("#first").firstChild, startOffset: 1, endContainer: document.querySelector("#second").firstChild, endOffset: 2}));
25-
h.add(new StaticRange({startContainer: document.querySelector("#second").firstChild, startOffset: 1, endContainer: document.querySelector("#third").firstChild, endOffset: 2}));
2621
CSS.highlights.set("example-highlight", h);
2722
script>

css/css-highlight-api/painting/custom-highlight-painting-staticrange-002.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
<title>CSS Highlight API Test: title>
44
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
55
<link rel="match" href="custom-highlight-painting-001-ref.html">
6-
<meta name="assert" value="StaticRanges crossing both boundaries of a css-contain (i.e. containing it entirely) should be painted">
6+
<meta name="assert" value="A StaticRange crossing a contain boundary should be painted">
77
<style>
88
::highlight(example-highlight) {
99
background-color: yellow;
1010
color: blue;
1111
}
1212
#contained {
13-
contain: style;
13+
contain: paint;
1414
}
1515
style>
1616
<body><span>One <span id="contained">two span>three…span>
1717
<script>
1818
let h = new Highlight();
19-
h.add(new StaticRange({startContainer: document.body.firstChild.childNodes[0], startOffset: 0, endContainer: document.body.firstChild.childNodes[2], endOffset: 0}));
19+
h.add(new StaticRange({startContainer: document.body.firstChild.childNodes[0], startOffset: 0, endContainer: document.body.firstChild.childNodes[1], endOffset: 1}));
2020
CSS.highlights.set("example-highlight", h);
2121
script>

css/css-highlight-api/painting/custom-highlight-painting-staticrange-004.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

css/css-highlight-api/painting/custom-highlight-painting-staticrange-005.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

css/css-highlight-api/painting/custom-highlight-painting-staticrange-006.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

css/css-highlight-api/painting/custom-highlight-painting-staticrange-007.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)