From 5f78e780f575e382d0198497d4b9b74601be040a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 12 Jul 2022 14:31:41 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index fb75cbb37f..4d6b36c1be 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -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 -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 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. 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