mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +00:00
LibWeb: Make box content sizes indefinite before intrinsic sizing
When calculating the intrinsic width of a box, we now make its content width & height indefinite before entering the intrinsic sizing layout. This ensures that any geometry assigned to the box by its parent formatting context is ignored. For intrinsic heights, we only make the content height indefinite. This is because used content width is a valid (but optional) input to intrinsic height calculation.
This commit is contained in:
parent
7639eccd53
commit
ca290b27ea
3 changed files with 23 additions and 0 deletions
|
@ -1093,6 +1093,8 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box)
|
|||
|
||||
auto& box_state = throwaway_state.get_mutable(box);
|
||||
box_state.width_constraint = SizeConstraint::MinContent;
|
||||
box_state.set_indefinite_content_width();
|
||||
box_state.set_indefinite_content_height();
|
||||
|
||||
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
VERIFY(context);
|
||||
|
@ -1127,6 +1129,8 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box)
|
|||
|
||||
auto& box_state = throwaway_state.get_mutable(box);
|
||||
box_state.width_constraint = SizeConstraint::MaxContent;
|
||||
box_state.set_indefinite_content_width();
|
||||
box_state.set_indefinite_content_height();
|
||||
|
||||
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
VERIFY(context);
|
||||
|
@ -1177,6 +1181,9 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
|
|||
|
||||
auto& box_state = throwaway_state.get_mutable(box);
|
||||
box_state.height_constraint = SizeConstraint::MinContent;
|
||||
box_state.set_indefinite_content_height();
|
||||
if (available_width.is_definite())
|
||||
box_state.set_content_width(available_width.to_px());
|
||||
|
||||
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
VERIFY(context);
|
||||
|
@ -1222,6 +1229,9 @@ CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box
|
|||
|
||||
auto& box_state = throwaway_state.get_mutable(box);
|
||||
box_state.height_constraint = SizeConstraint::MaxContent;
|
||||
box_state.set_indefinite_content_height();
|
||||
if (available_width.is_definite())
|
||||
box_state.set_content_width(available_width.to_px());
|
||||
|
||||
auto context = const_cast<FormattingContext*>(this)->create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
VERIFY(context);
|
||||
|
|
|
@ -416,4 +416,14 @@ void LayoutState::UsedValues::set_content_y(CSSPixels y)
|
|||
offset.set_y(y);
|
||||
}
|
||||
|
||||
void LayoutState::UsedValues::set_indefinite_content_width()
|
||||
{
|
||||
m_has_definite_width = false;
|
||||
}
|
||||
|
||||
void LayoutState::UsedValues::set_indefinite_content_height()
|
||||
{
|
||||
m_has_definite_height = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ struct LayoutState {
|
|||
void set_content_width(CSSPixels);
|
||||
void set_content_height(CSSPixels);
|
||||
|
||||
void set_indefinite_content_width();
|
||||
void set_indefinite_content_height();
|
||||
|
||||
// NOTE: These are used by FlexFormattingContext to assign a temporary main size to items
|
||||
// early on, so that descendants have something to resolve percentages against.
|
||||
void set_temporary_content_width(CSSPixels);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue