Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::css::ComplexSelector Struct Reference

A complex selector is a sequence of one or more compound selectors, separated by combinators. More...

#include "donner/css/selectors/ComplexSelector.h"

Collaboration diagram for donner::css::ComplexSelector:
[legend]

Classes

struct  Entry
 A single entry in a complex selector, which is a compound selector and a combinator. More...
 

Public Member Functions

bool isValid () const
 Return true if this selector is valid and supported by this implementation.
 
Specificity::ABC computeSpecificity () const
 Compute specificity of the ComplexSelector, see https://www.w3.org/TR/selectors-4/#specificity-rules.
 
template<ElementLike T>
SelectorMatchResult matches (const T &targetElement, const SelectorMatchOptions< T > &options) const
 Match a selector against an element, following the rules in the spec: https://www.w3.org/TR/selectors-4/#match-against-element.
 

Public Attributes

std::vector< Entryentries
 The entries in the complex selector.
 

Friends

std::ostream & operator<< (std::ostream &os, const ComplexSelector &obj)
 Ostream output operator for ComplexSelector, outputs debug strings e.g. "ComplexSelector(CompoundSelector(TypeSelector(name)))".
 

Detailed Description

A complex selector is a sequence of one or more compound selectors, separated by combinators.

For example, div > #foo is a complex selector, with two compound selectors separated by a Combinator::Child.


Class Documentation

◆ donner::css::ComplexSelector::Entry

struct donner::css::ComplexSelector::Entry

A single entry in a complex selector, which is a compound selector and a combinator.

Collaboration diagram for donner::css::ComplexSelector::Entry:
[legend]
Class Members
Combinator combinator The combinator between this compound selector and the next. For regular selector lists, the first entry is set to Combinator::Descendant but it has no effect. For relative selector lists, the first entry is the leading combinator, for example "> div".
CompoundSelector compoundSelector The compound selector.

Member Function Documentation

◆ isValid()

bool donner::css::ComplexSelector::isValid ( ) const

Return true if this selector is valid and supported by this implementation.

See also
https://www.w3.org/TR/selectors-4/#invalid

◆ matches()

template<ElementLike T>
SelectorMatchResult donner::css::ComplexSelector::matches ( const T & targetElement,
const SelectorMatchOptions< T > & options ) const
inline

Match a selector against an element, following the rules in the spec: https://www.w3.org/TR/selectors-4/#match-against-element.

Template Parameters
TA type that fulfills the ElementLike concept, to enable traversing the tree to match the selector.
Parameters
targetElementElement to match against.
optionsOptions to control matching.
Returns
true if the element matches the selector, within a SelectorMatchResult which also contains the specificity.

The documentation for this struct was generated from the following files: