stylo: Support other unit types in computed angle

This commit is contained in:
Nazım Can Altınova 2017-04-28 18:33:00 +03:00
parent 4483a7694a
commit f8710bc189
No known key found for this signature in database
GPG key ID: AF9BCD7CE6449954
7 changed files with 113 additions and 79 deletions

View file

@ -249,15 +249,16 @@ impl<T: GeckoStyleCoordConvertible> GeckoStyleCoordConvertible for Option<T> {
impl GeckoStyleCoordConvertible for Angle {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
coord.set_value(CoordDataValue::Radian(self.radians()))
coord.set_value(CoordDataValue::from(*self));
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
if let CoordDataValue::Radian(r) = coord.as_value() {
Some(Angle::from_radians(r))
// XXXManishearth should this handle Degree too?
} else {
None
match coord.as_value() {
CoordDataValue::Degree(val) => Some(Angle::Degree(val)),
CoordDataValue::Grad(val) => Some(Angle::Gradian(val)),
CoordDataValue::Radian(val) => Some(Angle::Radian(val)),
CoordDataValue::Turn(val) => Some(Angle::Turn(val)),
_ => None,
}
}
}