Candidate rules of one stylesheet, bucketed by a key of each selector-list entry's subject compound.
More...
|
|
| RuleIndex ()=default |
| | An empty index, for a stylesheet with no rules.
|
| | RuleIndex (std::span< const css::SelectorRule > rules) |
| | Build the index of rules.
|
| std::span< const AncestorHashGroup > | ancestorHashes (std::uint32_t rule) const |
| | The ancestor hash groups of the rule at rule, one per selector-list entry, or none when some entry has no ancestor key.
|
|
css::Specificity::ABC | specificity (std::uint32_t rule, std::size_t entry) const |
| | Specificity captured for one selector-list entry of the stylesheet used to build this index.
|
| template<RuleIndexElement Element> |
| std::size_t | collectCandidates (const Element &element, std::vector< std::uint32_t > &candidates) const |
| | Replace candidates with the positions of the rules that can match element, ascending and without duplicates.
|
|
bool | shallowForParallelCascade () const |
| | Whether every rule stays within the recursive CSS depth supported by scheduled style tasks.
|
|
std::size_t | ruleCount () const |
| | Number of rules the index was built from.
|
|
std::size_t | entryCount () const |
| | Number of filed entries: one per selector-list entry, less entries of one rule with the same key.
|
|
std::size_t | retainedBytes () const |
| | Bytes the index retains: vector capacities, plus the text of type and attribute keys, which may be lowercased copies.
|
|
| static RuleIndexKey | KeyFor (const css::ComplexSelector &selector) |
| | The key one selector-list entry is filed under: the subject compound's id, else a class, else an attribute local name without a namespace, else a non-universal type name.
|
| static BloomHash | AncestorKeyHash (RuleIndexKey::Kind kind, std::string_view name) |
| | The ancestor-filter hash of a key, as StyleAncestorFilter inserts it for an ancestor and ancestorHashes records it for a selector.
|
| static SmallVector< std::uint32_t, 4 > | AncestorHashesFor (const css::ComplexSelector &selector) |
| | Up to four keys that every element selector matches must have among its ancestors, as AncestorKeyHash values: from the compounds reached from the subject through descendant and child combinators, stopping at the first sibling combinator (compounds beyond it are siblings of an ancestor), taking ids, then classes, then attribute local names without a namespace, then non-universal type names.
|
|
static bool | IsDeclarationShallowForParallelCascade (const css::Declaration &declaration) |
| | Whether a declaration's component tree stays within the scheduled style depth limit.
|
Candidate rules of one stylesheet, bucketed by a key of each selector-list entry's subject compound.
Every key is a necessary condition for its entry to match, so the candidates of an element include every rule that can match it; the matcher still tests each candidate in full.
Built once per parsed stylesheet. It stores rule positions, not pointers, so it stays valid while the stylesheet it was built from is unchanged and must be rebuilt when it changes.
Up to four keys that every element selector matches must have among its ancestors, as AncestorKeyHash values: from the compounds reached from the subject through descendant and child combinators, stopping at the first sibling combinator (compounds beyond it are siblings of an ancestor), taking ids, then classes, then attribute local names without a namespace, then non-universal type names.
Simple selectors inside pseudo-class arguments are never used, because :not() inverts them and :is() lists alternatives.
- Parameters
-
| selector | One entry of a rule's selector list. |
- Returns
- The distinct hashes, at most four; empty when no ancestor compound has such a key.
template<RuleIndexElement Element>
| std::size_t donner::svg::components::RuleIndex::collectCandidates |
( |
const Element & | element, |
|
|
std::vector< std::uint32_t > & | candidates ) const |
|
inline |
Replace candidates with the positions of the rules that can match element, ascending and without duplicates.
Each bucket is gathered at most once per element, however often the element names its key: a repeated class token, or attribute names that differ only in case. Every filed entry sits in exactly one bucket or the universal span, so at most entryCount positions are gathered before duplicates are removed, and candidates never grows past that. The remaining work is one lookup per key the element carries, which is linear in the element's own source.
- Parameters
-
| element | The element, read only for the key kinds this index has. |
| candidates | Receives the rule positions; its capacity is reused. |
- Returns
- Rule positions gathered before duplicates were removed, at most entryCount.