return type == css_property_type::PROPERTY_DISPLAY;
}
+ auto is_visibility(void) const -> bool {
+ return type == css_property_type::PROPERTY_VISIBILITY;
+ }
+
auto operator==(const css_property &other) const { return type == other.type; }
};
}
}
}
+ if (prop.is_visibility()) {
+ if (parser_block.is_token()) {
+ /* A single token */
+ const auto &tok = parser_block.get_token_or_empty();
+
+ if (tok.type == css_parser_token::token_type::ident_token) {
+ return css_value::maybe_display_from_string(tok.get_string_or_default(""));
+ }
+ }
+ }
if (prop.is_normal_number()) {
if (parser_block.is_token()) {
/* A single token */
}
}
-void css_rule::add_value(const css_value &value) {
+void css_rule::add_value(const css_value &value)
+{
values.push_back(value);
}
+
TEST_SUITE("css rules") {
TEST_CASE("simple css rules") {
const std::vector<std::pair<const char *, std::vector<css_property>>> cases{
namespace rspamd::css {
-
+/**
+ * Class that is designed to hold css declaration (a set of rules)
+ */
class css_declarations_block {
public:
using rule_shared_ptr = std::shared_ptr<css_rule>;
return rules;
}
+ /**
+ * Returns if a declaration block has some property
+ * @param prop
+ * @return
+ */
auto has_property(const css_property &prop) const -> bool {
return (rules.find(css_rule{prop}) != rules.end());
}
+
private:
robin_hood::unordered_flat_set<rule_shared_ptr, rule_shared_hash, rule_shared_eq> rules;
};