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

@ -1834,7 +1834,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
fn match_non_ts_pseudo_class<F>(
&self,
pseudo_class: &NonTSPseudoClass,
context: &mut MatchingContext,
context: &mut MatchingContext<Self::Impl>,
relevant_link: &RelevantLinkStatus,
flags_setter: &mut F,
) -> bool
@ -1975,7 +1975,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
fn match_pseudo_element(
&self,
pseudo_element: &PseudoElement,
_context: &mut MatchingContext
_context: &mut MatchingContext<Self::Impl>,
) -> bool {
// TODO(emilio): I believe we could assert we are a pseudo-element and
// match the proper pseudo-element, given how we rulehash the stuff

View file

@ -152,7 +152,7 @@ impl<'a, E> Element for ElementWrapper<'a, E>
fn match_non_ts_pseudo_class<F>(
&self,
pseudo_class: &NonTSPseudoClass,
context: &mut MatchingContext,
context: &mut MatchingContext<Self::Impl>,
relevant_link: &RelevantLinkStatus,
_setter: &mut F,
) -> bool
@ -258,7 +258,7 @@ impl<'a, E> Element for ElementWrapper<'a, E>
fn match_pseudo_element(
&self,
pseudo_element: &PseudoElement,
context: &mut MatchingContext,
context: &mut MatchingContext<Self::Impl>,
) -> bool {
self.element.match_pseudo_element(pseudo_element, context)
}

View file

@ -162,17 +162,20 @@ impl SelectorMap<Rule> {
///
/// Extract matching rules as per element's ID, classes, tag name, etc..
/// Sort the Rules at the end to maintain cascading order.
pub fn get_all_matching_rules<E, V, F>(&self,
element: &E,
rule_hash_target: &E,
matching_rules_list: &mut V,
context: &mut MatchingContext,
quirks_mode: QuirksMode,
flags_setter: &mut F,
cascade_level: CascadeLevel)
where E: TElement,
V: VecLike<ApplicableDeclarationBlock>,
F: FnMut(&E, ElementSelectorFlags),
pub fn get_all_matching_rules<E, V, F>(
&self,
element: &E,
rule_hash_target: &E,
matching_rules_list: &mut V,
context: &mut MatchingContext<E::Impl>,
quirks_mode: QuirksMode,
flags_setter: &mut F,
cascade_level: CascadeLevel,
)
where
E: TElement,
V: VecLike<ApplicableDeclarationBlock>,
F: FnMut(&E, ElementSelectorFlags),
{
if self.is_empty() {
return
@ -223,15 +226,18 @@ impl SelectorMap<Rule> {
}
/// Adds rules in `rules` that match `element` to the `matching_rules` list.
fn get_matching_rules<E, V, F>(element: &E,
rules: &[Rule],
matching_rules: &mut V,
context: &mut MatchingContext,
flags_setter: &mut F,
cascade_level: CascadeLevel)
where E: TElement,
V: VecLike<ApplicableDeclarationBlock>,
F: FnMut(&E, ElementSelectorFlags),
fn get_matching_rules<E, V, F>(
element: &E,
rules: &[Rule],
matching_rules: &mut V,
context: &mut MatchingContext<E::Impl>,
flags_setter: &mut F,
cascade_level: CascadeLevel,
)
where
E: TElement,
V: VecLike<ApplicableDeclarationBlock>,
F: FnMut(&E, ElementSelectorFlags),
{
for rule in rules {
if matches_selector(&rule.selector,

View file

@ -1198,7 +1198,7 @@ impl Stylist {
animation_rules: AnimationRules,
rule_inclusion: RuleInclusion,
applicable_declarations: &mut V,
context: &mut MatchingContext,
context: &mut MatchingContext<E::Impl>,
flags_setter: &mut F,
)
where