mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
LibWeb: Simplify margin & border box construction in LayoutState
This commit is contained in:
parent
a02b28e6c8
commit
c03152c5d2
Notes:
sideshowbarker
2024-07-16 22:11:09 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/c03152c5d2 Pull-request: https://github.com/SerenityOS/serenity/pull/18970
@ -145,23 +145,25 @@ CSSPixels box_baseline(LayoutState const& state, Box const& box)
|
||||
CSSPixelRect margin_box_rect(Box const& box, LayoutState const& state)
|
||||
{
|
||||
auto const& box_state = state.get(box);
|
||||
auto rect = CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
|
||||
rect.set_x(rect.x() - box_state.margin_box_left());
|
||||
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());
|
||||
rect.set_height(rect.height() + box_state.margin_box_top() + box_state.margin_box_bottom());
|
||||
return rect;
|
||||
return {
|
||||
box_state.offset.translated(-box_state.margin_box_left(), -box_state.margin_box_top()),
|
||||
{
|
||||
box_state.margin_box_left() + box_state.content_width() + box_state.margin_box_right(),
|
||||
box_state.margin_box_top() + box_state.content_height() + box_state.margin_box_bottom(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
CSSPixelRect border_box_rect(Box const& box, LayoutState const& state)
|
||||
{
|
||||
auto const& box_state = state.get(box);
|
||||
auto rect = CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
|
||||
rect.set_x(rect.x() - box_state.border_box_left());
|
||||
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());
|
||||
rect.set_height(rect.height() + box_state.border_box_top() + box_state.border_box_bottom());
|
||||
return rect;
|
||||
return {
|
||||
box_state.offset.translated(-box_state.border_box_left(), -box_state.border_box_top()),
|
||||
{
|
||||
box_state.border_box_left() + box_state.content_width() + box_state.border_box_right(),
|
||||
box_state.border_box_top() + box_state.content_height() + box_state.border_box_bottom(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
CSSPixelRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
|
||||
|
Loading…
Reference in New Issue
Block a user