mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibWeb: Rename flexible_length to flex_factor in GridSize
Let's match the name used in the spec.
This commit is contained in:
parent
a3759b6e76
commit
95d17ee875
3 changed files with 11 additions and 11 deletions
|
@ -14,10 +14,10 @@ GridSize::GridSize(LengthPercentage length_percentage)
|
||||||
: m_type(Type::LengthPercentage)
|
: m_type(Type::LengthPercentage)
|
||||||
, m_length_percentage(length_percentage) {};
|
, m_length_percentage(length_percentage) {};
|
||||||
|
|
||||||
GridSize::GridSize(float flexible_length)
|
GridSize::GridSize(float flex_factor)
|
||||||
: m_type(Type::FlexibleLength)
|
: m_type(Type::FlexibleLength)
|
||||||
, m_length_percentage { Length::make_px(0) }
|
, m_length_percentage { Length::make_px(0) }
|
||||||
, m_flexible_length(flexible_length)
|
, m_flex_factor(flex_factor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ ErrorOr<String> GridSize::to_string() const
|
||||||
case Type::LengthPercentage:
|
case Type::LengthPercentage:
|
||||||
return m_length_percentage.to_string();
|
return m_length_percentage.to_string();
|
||||||
case Type::FlexibleLength:
|
case Type::FlexibleLength:
|
||||||
return String::formatted("{}fr", m_flexible_length);
|
return String::formatted("{}fr", m_flex_factor);
|
||||||
case Type::MaxContent:
|
case Type::MaxContent:
|
||||||
return "max-content"_string;
|
return "max-content"_string;
|
||||||
case Type::MinContent:
|
case Type::MinContent:
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
bool is_min_content() const { return m_type == Type::MinContent; }
|
bool is_min_content() const { return m_type == Type::MinContent; }
|
||||||
|
|
||||||
LengthPercentage length_percentage() const { return m_length_percentage; };
|
LengthPercentage length_percentage() const { return m_length_percentage; };
|
||||||
float flexible_length() const { return m_flexible_length; }
|
float flex_factor() const { return m_flex_factor; }
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-grid-2/#layout-algorithm
|
// https://www.w3.org/TR/css-grid-2/#layout-algorithm
|
||||||
// An intrinsic sizing function (min-content, max-content, auto, fit-content()).
|
// An intrinsic sizing function (min-content, max-content, auto, fit-content()).
|
||||||
|
@ -59,13 +59,13 @@ public:
|
||||||
{
|
{
|
||||||
return m_type == other.type()
|
return m_type == other.type()
|
||||||
&& m_length_percentage == other.length_percentage()
|
&& m_length_percentage == other.length_percentage()
|
||||||
&& m_flexible_length == other.flexible_length();
|
&& m_flex_factor == other.flex_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type;
|
Type m_type;
|
||||||
LengthPercentage m_length_percentage;
|
LengthPercentage m_length_percentage;
|
||||||
float m_flexible_length { 0 };
|
float m_flex_factor { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class GridMinMax {
|
class GridMinMax {
|
||||||
|
|
|
@ -1074,7 +1074,7 @@ void GridFormattingContext::expand_flexible_tracks(AvailableSpace const& availab
|
||||||
auto flex_factor_sum = 0;
|
auto flex_factor_sum = 0;
|
||||||
for (auto& track : tracks) {
|
for (auto& track : tracks) {
|
||||||
if (track.max_track_sizing_function.is_flexible_length())
|
if (track.max_track_sizing_function.is_flexible_length())
|
||||||
flex_factor_sum += track.max_track_sizing_function.flexible_length();
|
flex_factor_sum += track.max_track_sizing_function.flex_factor();
|
||||||
}
|
}
|
||||||
if (flex_factor_sum < 1)
|
if (flex_factor_sum < 1)
|
||||||
flex_factor_sum = 1;
|
flex_factor_sum = 1;
|
||||||
|
@ -1109,8 +1109,8 @@ void GridFormattingContext::expand_flexible_tracks(AvailableSpace const& availab
|
||||||
// the track’s base size by its flex factor; otherwise, the track’s base size.
|
// the track’s base size by its flex factor; otherwise, the track’s base size.
|
||||||
for (auto& track : tracks) {
|
for (auto& track : tracks) {
|
||||||
if (track.max_track_sizing_function.is_flexible_length()) {
|
if (track.max_track_sizing_function.is_flexible_length()) {
|
||||||
if (track.max_track_sizing_function.flexible_length() > 1) {
|
if (track.max_track_sizing_function.flex_factor() > 1) {
|
||||||
result = max(result, track.base_size / track.max_track_sizing_function.flexible_length());
|
result = max(result, track.base_size / track.max_track_sizing_function.flex_factor());
|
||||||
} else {
|
} else {
|
||||||
result = max(result, track.base_size);
|
result = max(result, track.base_size);
|
||||||
}
|
}
|
||||||
|
@ -1143,8 +1143,8 @@ void GridFormattingContext::expand_flexible_tracks(AvailableSpace const& availab
|
||||||
// For each flexible track, if the product of the used flex fraction and the track’s flex factor is greater than
|
// For each flexible track, if the product of the used flex fraction and the track’s flex factor is greater than
|
||||||
// the track’s base size, set its base size to that product.
|
// the track’s base size, set its base size to that product.
|
||||||
for (auto& track : tracks_and_gaps) {
|
for (auto& track : tracks_and_gaps) {
|
||||||
if (track.max_track_sizing_function.flexible_length() * flex_fraction > track.base_size) {
|
if (track.max_track_sizing_function.flex_factor() * flex_fraction > track.base_size) {
|
||||||
track.base_size = track.max_track_sizing_function.flexible_length() * flex_fraction;
|
track.base_size = track.max_track_sizing_function.flex_factor() * flex_fraction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue