1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 15:08:12 +00:00

LibWeb: Allow multiple text-decoration-lines

The spec grammar for `text-decoration-line` is:

`none | [ underline || overline || line-through || blink ]`

Which means that it's either `none`, or any combination of the other
values. This patch makes that parse for `text-decoration-line` and
`text-decoration`, stores the results as a Vector, and adjusts
`paint_text_decoration()` to run as a loop over all the values that are
provided.

As noted, storing a Vector of values is a bit wasteful, as they could be
stored as flags in a single `u8`. But I was getting too confused trying
to do that in a nice way.
This commit is contained in:
Sam Atkins 2022-04-14 16:22:35 +01:00 committed by Andreas Kling
parent 85da8cbb07
commit 7c91fda088
9 changed files with 142 additions and 66 deletions

View file

@ -140,8 +140,16 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
}
case CSS::PropertyID::TextAlign:
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().text_align()));
case CSS::PropertyID::TextDecorationLine:
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().text_decoration_line()));
case CSS::PropertyID::TextDecorationLine: {
auto text_decoration_lines = layout_node.computed_values().text_decoration_line();
if (text_decoration_lines.is_empty())
return IdentifierStyleValue::create(ValueID::None);
NonnullRefPtrVector<StyleValue> style_values;
for (auto const& line : text_decoration_lines) {
style_values.append(IdentifierStyleValue::create(to_value_id(line)));
}
return StyleValueList::create(move(style_values), StyleValueList::Separator::Space);
}
case CSS::PropertyID::TextDecorationStyle:
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().text_decoration_style()));
case CSS::PropertyID::TextTransform: