mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:42:13 +00:00
LibWeb: Allow comma- or space-separated StyleValueLists
This lets us produce valid CSS in its to_string() method, instead of always adding commas as before. :^) Also, finally added a Formatter for StyleValues.
This commit is contained in:
parent
f71db4afd8
commit
5826fe094f
4 changed files with 43 additions and 25 deletions
|
@ -595,15 +595,19 @@ String UnresolvedStyleValue::to_string() const
|
|||
|
||||
String StyleValueList::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.appendff("List[{}](", m_values.size());
|
||||
for (size_t i = 0; i < m_values.size(); ++i) {
|
||||
if (i)
|
||||
builder.append(',');
|
||||
builder.append(m_values[i].to_string());
|
||||
String separator = "";
|
||||
switch (m_separator) {
|
||||
case Separator::Space:
|
||||
separator = " ";
|
||||
break;
|
||||
case Separator::Comma:
|
||||
separator = ", ";
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.to_string();
|
||||
|
||||
return String::join(separator, m_values);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue