LibHTML: Include padding when rendering background colors

This commit is contained in:
Andreas Kling 2019-10-01 20:25:31 +02:00
parent 86b7dd6d5d
commit 7573e3c46d
Notes: sideshowbarker 2024-07-19 11:51:45 +09:00

View file

@ -44,8 +44,16 @@ void LayoutNode::render(RenderingContext& context)
#endif
auto bgcolor = style_properties().property("background-color");
if (bgcolor.has_value() && bgcolor.value()->is_color())
context.painter().fill_rect(rect(), bgcolor.value()->to_color());
if (bgcolor.has_value() && bgcolor.value()->is_color()) {
Rect background_rect;
background_rect.set_x(rect().x() - style().padding().left.to_px());
background_rect.set_width(rect().width() + style().padding().left.to_px() + style().padding().right.to_px());
background_rect.set_y(rect().y() - style().padding().top.to_px());
background_rect.set_height(rect().height() + style().padding().top.to_px() + style().padding().bottom.to_px());
context.painter().fill_rect(background_rect, bgcolor.value()->to_color());
}
// TODO: render our border
for_each_child([&](auto& child) {