mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibWeb: Serialize text-decoration closer to spec
This gets us 32 WPT subtest passes that I'm aware of. :^)
This commit is contained in:
parent
c405c4bcf1
commit
8e3adbe082
Notes:
github-actions[bot]
2024-11-30 10:02:21 +00:00
Author: https://github.com/AtkinsSJ
Commit: 8e3adbe082
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2638
5 changed files with 61 additions and 40 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue