diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-05-09 09:32:28 +0000 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-11-21 15:36:35 +0100 |
commit | 9ac97dd8ad05f6f325152a0be22b5d62ec02d778 (patch) | |
tree | 871c8d5db1b23a49ea5dcfa56cdcf7c843fc1448 /components/style/selector_map.rs | |
parent | 303ea410e20a029e55427af11d28f770d982f5ee (diff) | |
download | servo-9ac97dd8ad05f6f325152a0be22b5d62ec02d778.tar.gz servo-9ac97dd8ad05f6f325152a0be22b5d62ec02d778.zip |
style: when iterating over a selector to find a bucket, choose the rightmost
This restores the pre-regression behavior by choosing the later class in
cases where folks use stuff like `.foo.bar`.
This matches other browsers too.
Differential Revision: https://phabricator.services.mozilla.com/D177398
Diffstat (limited to 'components/style/selector_map.rs')
-rw-r--r-- | components/style/selector_map.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index 3b7515292bf..732168cbfd8 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -685,6 +685,11 @@ impl<'a> Bucket<'a> { } #[inline] + fn more_or_equally_specific_than(&self, other: &Self) -> bool { + self.specificity() >= other.specificity() + } + + #[inline] fn more_specific_than(&self, other: &Self) -> bool { self.specificity() > other.specificity() } @@ -787,7 +792,9 @@ fn find_bucket<'a>( loop { for ss in &mut iter { let new_bucket = specific_bucket_for(ss, disjoint_buckets, bucket_attributes); - if new_bucket.more_specific_than(¤t_bucket) { + // NOTE: When presented with the choice of multiple specific selectors, use the + // rightmost, on the assumption that that's less common, see bug 1829540. + if new_bucket.more_or_equally_specific_than(¤t_bucket) { current_bucket = new_bucket; } } |