mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-16 17:00:35 +03:00
LibWeb: Use correct box edge when looking for space between floats
This commit is contained in:
parent
0270500383
commit
af73a5d921
Notes:
sideshowbarker
2024-07-17 07:21:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/af73a5d921
@ -626,7 +626,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
|
||||
offset_from_edge = box_state.content_width() + box_state.margin_box_right();
|
||||
};
|
||||
|
||||
auto box_in_root_rect = border_box_rect_in_ancestor_coordinate_space(box, root(), m_state);
|
||||
auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(box, root(), m_state);
|
||||
float y_in_root = box_in_root_rect.y();
|
||||
float y = box_state.offset.y();
|
||||
|
||||
|
@ -52,7 +52,7 @@ BlockFormattingContext const& InlineFormattingContext::parent() const
|
||||
float InlineFormattingContext::leftmost_x_offset_at(float y) const
|
||||
{
|
||||
// NOTE: Floats are relative to the BFC root box, not necessarily the containing block of this IFC.
|
||||
auto box_in_root_rect = border_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state);
|
||||
auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state);
|
||||
float y_in_root = box_in_root_rect.y() + y;
|
||||
auto space = parent().space_used_by_floats(y_in_root);
|
||||
float containing_block_x = m_containing_block_state.offset.x();
|
||||
@ -68,7 +68,7 @@ float InlineFormattingContext::available_space_for_line(float y) const
|
||||
|
||||
// NOTE: Floats are relative to the BFC root box, not necessarily the containing block of this IFC.
|
||||
auto& root_block = parent().root();
|
||||
auto box_in_root_rect = border_box_rect_in_ancestor_coordinate_space(containing_block(), root_block, m_state);
|
||||
auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), root_block, m_state);
|
||||
float y_in_root = box_in_root_rect.y() + y;
|
||||
auto space = parent().space_used_by_floats(y_in_root);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -151,5 +151,7 @@ Gfx::FloatRect margin_box_rect(Box const&, LayoutState const&);
|
||||
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
|
||||
Gfx::FloatRect border_box_rect(Box const&, LayoutState const&);
|
||||
Gfx::FloatRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
|
||||
Gfx::FloatRect content_box_rect(Box const&, LayoutState const&);
|
||||
Gfx::FloatRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user