srctree

Robin Linden parent 1765412b 5c0f31b5
style: Rename matching_rules to matching_properties

inlinesplit
style/style.cpp added: 15, removed: 15, total 0
@@ -149,9 +149,9 @@ bool is_match(style::StyledNode const &node, std::string_view selector) {
return false;
}
 
std::vector<std::pair<css::PropertyId, std::string>> matching_rules(
std::vector<std::pair<css::PropertyId, std::string>> matching_properties(
style::StyledNode const &node, css::StyleSheet const &stylesheet, css::MediaQuery::Context const &ctx) {
std::vector<std::pair<css::PropertyId, std::string>> matched_rules;
std::vector<std::pair<css::PropertyId, std::string>> matched_properties;
 
for (auto const &rule : stylesheet.rules) {
if (rule.media_query.has_value() && !rule.media_query->evaluate(ctx)) {
@@ -159,7 +159,7 @@ std::vector<std::pair<css::PropertyId, std::string>> matching_rules(
}
 
if (std::ranges::any_of(rule.selectors, [&](auto const &selector) { return is_match(node, selector); })) {
std::ranges::copy(rule.declarations, std::back_inserter(matched_rules));
std::ranges::copy(rule.declarations, std::back_inserter(matched_properties));
}
}
 
@@ -172,7 +172,7 @@ std::vector<std::pair<css::PropertyId, std::string>> matching_rules(
// The above should always parse to 1 rule when using the old parser.
assert(element_style.size() == 1);
if (element_style.size() == 1) {
std::ranges::copy(element_style[0].declarations, std::back_inserter(matched_rules));
std::ranges::copy(element_style[0].declarations, std::back_inserter(matched_properties));
}
}
}
@@ -185,11 +185,11 @@ std::vector<std::pair<css::PropertyId, std::string>> matching_rules(
}
 
if (std::ranges::any_of(rule.selectors, [&](auto const &selector) { return is_match(node, selector); })) {
std::ranges::copy(rule.important_declarations, std::back_inserter(matched_rules));
std::ranges::copy(rule.important_declarations, std::back_inserter(matched_properties));
}
}
 
return matched_rules;
return matched_properties;
}
 
namespace {
@@ -211,7 +211,7 @@ void style_tree_impl(StyledNode &current,
style_tree_impl(child_node, child, stylesheet, ctx);
}
 
current.properties = matching_rules(current, stylesheet, ctx);
current.properties = matching_properties(current, stylesheet, ctx);
}
} // namespace
 
 
style/style.h added: 15, removed: 15, total 0
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -21,11 +21,11 @@ namespace style {
 
bool is_match(StyledNode const &, std::string_view selector);
 
std::vector<std::pair<css::PropertyId, std::string>> matching_rules(
StyledNode const &, css::StyleSheet const &stylesheet, css::MediaQuery::Context const &);
std::vector<std::pair<css::PropertyId, std::string>> matching_properties(
StyledNode const &, css::StyleSheet const &, css::MediaQuery::Context const &);
 
std::unique_ptr<StyledNode> style_tree(
dom::Node const &root, css::StyleSheet const &stylesheet, css::MediaQuery::Context const & = {});
dom::Node const &root, css::StyleSheet const &, css::MediaQuery::Context const & = {});
 
} // namespace style
 
 
style/style_test.cpp added: 15, removed: 15, total 0
@@ -33,7 +33,7 @@ bool is_match(dom::Element const &e, std::string_view selector) {
 
std::vector<std::pair<css::PropertyId, std::string>> matching_rules(
dom::Element const &element, css::StyleSheet const &stylesheet, css::MediaQuery::Context const &context = {}) {
return matching_rules(style::StyledNode{element}, stylesheet, context);
return matching_properties(style::StyledNode{element}, stylesheet, context);
}
 
bool check_parents(style::StyledNode const &a, style::StyledNode const &b) {