mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibWeb: Move clearing boxes below preceding floating boxes
When computing the y-position of a clearing element, use the height of the border box of the associated floating elements. This also extracts this block of code to a helper lambda since it is used twice.
This commit is contained in:
parent
e9a8646d3e
commit
1ec23f38ed
1 changed files with 10 additions and 16 deletions
|
@ -495,27 +495,21 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child_box.computed_values().clear() == CSS::Clear::Left || child_box.computed_values().clear() == CSS::Clear::Both) {
|
auto clear_floating_boxes = [&](auto& floating_boxes) {
|
||||||
if (!m_left_floating_boxes.is_empty()) {
|
if (!floating_boxes.is_empty()) {
|
||||||
float clearance_y = 0;
|
float clearance_y = 0;
|
||||||
for (auto* floating_box : m_left_floating_boxes) {
|
for (auto* floating_box : floating_boxes) {
|
||||||
clearance_y = max(clearance_y, floating_box->effective_offset().y() + floating_box->box_model().margin_box().bottom);
|
clearance_y = max(clearance_y, floating_box->effective_offset().y() + floating_box->border_box_height());
|
||||||
}
|
}
|
||||||
y = max(y, clearance_y);
|
y = max(y, clearance_y);
|
||||||
m_left_floating_boxes.clear();
|
floating_boxes.clear();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if (child_box.computed_values().clear() == CSS::Clear::Right || child_box.computed_values().clear() == CSS::Clear::Both) {
|
if (computed_values.clear() == CSS::Clear::Left || computed_values.clear() == CSS::Clear::Both)
|
||||||
if (!m_right_floating_boxes.is_empty()) {
|
clear_floating_boxes(m_left_floating_boxes);
|
||||||
float clearance_y = 0;
|
if (computed_values.clear() == CSS::Clear::Right || computed_values.clear() == CSS::Clear::Both)
|
||||||
for (auto* floating_box : m_right_floating_boxes) {
|
clear_floating_boxes(m_right_floating_boxes);
|
||||||
clearance_y = max(clearance_y, floating_box->effective_offset().y() + floating_box->box_model().margin_box().bottom);
|
|
||||||
}
|
|
||||||
y = max(y, clearance_y);
|
|
||||||
m_right_floating_boxes.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
child_box.set_offset(x, y);
|
child_box.set_offset(x, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue