Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS highlight pseudos: fix ‘currentColor’ resolution and painting #46968

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
body {
text-decoration: 2px green underline;
}
#highlight {
.foo {
color:blue;
text-decoration: 2px blue underline;
}
.bar {
text-decoration: 2px currentColor underline;
}
</style>
<body><span id="highlight">This part should be blue</span> and this part should be black
<body><span class="foo">This part should be blue</span> and <span class="bar">this part should be black</span>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-text">
<link rel="match" href="custom-highlight-painting-019-ref.html">
<meta name="assert" value="When painting non-overlapping highlights the current color should be resolved against the next layer beneath the highlight at the current location within the span.">
<meta name="fuzzy" content="0-130;0-4">
<meta name="fuzzy" content="0-250;0-6">
<style>
body {
text-decoration: 2px green underline;
Expand Down Expand Up @@ -36,4 +36,4 @@

CSS.highlights.set("foo", h1);
CSS.highlights.set("bar", h2);
</script>
</script>
19 changes: 19 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-001-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: currentColor;
background-color: black;
}
</style>
<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>
30 changes: 30 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ of overlapping highlights</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">
<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’.">
<link rel="match" href="highlight-painting-currentcolor-001-ref.html">
<meta name="fuzzy" content="0-120;0-10">
<link rel="stylesheet" href="support/highlights.css">
<script src="support/selections.js"></script>
<style>
::highlight(a) {
color: yellow;
background-color: blue;
}
::highlight(b) {
color: lime;
background-color: blue;
}
::selection {
color: currentColor;
background-color: black;
}
</style>
<div class="highlight_reftest" id="target">test test</div>
<script>
CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));
CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));
selectNodeContents(target);
</script>
19 changes: 19 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-001a-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: currentColor;
background-color: black;
}
</style>
<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>
34 changes: 34 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-001a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ of overlapping highlights</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">
<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’.">
<link rel="match" href="highlight-painting-currentcolor-001a-ref.html">
<meta name="fuzzy" content="0-120;0-10">
<link rel="stylesheet" href="support/highlights.css">
<script src="support/selections.js"></script>
<style>
::highlight(a) {
color: yellow;
background-color: blue;
}
::highlight(b) {
color: lime;
background-color: blue;
}
::selection {
color: currentColor;
background-color: black;
}
</style>
<div class="highlight_reftest" id="target">test test</div>
<script>
CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));
CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));
selectRangeWith(range => {
range.selectNodeContents(target);
range.setStart(target.firstChild, 2);
range.setEnd(target.firstChild, 7);
});
</script>
19 changes: 19 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-002-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: currentColor;
background-color: currentColor;
}
</style>
<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>
30 changes: 30 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘background-color’ of overlapping highlights</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">
<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘background-color’.">
<link rel="match" href="highlight-painting-currentcolor-002-ref.html">
<meta name="fuzzy" content="0-120;0-10">
<link rel="stylesheet" href="support/highlights.css">
<script src="support/selections.js"></script>
<style>
::highlight(a) {
color: yellow;
background-color: blue;
}
::highlight(b) {
color: lime;
background-color: blue;
}
::selection {
color: currentColor;
background-color: currentColor;
}
</style>
<div class="highlight_reftest" id="target">test test</div>
<script>
CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));
CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));
selectNodeContents(target);
</script>
19 changes: 19 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-002a-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: currentColor;
background-color: currentColor;
}
</style>
<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>
34 changes: 34 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-002a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘background-color’ of overlapping highlights</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">
<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘background-color’.">
<link rel="match" href="highlight-painting-currentcolor-002a-ref.html">
<meta name="fuzzy" content="0-120;0-10">
<link rel="stylesheet" href="support/highlights.css">
<script src="support/selections.js"></script>
<style>
::highlight(a) {
color: yellow;
background-color: blue;
}
::highlight(b) {
color: lime;
background-color: blue;
}
::selection {
color: currentColor;
background-color: currentColor;
}
</style>
<div class="highlight_reftest" id="target">test test</div>
<script>
CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));
CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));
selectRangeWith(range => {
range.selectNodeContents(target);
range.setStart(target.firstChild, 2);
range.setEnd(target.firstChild, 7);
});
</script>
19 changes: 19 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-002b-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: green;
background-color: currentColor;
}
</style>
<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>
30 changes: 30 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-002b.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘background-color’ (but not ‘color’) of overlapping highlights</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">
<meta name="assert" content="This test checks that ::selection does not take the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘background-color’ and ‘color’ is not ‘currentColor’.">
<link rel="match" href="highlight-painting-currentcolor-002b-ref.html">
<meta name="fuzzy" content="0-120;0-10">
<link rel="stylesheet" href="support/highlights.css">
<script src="support/selections.js"></script>
<style>
::highlight(a) {
color: yellow;
background-color: blue;
}
::highlight(b) {
color: lime;
background-color: blue;
}
::selection {
color: green;
background-color: currentColor;
}
</style>
<div class="highlight_reftest" id="target">test test</div>
<script>
CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));
CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));
selectNodeContents(target);
</script>
20 changes: 20 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-003-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: currentColor;
background-color: black;
text-decoration: /* currentColor */ underline;
}
</style>
<div class="highlight_reftest" id="target"><span class="b"><span class="selection">test</span></span><span class="selection"> </span><span class="a"><span class="selection">test</span></span></div>
31 changes: 31 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-003.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Pseudo-Elements Test: ‘currentColor’ in ‘color’ and ‘text-decoration-color’ of overlapping highlights</title>
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-painting">
<meta name="assert" content="This test checks that ::selection takes the ‘color’ of the next active highlight below when resolving ‘currentColor’ in ‘color’ and ‘text-decoration-color’.">
<link rel="match" href="highlight-painting-currentcolor-003-ref.html">
<meta name="fuzzy" content="0-120;0-10">
<link rel="stylesheet" href="support/highlights.css">
<script src="support/selections.js"></script>
<style>
::highlight(a) {
color: yellow;
background-color: blue;
}
::highlight(b) {
color: lime;
background-color: blue;
}
::selection {
color: currentColor;
background-color: black;
text-decoration: /* currentColor */ underline;
}
</style>
<div class="highlight_reftest" id="target">test test</div>
<script>
CSS.highlights.set("b", new Highlight(createRangeForTextOnly(target, 0, 4)));
CSS.highlights.set("a", new Highlight(createRangeForTextOnly(target, 5, 9)));
selectNodeContents(target);
</script>
20 changes: 20 additions & 0 deletions css/css-pseudo/highlight-painting-currentcolor-003a-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Delan Azabani" href="mailto:dazabani@igalia.com">
<link rel="stylesheet" href="support/highlights.css">
<style>
.a {
color: yellow;
background-color: blue;
}
.b {
color: lime;
background-color: blue;
}
.selection {
color: currentColor;
background-color: black;
text-decoration: /* currentColor */ underline;
}
</style>
<div class="highlight_reftest" id="target"><span class="b">te<span class="selection">st</span></span><span class="selection"> </span><span class="a"><span class="selection">te</span>st</span></div>
Loading