mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Bug 1340683 - stylo: Implement the :-moz-any pseudo-class
This commit is contained in:
parent
e34aac03ff
commit
2872c8bfab
10 changed files with 146 additions and 40 deletions
|
@ -269,14 +269,17 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
|||
impl<'a, E> Element for ElementWrapper<'a, E>
|
||||
where E: TElement,
|
||||
{
|
||||
fn match_non_ts_pseudo_class(&self, pseudo_class: &NonTSPseudoClass) -> bool {
|
||||
fn match_non_ts_pseudo_class(&self,
|
||||
pseudo_class: &NonTSPseudoClass,
|
||||
relations: &mut StyleRelations,
|
||||
flags: &mut ElementSelectorFlags) -> bool {
|
||||
let flag = SelectorImpl::pseudo_class_state_flag(pseudo_class);
|
||||
if flag == ElementState::empty() {
|
||||
self.element.match_non_ts_pseudo_class(pseudo_class)
|
||||
self.element.match_non_ts_pseudo_class(pseudo_class, relations, flags)
|
||||
} else {
|
||||
match self.snapshot.and_then(|s| s.state()) {
|
||||
Some(snapshot_state) => snapshot_state.contains(flag),
|
||||
_ => self.element.match_non_ts_pseudo_class(pseudo_class)
|
||||
_ => self.element.match_non_ts_pseudo_class(pseudo_class, relations, flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +350,13 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the union of any `ElementState` flags for components of a `ComplexSelector`
|
||||
pub fn complex_selector_to_state(sel: &ComplexSelector<SelectorImpl>) -> ElementState {
|
||||
sel.compound_selector.iter().fold(ElementState::empty(), |state, s| {
|
||||
state | selector_to_state(s)
|
||||
})
|
||||
}
|
||||
|
||||
fn selector_to_state(sel: &SimpleSelector<SelectorImpl>) -> ElementState {
|
||||
match *sel {
|
||||
SimpleSelector::NonTSPseudoClass(ref pc) => SelectorImpl::pseudo_class_state_flag(pc),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue