mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Make MatchingContext generic over SelectorImpl.
This will help Xidorn implement tree pseudos, and in general makes sense, allowing to put specific matching data in a selectors implementation.
This commit is contained in:
parent
4cf2ce66fc
commit
b0e54968ec
9 changed files with 121 additions and 85 deletions
|
@ -5,6 +5,7 @@
|
|||
use attr::CaseSensitivity;
|
||||
use bloom::BloomFilter;
|
||||
use nth_index_cache::NthIndexCache;
|
||||
use parser::SelectorImpl;
|
||||
use tree::OpaqueElement;
|
||||
|
||||
/// What kind of selector matching mode we should use.
|
||||
|
@ -74,7 +75,10 @@ impl QuirksMode {
|
|||
/// Data associated with the matching process for a element. This context is
|
||||
/// used across many selectors for an element, so it's not appropriate for
|
||||
/// transient data that applies to only a single selector.
|
||||
pub struct MatchingContext<'a> {
|
||||
pub struct MatchingContext<'a, Impl>
|
||||
where
|
||||
Impl: SelectorImpl,
|
||||
{
|
||||
/// Input with the matching mode we should use when matching selectors.
|
||||
pub matching_mode: MatchingMode,
|
||||
/// Input with the bloom filter used to fast-reject selectors.
|
||||
|
@ -107,9 +111,13 @@ pub struct MatchingContext<'a> {
|
|||
|
||||
quirks_mode: QuirksMode,
|
||||
classes_and_ids_case_sensitivity: CaseSensitivity,
|
||||
_impl: ::std::marker::PhantomData<Impl>,
|
||||
}
|
||||
|
||||
impl<'a> MatchingContext<'a> {
|
||||
impl<'a, Impl> MatchingContext<'a, Impl>
|
||||
where
|
||||
Impl: SelectorImpl,
|
||||
{
|
||||
/// Constructs a new `MatchingContext`.
|
||||
pub fn new(
|
||||
matching_mode: MatchingMode,
|
||||
|
@ -144,6 +152,7 @@ impl<'a> MatchingContext<'a> {
|
|||
classes_and_ids_case_sensitivity: quirks_mode.classes_and_ids_case_sensitivity(),
|
||||
scope_element: None,
|
||||
nesting_level: 0,
|
||||
_impl: ::std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue