From 9f0ca1bfb0cd3ad3fe857364055ea4a3048e04d8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 21 Nov 2019 13:14:03 +0100 Subject: [PATCH] LibHTML: Paint text background color before the underline decoration --- Libraries/LibHTML/Layout/LayoutText.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/LibHTML/Layout/LayoutText.cpp b/Libraries/LibHTML/Layout/LayoutText.cpp index 1b64b3dc1d..885c89fea5 100644 --- a/Libraries/LibHTML/Layout/LayoutText.cpp +++ b/Libraries/LibHTML/Layout/LayoutText.cpp @@ -42,6 +42,10 @@ void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragmen auto& painter = context.painter(); painter.set_font(style().font()); + 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())); + auto color = style().color_or_fallback(CSS::PropertyID::Color, document(), Color::Black); auto text_decoration = style().string_or_fallback(CSS::PropertyID::TextDecoration, "none"); @@ -52,10 +56,6 @@ 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); }