mirror of
https://github.com/RGBCube/serenity
synced 2025-07-22 13:07:40 +00:00
LibWeb: Calculate y of a box before resolving width in BFC
Calculating width of a box in BFC requires having resolved y to be able to check if a box overlaps with any floating boxes. This change makes compute_width() to be called after finding y position. That also required to move resolving of vertical metrics in the beginning of a box layout process to have vertical margins resolved before finding y position.
This commit is contained in:
parent
582c55a1c8
commit
bf41af6b9d
1 changed files with 7 additions and 6 deletions
|
@ -250,8 +250,6 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
||||||
|
|
||||||
box_state.margin_left = margin_left.to_px(box);
|
box_state.margin_left = margin_left.to_px(box);
|
||||||
box_state.margin_right = margin_right.to_px(box);
|
box_state.margin_right = margin_right.to_px(box);
|
||||||
|
|
||||||
resolve_vertical_box_model_metrics(box, m_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFormattingContext::compute_width_for_floating_box(Box const& box, AvailableSpace const& available_space)
|
void BlockFormattingContext::compute_width_for_floating_box(Box const& box, AvailableSpace const& available_space)
|
||||||
|
@ -329,8 +327,6 @@ void BlockFormattingContext::compute_width_for_floating_box(Box const& box, Avai
|
||||||
box_state.border_right = computed_values.border_right().width;
|
box_state.border_right = computed_values.border_right().width;
|
||||||
box_state.padding_left = padding_left.to_px(box);
|
box_state.padding_left = padding_left.to_px(box);
|
||||||
box_state.padding_right = padding_right.to_px(box);
|
box_state.padding_right = padding_right.to_px(box);
|
||||||
|
|
||||||
resolve_vertical_box_model_metrics(box, m_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_normal_flow(ReplacedBox const& box, AvailableSpace const& available_space)
|
void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_normal_flow(ReplacedBox const& box, AvailableSpace const& available_space)
|
||||||
|
@ -521,6 +517,8 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
||||||
if (is<ListItemMarkerBox>(box))
|
if (is<ListItemMarkerBox>(box))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
resolve_vertical_box_model_metrics(box, m_state);
|
||||||
|
|
||||||
auto const y = m_y_offset_of_current_block_container.value();
|
auto const y = m_y_offset_of_current_block_container.value();
|
||||||
|
|
||||||
if (box.is_floating()) {
|
if (box.is_floating()) {
|
||||||
|
@ -530,8 +528,6 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_width(box, available_space, layout_mode);
|
|
||||||
|
|
||||||
if (box_state.has_definite_height()) {
|
if (box_state.has_definite_height()) {
|
||||||
compute_height(box, available_space);
|
compute_height(box, available_space);
|
||||||
}
|
}
|
||||||
|
@ -550,6 +546,9 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
||||||
}
|
}
|
||||||
|
|
||||||
place_block_level_element_in_normal_flow_vertically(box, y + margin_top);
|
place_block_level_element_in_normal_flow_vertically(box, y + margin_top);
|
||||||
|
|
||||||
|
compute_width(box, available_space, layout_mode);
|
||||||
|
|
||||||
place_block_level_element_in_normal_flow_horizontally(box, available_space);
|
place_block_level_element_in_normal_flow_horizontally(box, available_space);
|
||||||
|
|
||||||
OwnPtr<FormattingContext> independent_formatting_context;
|
OwnPtr<FormattingContext> independent_formatting_context;
|
||||||
|
@ -796,6 +795,8 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
|
||||||
auto& box_state = m_state.get_mutable(box);
|
auto& box_state = m_state.get_mutable(box);
|
||||||
CSSPixels width_of_containing_block = available_space.width.to_px();
|
CSSPixels width_of_containing_block = available_space.width.to_px();
|
||||||
|
|
||||||
|
resolve_vertical_box_model_metrics(box, m_state);
|
||||||
|
|
||||||
compute_width(box, available_space, layout_mode);
|
compute_width(box, available_space, layout_mode);
|
||||||
auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space));
|
auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space));
|
||||||
compute_height(box, available_space);
|
compute_height(box, available_space);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue