mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 08:59:50 +00:00
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:
parent
ae40c7ed95
commit
381d3bf4e0
Notes:
github-actions[bot]
2025-09-04 12:34:14 +00:00
Author: https://github.com/AtkinsSJ
Commit: 381d3bf4e0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6043
5 changed files with 50 additions and 10 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue