Skip to content

Commit

Permalink
Fix text painting for ::target-text & ::highlight
Browse files Browse the repository at this point in the history
::target-text & ::highlight pseudo-elements were not painting
the text if the originating element color was transparent.

This patch fixes this removing two checks
in NGHighlightPainter::Paint().

BUG=1273943
TEST=web_tests/external/wpt/css/css-highlight-api/painting/custom-highlight-painting-017.html
TEST=web_tests/external/wpt/css/css-pseudo/target-text-007.html

Change-Id: Ie8198e8cf37d6ef89cdee341e84b6bc36ad6ec84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3302311
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Manuel Rego <rego@igalia.com>
Cr-Commit-Position: refs/heads/main@{#945638}
  • Loading branch information
mrego authored and chromium-wpt-export-bot committed Nov 26, 2021
1 parent ce8e732 commit 9263c77
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
27 changes: 27 additions & 0 deletions css/css-highlight-api/painting/custom-highlight-painting-017.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>CSS Highlight API Test: ::highlight color with transparent originating color</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#custom-highlight-pseudo">
<link rel="help" href="https://crbug.com/1273943">
<meta name="assert" content="This test checks that ::highlight pseudo-element uses the specified color even when the originating element text color was trasnparent.">
<link rel="match" href="/css/reference/pass_if_pass_below.html">
<style>
div {
color: transparent;
}
::highlight(example-highlight) {
color: black;
}
</style>

<p>Test passes if there is the word "PASS" below.</p>
<div id="target">PASS</div>

<script>
let r = new Range();
r.setStart(target, 0);
r.setEnd(target, 1);

CSS.highlights.set("example-highlight", new Highlight(r));
</script>
23 changes: 23 additions & 0 deletions css/css-pseudo/target-text-007.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>CSS Pseudo-Elements Test: ::target-text text color with transparent originating color</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-pseudo/#selectordef-target-text">
<link rel="help" href="https://crbug.com/1273943">
<meta name="assert" content="This test checks that ::target-text pseudo-element uses the specified color even when the originating element text color was trasnparent.">
<link rel="match" href="/css/reference/pass_if_pass_below.html">
<style>
div {
color: transparent;
}
::target-text {
color: black;
}
</style>

<p>Test passes if there is the word "PASS" below.</p>
<div>PASS&nbsp;</div>

<script>
window.location.hash = "#:~:text=PASS%20";
</script>

0 comments on commit 9263c77

Please sign in to comment.