mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
LibHTML: Respect the system theme
LibHTML will now use the palette colors for the default document background and the text. As always, a page can override this default styling with CSS if it really wants a specific color or style. Fixes https://github.com/SerenityOS/serenity/issues/963
This commit is contained in:
parent
7557251fac
commit
0f42908073
5 changed files with 14 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibHTML/CSS/StyleResolver.h>
|
||||
#include <LibHTML/DOM/Document.h>
|
||||
#include <LibHTML/DOM/DocumentType.h>
|
||||
|
@ -116,19 +117,20 @@ void Document::detach_from_frame(Badge<Frame>, Frame&)
|
|||
m_frame = nullptr;
|
||||
}
|
||||
|
||||
Color Document::background_color() const
|
||||
Color Document::background_color(const Palette& palette) const
|
||||
{
|
||||
auto default_color = palette.base();
|
||||
auto* body_element = body();
|
||||
if (!body_element)
|
||||
return Color::White;
|
||||
return default_color;
|
||||
|
||||
auto* body_layout_node = body_element->layout_node();
|
||||
if (!body_layout_node)
|
||||
return Color::White;
|
||||
return default_color;
|
||||
|
||||
auto background_color = body_layout_node->style().property(CSS::PropertyID::BackgroundColor);
|
||||
if (!background_color.has_value() || !background_color.value()->is_color())
|
||||
return Color::White;
|
||||
return default_color;
|
||||
|
||||
return background_color.value()->to_color(*this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue