From 4559d5f6f6183eaa8fb1eef85196262a37d8bb30 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Wed, 10 Sep 2025 13:49:02 +0100 Subject: [PATCH] LibWeb: Always round `text-decoration-thickness` value up to 1px --- Libraries/LibWeb/Painting/PaintableBox.cpp | 3 +- ...thickness-length-rounding-min-val-ref.html | 158 +++++++++++++++++ ...ion-thickness-length-rounding-min-val.html | 162 ++++++++++++++++++ 3 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Ref/expected/wpt-import/css/css-text-decor/reference/text-decoration-thickness-length-rounding-min-val-ref.html create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/css-text-decor/text-decoration-thickness-length-rounding-min-val.html diff --git a/Libraries/LibWeb/Painting/PaintableBox.cpp b/Libraries/LibWeb/Painting/PaintableBox.cpp index 0a5f20b19f1..e1deaf6d3a4 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -1589,7 +1589,8 @@ void PaintableWithLines::resolve_paint_properties() 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); + auto resolved_length = length_percentage.resolved(text_node, CSS::Length(1, CSS::Length::Type::Em).to_px(text_node)).to_px(*fragment.m_layout_node); + return max(resolved_length, 1); }); }(); fragment.set_text_decoration_thickness(css_line_thickness); diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-text-decor/reference/text-decoration-thickness-length-rounding-min-val-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text-decor/reference/text-decoration-thickness-length-rounding-min-val-ref.html new file mode 100644 index 00000000000..88bfbf920d6 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-text-decor/reference/text-decoration-thickness-length-rounding-min-val-ref.html @@ -0,0 +1,158 @@ + + + + + CSS Text Decoration Test: text-decoration-thickness length min rounding + + + + + + + + +

+ Test passes if text-decoration-thickness length is rounded up to 1px +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Line Type + + Line Style +
+ Solid + + Double + + Dotted + + Dashed + + Wavy +
+ Underline + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. +
+ Line-through + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. +
+ Overline + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. +
+ + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-text-decor/text-decoration-thickness-length-rounding-min-val.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-text-decor/text-decoration-thickness-length-rounding-min-val.html new file mode 100644 index 00000000000..10bcfa636ea --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-text-decor/text-decoration-thickness-length-rounding-min-val.html @@ -0,0 +1,162 @@ + + + + + CSS Text Decoration Test: text-decoration-thickness length min rounding + + + + + + + + + + + + +

+ Test passes if text-decoration-thickness length is rounded up to 1px +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Line Type + + Line Style +
+ Solid + + Double + + Dotted + + Dashed + + Wavy +
+ Underline + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. +
+ Line-through + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. +
+ Overline + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. + + Thickness test. +
+ +