1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:48:13 +00:00

LibWeb: Add bordered_rect() and padded_rect() helpers in Layout::Box

This commit is contained in:
Andreas Kling 2021-02-22 18:52:58 +01:00
parent 21371bf6ee
commit 543dd54a1d
2 changed files with 23 additions and 11 deletions

View file

@ -43,11 +43,7 @@ void Box::paint(PaintContext& context, PaintPhase phase)
if (is_fixed_position())
context.painter().translate(context.scroll_offset());
Gfx::FloatRect padded_rect;
padded_rect.set_x(absolute_x() - box_model().padding.left);
padded_rect.set_width(width() + box_model().padding.left + box_model().padding.right);
padded_rect.set_y(absolute_y() - box_model().padding.top);
padded_rect.set_height(height() + box_model().padding.top + box_model().padding.bottom);
auto padded_rect = this->padded_rect();
if (phase == PaintPhase::Background && !is_body()) {
context.painter().fill_rect(enclosing_int_rect(padded_rect), computed_values().background_color());
@ -57,12 +53,7 @@ void Box::paint(PaintContext& context, PaintPhase phase)
}
if (phase == PaintPhase::Border) {
Gfx::FloatRect bordered_rect;
bordered_rect.set_x(padded_rect.x() - box_model().border.left);
bordered_rect.set_width(padded_rect.width() + box_model().border.left + box_model().border.right);
bordered_rect.set_y(padded_rect.y() - box_model().border.top);
bordered_rect.set_height(padded_rect.height() + box_model().border.top + box_model().border.bottom);
auto bordered_rect = this->bordered_rect();
Painting::paint_border(context, Painting::BorderEdge::Left, bordered_rect, computed_values());
Painting::paint_border(context, Painting::BorderEdge::Right, bordered_rect, computed_values());
Painting::paint_border(context, Painting::BorderEdge::Top, bordered_rect, computed_values());