Skip to content

Commit

Permalink
style: Use Au::abs.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Aug 18, 2017
1 parent cf18d84 commit c3fc8ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions components/style/values/computed/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,8 @@ impl ToCss for CalcLengthOrPercentage {
percentage.to_css(dest)?;

dest.write_str(if length < Zero::zero() { " - " } else { " + " })?;
length.abs().to_css(dest)?;

// FIXME(emilio): Au::abs would be nice.
let length = if length < Zero::zero() { -length } else { length };

length.to_css(dest)?;
dest.write_str(")")
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/style/values/specified/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ impl HasViewportPercentage for CalcLengthOrPercentage {

impl ToCss for CalcLengthOrPercentage {
/// https://drafts.csswg.org/css-values/#calc-serialize
///
/// FIXME(emilio): Should this simplify away zeros?
#[allow(unused_assignments)]
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
use num_traits::Zero;
Expand Down Expand Up @@ -143,9 +145,7 @@ impl ToCss for CalcLengthOrPercentage {

if let Some(val) = self.absolute {
first_value_check!(val);
// FIXME(emilio): Au::abs() would be nice.
let abs = if val < Zero::zero() { -val } else { val };
abs.to_css(dest)?;
val.abs().to_css(dest)?;
}

serialize!(rem, vh, vmax, vmin, vw);
Expand Down

0 comments on commit c3fc8ef

Please sign in to comment.