mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Implement XUL tree pseudo style resolution for stylo.
This commit is contained in:
parent
915890af77
commit
2dc714f0ac
9 changed files with 172 additions and 10 deletions
|
@ -109,6 +109,10 @@ where
|
|||
/// The current nesting level of selectors that we're matching.
|
||||
pub nesting_level: usize,
|
||||
|
||||
/// An optional hook function for checking whether a pseudo-element
|
||||
/// should match when matching_mode is ForStatelessPseudoElement.
|
||||
pub pseudo_element_matching_fn: Option<&'a Fn(&Impl::PseudoElement) -> bool>,
|
||||
|
||||
quirks_mode: QuirksMode,
|
||||
classes_and_ids_case_sensitivity: CaseSensitivity,
|
||||
_impl: ::std::marker::PhantomData<Impl>,
|
||||
|
@ -152,6 +156,7 @@ where
|
|||
classes_and_ids_case_sensitivity: quirks_mode.classes_and_ids_case_sensitivity(),
|
||||
scope_element: None,
|
||||
nesting_level: 0,
|
||||
pseudo_element_matching_fn: None,
|
||||
_impl: ::std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,9 +387,20 @@ where
|
|||
if context.nesting_level == 0 &&
|
||||
context.matching_mode == MatchingMode::ForStatelessPseudoElement {
|
||||
// Consume the pseudo.
|
||||
let pseudo = iter.next().unwrap();
|
||||
debug_assert!(matches!(*pseudo, Component::PseudoElement(..)),
|
||||
"Used MatchingMode::ForStatelessPseudoElement in a non-pseudo selector");
|
||||
match *iter.next().unwrap() {
|
||||
Component::PseudoElement(ref pseudo) => {
|
||||
if let Some(ref f) = context.pseudo_element_matching_fn {
|
||||
if !f(pseudo) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
debug_assert!(false,
|
||||
"Used MatchingMode::ForStatelessPseudoElement \
|
||||
in a non-pseudo selector");
|
||||
}
|
||||
}
|
||||
|
||||
// The only other parser-allowed Component in this sequence is a state
|
||||
// class. We just don't match in that case.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue