Skip to content

Commit

Permalink
stylo: Clamp Au on accumulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Sep 6, 2017
1 parent 5e321ca commit c063ff8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/style/values/animated/mod.rs
Expand Up @@ -162,7 +162,7 @@ where
impl Animate for Au {
#[inline]
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
Ok(Au(self.0.animate(&other.0, procedure)?))
Ok(Au::new(self.0.animate(&other.0, procedure)?))
}
}

Expand Down
12 changes: 4 additions & 8 deletions components/style/values/specified/length.rs
Expand Up @@ -6,7 +6,7 @@
//!
//! [length]: https://drafts.csswg.org/css-values/#lengths

use app_units::Au;
use app_units::{Au, MAX_AU, MIN_AU};
use cssparser::{Parser, Token, BasicParseError};
use euclid::Size2D;
use font_metrics::FontMetricsQueryResult;
Expand Down Expand Up @@ -236,16 +236,12 @@ impl CharacterWidth {
}
}

/// Same as Gecko
const ABSOLUTE_LENGTH_MAX: i32 = (1 << 30);
const ABSOLUTE_LENGTH_MIN: i32 = - (1 << 30);

/// Helper to convert a floating point length to application units
fn to_au_round(length: CSSFloat, au_per_unit: CSSFloat) -> Au {
Au(
(length * au_per_unit)
.min(ABSOLUTE_LENGTH_MAX as f32)
.max(ABSOLUTE_LENGTH_MIN as f32)
((length * au_per_unit) as f64)
.min(MAX_AU.0 as f64)
.max(MIN_AU.0 as f64)
.round() as i32
)
}
Expand Down

0 comments on commit c063ff8

Please sign in to comment.