class EE::UI::CSS::StyleSheetSelectorRule

Overview

#include <stylesheetselectorrule.hpp>

class StyleSheetSelectorRule {
public:
    // enums

    enum AttributeOperator;
    enum PatternMatch;
    enum PseudoClasses;
    enum SelectorType;
    enum SpecificityVal;
    enum TypeIdentifier;

    // structs

    struct AttributeSelector;

    // fields

    static constexpr auto PseudoClassesTotal = 8;

    // construction

    StyleSheetSelectorRule(const std::string& selectorFragment, PatternMatch mPatternMatch);

    // methods

    static AttributeOperator attributeOperatorFromString(const std::string& op);
    static std::string attributeOperatorToString(AttributeOperator op);
    static PseudoClasses toPseudoClass(std::string_view cls);
    static std::vector<const char*> fromPseudoClass(Uint32 cls);
    void pushSelectorTypeIdentifier(TypeIdentifier selectorTypeIdentifier, std::string name);
    void parseFragment(const std::string& selectorFragment);
    const PatternMatch& getPatternMatch() const;
    const Int64& getSpecificity() const;
    bool matches(UIWidget* element, const bool& applyPseudo = true) const;
    bool hasClass(const std::string& cls) const;
    bool hasClasses() const;
    const std::vector<String::HashType>& getClassHashes() const;
    String::HashType getBestClassHash() const;
    bool hasPseudoClasses() const;
    bool hasPseudoClass(const std::string& cls) const;
    Uint32 getPseudoClasses() const;
    bool hasStructuralPseudoClasses() const;
    const std::vector<std::string>& getStructuralPseudoClasses() const;
    bool hasStructuralPseudoClass(const std::string& cls) const;
    const std::string& getTagName() const;
    const std::string& getId() const;
};

Detailed Documentation

Methods

bool hasClasses() const

Returns:

True when this rule requires at least one CSS class.

const std::vector<String::HashType>& getClassHashes() const

Returns:

Sorted unique hashes of every CSS class required by this rule.

String::HashType getBestClassHash() const

Returns:

The mandatory class used to place this rule in the stylesheet candidate index. Every matching element must have this class, but the full rule is still validated by matches(). The first sorted hash is used for now; a future implementation may choose the rarest class to reduce the candidate bucket further.