From 03a2b8b62f9fc6ed9b557ded11d1bb78f4e66a9b Mon Sep 17 00:00:00 2001 From: asun0204 Date: Thu, 26 Dec 2024 09:50:16 +0800 Subject: [PATCH] Change conversion from float to appunits of percentage calcuation, prevent the situation that child box size is calculated too large. Signed-off-by: asun0204 --- style/values/computed/length_percentage.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/style/values/computed/length_percentage.rs b/style/values/computed/length_percentage.rs index fed5c2a190..4b7a4b1026 100644 --- a/style/values/computed/length_percentage.rs +++ b/style/values/computed/length_percentage.rs @@ -514,7 +514,7 @@ impl LengthPercentage { /// Returns the used value. #[inline] pub fn to_used_value(&self, containing_length: Au) -> Au { - Au::from(self.to_pixel_length(containing_length)) + Au::from_f32_px_truncate(self.to_pixel_length(containing_length).px()) } /// Returns the used value as CSSPixelLength. @@ -527,7 +527,7 @@ impl LengthPercentage { #[inline] pub fn maybe_to_used_value(&self, container_len: Option) -> Option { self.maybe_percentage_relative_to(container_len.map(Length::from)) - .map(Au::from) + .map(|p| Au::from_f32_px_truncate(p.px())) } /// If there are special rules for computing percentages in a value (e.g.