summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp44
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.h11
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp6
4 files changed, 35 insertions, 30 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 8f03965073..8a47cd7245 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -689,8 +689,8 @@ float FlexFormattingContext::content_size_suggestion(FlexItem const& item) const
{
// FIXME: Apply clamps
if (is_row_layout())
- return calculate_min_and_max_content_width(item.box).min_content_size;
- return calculate_min_and_max_content_height(item.box).min_content_size;
+ return calculate_min_content_width(item.box);
+ return calculate_min_content_height(item.box);
}
// https://drafts.csswg.org/css-flexbox-1/#transferred-size-suggestion
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index db57ee0f76..a15981361a 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -164,10 +164,9 @@ float FormattingContext::greatest_child_width(Box const& box)
FormattingContext::ShrinkToFitResult FormattingContext::calculate_shrink_to_fit_widths(Box const& box)
{
- auto [min_content, max_content] = calculate_intrinsic_sizes(box);
return {
- .preferred_width = max_content.width(),
- .preferred_minimum_width = min_content.width(),
+ .preferred_width = calculate_max_content_width(box),
+ .preferred_minimum_width = calculate_min_content_width(box),
};
}
@@ -889,18 +888,6 @@ FormattingState::IntrinsicSizes FormattingContext::calculate_intrinsic_sizes(Lay
return cached_box_sizes;
}
-FormattingContext::MinAndMaxContentSize FormattingContext::calculate_min_and_max_content_width(Layout::Box const& box) const
-{
- auto const& sizes = calculate_intrinsic_sizes(box);
- return { sizes.min_content_size.width(), sizes.max_content_size.width() };
-}
-
-FormattingContext::MinAndMaxContentSize FormattingContext::calculate_min_and_max_content_height(Layout::Box const& box) const
-{
- auto const& sizes = calculate_intrinsic_sizes(box);
- return { sizes.min_content_size.height(), sizes.max_content_size.height() };
-}
-
float FormattingContext::calculate_fit_content_size(float min_content_size, float max_content_size, Optional<float> available_space) const
{
// If the available space in a given axis is definite, equal to clamp(min-content size, stretch-fit size, max-content size)
@@ -920,14 +907,12 @@ float FormattingContext::calculate_fit_content_size(float min_content_size, floa
float FormattingContext::calculate_fit_content_width(Layout::Box const& box, Optional<float> available_space) const
{
- auto [min_content_size, max_content_size] = calculate_min_and_max_content_width(box);
- return calculate_fit_content_size(min_content_size, max_content_size, available_space);
+ return calculate_fit_content_size(calculate_min_content_width(box), calculate_max_content_width(box), available_space);
}
float FormattingContext::calculate_fit_content_height(Layout::Box const& box, Optional<float> available_space) const
{
- auto [min_content_size, max_content_size] = calculate_min_and_max_content_height(box);
- return calculate_fit_content_size(min_content_size, max_content_size, available_space);
+ return calculate_fit_content_size(calculate_min_content_height(box), calculate_max_content_height(box), available_space);
}
float FormattingContext::calculate_auto_height(FormattingState const& state, Box const& box)
@@ -938,4 +923,25 @@ float FormattingContext::calculate_auto_height(FormattingState const& state, Box
return compute_auto_height_for_block_level_element(state, box);
}
+
+float FormattingContext::calculate_min_content_width(Layout::Box const& box) const
+{
+ return calculate_intrinsic_sizes(box).min_content_size.width();
+}
+
+float FormattingContext::calculate_max_content_width(Layout::Box const& box) const
+{
+ return calculate_intrinsic_sizes(box).max_content_size.width();
+}
+
+float FormattingContext::calculate_min_content_height(Layout::Box const& box) const
+{
+ return calculate_intrinsic_sizes(box).min_content_size.height();
+}
+
+float FormattingContext::calculate_max_content_height(Layout::Box const& box) const
+{
+ return calculate_intrinsic_sizes(box).max_content_size.height();
+}
+
}
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.h b/Userland/Libraries/LibWeb/Layout/FormattingContext.h
index d9f4572eb0..98cc417cc3 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.h
@@ -45,13 +45,10 @@ public:
virtual void parent_context_did_dimension_child_root_box() { }
- struct MinAndMaxContentSize {
- float min_content_size { 0 };
- float max_content_size { 0 };
- };
-
- MinAndMaxContentSize calculate_min_and_max_content_width(Layout::Box const&) const;
- MinAndMaxContentSize calculate_min_and_max_content_height(Layout::Box const&) const;
+ float calculate_min_content_width(Layout::Box const&) const;
+ float calculate_max_content_width(Layout::Box const&) const;
+ float calculate_min_content_height(Layout::Box const&) const;
+ float calculate_max_content_height(Layout::Box const&) const;
float calculate_fit_content_height(Layout::Box const&, Optional<float> available_height) const;
float calculate_fit_content_width(Layout::Box const&, Optional<float> available_width) const;
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
index 907ba5bd87..343df1584f 100644
--- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
@@ -123,7 +123,8 @@ void TableFormattingContext::calculate_column_widths(Box const& row, CSS::Length
(void)layout_inside(cell, LayoutMode::Normal);
if (cell.colspan() == 1) {
- auto [min_width, max_width] = calculate_min_and_max_content_width(cell);
+ auto min_width = calculate_min_content_width(cell);
+ auto max_width = calculate_max_content_width(cell);
min_width = max(min_width, cell_state.border_box_width());
max_width = max(max_width, cell_state.border_box_width());
column_widths[column_index].min = max(column_widths[column_index].min, min_width);
@@ -137,7 +138,8 @@ void TableFormattingContext::calculate_column_widths(Box const& row, CSS::Length
size_t colspan = cell.colspan();
if (colspan > 1) {
auto& cell_state = m_state.get_mutable(cell);
- auto [min_width, max_width] = calculate_min_and_max_content_width(cell);
+ auto min_width = calculate_min_content_width(cell);
+ auto max_width = calculate_max_content_width(cell);
float missing_min = max(min_width, cell_state.border_box_width());
float missing_max = max(max_width, cell_state.border_box_width());
for (size_t i = 0; i < colspan; ++i) {