mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
stylo: Support other unit types in computed angle
This commit is contained in:
parent
4483a7694a
commit
f8710bc189
7 changed files with 113 additions and 79 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue