summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-01 18:51:25 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-01 19:01:19 +0100
commit56df05ae446cd238af7234d004417ad72368b300 (patch)
tree2d351a87835cbe7286633ecfc55e2a3cf379cb97 /Userland/Libraries
parent6478b460fb390f103db8ede8e1964ca900184048 (diff)
downloadserenity-56df05ae446cd238af7234d004417ad72368b300.zip
LibWeb: Always include floats when computing height:auto for blocks
I'm not sure why we had two modes for this, but floats should always be included in the auto height AFAICT.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp28
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.h6
3 files changed, 15 insertions, 21 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index ce217f12ca..95a1179a15 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -310,7 +310,7 @@ float BlockFormattingContext::compute_theoretical_height(FormattingState const&
if (!box.computed_values().height().has_value()
|| (box.computed_values().height()->is_length() && box.computed_values().height()->length().is_auto())
|| (computed_values.height().has_value() && computed_values.height()->is_percentage() && !is_absolute(containing_block.computed_values().height()))) {
- height = compute_auto_height_for_block_level_element(state, box, ConsiderFloats::No);
+ height = compute_auto_height_for_block_level_element(state, box);
} else {
height = computed_values.height().has_value() ? computed_values.height()->resolved(box, containing_block_height).to_px(box) : 0;
}
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index f9595ff722..6188372f94 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -206,7 +206,7 @@ static Gfx::FloatSize solve_replaced_size_constraint(FormattingState const& stat
return { w, h };
}
-float FormattingContext::compute_auto_height_for_block_level_element(FormattingState const& state, Box const& box, ConsiderFloats consider_floats)
+float FormattingContext::compute_auto_height_for_block_level_element(FormattingState const& state, Box const& box)
{
Optional<float> top;
Optional<float> bottom;
@@ -250,24 +250,22 @@ float FormattingContext::compute_auto_height_for_block_level_element(FormattingS
return IterationDecision::Continue;
});
- if (consider_floats == ConsiderFloats::Yes) {
- // In addition, if the element has any floating descendants
- // whose bottom margin edge is below the element's bottom content edge,
- // then the height is increased to include those edges.
- box.for_each_child_of_type<Box>([&](Layout::Box& child_box) {
- if (!child_box.is_floating())
- return IterationDecision::Continue;
+ // In addition, if the element has any floating descendants
+ // whose bottom margin edge is below the element's bottom content edge,
+ // then the height is increased to include those edges.
+ box.for_each_child_of_type<Box>([&](Layout::Box& child_box) {
+ if (!child_box.is_floating())
+ return IterationDecision::Continue;
- auto const& child_box_state = state.get(child_box);
+ auto const& child_box_state = state.get(child_box);
- float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height + child_box_state.margin_box_bottom();
+ float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height + child_box_state.margin_box_bottom();
- if (!bottom.has_value() || child_box_bottom > bottom.value())
- bottom = child_box_bottom;
+ if (!bottom.has_value() || child_box_bottom > bottom.value())
+ bottom = child_box_bottom;
- return IterationDecision::Continue;
- });
- }
+ return IterationDecision::Continue;
+ });
}
return bottom.value_or(0) - top.value_or(0);
}
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.h b/Userland/Libraries/LibWeb/Layout/FormattingContext.h
index 853f5125bd..08bf0337f9 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.h
@@ -58,11 +58,7 @@ protected:
static float tentative_width_for_replaced_element(FormattingState const&, ReplacedBox const&, CSS::Length const& width);
static float tentative_height_for_replaced_element(FormattingState const&, ReplacedBox const&, CSS::Length const& height);
- enum ConsiderFloats {
- Yes,
- No,
- };
- static float compute_auto_height_for_block_level_element(FormattingState const&, Box const&, ConsiderFloats consider_floats = ConsiderFloats::Yes);
+ static float compute_auto_height_for_block_level_element(FormattingState const&, Box const&);
ShrinkToFitResult calculate_shrink_to_fit_widths(Box const&);