1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:47:34 +00:00

LibWeb: Use correct box edge when looking for space between floats

This commit is contained in:
Andreas Kling 2022-09-08 13:21:57 +02:00
parent 0270500383
commit af73a5d921
4 changed files with 25 additions and 3 deletions

View file

@ -132,6 +132,26 @@ Gfx::FloatRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box
return rect;
}
Gfx::FloatRect content_box_rect(Box const& box, LayoutState const& state)
{
auto const& box_state = state.get(box);
return Gfx::FloatRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
}
Gfx::FloatRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
{
auto rect = content_box_rect(box, state);
for (auto const* current = box.parent(); current; current = current->parent()) {
if (current == &ancestor_box)
break;
if (is<Box>(*current)) {
auto const& current_state = state.get(static_cast<Box const&>(*current));
rect.translate_by(current_state.offset);
}
}
return rect;
}
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
{
auto rect = margin_box_rect(box, state);