aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/sharing/checks.rs
diff options
context:
space:
mode:
authorDavid Shin <dshin@mozilla.com>2023-05-25 14:35:18 +0000
committerMartin Robinson <mrobinson@igalia.com>2023-11-24 08:57:14 +0100
commitff8100d3963ac88fa0001bec40472134dbb4394b (patch)
tree7f6485012d046f07afd2cc7eda7f8b44b8a214c6 /components/style/sharing/checks.rs
parent5c0897c8eb6ef789dd14918b9b427935a244a847 (diff)
downloadservo-ff8100d3963ac88fa0001bec40472134dbb4394b.tar.gz
servo-ff8100d3963ac88fa0001bec40472134dbb4394b.zip
style: Correct style sharing handling for any element that considered `:has()` in selector matching
For any element that anchors a `:has()` selector (i.e. Matches a selector that contains a `:has()` on its rightmost side), we prevent style sharing altogether, as evaluation of the `:has()` selector is required in the first place to determine style sharing. On the other hand, any element matching a rule containing `:has()` without anchoring it can do style sharing for siblings, but not cousins. Differential Revision: https://phabricator.services.mozilla.com/D176836
Diffstat (limited to 'components/style/sharing/checks.rs')
-rw-r--r--components/style/sharing/checks.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/components/style/sharing/checks.rs b/components/style/sharing/checks.rs
index 42c7110dce8..a691ac5c764 100644
--- a/components/style/sharing/checks.rs
+++ b/components/style/sharing/checks.rs
@@ -36,6 +36,15 @@ where
// Cousins are a bit more complicated.
//
+ // The fact that the candidate is here means that its element does not anchor
+ // the relative selector. However, it may have considered relative selector(s)
+ // to compute its style, i.e. there's a rule `<..> :has(<..>) <..> candidate`.
+ // In this case, evaluating style sharing requires evaluating the relative
+ // selector for the target anyway.
+ if candidate.considered_relative_selector {
+ return false;
+ }
+
// If a parent element was already styled and we traversed past it without
// restyling it, that may be because our clever invalidation logic was able
// to prove that the styles of that element would remain unchanged despite