summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2023-05-15 15:54:25 +0300
committerAndreas Kling <kling@serenityos.org>2023-05-15 16:27:53 +0200
commitae5bb13f1f6af2dc141d69179b09c8b747fdd99e (patch)
treeaa9b22f7be1ec75e53da1046c728e527844172ad /Userland/Libraries/LibWeb
parent1ecbbadf3a25cff8d240f096bd1e4b57f02ca229 (diff)
downloadserenity-ae5bb13f1f6af2dc141d69179b09c8b747fdd99e.zip
LibWeb: Do not layout grid items during grid container intrinsic sizing
There is not need to run layout inside grid items for intrinsic sizing of grid container.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp23
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.h1
2 files changed, 16 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
index 5310c1db6a..8c45f0aea1 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
@@ -1316,6 +1316,14 @@ void GridFormattingContext::place_grid_items(AvailableSpace const& available_spa
}
}
+void GridFormattingContext::determine_grid_container_height()
+{
+ CSSPixels total_y = 0;
+ for (auto& grid_row : m_grid_rows_and_gaps)
+ total_y += grid_row.full_vertical_size();
+ m_automatic_content_height = total_y;
+}
+
void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const& available_space)
{
place_grid_items(available_space);
@@ -1327,6 +1335,13 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
run_track_sizing(available_space, GridDimension::Column);
run_track_sizing(available_space, GridDimension::Row);
+ determine_grid_container_height();
+
+ if (available_space.height.is_intrinsic_sizing_constraint() || available_space.width.is_intrinsic_sizing_constraint()) {
+ determine_intrinsic_size_of_grid_container(available_space);
+ return;
+ }
+
auto layout_box = [&](int row_start, int row_end, int column_start, int column_end, Box const& child_box) -> void {
if (column_start < 0 || row_start < 0)
return;
@@ -1393,14 +1408,6 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
grid_item.gap_adjusted_column(box) + resolved_column_span,
grid_item.box());
}
-
- if (available_space.height.is_intrinsic_sizing_constraint() || available_space.width.is_intrinsic_sizing_constraint())
- determine_intrinsic_size_of_grid_container(available_space);
-
- CSSPixels total_y = 0;
- for (auto& grid_row : m_grid_rows_and_gaps)
- total_y += grid_row.full_vertical_size();
- m_automatic_content_height = total_y;
}
void GridFormattingContext::determine_intrinsic_size_of_grid_container(AvailableSpace const& available_space)
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
index dc8742d572..9c17b8ae5b 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
@@ -167,6 +167,7 @@ private:
Vector<GridItem> m_grid_items;
Vector<JS::NonnullGCPtr<Box const>> m_boxes_to_place;
+ void determine_grid_container_height();
void determine_intrinsic_size_of_grid_container(AvailableSpace const& available_space);
AvailableSize get_free_space(AvailableSpace const&, GridDimension const) const;