mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibWeb: Actually clamp flex line cross size to min/max-size
We were dropping the result of css_clamp() on the floor, oops! Let's also mark it [[nodiscard]] so it won't happen again.
This commit is contained in:
parent
f1576160d7
commit
5f78e780f5
1 changed files with 2 additions and 2 deletions
|
@ -22,7 +22,7 @@ namespace Web::Layout {
|
||||||
// NOTE: We use a custom clamping function here instead of AK::clamp(), since the AK version
|
// NOTE: We use a custom clamping function here instead of AK::clamp(), since the AK version
|
||||||
// will VERIFY(max >= min) and CSS explicitly allows that (see css-values-4.)
|
// will VERIFY(max >= min) and CSS explicitly allows that (see css-values-4.)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr T css_clamp(T const& value, T const& min, T const& max)
|
[[nodiscard]] constexpr T css_clamp(T const& value, T const& min, T const& max)
|
||||||
{
|
{
|
||||||
return ::max(min, ::min(value, max));
|
return ::max(min, ::min(value, max));
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1066,7 @@ void FlexFormattingContext::calculate_cross_size_of_each_flex_line(float const c
|
||||||
// If the flex container is single-line, then clamp the line’s cross-size to be within the container’s computed min and max cross sizes.
|
// If the flex container is single-line, then clamp the line’s cross-size to be within the container’s computed min and max cross sizes.
|
||||||
// Note that if CSS 2.1’s definition of min/max-width/height applied more generally, this behavior would fall out automatically.
|
// Note that if CSS 2.1’s definition of min/max-width/height applied more generally, this behavior would fall out automatically.
|
||||||
if (is_single_line())
|
if (is_single_line())
|
||||||
css_clamp(m_flex_lines[0].cross_size, cross_min_size, cross_max_size);
|
m_flex_lines[0].cross_size = css_clamp(m_flex_lines[0].cross_size, cross_min_size, cross_max_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-flexbox-1/#algo-stretch
|
// https://www.w3.org/TR/css-flexbox-1/#algo-stretch
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue