Skip to content

Commit 7dccc00

Browse files
Resolve highlight custom properties from the root
It was resolved in w3c/csswg-drafts#6641 that CSS Highlight Pseudos should inherit custom properties from the root element if those properties are not defined in the highlight inheritance path. Implement that by copying the variables when style is initialized for the pseudo elements. Bug: 1412395 Change-Id: I88c22cea6a9eb5f465a5c0dd97444b39b07368a2
1 parent dc5ea80 commit 7dccc00

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Diff for: css/css-pseudo/highlight-cascade-008-ref.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<title>Custom property values from the root element</title>
3+
<script src="support/selections.js"></script>
4+
<style>
5+
div::selection {
6+
background-color: green;
7+
text-decoration-line: underline;
8+
text-decoration-style: line;
9+
text-decoration-thickness: 1px;
10+
text-decoration-color: blue;
11+
}
12+
</style>
13+
<div>PASS if background-color is green when selected, underline is 1px thick and blue.</div>
14+
<script>
15+
selectNodeContents(document.querySelector("div"));
16+
</script>

Diff for: css/css-pseudo/highlight-cascade-008.html

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<title>Custom property values from the root element</title>
3+
<link rel="author" title="Stephen Chenney" href="mailto:[email protected]">
4+
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-cascade">
5+
<link rel="match" href="highlight-cascade-008-ref.html">
6+
<meta name="assert" value="This test verifies that when a custom property is not found in highlight cascade, it's value is taken from the root element.">
7+
<script src="support/selections.js"></script>
8+
<style>
9+
:root {
10+
--background-color: green;
11+
--decoration-thickness: 10px;
12+
--decoration-color: purple;
13+
}
14+
::selection {
15+
--decoration-thickness: 1px;
16+
--decoration-color: green;
17+
}
18+
div::selection {
19+
--decoration-color: blue;
20+
background-color: var(--background-color, red);
21+
text-decoration-line: underline;
22+
text-decoration-style: line;
23+
text-decoration-thickness: var(--decoration-thickness, 5px);
24+
text-decoration-color: var(--decoration-color, red);
25+
}
26+
</style>
27+
<div>PASS if background-color is green when selected, underline is 1px thick and blue.</div>
28+
<script>
29+
selectNodeContents(document.querySelector("div"));
30+
</script>

0 commit comments

Comments
 (0)