1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +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:
Andreas Kling 2022-07-12 14:31:41 +02:00
parent f1576160d7
commit 5f78e780f5

View file

@ -22,7 +22,7 @@ namespace Web::Layout {
// 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.)
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));
}
@ -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 lines cross-size to be within the containers computed min and max cross sizes.
// Note that if CSS 2.1s definition of min/max-width/height applied more generally, this behavior would fall out automatically.
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