Skip to content

Commit

Permalink
Bug 1618150 [wpt PR 21983] - Perform kNotInsideLink-related adjustmen…
Browse files Browse the repository at this point in the history
…ts in ElementRuleCollector, a=testonly

Automatic update from web-platform-tests
Perform kNotInsideLink-related adjustments in ElementRuleCollector

The link_match_type stored on the MatchedProperties object is only
relevant and correct if we're inside a link, hence we need to override
the effective link_match_type at some point.

Previously, we would do this apply-time, and not as part of the rule-
collection. This CL instead proposes that ElementRuleCollector take
the link-status into account, and perform the adjustment before storing
the link_match_type on MatchedProperties, such that no further
adjustments are required later.

This fixes a bug in the CSSCascade path, where we would incorrectly not
apply anything for selectors such as *:not(:link):not(:visited), even
for elements that are not inside links. (See AddLinkFilter in
cascade_expansion.cc. We would switch on the value 0, and then enter
the default case, causing a filter to be added on kProperty, which
causes all properties to be rejected. This is correct for elements
that are inside links, but not for elements that aren't).

Bug: 1055715
Change-Id: I2b63de41753fb0fa7b637a4be5bd009c2f165fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072223
Reviewed-by: Rune Lillesveen <futharkchromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org>
Cr-Commit-Position: refs/heads/master{#744631}

--

wpt-commits: 06114b9ab7eb85376ce6a1982fb850ba8c5c60ef
wpt-pr: 21983

UltraBlame original commit: 84b018a46e90f3047afd8c896a8fdd407d10bc4a
  • Loading branch information
marco-c committed Mar 3, 2020
1 parent b241d3e commit ac0f0f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions testing/web-platform/tests/css/selectors/not-links-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<title>Test that *:not(:link):not(:visited) does not match links</title>
<body>
<a href="#">Unvisited</a>
<a href="">Visited</a>
<span style="background-color: green">Green</span>
<p>
Only "Green" should have a green background.
</p>
</body>
17 changes: 17 additions & 0 deletions testing/web-platform/tests/css/selectors/not-links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<title>Test that *:not(:link):not(:visited) does not match links</title>
<link rel="match" href="not-links-ref.html">
<link rel="help" href="https://drafts.csswg.org/selectors-4/#negation">
<style>
body > *:not(:link):not(:visited) {
background-color: green;
}
</style>
<body>
<a href="#">Unvisited</a>
<a href="">Visited</a>
<span>Green</span>
<p style="background-color: initial">
Only "Green" should have a green background.
</p>
</body>

0 comments on commit ac0f0f2

Please sign in to comment.