summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-05-11 18:04:18 -0400
committerLinus Groh <mail@linusgroh.de>2021-05-12 08:50:20 +0100
commit1ec23f38ed4e7efa224f43d2461579a87d974e2e (patch)
tree6302f26c1d507a5f111243bc5b6e4c16f35557f4 /Userland/Libraries/LibWeb/Layout
parente9a8646d3e89bfd2a893bcf57c09bc12343fc98c (diff)
downloadserenity-1ec23f38ed4e7efa224f43d2461579a87d974e2e.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index 815f2bf6bc..b0650284ef 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -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) {
- if (!m_left_floating_boxes.is_empty()) {
+ auto clear_floating_boxes = [&](auto& floating_boxes) {
+ if (!floating_boxes.is_empty()) {
float clearance_y = 0;
- for (auto* floating_box : m_left_floating_boxes) {
- clearance_y = max(clearance_y, floating_box->effective_offset().y() + floating_box->box_model().margin_box().bottom);
+ for (auto* floating_box : floating_boxes) {
+ clearance_y = max(clearance_y, floating_box->effective_offset().y() + floating_box->border_box_height());
}
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 (!m_right_floating_boxes.is_empty()) {
- float clearance_y = 0;
- for (auto* floating_box : 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();
- }
- }
+ if (computed_values.clear() == CSS::Clear::Left || computed_values.clear() == CSS::Clear::Both)
+ clear_floating_boxes(m_left_floating_boxes);
+ if (computed_values.clear() == CSS::Clear::Right || computed_values.clear() == CSS::Clear::Both)
+ clear_floating_boxes(m_right_floating_boxes);
child_box.set_offset(x, y);
}