소스 검색

LibHTML: Include padding when rendering background colors

Andreas Kling 5 년 전
부모
커밋
7573e3c46d
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      Libraries/LibHTML/Layout/LayoutNode.cpp

+ 10 - 2
Libraries/LibHTML/Layout/LayoutNode.cpp

@@ -44,8 +44,16 @@ void LayoutNode::render(RenderingContext& context)
 #endif
 #endif
 
 
     auto bgcolor = style_properties().property("background-color");
     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
     // TODO: render our border
     for_each_child([&](auto& child) {
     for_each_child([&](auto& child) {