From 9a6388f71843bcd78532a24c055f36c6bf247f50 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 19 Nov 2019 19:23:14 +0100 Subject: [PATCH] LibHTML: Render a background-color behind line box fragments if needed --- Libraries/LibHTML/Layout/LayoutText.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibHTML/Layout/LayoutText.cpp b/Libraries/LibHTML/Layout/LayoutText.cpp index af49c185ac..1b64b3dc1d 100644 --- a/Libraries/LibHTML/Layout/LayoutText.cpp +++ b/Libraries/LibHTML/Layout/LayoutText.cpp @@ -52,6 +52,10 @@ void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragmen if (is_underline) painter.draw_line(enclosing_int_rect(fragment.rect()).bottom_left().translated(0, -1), enclosing_int_rect(fragment.rect()).bottom_right().translated(0, -1), color); + auto background_color = style().property(CSS::PropertyID::BackgroundColor); + if (background_color.has_value() && background_color.value()->is_color()) + painter.fill_rect(enclosing_int_rect(fragment.rect()), background_color.value()->to_color(document())); + painter.draw_text(enclosing_int_rect(fragment.rect()), m_text_for_rendering.substring_view(fragment.start(), fragment.length()), TextAlignment::TopLeft, color); }