From c801c26f4182f6e2fbf72ac3093a3746d8d50400 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Wed, 8 Jun 2022 10:39:21 -0700 Subject: [PATCH] currentColor for highlight pseudos uses the correct originating element Per the resolutions in [1], for a highlight pseudo with currentColor as its color, getComputedStyle(element, "::highlight(...)").color should return the color of the originating element (since this is the color that would be painted if that highlight were the only one applied). This is currently achieved by having Color::ApplyValue grab the color from the originating element for highlights using currentColor. This hits a problem when we do getComputedStyle(element, "::highlight(...)") on an element that doesn't directly match a highlight pseudo, but is a child of an element matching a highlight pseudo. In that case we end up reusing the computed style for the highlight that was built for the ancestor element. That highlight style still uses the color from the ancestor element, which is the wrong result. Here we fix this by having StyleAdjuster::AdjustComputedStyle adjust the style to use the color from the correct originating element. [1] https://github.com/w3c/csswg-drafts/issues/6818#issuecomment-995033957 Bug: 1321540 Change-Id: Ibbc9126811fe52ecadb358713857df05c1143708 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3690272 Reviewed-by: Delan Azabani Reviewed-by: Rune Lillesveen Commit-Queue: Dan Clark Cr-Commit-Position: refs/heads/main@{#1012045} --- ...currentcolor-inheritance-computed-002.html | 26 +++++++++++++++++++ ...entcolor-inheritance-computed-002-ref.html | 22 ++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 css/css-pseudo/highlight-pseudos-currentcolor-inheritance-computed-002.html create mode 100644 css/css-pseudo/reference/highlight-pseudos-currentcolor-inheritance-computed-002-ref.html diff --git a/css/css-pseudo/highlight-pseudos-currentcolor-inheritance-computed-002.html b/css/css-pseudo/highlight-pseudos-currentcolor-inheritance-computed-002.html new file mode 100644 index 00000000000000..0d0da9ecec96f7 --- /dev/null +++ b/css/css-pseudo/highlight-pseudos-currentcolor-inheritance-computed-002.html @@ -0,0 +1,26 @@ + + +CSS Pseudo-Elements Test: highlight selectors getComputedStyle for currentcolor + + +

Pass if text below is green on lime, and the text itself represents green, not initial (black).

+
FAIL
+
FAIL
+ + diff --git a/css/css-pseudo/reference/highlight-pseudos-currentcolor-inheritance-computed-002-ref.html b/css/css-pseudo/reference/highlight-pseudos-currentcolor-inheritance-computed-002-ref.html new file mode 100644 index 00000000000000..67ecb8df640f72 --- /dev/null +++ b/css/css-pseudo/reference/highlight-pseudos-currentcolor-inheritance-computed-002-ref.html @@ -0,0 +1,22 @@ + + +CSS Reftest Reference +

Pass if text below is green on lime, and the text itself represents green, not initial (black).

+
rgb(0, 128, 0)
+
rgb(0, 128, 0)
+ +