Skip to content

Commit

Permalink
Temporarily import Au::from_f32_px_trunc()
Browse files Browse the repository at this point in the history
Signed-off-by: Oriol Brufau <[email protected]>
  • Loading branch information
Loirooriol committed Jan 8, 2025
1 parent 03a2b8b commit 83dad25
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions style/values/computed/length_percentage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl LengthPercentage {
/// Returns the used value.
#[inline]
pub fn to_used_value(&self, containing_length: Au) -> Au {
Au::from_f32_px_truncate(self.to_pixel_length(containing_length).px())
au_from_f32_px_trunc(self.to_pixel_length(containing_length).px())
}

/// Returns the used value as CSSPixelLength.
Expand All @@ -527,7 +527,7 @@ impl LengthPercentage {
#[inline]
pub fn maybe_to_used_value(&self, container_len: Option<Au>) -> Option<Au> {
self.maybe_percentage_relative_to(container_len.map(Length::from))
.map(|p| Au::from_f32_px_truncate(p.px()))
.map(|length| au_from_f32_px_trunc(length.px()))
}

/// If there are special rules for computing percentages in a value (e.g.
Expand All @@ -554,6 +554,11 @@ impl LengthPercentage {
}
}

fn au_from_f32_px_trunc(px: f32) -> Au {
let float = (px * app_units::AU_PER_PX as f32).trunc();
Au::from_f64_au(float as f64)
}

impl PartialEq for LengthPercentage {
fn eq(&self, other: &Self) -> bool {
self.unpack() == other.unpack()
Expand Down

0 comments on commit 83dad25

Please sign in to comment.