From 84a5c67d6bfb9840fbf421bc638715ea45bbaf85 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 23 Aug 2023 17:18:33 +0100 Subject: [PATCH] LibWeb: Use system colors in more places --- Userland/Libraries/LibWeb/DOM/Document.cpp | 13 ++++--------- Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 7 ++++--- Userland/Services/WebContent/PageHost.cpp | 3 ++- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index ce30647700..8b056b1e95 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1296,27 +1297,21 @@ Color Document::link_color() const { if (m_link_color.has_value()) return m_link_color.value(); - if (!page()) - return Color::Blue; - return page()->palette().link(); + return CSS::SystemColor::link_text(); } Color Document::active_link_color() const { if (m_active_link_color.has_value()) return m_active_link_color.value(); - if (!page()) - return Color::Red; - return page()->palette().active_link(); + return CSS::SystemColor::active_text(); } Color Document::visited_link_color() const { if (m_visited_link_color.has_value()) return m_visited_link_color.value(); - if (!page()) - return Color::Magenta; - return page()->palette().visited_link(); + return CSS::SystemColor::visited_text(); } // https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 512ccdfd6c..8c6d0891c2 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -1,12 +1,13 @@ /* * Copyright (c) 2022-2023, Andreas Kling - * Copyright (c) 2022, Sam Atkins + * Copyright (c) 2022-2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #include #include +#include #include #include #include @@ -616,10 +617,10 @@ static void paint_text_fragment(PaintContext& context, Layout::TextNode const& t auto selection_rect = context.enclosing_device_rect(fragment.selection_rect(text_node.font())).to_type(); if (!selection_rect.is_empty()) { - painter.fill_rect(selection_rect, context.palette().selection()); + painter.fill_rect(selection_rect, CSS::SystemColor::highlight()); Gfx::PainterStateSaver saver(painter); painter.add_clip_rect(selection_rect); - painter.draw_text_run(baseline_start.to_type(), view, scaled_font, context.palette().selection_text()); + painter.draw_text_run(baseline_start.to_type(), view, scaled_font, CSS::SystemColor::highlight_text()); } paint_text_decoration(context, painter, text_node, fragment); diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index caa23f1bca..dd40822025 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -130,7 +131,7 @@ void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& targ auto background_color = this->background_color(); if (background_color.alpha() < 255) - painter.clear_rect(bitmap_rect, palette().base()); + painter.clear_rect(bitmap_rect, Web::CSS::SystemColor::canvas()); painter.fill_rect(bitmap_rect, background_color); if (!document->paintable())