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

A top-level Selector, which is a list of ComplexSelector. More...

#include "donner/css/Selector.h"

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

Public Member Functions

 Selector ()
 Constructor.
 
 ~Selector () noexcept
 Destructor.
 
 Selector (Selector &&) noexcept
 Move constructor.
 
Selectoroperator= (Selector &&) noexcept
 Move assignment operator.
 
 Selector (const Selector &)
 Copy constructor.
 
Selectoroperator= (const Selector &)
 Copy assignment operator.
 
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< ComplexSelectorentries
 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).
 

Detailed Description

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.

Member Function Documentation

◆ matches()

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

Match an element against a Selector.

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 any ComplexSelector in the Selector matches the given element.

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