|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
A top-level Selector, which is a list of ComplexSelector. More...
#include "donner/css/Selector.h"
Public Member Functions | |
| Selector () | |
| Constructor. | |
| ~Selector () noexcept | |
| Destructor. | |
| Selector (Selector &&) noexcept | |
| Move constructor. | |
| Selector & | operator= (Selector &&) noexcept |
| Move assignment operator. | |
| Selector (const Selector &) | |
| Copy constructor. | |
| Selector & | operator= (const Selector &) |
| Copy assignment operator. | |
| void | collectAttributeSelectorNames (std::vector< RcString > &outNames, bool &outMatchesAnyName) const |
| Collect the attribute names referenced by every attribute selector in this selector. | |
| Specificity::ABC | maxSpecificity () const |
| Get the max specificity of all ComplexSelectors in the Selector. | |
| template<ElementLike T> | |
| SelectorMatchResult | matches (const T &targetElement, const SelectorMatchOptions< T > &options=SelectorMatchOptions< T >()) const |
| Match an element against a Selector. | |
Public Attributes | |
| std::vector< ComplexSelector > | entries |
| The list of ComplexSelector entries that compose this selector. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Selector &obj) |
| Ostream output operator for Selector, prints a debug representation of the selector, e.g. Selector(div, .class, #id). | |
A top-level Selector, which is a list of ComplexSelector.
This represents the prelude in front of any CSS rule, e.g. div.foo > span#bar, which would be a single ComplexSelector. For a comma-separated list, such as div.foo > span#bar, span#bar, this would be a Selector with two ComplexSelector entries.
| void donner::css::Selector::collectAttributeSelectorNames | ( | std::vector< RcString > & | outNames, |
| bool & | outMatchesAnyName ) const |
Collect the attribute names referenced by every attribute selector in this selector.
Recurses into functional pseudo-classes that carry their own selector list, such as :is(), :not(), :has() and :nth-child(An+B of S), so a nested [attr] is not missed.
Namespaces are ignored: only the local name is collected, which over-approximates [ns|attr] to [attr]. Callers use this to decide whether writing an attribute can change selector matching, where over-approximating is the safe direction.
| outNames | Receives each distinct local name found, appended to any existing contents. |
| outMatchesAnyName | Set to true if a selector uses a wildcard local name, meaning any attribute write can change matching. No CSS syntax produces this today; it is a fail-safe. |
|
inline |
Match an element against a Selector.
| T | A type that fulfills the ElementLike concept, to enable traversing the tree to match the selector. |
| targetElement | Element to match against. |
| options | Options to control matching. |