LibWeb: Delete parent state pointer in LayoutState

It's safe to remove this pointer because intrinsic layout should never
look up a box's state beyond its containing block.

This change affects the expectations of two layout tests, but both
already differ slightly from other browsers, and the difference between
expectations is less than 5px.
This commit is contained in:
Aliaksandr Kalenik 2025-03-14 01:44:02 +01:00 committed by Andreas Kling
commit d8ff71fbb5
Notes: github-actions[bot] 2025-03-26 12:09:02 +00:00
5 changed files with 29 additions and 58 deletions

View file

@ -437,7 +437,7 @@ CSSPixels FormattingContext::compute_table_box_width_inside_table_wrapper(Box co
});
VERIFY(table_box.has_value());
LayoutState throwaway_state(&m_state);
LayoutState throwaway_state;
auto& table_box_state = throwaway_state.get_mutable(*table_box);
auto const& table_box_computed_values = table_box->computed_values();
@ -476,7 +476,8 @@ CSSPixels FormattingContext::compute_table_box_height_inside_table_wrapper(Box c
// table-wrapper can't have borders or paddings but it might have margin taken from table-root.
auto available_height = height_of_containing_block - margin_top.to_px(box) - margin_bottom.to_px(box);
LayoutState throwaway_state(&m_state);
LayoutState throwaway_state;
auto context = create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box);
VERIFY(context);
context->run(m_state.get(box).available_inner_space_or_constraints_from(available_space));
@ -1454,7 +1455,7 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box)
if (cache.has_value())
return cache.value();
LayoutState throwaway_state(&m_state);
LayoutState throwaway_state;
auto& box_state = throwaway_state.get_mutable(box);
box_state.width_constraint = SizeConstraint::MinContent;
@ -1486,7 +1487,7 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box)
if (cache.has_value())
return cache.value();
LayoutState throwaway_state(&m_state);
LayoutState throwaway_state;
auto& box_state = throwaway_state.get_mutable(box);
box_state.width_constraint = SizeConstraint::MaxContent;
@ -1523,7 +1524,7 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
if (cache.has_value())
return cache.value();
LayoutState throwaway_state(&m_state);
LayoutState throwaway_state;
auto& box_state = throwaway_state.get_mutable(box);
box_state.height_constraint = SizeConstraint::MinContent;
@ -1554,7 +1555,7 @@ CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box
if (cache_slot.has_value())
return cache_slot.value();
LayoutState throwaway_state(&m_state);
LayoutState throwaway_state;
auto& box_state = throwaway_state.get_mutable(box);
box_state.height_constraint = SizeConstraint::MaxContent;