| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "GridTrackSize.h"
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  | #include <LibWeb/CSS/Size.h>
 | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  | GridSize::GridSize(LengthPercentage length_percentage) | 
					
						
							|  |  |  |     : m_type(Type::LengthPercentage) | 
					
						
							|  |  |  |     , m_length_percentage(length_percentage) {}; | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-24 10:50:57 +02:00
										 |  |  | GridSize::GridSize(double flex_factor) | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  |     : m_type(Type::FlexibleLength) | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  |     , m_length_percentage { Length::make_px(0) } | 
					
						
							| 
									
										
										
										
											2023-05-16 14:19:28 +03:00
										 |  |  |     , m_flex_factor(flex_factor) | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-16 17:33:30 +01:00
										 |  |  | GridSize::GridSize(Type type) | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  |     : m_length_percentage { Length::make_auto() } | 
					
						
							| 
									
										
										
										
											2023-01-16 17:33:30 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(type == Type::MinContent || type == Type::MaxContent); | 
					
						
							|  |  |  |     m_type = type; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | GridSize::GridSize() | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  |     : m_type(Type::LengthPercentage) | 
					
						
							|  |  |  |     , m_length_percentage { Length::make_auto() } | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-13 17:42:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | GridSize::~GridSize() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-28 19:31:26 +03:00
										 |  |  | bool GridSize::is_auto(Layout::AvailableSize const& available_size) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_type == Type::LengthPercentage) { | 
					
						
							| 
									
										
										
										
											2023-06-02 18:31:39 +03:00
										 |  |  |         if (m_length_percentage.contains_percentage()) | 
					
						
							| 
									
										
										
										
											2023-05-28 19:31:26 +03:00
										 |  |  |             return !available_size.is_definite(); | 
					
						
							|  |  |  |         return m_length_percentage.is_auto(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GridSize::is_fixed(Layout::AvailableSize const& available_size) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_type == Type::LengthPercentage) { | 
					
						
							| 
									
										
										
										
											2023-06-02 18:31:39 +03:00
										 |  |  |         if (m_length_percentage.contains_percentage()) | 
					
						
							| 
									
										
										
										
											2023-05-28 19:31:26 +03:00
										 |  |  |             return available_size.is_definite(); | 
					
						
							|  |  |  |         return !m_length_percentage.is_auto(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GridSize::is_intrinsic(Layout::AvailableSize const& available_size) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return is_auto(available_size) || is_max_content() || is_min_content(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | GridSize GridSize::make_auto() | 
					
						
							| 
									
										
										
										
											2022-09-07 15:09:32 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     return GridSize(CSS::Length::make_auto()); | 
					
						
							| 
									
										
										
										
											2022-09-07 15:09:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  | Size GridSize::css_size() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(m_type == Type::LengthPercentage); | 
					
						
							|  |  |  |     if (m_length_percentage.is_auto()) | 
					
						
							|  |  |  |         return CSS::Size::make_auto(); | 
					
						
							|  |  |  |     if (m_length_percentage.is_length()) | 
					
						
							|  |  |  |         return CSS::Size::make_length(m_length_percentage.length()); | 
					
						
							| 
									
										
										
										
											2023-05-10 23:46:33 +03:00
										 |  |  |     if (m_length_percentage.is_calculated()) { | 
					
						
							|  |  |  |         return CSS::Size::make_calculated(m_length_percentage.calculated()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  |     return CSS::Size::make_percentage(m_length_percentage.percentage()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  | ErrorOr<String> GridSize::to_string() const | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     switch (m_type) { | 
					
						
							| 
									
										
										
										
											2023-05-10 22:38:44 +03:00
										 |  |  |     case Type::LengthPercentage: | 
					
						
							|  |  |  |         return m_length_percentage.to_string(); | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  |     case Type::FlexibleLength: | 
					
						
							| 
									
										
										
										
											2023-05-16 14:19:28 +03:00
										 |  |  |         return String::formatted("{}fr", m_flex_factor); | 
					
						
							| 
									
										
										
										
											2023-01-16 17:33:30 +01:00
										 |  |  |     case Type::MaxContent: | 
					
						
							| 
									
										
										
										
											2023-02-25 16:40:37 +01:00
										 |  |  |         return "max-content"_string; | 
					
						
							| 
									
										
										
										
											2023-01-16 17:33:30 +01:00
										 |  |  |     case Type::MinContent: | 
					
						
							| 
									
										
										
										
											2023-02-25 16:40:37 +01:00
										 |  |  |         return "min-content"_string; | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | GridMinMax::GridMinMax(GridSize min_grid_size, GridSize max_grid_size) | 
					
						
							|  |  |  |     : m_min_grid_size(min_grid_size) | 
					
						
							|  |  |  |     , m_max_grid_size(max_grid_size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  | ErrorOr<String> GridMinMax::to_string() const | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     StringBuilder builder; | 
					
						
							|  |  |  |     builder.append("minmax("sv); | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     builder.appendff("{}", TRY(m_min_grid_size.to_string())); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     builder.append(", "sv); | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     builder.appendff("{}", TRY(m_max_grid_size.to_string())); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     builder.append(")"sv); | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     return builder.to_string(); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GridRepeat::GridRepeat(GridTrackSizeList grid_track_size_list, int repeat_count) | 
					
						
							|  |  |  |     : m_type(Type::Default) | 
					
						
							|  |  |  |     , m_grid_track_size_list(grid_track_size_list) | 
					
						
							|  |  |  |     , m_repeat_count(repeat_count) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GridRepeat::GridRepeat(GridTrackSizeList grid_track_size_list, Type type) | 
					
						
							|  |  |  |     : m_type(type) | 
					
						
							|  |  |  |     , m_grid_track_size_list(grid_track_size_list) | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | GridRepeat::GridRepeat() | 
					
						
							| 
									
										
										
										
											2022-10-15 13:04:24 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  | ErrorOr<String> GridRepeat::to_string() const | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     StringBuilder builder; | 
					
						
							|  |  |  |     builder.append("repeat("sv); | 
					
						
							|  |  |  |     switch (m_type) { | 
					
						
							|  |  |  |     case Type::AutoFit: | 
					
						
							|  |  |  |         builder.append("auto-fill"sv); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Type::AutoFill: | 
					
						
							|  |  |  |         builder.append("auto-fit"sv); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case Type::Default: | 
					
						
							|  |  |  |         builder.appendff("{}", m_repeat_count); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         VERIFY_NOT_REACHED(); | 
					
						
							| 
									
										
										
										
											2022-10-15 13:04:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     builder.append(", "sv); | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     builder.appendff("{}", TRY(m_grid_track_size_list.to_string())); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     builder.append(")"sv); | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     return builder.to_string(); | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | ExplicitGridTrack::ExplicitGridTrack(CSS::GridMinMax grid_minmax) | 
					
						
							|  |  |  |     : m_type(Type::MinMax) | 
					
						
							|  |  |  |     , m_grid_minmax(grid_minmax) | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | ExplicitGridTrack::ExplicitGridTrack(CSS::GridRepeat grid_repeat) | 
					
						
							|  |  |  |     : m_type(Type::Repeat) | 
					
						
							|  |  |  |     , m_grid_repeat(grid_repeat) | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | ExplicitGridTrack::ExplicitGridTrack(CSS::GridSize grid_size) | 
					
						
							|  |  |  |     : m_type(Type::Default) | 
					
						
							|  |  |  |     , m_grid_size(grid_size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  | ErrorOr<String> ExplicitGridTrack::to_string() const | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     switch (m_type) { | 
					
						
							|  |  |  |     case Type::MinMax: | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |         return m_grid_minmax.to_string(); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     case Type::Repeat: | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |         return m_grid_repeat.to_string(); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     case Type::Default: | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |         return m_grid_size.to_string(); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     default: | 
					
						
							|  |  |  |         VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-16 17:29:15 +01:00
										 |  |  | GridTrackSizeList::GridTrackSizeList(Vector<CSS::ExplicitGridTrack> track_list, Vector<Vector<String>> line_names) | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     : m_track_list(track_list) | 
					
						
							| 
									
										
										
										
											2022-10-30 13:45:40 +01:00
										 |  |  |     , m_line_names(line_names) | 
					
						
							| 
									
										
										
										
											2022-10-15 13:02:45 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | GridTrackSizeList::GridTrackSizeList() | 
					
						
							|  |  |  |     : m_track_list({}) | 
					
						
							| 
									
										
										
										
											2022-10-30 13:45:40 +01:00
										 |  |  |     , m_line_names({}) | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-07 13:04:06 +03:00
										 |  |  | GridTrackSizeList GridTrackSizeList::make_none() | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return GridTrackSizeList(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  | ErrorOr<String> GridTrackSizeList::to_string() const | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     StringBuilder builder; | 
					
						
							| 
									
										
										
										
											2022-10-30 13:45:40 +01:00
										 |  |  |     auto print_line_names = [&](size_t index) -> void { | 
					
						
							|  |  |  |         builder.append("["sv); | 
					
						
							|  |  |  |         for (size_t y = 0; y < m_line_names[index].size(); ++y) { | 
					
						
							|  |  |  |             builder.append(m_line_names[index][y]); | 
					
						
							|  |  |  |             if (y != m_line_names[index].size() - 1) | 
					
						
							|  |  |  |                 builder.append(" "sv); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         builder.append("]"sv); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     for (size_t i = 0; i < m_track_list.size(); ++i) { | 
					
						
							| 
									
										
										
										
											2023-05-21 18:03:09 +03:00
										 |  |  |         if (m_line_names.size() > 0 && m_line_names[i].size() > 0) { | 
					
						
							| 
									
										
										
										
											2022-10-30 13:45:40 +01:00
										 |  |  |             print_line_names(i); | 
					
						
							|  |  |  |             builder.append(" "sv); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |         builder.append(TRY(m_track_list[i].to_string())); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |         if (i < m_track_list.size() - 1) | 
					
						
							|  |  |  |             builder.append(" "sv); | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-05-21 18:03:09 +03:00
										 |  |  |     if (m_line_names.size() > 0 && m_line_names[m_track_list.size()].size() > 0) { | 
					
						
							| 
									
										
										
										
											2022-10-30 13:45:40 +01:00
										 |  |  |         builder.append(" "sv); | 
					
						
							|  |  |  |         print_line_names(m_track_list.size()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     return builder.to_string(); | 
					
						
							| 
									
										
											  
											
												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.
											
										 
											2022-10-09 19:34:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:15 +02:00
										 |  |  | } |