summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-23 14:45:52 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-24 11:44:03 +0100
commitd5480a44e5de019bd4dcc5048167875fa016a3ee (patch)
tree81ff50b6764b627a243f7039739c27e58843f980
parenta1d37420d5fc314fdc292f4502945d15b73c0674 (diff)
downloadserenity-d5480a44e5de019bd4dcc5048167875fa016a3ee.zip
LibWeb: Allow BFC auto height calculation on any Layout::Box
This algorithm is reused in abspos sizing, and so should not be specific to block containers (even if the name suggests it.)
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp8
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.h2
3 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index e33d184b49..a8613da044 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -387,7 +387,7 @@ static bool margins_collapse_through(Box const& box, LayoutState& state)
CSSPixels BlockFormattingContext::compute_auto_height_for_block_level_element(Box const& box, AvailableSpace const& available_space)
{
if (creates_block_formatting_context(box)) {
- return compute_auto_height_for_block_formatting_context_root(verify_cast<BlockContainer>(box));
+ return compute_auto_height_for_block_formatting_context_root(box);
}
auto const& box_state = m_state.get(box);
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index b735980240..39026d3d70 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -275,7 +275,7 @@ static CSSPixelSize solve_replaced_size_constraint(LayoutState const& state, CSS
}
// https://www.w3.org/TR/CSS22/visudet.html#root-height
-CSSPixels FormattingContext::compute_auto_height_for_block_formatting_context_root(BlockContainer const& root) const
+CSSPixels FormattingContext::compute_auto_height_for_block_formatting_context_root(Box const& root) const
{
// 10.6.7 'Auto' heights for block formatting context roots
Optional<CSSPixels> top;
@@ -716,7 +716,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
top = CSS::Length::make_px(static_position.y());
// and finally apply rule number three below.
- height = CSS::Size::make_px(compute_auto_height_for_block_formatting_context_root(verify_cast<BlockContainer>(box)));
+ height = CSS::Size::make_px(compute_auto_height_for_block_formatting_context_root(box));
solve_for_bottom();
}
@@ -761,7 +761,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
return;
// then the height is based on the Auto heights for block formatting context roots,
- height = CSS::Size::make_px(compute_auto_height_for_block_formatting_context_root(verify_cast<BlockContainer>(box)));
+ height = CSS::Size::make_px(compute_auto_height_for_block_formatting_context_root(box));
// and solve for top.
solve_for_top();
@@ -783,7 +783,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
return;
// then the height is based on the Auto heights for block formatting context roots,
- height = CSS::Size::make_px(compute_auto_height_for_block_formatting_context_root(verify_cast<BlockContainer>(box)));
+ height = CSS::Size::make_px(compute_auto_height_for_block_formatting_context_root(box));
// and solve for bottom.
solve_for_bottom();
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.h b/Userland/Libraries/LibWeb/Layout/FormattingContext.h
index 7e1692c8e0..f9059176b5 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.h
@@ -102,7 +102,7 @@ protected:
static CSSPixels tentative_width_for_replaced_element(LayoutState const&, ReplacedBox const&, CSS::Size const& computed_width, AvailableSpace const&);
static CSSPixels tentative_height_for_replaced_element(LayoutState const&, ReplacedBox const&, CSS::Size const& computed_height, AvailableSpace const&);
- CSSPixels compute_auto_height_for_block_formatting_context_root(BlockContainer const&) const;
+ CSSPixels compute_auto_height_for_block_formatting_context_root(Box const&) const;
ShrinkToFitResult calculate_shrink_to_fit_widths(Box const&);