mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Store GridSize values as a Variant
A GridSize can't hold both a LengthPercentage and a Flex at the same time, so let's limit that.
This commit is contained in:
parent
b66ff21379
commit
ca16a1ed08
2 changed files with 26 additions and 25 deletions
|
@ -37,8 +37,8 @@ public:
|
|||
bool is_max_content() const { return m_type == Type::MaxContent; }
|
||||
bool is_min_content() const { return m_type == Type::MinContent; }
|
||||
|
||||
LengthPercentage length_percentage() const { return m_length_percentage; }
|
||||
double flex_factor() const { return m_flex_factor.to_fr(); }
|
||||
LengthPercentage length_percentage() const { return m_value.get<LengthPercentage>(); }
|
||||
double flex_factor() const { return m_value.get<Flex>().to_fr(); }
|
||||
|
||||
// https://www.w3.org/TR/css-grid-2/#layout-algorithm
|
||||
// An intrinsic sizing function (min-content, max-content, auto, fit-content()).
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
bool is_definite() const
|
||||
{
|
||||
return type() == Type::LengthPercentage && !m_length_percentage.is_auto();
|
||||
return type() == Type::LengthPercentage && !length_percentage().is_auto();
|
||||
}
|
||||
|
||||
Size css_size() const;
|
||||
|
@ -56,14 +56,12 @@ public:
|
|||
bool operator==(GridSize const& other) const
|
||||
{
|
||||
return m_type == other.type()
|
||||
&& m_length_percentage == other.length_percentage()
|
||||
&& m_flex_factor == other.m_flex_factor;
|
||||
&& m_value == other.m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
LengthPercentage m_length_percentage;
|
||||
Flex m_flex_factor { 0, Flex::Type::Fr };
|
||||
Variant<Empty, LengthPercentage, Flex> m_value;
|
||||
};
|
||||
|
||||
class GridMinMax {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue