mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 20:27:35 +00:00
LibWeb: Convert StyleFunctionRule.m_values to ComponentValues
The input is ComponentValues, and the output is too, so storing as a String in the middle was inefficient and unnecessary.
This commit is contained in:
parent
fabc09a593
commit
cf333574ac
3 changed files with 17 additions and 12 deletions
|
@ -734,7 +734,7 @@ NonnullRefPtr<StyleFunctionRule> Parser::consume_a_function(TokenStream<T>& toke
|
||||||
|
|
||||||
tokens.reconsume_current_input_token();
|
tokens.reconsume_current_input_token();
|
||||||
auto value = consume_a_component_value(tokens);
|
auto value = consume_a_component_value(tokens);
|
||||||
function->m_values.append(value.token().m_value.to_string());
|
function->m_values.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return function;
|
return function;
|
||||||
|
@ -1059,8 +1059,13 @@ RefPtr<CSSRule> Parser::convert_to_rule(NonnullRefPtr<StyleRule> rule)
|
||||||
auto url_token = rule->prelude().first();
|
auto url_token = rule->prelude().first();
|
||||||
if (url_token.is_function()) {
|
if (url_token.is_function()) {
|
||||||
auto& function = url_token.function();
|
auto& function = url_token.function();
|
||||||
if (function.name().equals_ignoring_case("url"sv) && !function.values().is_empty())
|
if (function.name().equals_ignoring_case("url"sv) && !function.values().is_empty()) {
|
||||||
url = url_token.function().values().first();
|
auto& argument_token = url_token.function().values().first();
|
||||||
|
if (argument_token.is(Token::Type::String))
|
||||||
|
url = argument_token.token().string();
|
||||||
|
else
|
||||||
|
dbgln("First argument to url() was not a string: '{}'", argument_token.to_debug_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url_token.is(Token::Type::String))
|
if (url_token.is(Token::Type::String))
|
||||||
|
@ -1307,8 +1312,11 @@ RefPtr<StyleValue> Parser::parse_css_value(PropertyID property_id, TokenStream<S
|
||||||
// FIXME: Handle fallback value as second parameter
|
// FIXME: Handle fallback value as second parameter
|
||||||
// https://www.w3.org/TR/css-variables-1/#using-variables
|
// https://www.w3.org/TR/css-variables-1/#using-variables
|
||||||
if (!token.function().values().is_empty()) {
|
if (!token.function().values().is_empty()) {
|
||||||
auto& property_name = token.function().values().first();
|
auto& property_name_token = token.function().values().first();
|
||||||
return CustomStyleValue::create(property_name);
|
if (property_name_token.is(Token::Type::Ident))
|
||||||
|
return CustomStyleValue::create(property_name_token.token().ident());
|
||||||
|
else
|
||||||
|
dbgln("First argument to var() function was not an ident: '{}'", property_name_token.to_debug_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,20 +23,17 @@ public:
|
||||||
~StyleFunctionRule();
|
~StyleFunctionRule();
|
||||||
|
|
||||||
String const& name() const { return m_name; }
|
String const& name() const { return m_name; }
|
||||||
Vector<String> const& values() const { return m_values; }
|
Vector<StyleComponentValueRule> const& values() const { return m_values; }
|
||||||
// FIXME: This method is a temporary hack while much of the parser still expects a string, rather than tokens.
|
// FIXME: This method is a temporary hack while much of the parser still expects a string, rather than tokens.
|
||||||
String values_as_string() const
|
String values_as_string() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
return "";
|
||||||
for (auto& value : m_values)
|
|
||||||
builder.append(value);
|
|
||||||
return builder.to_string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const;
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_name;
|
String m_name;
|
||||||
Vector<String> m_values;
|
Vector<StyleComponentValueRule> m_values;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ String StyleFunctionRule::to_string() const
|
||||||
|
|
||||||
builder.append(m_name);
|
builder.append(m_name);
|
||||||
builder.append("(");
|
builder.append("(");
|
||||||
append_raw(builder, ", ", m_values);
|
append_with_to_string(builder, ", ", m_values);
|
||||||
builder.append(")");
|
builder.append(")");
|
||||||
|
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue