mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibWeb: Simplify margin & border box construction in LayoutState
This commit is contained in:
parent
a02b28e6c8
commit
c03152c5d2
1 changed files with 14 additions and 12 deletions
|
@ -145,23 +145,25 @@ CSSPixels box_baseline(LayoutState const& state, Box const& box)
|
||||||
CSSPixelRect margin_box_rect(Box const& box, LayoutState const& state)
|
CSSPixelRect margin_box_rect(Box const& box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto const& box_state = state.get(box);
|
auto const& box_state = state.get(box);
|
||||||
auto rect = CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
|
return {
|
||||||
rect.set_x(rect.x() - box_state.margin_box_left());
|
box_state.offset.translated(-box_state.margin_box_left(), -box_state.margin_box_top()),
|
||||||
rect.set_width(rect.width() + box_state.margin_box_left() + box_state.margin_box_right());
|
{
|
||||||
rect.set_y(rect.y() - box_state.margin_box_top());
|
box_state.margin_box_left() + box_state.content_width() + box_state.margin_box_right(),
|
||||||
rect.set_height(rect.height() + box_state.margin_box_top() + box_state.margin_box_bottom());
|
box_state.margin_box_top() + box_state.content_height() + box_state.margin_box_bottom(),
|
||||||
return rect;
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixelRect border_box_rect(Box const& box, LayoutState const& state)
|
CSSPixelRect border_box_rect(Box const& box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto const& box_state = state.get(box);
|
auto const& box_state = state.get(box);
|
||||||
auto rect = CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
|
return {
|
||||||
rect.set_x(rect.x() - box_state.border_box_left());
|
box_state.offset.translated(-box_state.border_box_left(), -box_state.border_box_top()),
|
||||||
rect.set_width(rect.width() + box_state.border_box_left() + box_state.border_box_right());
|
{
|
||||||
rect.set_y(rect.y() - box_state.border_box_top());
|
box_state.border_box_left() + box_state.content_width() + box_state.border_box_right(),
|
||||||
rect.set_height(rect.height() + box_state.border_box_top() + box_state.border_box_bottom());
|
box_state.border_box_top() + box_state.content_height() + box_state.border_box_bottom(),
|
||||||
return rect;
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixelRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
|
CSSPixelRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue