mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Introduce an NthIndexCache type and pipe it from ThreadLocalStyleContext to MatchingContext.
Some future refactoring here to pass fewer things as parameters would be nice.
This commit is contained in:
parent
05c03d5104
commit
48466bf876
11 changed files with 83 additions and 24 deletions
|
@ -724,26 +724,26 @@ fn matches_simple_selector<E, F>(
|
|||
element.is_empty()
|
||||
}
|
||||
Component::NthChild(a, b) => {
|
||||
matches_generic_nth_child(element, a, b, false, false, flags_setter)
|
||||
matches_generic_nth_child(element, context, a, b, false, false, flags_setter)
|
||||
}
|
||||
Component::NthLastChild(a, b) => {
|
||||
matches_generic_nth_child(element, a, b, false, true, flags_setter)
|
||||
matches_generic_nth_child(element, context, a, b, false, true, flags_setter)
|
||||
}
|
||||
Component::NthOfType(a, b) => {
|
||||
matches_generic_nth_child(element, a, b, true, false, flags_setter)
|
||||
matches_generic_nth_child(element, context, a, b, true, false, flags_setter)
|
||||
}
|
||||
Component::NthLastOfType(a, b) => {
|
||||
matches_generic_nth_child(element, a, b, true, true, flags_setter)
|
||||
matches_generic_nth_child(element, context, a, b, true, true, flags_setter)
|
||||
}
|
||||
Component::FirstOfType => {
|
||||
matches_generic_nth_child(element, 0, 1, true, false, flags_setter)
|
||||
matches_generic_nth_child(element, context, 0, 1, true, false, flags_setter)
|
||||
}
|
||||
Component::LastOfType => {
|
||||
matches_generic_nth_child(element, 0, 1, true, true, flags_setter)
|
||||
matches_generic_nth_child(element, context, 0, 1, true, true, flags_setter)
|
||||
}
|
||||
Component::OnlyOfType => {
|
||||
matches_generic_nth_child(element, 0, 1, true, false, flags_setter) &&
|
||||
matches_generic_nth_child(element, 0, 1, true, true, flags_setter)
|
||||
matches_generic_nth_child(element, context, 0, 1, true, false, flags_setter) &&
|
||||
matches_generic_nth_child(element, context, 0, 1, true, true, flags_setter)
|
||||
}
|
||||
Component::Negation(ref negated) => {
|
||||
context.nesting_level += 1;
|
||||
|
@ -767,6 +767,7 @@ fn select_name<'a, T>(is_html: bool, local_name: &'a T, local_name_lower: &'a T)
|
|||
|
||||
#[inline]
|
||||
fn matches_generic_nth_child<E, F>(element: &E,
|
||||
context: &mut LocalMatchingContext<E::Impl>,
|
||||
a: i32,
|
||||
b: i32,
|
||||
is_of_type: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue