Quellcode durchsuchen

LibWeb: Use system colors in more places

Sam Atkins vor 1 Jahr
Ursprung
Commit
84a5c67d6b

+ 4 - 9
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -20,6 +20,7 @@
 #include <LibWeb/CSS/MediaQueryList.h>
 #include <LibWeb/CSS/MediaQueryListEvent.h>
 #include <LibWeb/CSS/StyleComputer.h>
+#include <LibWeb/CSS/SystemColor.h>
 #include <LibWeb/CSS/VisualViewport.h>
 #include <LibWeb/Cookie/ParsedCookie.h>
 #include <LibWeb/DOM/Attr.h>
@@ -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

+ 4 - 3
Userland/Libraries/LibWeb/Painting/PaintableBox.cpp

@@ -1,12 +1,13 @@
 /*
  * Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
 #include <AK/GenericShorthands.h>
 #include <LibUnicode/CharacterTypes.h>
+#include <LibWeb/CSS/SystemColor.h>
 #include <LibWeb/DOM/Document.h>
 #include <LibWeb/HTML/HTMLHtmlElement.h>
 #include <LibWeb/Layout/BlockContainer.h>
@@ -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<int>();
         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<int>(), view, scaled_font, context.palette().selection_text());
+            painter.draw_text_run(baseline_start.to_type<int>(), view, scaled_font, CSS::SystemColor::highlight_text());
         }
 
         paint_text_decoration(context, painter, text_node, fragment);

+ 2 - 1
Userland/Services/WebContent/PageHost.cpp

@@ -10,6 +10,7 @@
 #include <LibGfx/Painter.h>
 #include <LibGfx/ShareableBitmap.h>
 #include <LibGfx/SystemTheme.h>
+#include <LibWeb/CSS/SystemColor.h>
 #include <LibWeb/Cookie/ParsedCookie.h>
 #include <LibWeb/HTML/BrowsingContext.h>
 #include <LibWeb/Layout/Viewport.h>
@@ -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())