diff --git a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp index 2afb72ad6958..419a8cf7d99e 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ShorthandStyleValue.cpp @@ -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; diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt index eec621fd3ae1..7bf960ade92e 100644 --- a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt +++ b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-all-supported-properties-and-default-values.txt @@ -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' diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-computed.txt index 5224236c129d..5064266ac0ff 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-computed.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-computed.txt @@ -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' \ No newline at end of file +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' \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-valid.txt index ffa2a8f7830e..61f1f07b02de 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-valid.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text-decor/parsing/text-decoration-valid.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt index 1e60246dcf5d..4aaae3173c50 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/serialize-values.txt @@ -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