LibWeb/CSS: Prepare Size for use in GridSize

Make it constructible from a LengthPercentage, report whether it
contains a length-percentage, and add an equality operator.
This commit is contained in:
Sam Atkins 2025-08-27 11:43:44 +01:00
commit ad5f7c56c1
Notes: github-actions[bot] 2025-09-04 12:34:27 +00:00
2 changed files with 16 additions and 0 deletions

View file

@ -44,6 +44,18 @@ Size Size::make_calculated(NonnullRefPtr<CalculatedStyleValue const> calculated)
return Size { Type::Calculated, move(calculated) };
}
Size Size::make_length_percentage(LengthPercentage const& length_percentage)
{
if (length_percentage.is_auto())
return make_auto();
if (length_percentage.is_length())
return make_length(length_percentage.length());
if (length_percentage.is_percentage())
return make_percentage(length_percentage.percentage());
VERIFY(length_percentage.is_calculated());
return make_calculated(length_percentage.calculated());
}
Size Size::make_min_content()
{
return Size { Type::MinContent, Length::make_auto() };