LibWeb: Define static position calculation separately for each FC

Static position of a box is defined by formatting context type it
belongs to, so let's define this algorithm separately for each FC
instead of assuming FormattingContext::calculate_static_position_rect()
understands how to handle all of them.

Also with this change calculate_static_position_rect() is no longer
virtual function.
This commit is contained in:
Aliaksandr Kalenik 2024-10-05 22:18:53 +02:00 committed by Alexander Kalenik
commit 1a78edb8c9
Notes: github-actions[bot] 2024-10-06 13:45:57 +00:00
11 changed files with 73 additions and 49 deletions

View file

@ -1329,4 +1329,13 @@ CSSPixels BlockFormattingContext::greatest_child_width(Box const& box) const
return max_width;
}
StaticPositionRect BlockFormattingContext::calculate_static_position_rect(Box const& box) const
{
StaticPositionRect static_position;
auto const& box_state = m_state.get(box);
auto offset_to_static_parent = content_box_rect_in_static_position_ancestor_coordinate_space(box, *box.containing_block());
static_position.rect = { offset_to_static_parent.location().translated(0, box_state.vertical_offset_of_parent_block_container), { 0, 0 } };
return static_position;
}
}