From d3bad404a71803ca5d528c306ef87435f68c80c2 Mon Sep 17 00:00:00 2001 From: Byungwoo Lee Date: Fri, 13 May 2022 09:29:42 +0000 Subject: [PATCH] Support invalidation for location pseudo classes inside :has() Support invalidation for :link, :any-link and :target pseudo class inside :has(). Invalidation for :visited inside :has() is not needed since :visited is not matched inside :has() to prevent leaking visitedness. Ignored invalidation of :scope inside :has() due to an issue in the csswg-draft. - https://github.com/w3c/csswg-drafts/issues/7211 Bug: 669058, 1324834 Change-Id: Ice42f0113f0cdc69a8054c2778c9cab3cdd5ef10 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3645177 Reviewed-by: Rune Lillesveen Commit-Queue: Byungwoo Lee Cr-Commit-Position: refs/heads/main@{#1003038} NOKEYCHECK=True GitOrigin-RevId: 1d9eb9e8bb664b1f3117b788f1ab48bcc89648ee --- blink/renderer/core/dom/element.cc | 3 + .../invalidation/link-pseudo-in-has.html | 97 +++++++++++++++++++ .../target-pseudo-in-has-expected.txt | 4 - .../target-pseudo-in-has-expected.txt | 4 - .../target-pseudo-in-has-expected.txt | 4 - 5 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 blink/web_tests/external/wpt/css/selectors/invalidation/link-pseudo-in-has.html delete mode 100644 blink/web_tests/flag-specific/highdpi/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt delete mode 100644 blink/web_tests/platform/generic/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt delete mode 100644 blink/web_tests/platform/mac-mac10.14/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt diff --git a/blink/renderer/core/dom/element.cc b/blink/renderer/core/dom/element.cc index 5e7d3513350..8208fc340df 100644 --- a/blink/renderer/core/dom/element.cc +++ b/blink/renderer/core/dom/element.cc @@ -4301,6 +4301,7 @@ struct Element::AffectedByPseudoStateChange { element.AncestorsOrSiblingsAffectedByActiveInHas(); break; + case CSSSelector::kPseudoAnyLink: case CSSSelector::kPseudoChecked: case CSSSelector::kPseudoDefault: case CSSSelector::kPseudoDisabled: @@ -4308,12 +4309,14 @@ struct Element::AffectedByPseudoStateChange { case CSSSelector::kPseudoIndeterminate: case CSSSelector::kPseudoInRange: case CSSSelector::kPseudoInvalid: + case CSSSelector::kPseudoLink: case CSSSelector::kPseudoOutOfRange: case CSSSelector::kPseudoOptional: case CSSSelector::kPseudoPlaceholderShown: case CSSSelector::kPseudoReadOnly: case CSSSelector::kPseudoReadWrite: case CSSSelector::kPseudoRequired: + case CSSSelector::kPseudoTarget: case CSSSelector::kPseudoValid: ancestors_or_siblings = true; break; diff --git a/blink/web_tests/external/wpt/css/selectors/invalidation/link-pseudo-in-has.html b/blink/web_tests/external/wpt/css/selectors/invalidation/link-pseudo-in-has.html new file mode 100644 index 00000000000..0ff879768b7 --- /dev/null +++ b/blink/web_tests/external/wpt/css/selectors/invalidation/link-pseudo-in-has.html @@ -0,0 +1,97 @@ + + +CSS Selectors Invalidation: :link, :visited :any-link, pseudo-class in :has() argument + + + + + +
+ diff --git a/blink/web_tests/flag-specific/highdpi/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt b/blink/web_tests/flag-specific/highdpi/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt deleted file mode 100644 index 9f19c5d9c92..00000000000 --- a/blink/web_tests/flag-specific/highdpi/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt +++ /dev/null @@ -1,4 +0,0 @@ -This is a testharness.js-based test. -FAIL CSS Selectors Invalidation: target pseudo in :has() argument assert_equals: parent should be yellowgreen on fragment click expected "rgb(154, 205, 50)" but got "rgb(0, 128, 0)" -Harness: the test ran to completion. - diff --git a/blink/web_tests/platform/generic/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt b/blink/web_tests/platform/generic/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt deleted file mode 100644 index 574ddd3f87b..00000000000 --- a/blink/web_tests/platform/generic/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt +++ /dev/null @@ -1,4 +0,0 @@ -This is a testharness.js-based test. -FAIL CSS Selectors Invalidation: :target pseudo-class in :has() argument assert_equals: parent1 should be green on fragment click expected "rgb(0, 128, 0)" but got "rgb(128, 128, 128)" -Harness: the test ran to completion. - diff --git a/blink/web_tests/platform/mac-mac10.14/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt b/blink/web_tests/platform/mac-mac10.14/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt deleted file mode 100644 index 9f19c5d9c92..00000000000 --- a/blink/web_tests/platform/mac-mac10.14/external/wpt/css/selectors/invalidation/target-pseudo-in-has-expected.txt +++ /dev/null @@ -1,4 +0,0 @@ -This is a testharness.js-based test. -FAIL CSS Selectors Invalidation: target pseudo in :has() argument assert_equals: parent should be yellowgreen on fragment click expected "rgb(154, 205, 50)" but got "rgb(0, 128, 0)" -Harness: the test ran to completion. -