From 2784f3642d6176da66038aa7db2bf68cfa6aaeca Mon Sep 17 00:00:00 2001 From: asun0204 Date: Thu, 26 Dec 2024 09:50:16 +0800 Subject: [PATCH] [fixbug] change conversion to appunit from float of percentage calcuation, prevent 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 ade53ce5e..0a2a50289 100644 --- a/style/values/computed/length_percentage.rs +++ b/style/values/computed/length_percentage.rs @@ -509,7 +509,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(self.to_pixel_length(containing_length).px().floor()) } /// Returns the used value as CSSPixelLength. @@ -522,7 +522,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(p.px().floor())) } /// If there are special rules for computing percentages in a value (e.g.