1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibWeb: Add parent classes for managing GridTrackSizes

Add classes ExplicitTrackSizing and MetaGridTrackSize which will allow
for managing properties like auto-fill and minmax.

In the following CSS example there are 3 classes that will be used:
grid-template-column: repeat(auto-fill, minmax(50px, 1fr) 75px);

ExplicitTrackSizing - will contain the entire value. e.g.
repeat(auto-fill, minmax(50px, 1fr) 75px)

With a flag if it's a repeat, as well as references to the
MetaGridTrackSizes which is the next step down.

MetaGridTrackSize:
Contain the individual grid track sizes. Here there are two:
minmax(50px, 1fr) as well as 75px.

This way can keep track if it's a minmax function or not, and the
references to both GridTrackSizes in the case it is, or in just the one
if it is not.

GridTrackSize:
Is the most basic element, in this case there are three in total; two of
which are held by the first MetaGridTrackSize, and the third is held by
the second MetaGridTrackSize.
Examples: 50px, 1fr and 75px.
This commit is contained in:
martinfalisse 2022-10-09 19:34:27 +02:00 committed by Andreas Kling
parent 414a22a386
commit f7af190de0
10 changed files with 144 additions and 54 deletions

View file

@ -64,8 +64,8 @@ public:
static CSS::Size height() { return CSS::Size::make_auto(); }
static CSS::Size min_height() { return CSS::Size::make_auto(); }
static CSS::Size max_height() { return CSS::Size::make_none(); }
static Vector<CSS::GridTrackSize> grid_template_columns() { return Vector<CSS::GridTrackSize> {}; }
static Vector<CSS::GridTrackSize> grid_template_rows() { return Vector<CSS::GridTrackSize> {}; }
static CSS::ExplicitTrackSizing grid_template_columns() { return CSS::ExplicitTrackSizing::make_auto(); }
static CSS::ExplicitTrackSizing grid_template_rows() { return CSS::ExplicitTrackSizing::make_auto(); }
static CSS::GridTrackPlacement grid_column_end() { return CSS::GridTrackPlacement::make_auto(); }
static CSS::GridTrackPlacement grid_column_start() { return CSS::GridTrackPlacement::make_auto(); }
static CSS::GridTrackPlacement grid_row_end() { return CSS::GridTrackPlacement::make_auto(); }
@ -182,8 +182,8 @@ public:
CSS::Size const& min_height() const { return m_noninherited.min_height; }
CSS::Size const& max_height() const { return m_noninherited.max_height; }
Variant<CSS::VerticalAlign, CSS::LengthPercentage> const& vertical_align() const { return m_noninherited.vertical_align; }
Vector<CSS::GridTrackSize> const& grid_template_columns() const { return m_noninherited.grid_template_columns; }
Vector<CSS::GridTrackSize> const& grid_template_rows() const { return m_noninherited.grid_template_rows; }
CSS::ExplicitTrackSizing const& grid_template_columns() const { return m_noninherited.grid_template_columns; }
CSS::ExplicitTrackSizing const& grid_template_rows() const { return m_noninherited.grid_template_rows; }
CSS::GridTrackPlacement const& grid_column_end() const { return m_noninherited.grid_column_end; }
CSS::GridTrackPlacement const& grid_column_start() const { return m_noninherited.grid_column_start; }
CSS::GridTrackPlacement const& grid_row_end() const { return m_noninherited.grid_row_end; }
@ -304,8 +304,8 @@ protected:
CSS::BoxSizing box_sizing { InitialValues::box_sizing() };
CSS::ContentData content;
Variant<CSS::VerticalAlign, CSS::LengthPercentage> vertical_align { InitialValues::vertical_align() };
Vector<CSS::GridTrackSize> grid_template_columns;
Vector<CSS::GridTrackSize> grid_template_rows;
CSS::ExplicitTrackSizing grid_template_columns;
CSS::ExplicitTrackSizing grid_template_rows;
CSS::GridTrackPlacement grid_column_end { InitialValues::grid_column_end() };
CSS::GridTrackPlacement grid_column_start { InitialValues::grid_column_start() };
CSS::GridTrackPlacement grid_row_end { InitialValues::grid_row_end() };
@ -382,8 +382,8 @@ public:
void set_box_sizing(CSS::BoxSizing value) { m_noninherited.box_sizing = value; }
void set_vertical_align(Variant<CSS::VerticalAlign, CSS::LengthPercentage> value) { m_noninherited.vertical_align = move(value); }
void set_visibility(CSS::Visibility value) { m_inherited.visibility = value; }
void set_grid_template_columns(Vector<CSS::GridTrackSize> value) { m_noninherited.grid_template_columns = move(value); }
void set_grid_template_rows(Vector<CSS::GridTrackSize> value) { m_noninherited.grid_template_rows = move(value); }
void set_grid_template_columns(CSS::ExplicitTrackSizing value) { m_noninherited.grid_template_columns = move(value); }
void set_grid_template_rows(CSS::ExplicitTrackSizing value) { m_noninherited.grid_template_rows = move(value); }
void set_grid_column_end(CSS::GridTrackPlacement value) { m_noninherited.grid_column_end = value; }
void set_grid_column_start(CSS::GridTrackPlacement value) { m_noninherited.grid_column_start = value; }
void set_grid_row_end(CSS::GridTrackPlacement value) { m_noninherited.grid_row_end = value; }