LibWeb: Move css_clamp function to FormattingContext

Since we need it in the FlexFormattingContext and
GridFormatting context now.
This commit is contained in:
Edwin Hoksberg 2024-07-24 09:17:47 +02:00 committed by Andreas Kling
parent 4d78c66b3d
commit de84e6f93a
Notes: github-actions[bot] 2024-07-25 11:13:37 +00:00
2 changed files with 8 additions and 8 deletions

View file

@ -19,14 +19,6 @@
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>
[[nodiscard]] constexpr T css_clamp(T const& value, T const& min, T const& max)
{
return ::max(min, ::min(value, max));
}
CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, CSS::Size const& size) const
{
return calculate_inner_width(box, containing_block_width_as_available_size(box), size);

View file

@ -13,6 +13,14 @@
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>
[[nodiscard]] constexpr T css_clamp(T const& value, T const& min, T const& max)
{
return ::max(min, ::min(value, max));
}
class FormattingContext {
public:
virtual ~FormattingContext();