mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Move css_clamp function to FormattingContext
Since we need it in the FlexFormattingContext and GridFormatting context now.
This commit is contained in:
parent
4d78c66b3d
commit
de84e6f93a
Notes:
github-actions[bot]
2024-07-25 11:13:37 +00:00
Author: https://github.com/EdwinHoksberg Commit: https://github.com/LadybirdBrowser/ladybird/commit/de84e6f93ac Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/815 Reviewed-by: https://github.com/kalenikaliaksandr ✅
2 changed files with 8 additions and 8 deletions
|
@ -19,14 +19,6 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
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
|
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);
|
return calculate_inner_width(box, containing_block_width_as_available_size(box), size);
|
||||||
|
|
|
@ -13,6 +13,14 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
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 {
|
class FormattingContext {
|
||||||
public:
|
public:
|
||||||
virtual ~FormattingContext();
|
virtual ~FormattingContext();
|
||||||
|
|
Loading…
Reference in a new issue