mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibWeb: Simplify static position calculation for block-level boxes
There is no need to save vertical offset in UsedValues to use later, when static position could be assigned directly upon encountering abspos box.
This commit is contained in:
parent
7225087fa2
commit
d0463bf652
Notes:
github-actions[bot]
2024-10-06 17:26:04 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: d0463bf652
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1652
3 changed files with 4 additions and 15 deletions
|
@ -640,8 +640,10 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
|||
auto& box_state = m_state.get_mutable(box);
|
||||
|
||||
if (box.is_absolutely_positioned()) {
|
||||
box_state.vertical_offset_of_parent_block_container = m_y_offset_of_current_block_container.value();
|
||||
box_state.set_static_position_rect(calculate_static_position_rect(box));
|
||||
StaticPositionRect static_position;
|
||||
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, m_y_offset_of_current_block_container.value()), { 0, 0 } };
|
||||
box_state.set_static_position_rect(static_position);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1329,13 +1331,4 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ public:
|
|||
virtual void run(AvailableSpace const&) override;
|
||||
virtual CSSPixels automatic_content_width() const override;
|
||||
virtual CSSPixels automatic_content_height() const override;
|
||||
StaticPositionRect calculate_static_position_rect(Box const&) const;
|
||||
|
||||
auto const& left_side_floats() const { return m_left_floats; }
|
||||
auto const& right_side_floats() const { return m_right_floats; }
|
||||
|
|
|
@ -130,9 +130,6 @@ struct LayoutState {
|
|||
CSSPixels inset_top { 0 };
|
||||
CSSPixels inset_bottom { 0 };
|
||||
|
||||
// Used for calculating the static position of an abspos block-level box.
|
||||
CSSPixels vertical_offset_of_parent_block_container { 0 };
|
||||
|
||||
Vector<LineBox> line_boxes;
|
||||
|
||||
CSSPixels margin_box_left() const { return margin_left + border_left_collapsed() + padding_left; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue