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
parent 70695e4fce
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));
{
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)
builder.append(" list-item"sv);
parts.append("list-item"sv);
builder.join(' ', parts);
}
break;
case Type::Internal:
builder.append(CSS::to_string(m_value.internal));

View file

@ -6,8 +6,7 @@ Rerun
Found 112 tests
88 Pass
24 Fail
112 Pass
Details
Result Test Name MessagePass Property display value 'grid'
Pass Property display value 'inline-grid'
@ -37,8 +36,8 @@ Pass Property display value 'ruby-base'
Pass Property display value 'ruby-text'
Pass Property display value 'flow list-item'
Pass Property display value 'list-item flow'
Fail Property display value 'flow-root list-item'
Fail Property display value 'list-item flow-root'
Pass Property display value 'flow-root list-item'
Pass Property display value 'list-item flow-root'
Pass Property display value 'block flow'
Pass Property display value 'flow block'
Pass Property display value 'flow-root block'
@ -59,12 +58,12 @@ Pass Property display value 'flow list-item block'
Pass Property display value 'block list-item flow'
Pass Property display value 'list-item block flow'
Pass Property display value 'list-item flow block'
Fail Property display value 'flow-root block list-item'
Fail Property display value 'block flow-root list-item'
Fail Property display value 'flow-root list-item block'
Fail Property display value 'block list-item flow-root'
Fail Property display value 'list-item block flow-root'
Fail Property display value 'list-item flow-root block'
Pass Property display value 'flow-root block list-item'
Pass Property display value 'block flow-root list-item'
Pass Property display value 'flow-root list-item block'
Pass Property display value 'block list-item flow-root'
Pass Property display value 'list-item block flow-root'
Pass Property display value 'list-item flow-root block'
Pass Property display value 'inline flow'
Pass Property display value 'flow inline'
Pass Property display value 'flow-root inline'
@ -77,14 +76,14 @@ Pass Property display value 'table inline'
Pass Property display value 'inline table'
Pass Property display value 'inline ruby'
Pass Property display value 'ruby inline'
Fail Property display value 'inline list-item'
Fail Property display value 'list-item inline'
Fail Property display value 'flow inline list-item'
Fail Property display value 'inline flow list-item'
Fail Property display value 'flow list-item inline'
Fail Property display value 'inline list-item flow'
Fail Property display value 'list-item inline flow'
Fail Property display value 'list-item flow inline'
Pass Property display value 'inline list-item'
Pass Property display value 'list-item inline'
Pass Property display value 'flow inline list-item'
Pass Property display value 'inline flow list-item'
Pass Property display value 'flow list-item inline'
Pass Property display value 'inline list-item flow'
Pass Property display value 'list-item inline flow'
Pass Property display value 'list-item flow inline'
Pass Property display value 'flow-root inline list-item'
Pass Property display value 'inline flow-root list-item'
Pass Property display value 'flow-root list-item inline'
@ -103,14 +102,14 @@ Pass Property display value 'table run-in'
Pass Property display value 'run-in table'
Pass Property display value 'run-in ruby'
Pass Property display value 'ruby run-in'
Fail Property display value 'run-in list-item'
Fail Property display value 'list-item run-in'
Fail Property display value 'flow run-in list-item'
Fail Property display value 'run-in flow list-item'
Fail Property display value 'flow list-item run-in'
Fail Property display value 'run-in list-item flow'
Fail Property display value 'list-item run-in flow'
Fail Property display value 'list-item flow run-in'
Pass Property display value 'run-in list-item'
Pass Property display value 'list-item run-in'
Pass Property display value 'flow run-in list-item'
Pass Property display value 'run-in flow list-item'
Pass Property display value 'flow list-item run-in'
Pass Property display value 'run-in list-item flow'
Pass Property display value 'list-item run-in flow'
Pass Property display value 'list-item flow run-in'
Pass Property display value 'flow-root run-in list-item'
Pass Property display value 'run-in flow-root list-item'
Pass Property display value 'flow-root list-item run-in'

View file

@ -6,8 +6,7 @@ Rerun
Found 108 tests
84 Pass
24 Fail
108 Pass
Details
Result Test Name MessagePass e.style['display'] = "grid" should set the property value
Pass e.style['display'] = "inline-grid" should set the property value
@ -37,8 +36,8 @@ Pass e.style['display'] = "ruby-base" should set the property value
Pass e.style['display'] = "ruby-text" should set the property value
Pass e.style['display'] = "flow list-item" should set the property value
Pass e.style['display'] = "list-item flow" should set the property value
Fail e.style['display'] = "flow-root list-item" should set the property value
Fail e.style['display'] = "list-item flow-root" should set the property value
Pass e.style['display'] = "flow-root list-item" should set the property value
Pass e.style['display'] = "list-item flow-root" should set the property value
Pass e.style['display'] = "block flow" should set the property value
Pass e.style['display'] = "flow block" should set the property value
Pass e.style['display'] = "flow-root block" should set the property value
@ -59,12 +58,12 @@ Pass e.style['display'] = "flow list-item block" should set the property value
Pass e.style['display'] = "block list-item flow" should set the property value
Pass e.style['display'] = "list-item block flow" should set the property value
Pass e.style['display'] = "list-item flow block" should set the property value
Fail e.style['display'] = "flow-root block list-item" should set the property value
Fail e.style['display'] = "block flow-root list-item" should set the property value
Fail e.style['display'] = "flow-root list-item block" should set the property value
Fail e.style['display'] = "block list-item flow-root" should set the property value
Fail e.style['display'] = "list-item block flow-root" should set the property value
Fail e.style['display'] = "list-item flow-root block" should set the property value
Pass e.style['display'] = "flow-root block list-item" should set the property value
Pass e.style['display'] = "block flow-root list-item" should set the property value
Pass e.style['display'] = "flow-root list-item block" should set the property value
Pass e.style['display'] = "block list-item flow-root" should set the property value
Pass e.style['display'] = "list-item block flow-root" should set the property value
Pass e.style['display'] = "list-item flow-root block" should set the property value
Pass e.style['display'] = "inline flow" should set the property value
Pass e.style['display'] = "flow inline" should set the property value
Pass e.style['display'] = "flow-root inline" should set the property value
@ -77,14 +76,14 @@ Pass e.style['display'] = "table inline" should set the property value
Pass e.style['display'] = "inline table" should set the property value
Pass e.style['display'] = "inline ruby" should set the property value
Pass e.style['display'] = "ruby inline" should set the property value
Fail e.style['display'] = "inline list-item" should set the property value
Fail e.style['display'] = "list-item inline" should set the property value
Fail e.style['display'] = "flow inline list-item" should set the property value
Fail e.style['display'] = "inline flow list-item" should set the property value
Fail e.style['display'] = "flow list-item inline" should set the property value
Fail e.style['display'] = "inline list-item flow" should set the property value
Fail e.style['display'] = "list-item inline flow" should set the property value
Fail e.style['display'] = "list-item flow inline" should set the property value
Pass e.style['display'] = "inline list-item" should set the property value
Pass e.style['display'] = "list-item inline" should set the property value
Pass e.style['display'] = "flow inline list-item" should set the property value
Pass e.style['display'] = "inline flow list-item" should set the property value
Pass e.style['display'] = "flow list-item inline" should set the property value
Pass e.style['display'] = "inline list-item flow" should set the property value
Pass e.style['display'] = "list-item inline flow" should set the property value
Pass e.style['display'] = "list-item flow inline" should set the property value
Pass e.style['display'] = "flow-root inline list-item" should set the property value
Pass e.style['display'] = "inline flow-root list-item" should set the property value
Pass e.style['display'] = "flow-root list-item inline" should set the property value
@ -103,14 +102,14 @@ Pass e.style['display'] = "table run-in" should set the property value
Pass e.style['display'] = "run-in table" should set the property value
Pass e.style['display'] = "run-in ruby" should set the property value
Pass e.style['display'] = "ruby run-in" should set the property value
Fail e.style['display'] = "run-in list-item" should set the property value
Fail e.style['display'] = "list-item run-in" should set the property value
Fail e.style['display'] = "flow run-in list-item" should set the property value
Fail e.style['display'] = "run-in flow list-item" should set the property value
Fail e.style['display'] = "flow list-item run-in" should set the property value
Fail e.style['display'] = "run-in list-item flow" should set the property value
Fail e.style['display'] = "list-item run-in flow" should set the property value
Fail e.style['display'] = "list-item flow run-in" should set the property value
Pass e.style['display'] = "run-in list-item" should set the property value
Pass e.style['display'] = "list-item run-in" should set the property value
Pass e.style['display'] = "flow run-in list-item" should set the property value
Pass e.style['display'] = "run-in flow list-item" should set the property value
Pass e.style['display'] = "flow list-item run-in" should set the property value
Pass e.style['display'] = "run-in list-item flow" should set the property value
Pass e.style['display'] = "list-item run-in flow" should set the property value
Pass e.style['display'] = "list-item flow run-in" should set the property value
Pass e.style['display'] = "flow-root run-in list-item" should set the property value
Pass e.style['display'] = "run-in flow-root list-item" should set the property value
Pass e.style['display'] = "flow-root list-item run-in" should set the property value