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 @@ -684,6 +684,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; } }