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:
Emilio Cobos Álvarez 2017-10-18 09:13:00 +02:00
parent 4cf2ce66fc
commit b0e54968ec
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
9 changed files with 121 additions and 85 deletions

View file

@ -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,
}
}