Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::components::SelectorDependencySummary Class Reference

For every id, class and attribute local name that appears in a stylesheet's selectors, the relations whose selector matching a change to that name can affect, plus the selector features that make a change reach further than names can express. More...

#include "donner/svg/components/style/SelectorDependencySummary.h"

Classes

struct  Entry
 One name and the relations a change to it can affect. More...

Public Member Functions

 SelectorDependencySummary ()=default
 A summary of no selectors.
 SelectorDependencySummary (std::span< const css::Stylesheet *const > sheets)
 Summarize every selector of sheets.
std::uint8_t idDependency (std::string_view id) const
 Relations an id change on an element can affect, compared exactly; 0 if no selector names it.
std::uint8_t classDependency (std::string_view className) const
 Relations a class change can affect, compared exactly; 0 if no selector names the class.
std::uint8_t attributeDependency (std::string_view localName) const
 Relations a write of the attribute localName can affect, compared ASCII-case-insensitively; every relation when a selector uses a wildcard attribute name.
bool usesAttribute (std::string_view localName) const
 Whether some attribute selector names localName, or any name, so a write of that attribute can change selector matching.
bool usesHas () const
 Whether a selector uses :has(), which makes an element's match depend on its descendants.
bool usesStructuralPseudoClass () const
 Whether a selector uses a structural pseudo-class (:nth-*, :first-*, :last-*, :only-* or :empty).
bool usesAnyAttributeName () const
 Whether an attribute selector uses a wildcard local name, so any attribute write can change matching. No CSS syntax produces this today; it is a fail-safe.
bool dependsOnTextContent () const
 Whether a selector can change matching after a text edit (:empty, anywhere).
std::size_t retainedBytes () const
 Bytes the summary retains: vector capacities plus the text of lowercased attribute names.

Friends

class SelectorDependencyBuilder

Detailed Description

For every id, class and attribute local name that appears in a stylesheet's selectors, the relations whose selector matching a change to that name can affect, plus the selector features that make a change reach further than names can express.

A name in a subject (rightmost) compound affects the element itself; one left of a descendant or child combinator affects descendants; one left of a sibling combinator affects following siblings and their subtrees. A name inside :is(), :where(), :not() or another pseudo-class argument takes the relations of the compound holding the pseudo-class, widened by any combinator inside the argument. A name inside the of S filter of :nth-child() affects following siblings, and inside that of :nth-last-child() preceding siblings, because the filter counts the matching siblings before or after the subject; when the pseudo-class's compound already reaches siblings (left of a sibling combinator, here or in an enclosing selector), both directions. A name inside :has() affects ancestors and preceding siblings as well.

Built once per parsed stylesheet, from the sheet's own rules and its imports. Names are local: attribute namespaces are ignored, which over-approximates [ns|name] to [name].


Class Documentation

◆ donner::svg::components::SelectorDependencySummary::Entry

struct donner::svg::components::SelectorDependencySummary::Entry

One name and the relations a change to it can affect.

Class Members
RcString name The name; lowercased for attributes.
uint8_t relations SelectorDependency::Bits.

Constructor & Destructor Documentation

◆ SelectorDependencySummary()

donner::svg::components::SelectorDependencySummary::SelectorDependencySummary ( std::span< const css::Stylesheet *const > sheets)
explicit

Summarize every selector of sheets.

Parameters
sheetsStylesheets whose rules are summarized together.

The documentation for this class was generated from the following file: