LibWeb: Serialize text-decoration closer to spec

This gets us 32 WPT subtest passes that I'm aware of. :^)
This commit is contained in:
Sam Atkins 2024-11-29 14:49:31 +00:00 committed by Andreas Kling
parent c405c4bcf1
commit 8e3adbe082
Notes: github-actions[bot] 2024-11-30 10:02:21 +00:00
5 changed files with 61 additions and 40 deletions

View file

@ -233,8 +233,29 @@ String ShorthandStyleValue::to_string() const
return align_self;
return MUST(String::formatted("{} {}", align_self, justify_self));
}
case PropertyID::TextDecoration:
return MUST(String::formatted("{} {} {} {}", longhand(PropertyID::TextDecorationLine)->to_string(), longhand(PropertyID::TextDecorationThickness)->to_string(), longhand(PropertyID::TextDecorationStyle)->to_string(), longhand(PropertyID::TextDecorationColor)->to_string()));
case PropertyID::TextDecoration: {
// The rule here seems to be, only print what's different from the default value,
// but if they're all default, print the line.
StringBuilder builder;
auto append_if_non_default = [&](PropertyID property_id) {
auto value = longhand(property_id);
if (!value->equals(property_initial_value({}, property_id))) {
if (!builder.is_empty())
builder.append(' ');
builder.append(value->to_string());
}
};
append_if_non_default(PropertyID::TextDecorationLine);
append_if_non_default(PropertyID::TextDecorationThickness);
append_if_non_default(PropertyID::TextDecorationStyle);
append_if_non_default(PropertyID::TextDecorationColor);
if (builder.is_empty())
return longhand(PropertyID::TextDecorationLine)->to_string();
return builder.to_string_without_validation();
}
default:
StringBuilder builder;
auto first = true;

View file

@ -518,8 +518,8 @@ All supported properties and their default values exposed from CSSStyleDeclarati
'text-align': 'start'
'textAnchor': 'start'
'text-anchor': 'start'
'textDecoration': 'none auto solid rgb(0, 0, 0)'
'text-decoration': 'none auto solid rgb(0, 0, 0)'
'textDecoration': 'rgb(0, 0, 0)'
'text-decoration': 'rgb(0, 0, 0)'
'textDecorationColor': 'rgb(0, 0, 0)'
'text-decoration-color': 'rgb(0, 0, 0)'
'textDecorationLine': 'none'

View file

@ -6,17 +6,17 @@ Rerun
Found 12 tests
12 Fail
12 Pass
Details
Result Test Name MessageFail Property text-decoration value 'none'
Fail Property text-decoration value 'line-through'
Fail Property text-decoration value 'solid'
Fail Property text-decoration value 'currentcolor'
Fail Property text-decoration value 'double overline underline'
Fail Property text-decoration value 'underline overline line-through red'
Fail Property text-decoration value 'rgba(10, 20, 30, 0.4) dotted'
Fail Property text-decoration value 'underline dashed rgb(0, 255, 0)'
Fail Property text-decoration value 'auto'
Fail Property text-decoration value 'from-font'
Fail Property text-decoration value '10px'
Fail Property text-decoration value 'underline red from-font'
Result Test Name MessagePass Property text-decoration value 'none'
Pass Property text-decoration value 'line-through'
Pass Property text-decoration value 'solid'
Pass Property text-decoration value 'currentcolor'
Pass Property text-decoration value 'double overline underline'
Pass Property text-decoration value 'underline overline line-through red'
Pass Property text-decoration value 'rgba(10, 20, 30, 0.4) dotted'
Pass Property text-decoration value 'underline dashed rgb(0, 255, 0)'
Pass Property text-decoration value 'auto'
Pass Property text-decoration value 'from-font'
Pass Property text-decoration value '10px'
Pass Property text-decoration value 'underline red from-font'

View file

@ -6,20 +6,20 @@ Rerun
Found 15 tests
15 Fail
15 Pass
Details
Result Test Name MessageFail e.style['text-decoration'] = "none" should set the property value
Fail e.style['text-decoration'] = "line-through" should set the property value
Fail e.style['text-decoration'] = "solid" should set the property value
Fail e.style['text-decoration'] = "currentcolor" should set the property value
Fail e.style['text-decoration'] = "auto" should set the property value
Fail e.style['text-decoration'] = "from-font" should set the property value
Fail e.style['text-decoration'] = "10px" should set the property value
Fail e.style['text-decoration'] = "double overline underline" should set the property value
Fail e.style['text-decoration'] = "underline overline line-through red" should set the property value
Fail e.style['text-decoration'] = "rgba(10, 20, 30, 0.4) dotted" should set the property value
Fail e.style['text-decoration'] = "overline green from-font" should set the property value
Fail e.style['text-decoration'] = "underline dashed green" should set the property value
Fail e.style['text-decoration'] = "underline auto" should set the property value
Fail e.style['text-decoration'] = "line-through 20px" should set the property value
Fail e.style['text-decoration'] = "overline 3em" should set the property value
Result Test Name MessagePass e.style['text-decoration'] = "none" should set the property value
Pass e.style['text-decoration'] = "line-through" should set the property value
Pass e.style['text-decoration'] = "solid" should set the property value
Pass e.style['text-decoration'] = "currentcolor" should set the property value
Pass e.style['text-decoration'] = "auto" should set the property value
Pass e.style['text-decoration'] = "from-font" should set the property value
Pass e.style['text-decoration'] = "10px" should set the property value
Pass e.style['text-decoration'] = "double overline underline" should set the property value
Pass e.style['text-decoration'] = "underline overline line-through red" should set the property value
Pass e.style['text-decoration'] = "rgba(10, 20, 30, 0.4) dotted" should set the property value
Pass e.style['text-decoration'] = "overline green from-font" should set the property value
Pass e.style['text-decoration'] = "underline dashed green" should set the property value
Pass e.style['text-decoration'] = "underline auto" should set the property value
Pass e.style['text-decoration'] = "line-through 20px" should set the property value
Pass e.style['text-decoration'] = "overline 3em" should set the property value

View file

@ -6,8 +6,8 @@ Rerun
Found 687 tests
473 Pass
214 Fail
478 Pass
209 Fail
Details
Result Test Name MessagePass background-attachment: scroll
Pass background-attachment: fixed
@ -625,11 +625,11 @@ Pass text-align: right
Pass text-align: center
Pass text-align: justify
Pass text-align: inherit
Fail text-decoration: none
Fail text-decoration: underline
Fail text-decoration: overline
Fail text-decoration: line-through
Fail text-decoration: blink
Pass text-decoration: none
Pass text-decoration: underline
Pass text-decoration: overline
Pass text-decoration: line-through
Pass text-decoration: blink
Pass text-decoration: inherit
Pass text-indent: 0px
Pass text-indent: 1px