summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authormartinfalisse <martinmotteditfalisse@gmail.com>2022-11-06 13:37:26 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-07 10:06:07 +0100
commit2b69fa564953cebc53f06afd558d5d291e962d50 (patch)
tree33ceb0061db523b24d2d59b4c22f785452cdda31 /Userland
parent9e6612c49b874f5203d0d1fe31a070492ca219c3 (diff)
downloadserenity-2b69fa564953cebc53f06afd558d5d291e962d50.zip
LibWeb: Add some helpers for TemporaryTrack
Add some helpers to the TemporaryTrack struct to assist in making future commits more legible.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp20
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.h24
2 files changed, 31 insertions, 13 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
index a301cf2485..b188e3d064 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
@@ -684,19 +684,19 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
for (auto _ = 0; _ < repeat_count; _++) {
switch (track_in_list.type()) {
case CSS::ExplicitGridTrack::Type::MinMax:
- m_grid_columns.append({ track_in_list.minmax().min_grid_size(), track_in_list.minmax().max_grid_size() });
+ m_grid_columns.append(TemporaryTrack(track_in_list.minmax().min_grid_size(), track_in_list.minmax().max_grid_size()));
break;
case CSS::ExplicitGridTrack::Type::Repeat:
for (auto& explicit_grid_track : track_in_list.repeat().grid_track_size_list().track_list()) {
auto track_sizing_function = explicit_grid_track;
if (track_sizing_function.is_minmax())
- m_grid_columns.append({ track_sizing_function.minmax().min_grid_size(), track_sizing_function.minmax().max_grid_size() });
+ m_grid_columns.append(TemporaryTrack(track_sizing_function.minmax().min_grid_size(), track_sizing_function.minmax().max_grid_size()));
else
- m_grid_columns.append({ track_sizing_function.grid_size(), track_sizing_function.grid_size() });
+ m_grid_columns.append(TemporaryTrack(track_sizing_function.grid_size()));
}
break;
case CSS::ExplicitGridTrack::Type::Default:
- m_grid_columns.append({ track_in_list.grid_size(), track_in_list.grid_size() });
+ m_grid_columns.append(TemporaryTrack(track_in_list.grid_size()));
break;
default:
VERIFY_NOT_REACHED();
@@ -712,19 +712,19 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
for (auto _ = 0; _ < repeat_count; _++) {
switch (track_in_list.type()) {
case CSS::ExplicitGridTrack::Type::MinMax:
- m_grid_rows.append({ track_in_list.minmax().min_grid_size(), track_in_list.minmax().max_grid_size() });
+ m_grid_rows.append(TemporaryTrack(track_in_list.minmax().min_grid_size(), track_in_list.minmax().max_grid_size()));
break;
case CSS::ExplicitGridTrack::Type::Repeat:
for (auto& explicit_grid_track : track_in_list.repeat().grid_track_size_list().track_list()) {
auto track_sizing_function = explicit_grid_track;
if (track_sizing_function.is_minmax())
- m_grid_rows.append({ track_sizing_function.minmax().min_grid_size(), track_sizing_function.minmax().max_grid_size() });
+ m_grid_rows.append(TemporaryTrack(track_sizing_function.minmax().min_grid_size(), track_sizing_function.minmax().max_grid_size()));
else
- m_grid_rows.append({ track_sizing_function.grid_size(), track_sizing_function.grid_size() });
+ m_grid_rows.append(TemporaryTrack(track_sizing_function.grid_size()));
}
break;
case CSS::ExplicitGridTrack::Type::Default:
- m_grid_rows.append({ track_in_list.grid_size(), track_in_list.grid_size() });
+ m_grid_rows.append(TemporaryTrack(track_in_list.grid_size()));
break;
default:
VERIFY_NOT_REACHED();
@@ -733,9 +733,9 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
}
for (int column_index = m_grid_columns.size(); column_index < occupation_grid.column_count(); column_index++)
- m_grid_columns.append({ CSS::GridSize::make_auto(), CSS::GridSize::make_auto() });
+ m_grid_columns.append(TemporaryTrack());
for (int row_index = m_grid_rows.size(); row_index < occupation_grid.row_count(); row_index++)
- m_grid_rows.append({ CSS::GridSize::make_auto(), CSS::GridSize::make_auto() });
+ m_grid_rows.append(TemporaryTrack());
// https://www.w3.org/TR/css-grid-2/#algo-overview
// 12.1. Grid Sizing Algorithm
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
index 43c797eb0b..249178aea3 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
@@ -26,17 +26,35 @@ private:
bool is_auto_positioned_column(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
bool is_auto_positioned_track(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
- struct GridTrackSizeConstraints {
+ struct TemporaryTrack {
CSS::GridSize min_track_sizing_function;
CSS::GridSize max_track_sizing_function;
float base_size { 0 };
float growth_limit { 0 };
float space_to_distribute { 0 };
float planned_increase { 0 };
+
+ TemporaryTrack(CSS::GridSize min_track_sizing_function, CSS::GridSize max_track_sizing_function)
+ : min_track_sizing_function(min_track_sizing_function)
+ , max_track_sizing_function(max_track_sizing_function)
+ {
+ }
+
+ TemporaryTrack(CSS::GridSize track_sizing_function)
+ : min_track_sizing_function(track_sizing_function)
+ , max_track_sizing_function(track_sizing_function)
+ {
+ }
+
+ TemporaryTrack()
+ : min_track_sizing_function(CSS::GridSize::make_auto())
+ , max_track_sizing_function(CSS::GridSize::make_auto())
+ {
+ }
};
- Vector<GridTrackSizeConstraints> m_grid_rows;
- Vector<GridTrackSizeConstraints> m_grid_columns;
+ Vector<TemporaryTrack> m_grid_rows;
+ Vector<TemporaryTrack> m_grid_columns;
float get_free_space_x(AvailableSpace const& available_space);
float get_free_space_y(Box const&);