From 31abc4ce0d8be384872c26fd1209382af6231c6c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector0193@gmail.com> Date: Thu, 5 Jan 2023 16:40:45 +0100 Subject: Fix `Layout::resolve` panicking under some circumstances When `fill` has a bigger `Size` than `max`. --- native/src/layout/limits.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'native/src/layout/limits.rs') diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs index 33a452d0..0ddee91a 100644 --- a/native/src/layout/limits.rs +++ b/native/src/layout/limits.rs @@ -153,12 +153,17 @@ impl Limits { /// Computes the resulting [`Size`] that fits the [`Limits`] given the /// intrinsic size of some content. + #[allow(clippy::manual_clamp)] pub fn resolve(&self, intrinsic_size: Size) -> Size { Size::new( - intrinsic_size.width.clamp(self.fill.width, self.max.width), + intrinsic_size + .width + .min(self.max.width) + .max(self.fill.width), intrinsic_size .height - .clamp(self.fill.height, self.max.height), + .min(self.max.height) + .max(self.fill.height), ) } } -- cgit