diff options
Diffstat (limited to 'Libraries/LibHTML')
-rw-r--r-- | Libraries/LibHTML/CSS/StyleValue.h | 3 | ||||
-rw-r--r-- | Libraries/LibHTML/Layout/LayoutNode.cpp | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Libraries/LibHTML/CSS/StyleValue.h b/Libraries/LibHTML/CSS/StyleValue.h index 02dd2a1cc0..5dd8e2cc1c 100644 --- a/Libraries/LibHTML/CSS/StyleValue.h +++ b/Libraries/LibHTML/CSS/StyleValue.h @@ -24,9 +24,11 @@ public: bool is_inherit() const { return type() == Type::Inherit; } bool is_initial() const { return type() == Type::Initial; } + bool is_color() const { return type() == Type::Color; } virtual String to_string() const = 0; virtual Length to_length() const { return {}; } + virtual Color to_color() const { return {}; } virtual bool is_auto() const { return false; } @@ -120,6 +122,7 @@ public: Color color() const { return m_color; } String to_string() const override { return String::format("COLOR: %s", m_color.to_string().characters()); } + Color to_color() const override { return m_color; } private: explicit ColorStyleValue(Color color) diff --git a/Libraries/LibHTML/Layout/LayoutNode.cpp b/Libraries/LibHTML/Layout/LayoutNode.cpp index ff44ed7bc6..c448c56a5e 100644 --- a/Libraries/LibHTML/Layout/LayoutNode.cpp +++ b/Libraries/LibHTML/Layout/LayoutNode.cpp @@ -42,7 +42,12 @@ void LayoutNode::render(RenderingContext& context) if (!is_anonymous() && node() == document().hovered_node()) context.painter().draw_rect(m_rect, Color::Red); #endif - // TODO: render our background and border + + auto bgcolor = style_properties().property("background-color"); + if (bgcolor.has_value() && bgcolor.value()->is_color()) + context.painter().fill_rect(rect(), bgcolor.value()->to_color()); + + // TODO: render our border for_each_child([&](auto& child) { child.render(context); }); |