mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibWeb: Better handling of floating boxes from inline formatting context
Handle the clear property for floating boxes and add tracking for vertical clearence within an inline formatting context.
This commit is contained in:
parent
fd86509ef8
commit
62f15f94d2
9 changed files with 78 additions and 8 deletions
|
@ -601,7 +601,7 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
|||
}
|
||||
|
||||
m_margin_state.add_margin(box_state.margin_top);
|
||||
auto introduce_clearance = clear_floating_boxes(box);
|
||||
auto introduce_clearance = clear_floating_boxes(box, {});
|
||||
if (introduce_clearance == DidIntroduceClearance::Yes)
|
||||
m_margin_state.reset();
|
||||
|
||||
|
@ -752,7 +752,7 @@ CSSPixels BlockFormattingContext::BlockMarginState::current_collapsed_margin() c
|
|||
return collapsed_margin;
|
||||
}
|
||||
|
||||
BlockFormattingContext::DidIntroduceClearance BlockFormattingContext::clear_floating_boxes(Node const& child_box)
|
||||
BlockFormattingContext::DidIntroduceClearance BlockFormattingContext::clear_floating_boxes(Node const& child_box, Optional<InlineFormattingContext&> inline_formatting_context)
|
||||
{
|
||||
auto const& computed_values = child_box.computed_values();
|
||||
auto result = DidIntroduceClearance::No;
|
||||
|
@ -777,7 +777,12 @@ BlockFormattingContext::DidIntroduceClearance BlockFormattingContext::clear_floa
|
|||
for (auto* containing_block = child_box.containing_block(); containing_block && containing_block != &root(); containing_block = containing_block->containing_block())
|
||||
clearance_y_in_containing_block -= m_state.get(*containing_block).offset.y();
|
||||
|
||||
if (clearance_y_in_containing_block > m_y_offset_of_current_block_container.value()) {
|
||||
if (inline_formatting_context.has_value()) {
|
||||
if (clearance_y_in_containing_block > inline_formatting_context->vertical_float_clearance()) {
|
||||
result = DidIntroduceClearance::Yes;
|
||||
inline_formatting_context->set_vertical_float_clearance(clearance_y_in_containing_block);
|
||||
}
|
||||
} else if (clearance_y_in_containing_block > m_y_offset_of_current_block_container.value()) {
|
||||
result = DidIntroduceClearance::Yes;
|
||||
m_y_offset_of_current_block_container = clearance_y_in_containing_block;
|
||||
}
|
||||
|
@ -879,7 +884,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
|
|||
// First we place the box normally (to get the right y coordinate.)
|
||||
// If we have a LineBuilder, we're in the middle of inline layout, otherwise this is block layout.
|
||||
if (line_builder) {
|
||||
auto y = line_builder->y_for_float_to_be_inserted_here(box);
|
||||
auto y = max(line_builder->y_for_float_to_be_inserted_here(box), line_builder->inline_formatting_context().vertical_float_clearance());
|
||||
box_state.set_content_y(y + box_state.margin_box_top());
|
||||
} else {
|
||||
place_block_level_element_in_normal_flow_vertically(box, y + box_state.margin_top);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue