mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Make it easier to check if grid track is auto positioned
Add some helper functions for checking if a grid-track is auto-positioned. I think this makes the code more legible.
This commit is contained in:
parent
236795e931
commit
9fd07e9cb1
Notes:
sideshowbarker
2024-07-17 06:14:03 +09:00
Author: https://github.com/martinfalisse Commit: https://github.com/SerenityOS/serenity/commit/9fd07e9cb1 Pull-request: https://github.com/SerenityOS/serenity/pull/15271 Reviewed-by: https://github.com/MacDue
2 changed files with 22 additions and 4 deletions
|
@ -107,8 +107,8 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
|
|||
// 1. Position anything that's not auto-positioned.
|
||||
for (size_t i = 0; i < boxes_to_place.size(); i++) {
|
||||
auto const& child_box = boxes_to_place[i];
|
||||
if ((child_box.computed_values().grid_row_start().is_auto_positioned() && child_box.computed_values().grid_row_end().is_auto_positioned())
|
||||
|| (child_box.computed_values().grid_column_start().is_auto_positioned() && child_box.computed_values().grid_column_end().is_auto_positioned()))
|
||||
if (is_auto_positioned_row(child_box.computed_values().grid_row_start(), child_box.computed_values().grid_row_end())
|
||||
|| is_auto_positioned_column(child_box.computed_values().grid_column_start(), child_box.computed_values().grid_column_end()))
|
||||
continue;
|
||||
|
||||
int row_start = child_box.computed_values().grid_row_start().raw_value();
|
||||
|
@ -219,7 +219,7 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
|
|||
// FIXME: Do "dense" packing
|
||||
for (size_t i = 0; i < boxes_to_place.size(); i++) {
|
||||
auto const& child_box = boxes_to_place[i];
|
||||
if (child_box.computed_values().grid_row_start().is_auto_positioned() && child_box.computed_values().grid_row_end().is_auto_positioned())
|
||||
if (is_auto_positioned_row(child_box.computed_values().grid_row_start(), child_box.computed_values().grid_row_end()))
|
||||
continue;
|
||||
|
||||
int row_start = child_box.computed_values().grid_row_start().raw_value();
|
||||
|
@ -349,7 +349,7 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
|
|||
// FIXME: no distinction made. See #4.2
|
||||
|
||||
// 4.1.1. If the item has a definite column position:
|
||||
if (!(child_box.computed_values().grid_column_start().is_auto_positioned() && child_box.computed_values().grid_column_end().is_auto_positioned())) {
|
||||
if (!is_auto_positioned_column(child_box.computed_values().grid_column_start(), child_box.computed_values().grid_column_end())) {
|
||||
int column_start = child_box.computed_values().grid_column_start().raw_value();
|
||||
int column_end = child_box.computed_values().grid_column_end().raw_value();
|
||||
|
||||
|
@ -1136,4 +1136,19 @@ float GridFormattingContext::automatic_content_height() const
|
|||
return m_automatic_content_height;
|
||||
}
|
||||
|
||||
bool GridFormattingContext::is_auto_positioned_row(CSS::GridTrackPlacement const& grid_row_start, CSS::GridTrackPlacement const& grid_row_end) const
|
||||
{
|
||||
return is_auto_positioned_track(grid_row_start, grid_row_end);
|
||||
}
|
||||
|
||||
bool GridFormattingContext::is_auto_positioned_column(CSS::GridTrackPlacement const& grid_column_start, CSS::GridTrackPlacement const& grid_column_end) const
|
||||
{
|
||||
return is_auto_positioned_track(grid_column_start, grid_column_end);
|
||||
}
|
||||
|
||||
bool GridFormattingContext::is_auto_positioned_track(CSS::GridTrackPlacement const& grid_track_start, CSS::GridTrackPlacement const& grid_track_end) const
|
||||
{
|
||||
return grid_track_start.is_auto_positioned() && grid_track_end.is_auto_positioned();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ public:
|
|||
|
||||
private:
|
||||
float m_automatic_content_height { 0 };
|
||||
bool is_auto_positioned_row(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
|
||||
bool is_auto_positioned_column(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
|
||||
bool is_auto_positioned_track(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue