mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
stylo: Support :hover and :active quirk
This commit is contained in:
parent
ff17af064b
commit
15fe48f3f6
15 changed files with 229 additions and 73 deletions
|
@ -103,6 +103,10 @@ macro_rules! with_all_bounds {
|
|||
|
||||
/// pseudo-elements
|
||||
type PseudoElement: $($CommonBounds)* + PseudoElement<Impl = Self>;
|
||||
|
||||
/// Returns whether the given pseudo class is :active or :hover.
|
||||
#[inline]
|
||||
fn is_active_or_hover(pseudo_class: &Self::NonTSPseudoClass) -> bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +431,7 @@ impl<Impl: SelectorImpl> Selector<Impl> {
|
|||
|
||||
pub fn iter_from(&self, offset: usize) -> SelectorIter<Impl> {
|
||||
// Note: selectors are stored left-to-right but logical order is right-to-left.
|
||||
let iter = self.0.slice[..(self.0.slice.len() - offset)].iter().rev();
|
||||
let iter = self.0.slice[..(self.len() - offset)].iter().rev();
|
||||
SelectorIter {
|
||||
iter: iter,
|
||||
next_combinator: None,
|
||||
|
@ -451,6 +455,11 @@ impl<Impl: SelectorImpl> Selector<Impl> {
|
|||
let header = HeaderWithLength::new(SpecificityAndFlags(specificity_and_flags), vec.len());
|
||||
Selector(Arc::into_thin(Arc::from_header_and_iter(header, vec.into_iter())))
|
||||
}
|
||||
|
||||
/// Returns count of simple selectors and combinators in the Selector.
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.slice.len()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -465,6 +474,11 @@ impl<'a, Impl: 'a + SelectorImpl> SelectorIter<'a, Impl> {
|
|||
pub fn next_sequence(&mut self) -> Option<Combinator> {
|
||||
self.next_combinator.take()
|
||||
}
|
||||
|
||||
/// Returns remaining count of the simple selectors and combinators in the Selector.
|
||||
pub fn selector_length(&self) -> usize {
|
||||
self.iter.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Impl: SelectorImpl> Iterator for SelectorIter<'a, Impl> {
|
||||
|
@ -1711,6 +1725,12 @@ pub mod tests {
|
|||
type BorrowedNamespaceUrl = DummyAtom;
|
||||
type NonTSPseudoClass = PseudoClass;
|
||||
type PseudoElement = PseudoElement;
|
||||
|
||||
#[inline]
|
||||
fn is_active_or_hover(pseudo_class: &Self::NonTSPseudoClass) -> bool {
|
||||
matches!(*pseudo_class, PseudoClass::Active |
|
||||
PseudoClass::Hover)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue