Struct selectors::matching::SelectorMap [] [src]

pub struct SelectorMap<T, Impl: SelectorImpl> {
    // some fields omitted
}

Map element data to Rules whose last simple selector starts with them.

e.g., "p > img" would go into the set of Rules corresponding to the element "img" "a .foo .bar.baz" would go into the set of Rules corresponding to the class "bar"

Because we match Rules right-to-left (i.e., moving up the tree from an element), we need to compare the last simple selector in the Rule with the element.

So, if an element has ID "id1" and classes "foo" and "bar", then all the rules it matches will have their last simple selector starting either with "#id1" or with ".foo" or with ".bar".

Hence, the union of the rules keyed on each of element's classes, ID, element name, etc. will contain the Rules that actually match that element.

Methods

impl<T, Impl: SelectorImpl> SelectorMap<T, Impl>
[src]

fn new() -> SelectorMap<T, Impl>

fn get_all_matching_rules<E, V>(&self, element: &E, parent_bf: Option<&BloomFilter>, matching_rules_list: &mut V, shareable: &mut bool) where E: Element<Impl=Impl, AttrString=Impl::AttrString>, V: VecLike<DeclarationBlock<T>>

Append to rule_list all Rules in self that match element.

Extract matching rules as per element's ID, classes, tag name, etc.. Sort the Rules at the end to maintain cascading order.

fn get_universal_rules<V>(&self, matching_rules_list: &mut V) where V: VecLike<DeclarationBlock<T>>

Append to rule_list all universal Rules (rules with selector *|*) in self sorted by specifity and source order.

fn insert(&mut self, rule: Rule<T, Impl>)

Insert rule into the correct hash. Order in which to try: id_hash, class_hash, local_name_hash, other_rules.