2022-08-24 12:21:15 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
2025-06-18 15:47:41 +02:00
|
|
|
* Copyright (c) 2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
2025-11-18 15:25:03 +00:00
|
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
2022-08-24 12:21:15 +02:00
|
|
|
*
|
|
|
|
|
* 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>
|
2026-04-02 13:15:26 +13:00
|
|
|
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
|
2022-08-24 12:21:15 +02:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2026-04-02 13:15:26 +13:00
|
|
|
GridSize::GridSize(NonnullRefPtr<StyleValue const> size)
|
2025-09-04 11:38:27 +01:00
|
|
|
: m_value(move(size))
|
2023-09-28 16:16:25 +01:00
|
|
|
{
|
|
|
|
|
}
|
2022-08-24 12:21:15 +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
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
if (m_value->to_keyword() == Keyword::Auto)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (m_value->is_percentage() || (m_value->is_calculated() && m_value->as_calculated().contains_percentage()))
|
|
|
|
|
return !available_size.is_definite();
|
2023-05-28 19:31:26 +03:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 13:15:26 +13:00
|
|
|
static bool is_length_percentage(NonnullRefPtr<StyleValue const> const& value)
|
|
|
|
|
{
|
|
|
|
|
return value->is_length() || value->is_percentage() || (value->is_calculated() && value->as_calculated().resolves_to_length());
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-28 19:31:26 +03:00
|
|
|
bool GridSize::is_fixed(Layout::AvailableSize const& available_size) const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
if (!is_length_percentage(m_value))
|
|
|
|
|
return false;
|
2023-05-28 19:31:26 +03:00
|
|
|
|
2026-04-02 13:15:26 +13:00
|
|
|
if (m_value->is_percentage() || (m_value->is_calculated() && m_value->as_calculated().contains_percentage()))
|
|
|
|
|
return available_size.is_definite();
|
|
|
|
|
|
|
|
|
|
return true;
|
2023-05-28 19:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-04 11:38:27 +01:00
|
|
|
bool GridSize::is_flexible_length() const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return m_value->is_flex() || (m_value->is_calculated() && m_value->as_calculated().resolves_to_flex());
|
2025-09-04 11:38:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GridSize::is_fit_content() const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return m_value->is_fit_content();
|
2025-09-04 11:38:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GridSize::is_max_content() const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return m_value->to_keyword() == Keyword::MaxContent;
|
2025-09-04 11:38:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GridSize::is_min_content() const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return m_value->to_keyword() == Keyword::MinContent;
|
2025-09-04 11:38:27 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-28 19:31:26 +03:00
|
|
|
bool GridSize::is_intrinsic(Layout::AvailableSize const& available_size) const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return is_auto(available_size) || is_max_content() || is_min_content() || is_fit_content();
|
2023-05-28 19:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-04 11:38:27 +01:00
|
|
|
bool GridSize::is_definite() const
|
2022-09-07 15:09:32 +02:00
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return is_length_percentage(m_value);
|
2022-09-07 15:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-04 11:38:27 +01:00
|
|
|
GridSize GridSize::make_auto()
|
2023-05-10 22:38:44 +03:00
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
return GridSize(KeywordStyleValue::create(Keyword::Auto));
|
2023-05-10 22:38:44 +03:00
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
void GridSize::serialize(StringBuilder& builder, SerializationMode mode) const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
m_value->serialize(builder, mode);
|
2026-01-08 15:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
2025-08-03 15:37:42 +12:00
|
|
|
String GridSize::to_string(SerializationMode mode) const
|
2022-08-24 12:21:15 +02:00
|
|
|
{
|
2026-01-08 15:11:02 +00:00
|
|
|
StringBuilder builder;
|
|
|
|
|
serialize(builder, mode);
|
|
|
|
|
return MUST(builder.to_string());
|
2022-08-24 12:21:15 +02:00
|
|
|
}
|
|
|
|
|
|
2025-11-18 15:25:03 +00:00
|
|
|
GridSize GridSize::absolutized(ComputationContext const& context) const
|
|
|
|
|
{
|
2026-04-02 13:15:26 +13:00
|
|
|
auto absolutized_value = m_value->absolutized(context);
|
2025-11-18 15:25:03 +00:00
|
|
|
|
2026-04-02 13:15:26 +13:00
|
|
|
if (absolutized_value == m_value)
|
|
|
|
|
return *this;
|
2025-11-18 15:25:03 +00:00
|
|
|
|
2026-04-02 13:15:26 +13:00
|
|
|
return GridSize { absolutized_value };
|
2025-11-18 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-30 13:27:57 +01:00
|
|
|
GridMinMax::GridMinMax(GridSize min_grid_size, GridSize max_grid_size)
|
2025-09-04 11:38:27 +01:00
|
|
|
: m_min_grid_size(move(min_grid_size))
|
|
|
|
|
, m_max_grid_size(move(max_grid_size))
|
2022-10-30 13:27:57 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
void GridMinMax::serialize(StringBuilder& builder, SerializationMode mode) const
|
2022-10-30 13:27:57 +01:00
|
|
|
{
|
|
|
|
|
builder.append("minmax("sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
m_min_grid_size.serialize(builder, mode);
|
2022-10-30 13:27:57 +01:00
|
|
|
builder.append(", "sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
m_max_grid_size.serialize(builder, mode);
|
2022-10-30 13:27:57 +01:00
|
|
|
builder.append(")"sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String GridMinMax::to_string(SerializationMode mode) const
|
|
|
|
|
{
|
|
|
|
|
StringBuilder builder;
|
|
|
|
|
serialize(builder, mode);
|
2023-08-22 12:35:16 +01:00
|
|
|
return MUST(builder.to_string());
|
2022-10-30 13:27:57 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-18 15:25:03 +00:00
|
|
|
GridMinMax GridMinMax::absolutized(ComputationContext const& context) const
|
|
|
|
|
{
|
|
|
|
|
return GridMinMax {
|
|
|
|
|
m_min_grid_size.absolutized(context),
|
|
|
|
|
m_max_grid_size.absolutized(context),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 14:50:35 +13:00
|
|
|
GridRepeat::GridRepeat(GridRepeatType grid_repeat_type, GridTrackSizeList&& grid_track_size_list, RefPtr<StyleValue const> repeat_count)
|
2025-09-23 15:02:51 +01:00
|
|
|
: m_type(grid_repeat_type)
|
2025-06-16 22:27:17 +02:00
|
|
|
, m_grid_track_size_list(move(grid_track_size_list))
|
2026-03-29 14:50:35 +13:00
|
|
|
, m_repeat_count(move(repeat_count))
|
2025-09-23 15:02:51 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridRepeat::GridRepeat(GridTrackSizeList&& grid_track_size_list, GridRepeatParams const& params)
|
|
|
|
|
: GridRepeat(params.type, move(grid_track_size_list), params.count)
|
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
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
void GridRepeat::serialize(StringBuilder& builder, SerializationMode mode) 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
|
|
|
builder.append("repeat("sv);
|
|
|
|
|
switch (m_type) {
|
2025-06-16 22:27:17 +02:00
|
|
|
case GridRepeatType::AutoFit:
|
2025-06-17 17:15:00 +02:00
|
|
|
builder.append("auto-fit"sv);
|
2022-10-30 13:27:57 +01:00
|
|
|
break;
|
2025-06-16 22:27:17 +02:00
|
|
|
case GridRepeatType::AutoFill:
|
2025-06-17 17:15:00 +02:00
|
|
|
builder.append("auto-fill"sv);
|
2022-10-30 13:27:57 +01:00
|
|
|
break;
|
2025-06-16 22:27:17 +02:00
|
|
|
case GridRepeatType::Fixed:
|
2026-03-29 14:50:35 +13:00
|
|
|
m_repeat_count->serialize(builder, mode);
|
2022-10-30 13:27:57 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
VERIFY_NOT_REACHED();
|
2022-10-15 13:04:24 +02:00
|
|
|
}
|
2022-10-30 13:27:57 +01:00
|
|
|
builder.append(", "sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
m_grid_track_size_list.serialize(builder, mode);
|
2022-10-30 13:27:57 +01:00
|
|
|
builder.append(")"sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String GridRepeat::to_string(SerializationMode mode) const
|
|
|
|
|
{
|
|
|
|
|
StringBuilder builder;
|
|
|
|
|
serialize(builder, mode);
|
2023-08-22 12:35:16 +01:00
|
|
|
return MUST(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
|
|
|
}
|
|
|
|
|
|
2025-11-18 15:25:03 +00:00
|
|
|
GridRepeat GridRepeat::absolutized(ComputationContext const& context) const
|
|
|
|
|
{
|
|
|
|
|
return GridRepeat {
|
|
|
|
|
m_type,
|
|
|
|
|
m_grid_track_size_list.absolutized(context),
|
2026-03-29 14:50:35 +13:00
|
|
|
m_repeat_count ? RefPtr<StyleValue const> { m_repeat_count->absolutized(context) } : nullptr,
|
2025-11-18 15:25:03 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-18 15:47:41 +02:00
|
|
|
ExplicitGridTrack::ExplicitGridTrack(Variant<GridRepeat, GridMinMax, GridSize>&& value)
|
2025-06-13 17:12:04 +02:00
|
|
|
: m_value(move(value))
|
2022-10-30 13:27:57 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
void ExplicitGridTrack::serialize(StringBuilder& builder, SerializationMode mode) 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
|
|
|
{
|
2026-01-08 15:11:02 +00:00
|
|
|
m_value.visit([&builder, mode](auto const& track) {
|
|
|
|
|
track.serialize(builder, mode);
|
2025-06-13 17:12:04 +02: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.
2022-10-09 19:34:27 +02:00
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
String ExplicitGridTrack::to_string(SerializationMode mode) const
|
|
|
|
|
{
|
|
|
|
|
StringBuilder builder;
|
|
|
|
|
serialize(builder, mode);
|
|
|
|
|
return MUST(builder.to_string());
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 15:25:03 +00:00
|
|
|
ExplicitGridTrack ExplicitGridTrack::absolutized(ComputationContext const& context) const
|
|
|
|
|
{
|
|
|
|
|
return m_value.visit([&](auto const& it) {
|
|
|
|
|
return ExplicitGridTrack { it.absolutized(context) };
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
void GridLineNames::serialize(StringBuilder& builder) const
|
2024-01-05 04:24:36 +01:00
|
|
|
{
|
|
|
|
|
builder.append("["sv);
|
2025-06-25 17:58:07 +02:00
|
|
|
for (size_t i = 0; i < m_names.size(); ++i) {
|
|
|
|
|
if (i > 0)
|
|
|
|
|
builder.append(" "sv);
|
|
|
|
|
builder.append(m_names[i].name);
|
|
|
|
|
}
|
2024-01-05 04:24:36 +01:00
|
|
|
builder.append("]"sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String GridLineNames::to_string() const
|
|
|
|
|
{
|
|
|
|
|
StringBuilder builder;
|
|
|
|
|
serialize(builder);
|
2024-01-05 04:24:36 +01:00
|
|
|
return MUST(builder.to_string());
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-07 13:04:06 +03:00
|
|
|
GridTrackSizeList GridTrackSizeList::make_none()
|
2022-10-30 13:27:57 +01:00
|
|
|
{
|
|
|
|
|
return GridTrackSizeList();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
void GridTrackSizeList::serialize(StringBuilder& builder, SerializationMode mode) 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
|
|
|
{
|
2026-01-08 15:11:02 +00:00
|
|
|
if (m_list.is_empty()) {
|
|
|
|
|
builder.append("none"sv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-10-14 14:32:27 +01:00
|
|
|
|
2026-01-08 15:11:02 +00:00
|
|
|
bool first = true;
|
2024-01-05 04:24:36 +01:00
|
|
|
for (auto const& line_definition_or_name : m_list) {
|
2026-01-08 15:11:02 +00:00
|
|
|
if (!first)
|
2022-10-30 13:45:40 +01:00
|
|
|
builder.append(" "sv);
|
2026-01-08 15:11:02 +00:00
|
|
|
first = false;
|
2024-01-05 04:24:36 +01:00
|
|
|
if (line_definition_or_name.has<ExplicitGridTrack>()) {
|
2026-01-08 15:11:02 +00:00
|
|
|
line_definition_or_name.get<ExplicitGridTrack>().serialize(builder, mode);
|
2024-01-05 04:24:36 +01:00
|
|
|
} else if (line_definition_or_name.has<GridLineNames>()) {
|
2026-01-08 15:11:02 +00:00
|
|
|
line_definition_or_name.get<GridLineNames>().serialize(builder);
|
2022-10-30 13:45:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 15:11:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String GridTrackSizeList::to_string(SerializationMode mode) const
|
|
|
|
|
{
|
|
|
|
|
StringBuilder builder;
|
|
|
|
|
serialize(builder, mode);
|
2023-08-22 12:35:16 +01:00
|
|
|
return MUST(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
|
|
|
}
|
|
|
|
|
|
2024-01-05 04:24:36 +01:00
|
|
|
Vector<ExplicitGridTrack> GridTrackSizeList::track_list() const
|
|
|
|
|
{
|
|
|
|
|
Vector<ExplicitGridTrack> track_list;
|
|
|
|
|
for (auto const& line_definition_or_name : m_list) {
|
|
|
|
|
if (line_definition_or_name.has<ExplicitGridTrack>())
|
|
|
|
|
track_list.append(line_definition_or_name.get<ExplicitGridTrack>());
|
|
|
|
|
}
|
|
|
|
|
return track_list;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-13 17:17:53 +02:00
|
|
|
bool GridTrackSizeList::operator==(GridTrackSizeList const& other) const = default;
|
2024-01-05 04:24:36 +01:00
|
|
|
|
2025-06-16 22:27:17 +02:00
|
|
|
void GridTrackSizeList::append(GridLineNames&& line_names)
|
|
|
|
|
{
|
2025-06-22 20:41:51 +02:00
|
|
|
if (!m_list.is_empty() && m_list.last().has<GridLineNames>()) {
|
|
|
|
|
auto& last_line_names = m_list.last().get<GridLineNames>();
|
2025-06-25 17:58:07 +02:00
|
|
|
for (auto const& name : line_names.names())
|
|
|
|
|
last_line_names.append(name.name);
|
2025-06-22 20:41:51 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2025-06-16 22:27:17 +02:00
|
|
|
m_list.append(move(line_names));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GridTrackSizeList::append(ExplicitGridTrack&& explicit_track)
|
|
|
|
|
{
|
|
|
|
|
m_list.append(move(explicit_track));
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 15:25:03 +00:00
|
|
|
GridTrackSizeList GridTrackSizeList::absolutized(ComputationContext const& context) const
|
|
|
|
|
{
|
|
|
|
|
GridTrackSizeList result;
|
|
|
|
|
for (auto const& item : m_list) {
|
|
|
|
|
item.visit(
|
|
|
|
|
[&result, &context](ExplicitGridTrack const& track) {
|
|
|
|
|
result.append(track.absolutized(context));
|
|
|
|
|
},
|
|
|
|
|
[&result](GridLineNames names) {
|
|
|
|
|
result.append(move(names));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-08 16:19:00 +13:00
|
|
|
bool GridTrackSizeList::is_computationally_independent() const
|
|
|
|
|
{
|
|
|
|
|
return all_of(m_list, [](auto const& item) {
|
|
|
|
|
return item.visit(
|
|
|
|
|
[](ExplicitGridTrack const& track) { return track.is_computationally_independent(); },
|
|
|
|
|
[](GridLineNames const&) { return true; });
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-24 12:21:15 +02:00
|
|
|
}
|