1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibWeb: Move available_space_for_line() from IFC to BFC

This is preparation for allowing blocks with their own internal BFC to
flow around floating boxes in the parent BFC.

Note that IFC still has the available_space_for_line() API, which
returns space available within the IFC's own containing block, while the
BFC available_space_for_line() returns space available within its root.
This commit is contained in:
Andreas Kling 2022-03-17 12:30:30 +01:00
parent fc6b7fcd97
commit ef8a72ff3f
5 changed files with 36 additions and 32 deletions

View file

@ -692,4 +692,29 @@ void BlockFormattingContext::layout_list_item_marker(ListItemBox const& list_ite
list_item_state.content_height = marker_state.content_height;
}
BlockFormattingContext::AvailableSpaceForLineInfo BlockFormattingContext::available_space_for_line(float y) const
{
AvailableSpaceForLineInfo info;
for (auto const& floating_box : m_left_floats.boxes.in_reverse()) {
auto rect = margin_box_rect_in_ancestor_coordinate_space(floating_box, root(), m_state);
if (rect.contains_vertically(y)) {
info.left = rect.right() + 1;
break;
}
}
info.right = m_state.get(root()).content_width;
for (auto const& floating_box : m_right_floats.boxes.in_reverse()) {
auto rect = margin_box_rect_in_ancestor_coordinate_space(floating_box, root(), m_state);
if (rect.contains_vertically(y)) {
info.right = rect.left();
break;
}
}
return info;
}
}