LibWeb: Make CSS display serialization match other engines

The spec just says to follow "most backwards-compatible, then shortest"
when serializing these (and it does so in a very hand-wavy fashion).

By omitting some keywords when they are implied, we end up matching
other engines and pass a bunch of WPT tests.
This commit is contained in:
Andreas Kling 2024-11-15 13:07:23 +01:00 committed by Andreas Kling
commit ce23efc5f6
Notes: github-actions[bot] 2024-11-15 13:47:01 +00:00
3 changed files with 60 additions and 57 deletions

View file

@ -42,11 +42,16 @@ String Display::to_string() const
if (*this == Display::from_short(Display::Short::InlineTable))
return "inline-table"_string;
builder.append(CSS::to_string(m_value.outside_inside.outside));
builder.append(' ');
builder.append(CSS::to_string(m_value.outside_inside.inside));
if (m_value.outside_inside.list_item == ListItem::Yes)
builder.append(" list-item"sv);
{
Vector<StringView, 3> parts;
if (!(m_value.outside_inside.outside == DisplayOutside::Block && m_value.outside_inside.inside == DisplayInside::FlowRoot))
parts.append(CSS::to_string(m_value.outside_inside.outside));
if (m_value.outside_inside.inside != DisplayInside::Flow)
parts.append(CSS::to_string(m_value.outside_inside.inside));
if (m_value.outside_inside.list_item == ListItem::Yes)
parts.append("list-item"sv);
builder.join(' ', parts);
}
break;
case Type::Internal:
builder.append(CSS::to_string(m_value.internal));