LibWeb: Stop pretending text-decoration-thickness is a LengthPercentage

It has two keywords: auto and from-font. from-font isn't handled
properly yet, but at least we have a FIXME for it now. :^)
This commit is contained in:
Sam Atkins 2025-08-27 15:12:17 +01:00
commit 381d3bf4e0
Notes: github-actions[bot] 2025-09-04 12:34:14 +00:00
5 changed files with 50 additions and 10 deletions

View file

@ -1570,10 +1570,23 @@ void PaintableWithLines::resolve_paint_properties()
auto const& font = fragment.m_layout_node->first_available_font();
auto const glyph_height = CSSPixels::nearest_value_for(font.pixel_size());
auto const css_line_thickness = [&] {
auto computed_thickness = text_node.computed_values().text_decoration_thickness().resolved(text_node, CSS::Length(1, CSS::Length::Type::Em).to_px(text_node));
if (computed_thickness.is_auto())
return max(glyph_height.scaled(0.1), 1);
return computed_thickness.to_px(*fragment.m_layout_node);
auto const& thickness = text_node.computed_values().text_decoration_thickness();
return thickness.value.visit(
[glyph_height](CSS::TextDecorationThickness::Auto) {
// The UA chooses an appropriate thickness for text decoration lines; see below.
// https://drafts.csswg.org/css-text-decor-4/#valdef-text-decoration-thickness-auto
return max(glyph_height.scaled(0.1), 1);
},
[glyph_height](CSS::TextDecorationThickness::FromFont) {
// If the first available font has metrics indicating a preferred underline width, use that width,
// otherwise behaves as auto.
// https://drafts.csswg.org/css-text-decor-4/#valdef-text-decoration-thickness-from-font
// FIXME: Implement this properly.
return max(glyph_height.scaled(0.1), 1);
},
[&](CSS::LengthPercentage const& length_percentage) {
return length_percentage.resolved(text_node, CSS::Length(1, CSS::Length::Type::Em).to_px(text_node)).to_px(*fragment.m_layout_node);
});
}();
fragment.set_text_decoration_thickness(css_line_thickness);