mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibWeb: Delete redundant GridFitContent class from track representation
GridSize already supports the FitContent type, so there is no need to additionally wrap it in a GridFitContent class.
This commit is contained in:
parent
e0af205d69
commit
6169e91994
Notes:
github-actions[bot]
2025-06-18 14:52:36 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 6169e91994
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5134
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 12 additions and 42 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
||||
* Copyright (c) 2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -89,8 +90,9 @@ String GridSize::to_string() const
|
|||
{
|
||||
switch (m_type) {
|
||||
case Type::LengthPercentage:
|
||||
case Type::FitContent:
|
||||
return m_value.get<LengthPercentage>().to_string();
|
||||
case Type::FitContent:
|
||||
return MUST(String::formatted("fit-content({})", m_value.get<LengthPercentage>().to_string()));
|
||||
case Type::FlexibleLength:
|
||||
return m_value.get<Flex>().to_string();
|
||||
case Type::MaxContent:
|
||||
|
@ -118,16 +120,6 @@ String GridMinMax::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
GridFitContent::GridFitContent(GridSize max_grid_size)
|
||||
: m_max_grid_size(max_grid_size)
|
||||
{
|
||||
}
|
||||
|
||||
String GridFitContent::to_string() const
|
||||
{
|
||||
return MUST(String::formatted("fit-content({})", m_max_grid_size.to_string()));
|
||||
}
|
||||
|
||||
GridRepeat::GridRepeat(GridTrackSizeList grid_track_size_list, int repeat_count)
|
||||
: m_type(Type::Default)
|
||||
, m_grid_track_size_list(grid_track_size_list)
|
||||
|
@ -164,7 +156,7 @@ String GridRepeat::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
ExplicitGridTrack::ExplicitGridTrack(Variant<GridFitContent, GridRepeat, GridMinMax, GridSize>&& value)
|
||||
ExplicitGridTrack::ExplicitGridTrack(Variant<GridRepeat, GridMinMax, GridSize>&& value)
|
||||
: m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
||||
* Copyright (c) 2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -61,19 +62,6 @@ private:
|
|||
Variant<Empty, LengthPercentage, Flex> m_value;
|
||||
};
|
||||
|
||||
class GridFitContent {
|
||||
public:
|
||||
GridFitContent(GridSize);
|
||||
|
||||
GridSize const& max_grid_size() const& { return m_max_grid_size; }
|
||||
|
||||
String to_string() const;
|
||||
bool operator==(GridFitContent const& other) const = default;
|
||||
|
||||
private:
|
||||
GridSize m_max_grid_size;
|
||||
};
|
||||
|
||||
class GridMinMax {
|
||||
public:
|
||||
GridMinMax(CSS::GridSize min_grid_size, CSS::GridSize max_grid_size);
|
||||
|
@ -145,10 +133,7 @@ private:
|
|||
|
||||
class ExplicitGridTrack {
|
||||
public:
|
||||
ExplicitGridTrack(Variant<GridFitContent, GridRepeat, GridMinMax, GridSize>&& value);
|
||||
|
||||
bool is_fit_content() const { return m_value.has<GridFitContent>(); }
|
||||
GridFitContent const& fit_content() const { return m_value.get<GridFitContent>(); }
|
||||
ExplicitGridTrack(Variant<GridRepeat, GridMinMax, GridSize>&& value);
|
||||
|
||||
bool is_repeat() const { return m_value.has<GridRepeat>(); }
|
||||
GridRepeat const& repeat() const { return m_value.get<GridRepeat>(); }
|
||||
|
@ -163,7 +148,7 @@ public:
|
|||
bool operator==(ExplicitGridTrack const& other) const = default;
|
||||
|
||||
private:
|
||||
Variant<GridFitContent, GridRepeat, GridMinMax, GridSize> m_value;
|
||||
Variant<GridRepeat, GridMinMax, GridSize> m_value;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ private:
|
|||
Vector<Gfx::UnicodeRange> parse_unicode_ranges(TokenStream<ComponentValue>&);
|
||||
RefPtr<UnicodeRangeStyleValue const> parse_unicode_range_value(TokenStream<ComponentValue>&);
|
||||
Optional<GridSize> parse_grid_size(ComponentValue const&);
|
||||
Optional<GridFitContent> parse_grid_fit_content(Vector<ComponentValue> const&);
|
||||
Optional<GridSize> parse_grid_fit_content(Vector<ComponentValue> const&);
|
||||
Optional<GridMinMax> parse_min_max(Vector<ComponentValue> const&);
|
||||
Optional<GridRepeat> parse_repeat(Vector<ComponentValue> const&);
|
||||
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
|
||||
|
|
|
@ -3243,7 +3243,7 @@ Optional<CSS::GridSize> Parser::parse_grid_size(ComponentValue const& component_
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<CSS::GridFitContent> Parser::parse_grid_fit_content(Vector<ComponentValue> const& component_values)
|
||||
Optional<GridSize> Parser::parse_grid_fit_content(Vector<ComponentValue> const& component_values)
|
||||
{
|
||||
// https://www.w3.org/TR/css-grid-2/#valdef-grid-template-columns-fit-content
|
||||
// 'fit-content( <length-percentage> )'
|
||||
|
@ -3254,7 +3254,7 @@ Optional<CSS::GridFitContent> Parser::parse_grid_fit_content(Vector<ComponentVal
|
|||
function_tokens.discard_whitespace();
|
||||
auto maybe_length_percentage = parse_length_percentage(function_tokens);
|
||||
if (maybe_length_percentage.has_value())
|
||||
return CSS::GridFitContent(CSS::GridSize(CSS::GridSize::Type::FitContent, maybe_length_percentage.value()));
|
||||
return GridSize(GridSize::Type::FitContent, maybe_length_percentage.value());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue