srctree

Robin Linden parent 5c0f31b5 824c04d2
style: Wrap matched properties in a struct

inlinesplit
style/style.cpp added: 12, removed: 9, total 3
@@ -149,7 +149,7 @@ bool is_match(style::StyledNode const &node, std::string_view selector) {
return false;
}
 
std::vector<std::pair<css::PropertyId, std::string>> matching_properties(
MatchingProperties matching_properties(
style::StyledNode const &node, css::StyleSheet const &stylesheet, css::MediaQuery::Context const &ctx) {
std::vector<std::pair<css::PropertyId, std::string>> matched_properties;
 
@@ -189,7 +189,7 @@ std::vector<std::pair<css::PropertyId, std::string>> matching_properties(
}
}
 
return matched_properties;
return {std::move(matched_properties)};
}
 
namespace {
@@ -211,7 +211,7 @@ void style_tree_impl(StyledNode &current,
style_tree_impl(child_node, child, stylesheet, ctx);
}
 
current.properties = matching_properties(current, stylesheet, ctx);
current.properties = matching_properties(current, stylesheet, ctx).normal;
}
} // namespace
 
 
style/style.h added: 12, removed: 9, total 3
@@ -21,8 +21,11 @@ namespace style {
 
bool is_match(StyledNode const &, std::string_view selector);
 
std::vector<std::pair<css::PropertyId, std::string>> matching_properties(
StyledNode const &, css::StyleSheet const &, css::MediaQuery::Context const &);
struct MatchingProperties {
std::vector<std::pair<css::PropertyId, std::string>> normal;
};
 
MatchingProperties matching_properties(StyledNode const &, css::StyleSheet const &, css::MediaQuery::Context const &);
 
std::unique_ptr<StyledNode> style_tree(
dom::Node const &root, css::StyleSheet const &, css::MediaQuery::Context const & = {});
 
style/style_test.cpp added: 12, removed: 9, total 3
@@ -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_properties(style::StyledNode{element}, stylesheet, context);
return matching_properties(style::StyledNode{element}, stylesheet, context).normal;
}
 
bool check_parents(style::StyledNode const &a, style::StyledNode const &b) {