mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibHTML: Implement basic support for background-color
This commit is contained in:
parent
a4fccc02ec
commit
37a37accd4
2 changed files with 9 additions and 1 deletions
|
@ -24,9 +24,11 @@ public:
|
||||||
|
|
||||||
bool is_inherit() const { return type() == Type::Inherit; }
|
bool is_inherit() const { return type() == Type::Inherit; }
|
||||||
bool is_initial() const { return type() == Type::Initial; }
|
bool is_initial() const { return type() == Type::Initial; }
|
||||||
|
bool is_color() const { return type() == Type::Color; }
|
||||||
|
|
||||||
virtual String to_string() const = 0;
|
virtual String to_string() const = 0;
|
||||||
virtual Length to_length() const { return {}; }
|
virtual Length to_length() const { return {}; }
|
||||||
|
virtual Color to_color() const { return {}; }
|
||||||
|
|
||||||
virtual bool is_auto() const { return false; }
|
virtual bool is_auto() const { return false; }
|
||||||
|
|
||||||
|
@ -120,6 +122,7 @@ public:
|
||||||
|
|
||||||
Color color() const { return m_color; }
|
Color color() const { return m_color; }
|
||||||
String to_string() const override { return String::format("COLOR: %s", m_color.to_string().characters()); }
|
String to_string() const override { return String::format("COLOR: %s", m_color.to_string().characters()); }
|
||||||
|
Color to_color() const override { return m_color; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ColorStyleValue(Color color)
|
explicit ColorStyleValue(Color color)
|
||||||
|
|
|
@ -42,7 +42,12 @@ void LayoutNode::render(RenderingContext& context)
|
||||||
if (!is_anonymous() && node() == document().hovered_node())
|
if (!is_anonymous() && node() == document().hovered_node())
|
||||||
context.painter().draw_rect(m_rect, Color::Red);
|
context.painter().draw_rect(m_rect, Color::Red);
|
||||||
#endif
|
#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) {
|
for_each_child([&](auto& child) {
|
||||||
child.render(context);
|
child.render(context);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue