From 3b877c889b8d2558ed0a73f6c4b2e3bc6660f5ca Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Thu, 20 Jan 2022 20:30:00 +0100 Subject: [PATCH] LibWeb: Consider TextDecorationStyle when rendering text For now only Wavy is additionally supported, but the infrastructure is there. --- Userland/Libraries/LibWeb/Layout/TextNode.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.cpp b/Userland/Libraries/LibWeb/Layout/TextNode.cpp index b53d42d5ea..ba766ec9f9 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.cpp +++ b/Userland/Libraries/LibWeb/Layout/TextNode.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2022, Tobias Christiansen * * SPDX-License-Identifier: BSD-2-Clause */ @@ -67,7 +68,19 @@ void TextNode::paint_text_decoration(Gfx::Painter& painter, LineBoxFragment cons return; } - painter.draw_line(line_start_point, line_end_point, computed_values().color()); + switch (computed_values().text_decoration_style()) { + // FIXME: Implement the other styles + case CSS::TextDecorationStyle::Solid: + case CSS::TextDecorationStyle::Double: + case CSS::TextDecorationStyle::Dashed: + case CSS::TextDecorationStyle::Dotted: + painter.draw_line(line_start_point, line_end_point, computed_values().color()); + break; + case CSS::TextDecorationStyle::Wavy: + // FIXME: There is a thing called text-decoration-thickness which also affects the amplitude here. + painter.draw_triangle_wave(line_start_point, line_end_point, computed_values().color(), 2); + break; + } } void TextNode::paint_fragment(PaintContext& context, const LineBoxFragment& fragment, PaintPhase phase) const