aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2014-09-19 13:54:57 +0100
committerSimon Sapin <simon.sapin@exyr.org>2014-09-19 13:54:57 +0100
commit415bbaeb2e7a3e724d4edecd82b823d681d6a270 (patch)
treeeac42c97bb8f91e3f7fa4d632d2ce5d2ea1053b6
parent2652d223f50d53ee5a8a07ff4a3d6a25b510d1f1 (diff)
downloadservo-415bbaeb2e7a3e724d4edecd82b823d681d6a270.tar.gz
servo-415bbaeb2e7a3e724d4edecd82b823d681d6a270.zip
Fix dimensionality of Au
Previously, we implemented: Au * Au -> Au Au / Au -> Au Au % Au -> Au ... which are inconsistent. It should be: Au * Au -> SquaredAu Au / Au -> i32 Au % Au -> i32 or: Au * i32 -> Au Au / i32 -> Au Au % i32 -> Au I picked the latter. Also, the multiplicative identity does not make sense when multiplication take two different types.
-rw-r--r--components/layout/table.rs2
-rw-r--r--components/util/geometry.rs30
2 files changed, 11 insertions, 21 deletions
diff --git a/components/layout/table.rs b/components/layout/table.rs
index c9f80f888dd..1fa29159cbf 100644
--- a/components/layout/table.rs
+++ b/components/layout/table.rs
@@ -273,7 +273,7 @@ impl Flow for TableFlow {
*col_inline_size = (*col_inline_size).scale_by(ratio);
}
} else if num_unspecified_inline_sizes != 0 {
- let extra_column_inline_size = (content_inline_size - total_column_inline_size) / Au::new(num_unspecified_inline_sizes);
+ let extra_column_inline_size = (content_inline_size - total_column_inline_size) / num_unspecified_inline_sizes;
for col_inline_size in self.col_inline_sizes.mut_iter() {
if *col_inline_size == Au(0) {
*col_inline_size = extra_column_inline_size;
diff --git a/components/util/geometry.rs b/components/util/geometry.rs
index c87e98e38b7..50fb1a634f6 100644
--- a/components/util/geometry.rs
+++ b/components/util/geometry.rs
@@ -9,7 +9,7 @@ use geom::size::Size2D;
use serialize::{Encodable, Encoder};
use std::default::Default;
-use std::num::{NumCast, One, Zero};
+use std::num::{NumCast, Zero};
use std::fmt;
// Units for use with geom::length and geom::scale_factor.
@@ -102,30 +102,27 @@ impl Sub<Au,Au> for Au {
}
-impl Mul<Au,Au> for Au {
+impl Mul<i32, Au> for Au {
#[inline]
- fn mul(&self, other: &Au) -> Au {
+ fn mul(&self, other: &i32) -> Au {
let Au(s) = *self;
- let Au(o) = *other;
- Au(s * o)
+ Au(s * *other)
}
}
-impl Div<Au,Au> for Au {
+impl Div<i32, Au> for Au {
#[inline]
- fn div(&self, other: &Au) -> Au {
+ fn div(&self, other: &i32) -> Au {
let Au(s) = *self;
- let Au(o) = *other;
- Au(s / o)
+ Au(s / *other)
}
}
-impl Rem<Au,Au> for Au {
+impl Rem<i32, Au> for Au {
#[inline]
- fn rem(&self, other: &Au) -> Au {
+ fn rem(&self, other: &i32) -> Au {
let Au(s) = *self;
- let Au(o) = *other;
- Au(s % o)
+ Au(s % *other)
}
}
@@ -137,13 +134,6 @@ impl Neg<Au> for Au {
}
}
-impl One for Au {
- #[inline]
- fn one() -> Au { Au(1) }
-}
-
-impl Num for Au {}
-
#[inline]
pub fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } }
#[inline]