From 119873b8229914b9e709e446e4e5f1f5df83b13d Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Mon, 4 Apr 2022 22:00:09 +0200 Subject: [PATCH] LibWeb: Make default text-decoration-thickness a fraction of font height Previously the default was always 1px, which didn't look great on higher font sizes. This changes the default thickness to one-tenth to the font height. The one-tenth part was chosen arbitrarily, but I think it does the job pretty well. :^) --- Userland/Libraries/LibWeb/CSS/ComputedValues.h | 2 +- Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index c8b14a3f82..cd12e06de9 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -25,7 +25,7 @@ public: static CSS::TextJustify text_justify() { return CSS::TextJustify::Auto; } static CSS::Position position() { return CSS::Position::Static; } static CSS::TextDecorationLine text_decoration_line() { return CSS::TextDecorationLine::None; } - static CSS::Length text_decoration_thickness() { return Length::make_px(1); } + static CSS::Length text_decoration_thickness() { return Length::make_auto(); } static CSS::TextDecorationStyle text_decoration_style() { return CSS::TextDecorationStyle::Solid; } static CSS::TextTransform text_transform() { return CSS::TextTransform::None; } static CSS::Display display() { return CSS::Display { CSS::Display::Outside::Inline, CSS::Display::Inside::Flow }; } diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 86f8f5bee4..16c329971b 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -324,7 +324,7 @@ static void paint_text_decoration(Gfx::Painter& painter, Layout::Node const& tex int line_thickness = [&] { CSS::Length computed_thickness = text_node.computed_values().text_decoration_thickness().resolved(text_node, CSS::Length(1, CSS::Length::Type::Em)); if (computed_thickness.is_auto()) - return CSS::InitialValues::text_decoration_thickness().to_px(text_node); + return max(glyph_height * 0.1f, 1.f); return computed_thickness.to_px(text_node); }();