if (tok.type == css_parser_token::token_type::hash_token) {
return css_value::maybe_color_from_hex(tok.get_string_or_default(""));
}
- else if (tok.type == css_parser_token::token_type::string_token) {
+ else if (tok.type == css_parser_token::token_type::ident_token) {
return css_value::maybe_color_from_string(tok.get_string_or_default(""));
}
}
switch (next_tok.tag) {
case css_consumed_block::parser_tag_type::css_component:
+ /* Component can be a property or a compound list of values */
if (state == parse_property) {
cur_property = css_property::from_token(next_tok.get_token_or_empty())
.value_or(bad_property);
const auto &expect_colon_block = next_block_functor();
if (expect_colon_block.tag != css_consumed_block::parser_tag_type::css_component) {
-
state = ignore_value; /* Ignore up to the next rule */
}
else {
}
break;
case css_consumed_block::parser_tag_type::css_function:
- case css_consumed_block::parser_tag_type::css_function_arg:
if (state == parse_value) {
- auto maybe_value = css_value::from_css_block(next_tok);
+ auto maybe_value = allowed_property_value(cur_property, next_tok);
if (maybe_value) {
+ msg_debug_css("added value %s to the property %s",
+ maybe_value.value().debug_str().c_str(),
+ cur_property.to_string());
cur_rule->add_value(maybe_value.value());
}
}
break;
case css_consumed_block::parser_tag_type::css_eof_block:
+ if (state == parse_value) {
+ ret.push_back(std::move(cur_rule));
+ }
+ can_continue = false;
+ break;
default:
can_continue = false;
break;
hexpair_decode(input[4], input[5]));
return css_value(col);
}
+ else if (input.length() == 3) {
+ /* Rgb as 3 hex digests */
+ css_color col(hexpair_decode(input[0], input[0]),
+ hexpair_decode(input[1], input[1]),
+ hexpair_decode(input[2], input[2]));
+ return css_value(col);
+ }
else if (input.length() == 8) {
/* RGBA */
css_color col(hexpair_decode(input[0], input[1]),
{
std::string ret;
- std::visit([&](auto& arg) {
+ std::visit([&](const auto& arg) {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, css_color>) {