mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
style: Implement selector matching for :nth-child(An+B of selector list) and :nth-last-child(An+B of selector list)
Since we have been using a single hash map to cache all :nth-child indices (with no selector list), each different selector will need its own cache. As a side note, this patch does not address invalidation. Differential Revision: https://phabricator.services.mozilla.com/D166266
This commit is contained in:
parent
a973371cf2
commit
3076481c52
8 changed files with 223 additions and 71 deletions
|
@ -1125,6 +1125,7 @@ impl Stylist {
|
|||
{
|
||||
debug_assert!(pseudo.is_lazy());
|
||||
|
||||
let mut nth_index_cache = Default::default();
|
||||
// No need to bother setting the selector flags when we're computing
|
||||
// default styles.
|
||||
let needs_selector_flags = if rule_inclusion == RuleInclusion::DefaultOnly {
|
||||
|
@ -1137,7 +1138,7 @@ impl Stylist {
|
|||
let mut matching_context = MatchingContext::<'_, E::Impl>::new(
|
||||
MatchingMode::ForStatelessPseudoElement,
|
||||
None,
|
||||
None,
|
||||
&mut nth_index_cache,
|
||||
self.quirks_mode,
|
||||
needs_selector_flags,
|
||||
);
|
||||
|
@ -1166,10 +1167,12 @@ impl Stylist {
|
|||
let mut visited_rules = None;
|
||||
if parent_style.visited_style().is_some() {
|
||||
let mut declarations = ApplicableDeclarationList::new();
|
||||
let mut nth_index_cache = Default::default();
|
||||
|
||||
let mut matching_context = MatchingContext::<'_, E::Impl>::new_for_visited(
|
||||
MatchingMode::ForStatelessPseudoElement,
|
||||
None,
|
||||
None,
|
||||
&mut nth_index_cache,
|
||||
VisitedHandlingMode::RelevantLinkVisited,
|
||||
self.quirks_mode,
|
||||
needs_selector_flags,
|
||||
|
@ -1417,7 +1420,7 @@ impl Stylist {
|
|||
let mut matching_context = MatchingContext::new(
|
||||
MatchingMode::Normal,
|
||||
bloom,
|
||||
Some(nth_index_cache),
|
||||
nth_index_cache,
|
||||
self.quirks_mode,
|
||||
needs_selector_flags,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue