42 if (classes != o.classes)
43 return classes < o.classes;
49 return ids == o.ids && classes == o.classes && tags == o.tags;
60 if (item.kind == SimpleSelector::Kind::Id)
62 else if (item.kind == SimpleSelector::Kind::Class)
64 else if (item.kind == SimpleSelector::Kind::Tag)
67 for (
const auto &[kind, name] : item.extras)
70 if (kind == SimpleSelector::Kind::Id)
72 else if (kind == SimpleSelector::Kind::Class)
74 else if (kind == SimpleSelector::Kind::Tag)
78 if (item.requireHover)
80 if (item.requirePressed)
82 if (item.requireFocus)
84 if (item.requireDisabled)
86 if (item.requireChecked)
95 for (
const auto &sel : chain)
97 if (sel.kind == SimpleSelector::Kind::Id)
99 else if (sel.kind == SimpleSelector::Kind::Class)
101 else if (sel.kind == SimpleSelector::Kind::Tag)
104 for (
const auto &[kind, name] : sel.extras)
107 if (kind == SimpleSelector::Kind::Id)
109 else if (kind == SimpleSelector::Kind::Class)
111 else if (kind == SimpleSelector::Kind::Tag)
115 if (sel.requireHover)
117 if (sel.requirePressed)
119 if (sel.requireFocus)
121 if (sel.requireDisabled)
123 if (sel.requireChecked)
126 for (
const auto &neg : sel.negations)
129 for (
const auto &item : neg.items)
131 Specificity cur = computeNegatedItemSpecificity(item);
136 s.classes += best.classes;
149 std::vector<SimpleSelector> chain;
154 std::optional<MediaQuery> media;
172 bool operator==(
const SymbolKey &o)
const noexcept
174 return kind == o.kind && name == o.name;
181 size_t operator()(
const SymbolKey &k)
const noexcept
183 return std::hash<std::string>{}(k.name) ^
184 (
static_cast<size_t>(k.kind) * 0x9e3779b97f4a7c15ULL);
188 std::vector<ThemeRule> rules;
190 std::unordered_map<std::string, KeyframeAnimation> keyframes;
191 std::unordered_map<std::string, std::vector<size_t>> rulesByTag;
192 std::vector<size_t> rulesNoTag;
193 std::unordered_map<SymbolKey, std::vector<uint32_t>,
SymbolKeyHash> rulesByLastSymbol;
194 bool hasSiblingCombinators{
false};
203 r.order = (int)rules.size();
205 for (
size_t i = 1; i < r.chain.size(); ++i)
210 hasSiblingCombinators =
true;
215 if (r.part.empty() && !r.chain.empty())
217 const auto &back = r.chain.back();
218 if (back.kind == SimpleSelector::Kind::Tag)
219 rulesByTag[back.name].push_back((
size_t)r.order);
221 rulesNoTag.push_back((
size_t)r.order);
223 rulesByLastSymbol[
SymbolKey{back.kind, back.name}]
224 .push_back((uint32_t)r.order);
225 for (
const auto &[kind, name] : back.extras)
227 .push_back((uint32_t)r.order);
230 rules.push_back(std::move(r));
237 keyframes[anim.name] = anim;
249 rulesByLastSymbol.clear();
251 hasSiblingCombinators =
false;
Low-level animation types: imperative tracks, CSS keyframes, and the per-instance active animation st...
Centralized standard library includes used throughout ZenitUI.
The Style / ComputedStyle pair and all style-related value types.
Per-context stylesheet: rules, keyframes, and root style.
Definition Theme.hpp:164
void addRule(ThemeRule r)
Insert a rule into the theme.
Definition Theme.hpp:200
void addKeyframes(const KeyframeAnimation &anim)
Insert or replace a keyframe animation and bump the version.
Definition Theme.hpp:235
void clear()
Remove every rule, keyframe, and root declaration.
Definition Theme.hpp:242
Specificity computeSpecificity(const std::vector< SimpleSelector > &chain)
Compute the specificity of a full selector chain.
Definition Theme.hpp:92
@ GeneralSibling
A ~ B (any preceding sibling).
Definition Style.hpp:625
@ AdjacentSibling
A + B (immediately preceding sibling).
Definition Style.hpp:624
A named list of keyframes, keyed by name in Theme::keyframes.
Definition AnimPrimitives.hpp:115
Single compound argument inside a :not(...) pseudo-class.
Definition Style.hpp:643
Kind
Definition Style.hpp:634
CSS-style specificity triple used to sort matching rules.
Definition Theme.hpp:33
Sparse style: every property is Opt<T>, unset by default.
Definition Style.hpp:932
A single selector-plus-declarations entry in the stylesheet.
Definition Theme.hpp:148
Hash for SymbolKey.
Definition Theme.hpp:180
Key for rulesByLastSymbol: the last selector component.
Definition Theme.hpp:168