mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
style: Store values for :nth- selectors in dedicated struct NthSelectorData
To accomplish this, all :nth- Components were replaced with type Nth, which uses NthSelectorData. Using NthSelectorData will make it easier to add selector lists for :nth selectors later on, but this change by itself shouldn't change any behavior. Differential Revision: https://phabricator.services.mozilla.com/D165831
This commit is contained in:
parent
b373d9c1c4
commit
281ae0748f
5 changed files with 49 additions and 49 deletions
|
@ -8,7 +8,7 @@ use crate::attr::{
|
|||
};
|
||||
use crate::bloom::{BloomFilter, BLOOM_HASH_MASK};
|
||||
use crate::nth_index_cache::NthIndexCacheInner;
|
||||
use crate::parser::{AncestorHashes, Combinator, Component, LocalName};
|
||||
use crate::parser::{AncestorHashes, Combinator, Component, LocalName, NthType};
|
||||
use crate::parser::{NonTSPseudoClass, Selector, SelectorImpl, SelectorIter, SelectorList};
|
||||
use crate::tree::Element;
|
||||
use bitflags::bitflags;
|
||||
|
@ -391,10 +391,7 @@ fn hover_and_active_quirk_applies<Impl: SelectorImpl>(
|
|||
Component::LastChild |
|
||||
Component::OnlyChild |
|
||||
Component::Empty |
|
||||
Component::NthChild(_, _) |
|
||||
Component::NthLastChild(_, _) |
|
||||
Component::NthOfType(_, _) |
|
||||
Component::NthLastOfType(_, _) |
|
||||
Component::Nth(_) |
|
||||
Component::FirstOfType |
|
||||
Component::LastOfType |
|
||||
Component::OnlyOfType => false,
|
||||
|
@ -815,18 +812,14 @@ where
|
|||
Some(ref scope_element) => element.opaque() == *scope_element,
|
||||
None => element.is_root(),
|
||||
},
|
||||
Component::NthChild(a, b) => {
|
||||
matches_generic_nth_child(element, context.shared, a, b, false, false)
|
||||
},
|
||||
Component::NthLastChild(a, b) => {
|
||||
matches_generic_nth_child(element, context.shared, a, b, false, true)
|
||||
},
|
||||
Component::NthOfType(a, b) => {
|
||||
matches_generic_nth_child(element, context.shared, a, b, true, false)
|
||||
},
|
||||
Component::NthLastOfType(a, b) => {
|
||||
matches_generic_nth_child(element, context.shared, a, b, true, true)
|
||||
},
|
||||
Component::Nth(nth_data) => matches_generic_nth_child(
|
||||
element,
|
||||
context.shared,
|
||||
nth_data.a,
|
||||
nth_data.b,
|
||||
nth_data.ty == NthType::OfType || nth_data.ty == NthType::LastOfType,
|
||||
nth_data.ty == NthType::LastChild || nth_data.ty == NthType::LastOfType,
|
||||
),
|
||||
Component::FirstOfType => {
|
||||
matches_generic_nth_child(element, context.shared, 0, 1, true, false)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue