mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Always compute angle values to degrees.
This matches the spec, https://drafts.csswg.org/css-values/#angles, which says: > All <angle> units are compatible, and deg is their canonical unit. And https://drafts.csswg.org/css-values/#compat, which says: >When serializing computed values [...], compatible units [...] are converted into a single canonical unit. And also other implementations (Blink always serializes angles as degrees in computed style for example). Also allows us to get rid of quite a bit of code, and makes computed angle value representation just a number, which is nice. Differential Revision: https://phabricator.services.mozilla.com/D8619
This commit is contained in:
parent
11fedf18d9
commit
42def5a011
11 changed files with 142 additions and 209 deletions
|
@ -198,19 +198,19 @@ impl nsCSSValue {
|
|||
|
||||
/// Returns an `Angle` value from this `nsCSSValue`.
|
||||
///
|
||||
/// Panics if the unit is not `eCSSUnit_Degree` `eCSSUnit_Grad`, `eCSSUnit_Turn`
|
||||
/// or `eCSSUnit_Radian`.
|
||||
/// Panics if the unit is not `eCSSUnit_Degree`.
|
||||
#[inline]
|
||||
pub fn get_angle(&self) -> Angle {
|
||||
Angle::from_gecko_values(self.float_unchecked(), self.mUnit)
|
||||
debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_Degree);
|
||||
Angle::from_degrees(self.float_unchecked())
|
||||
}
|
||||
|
||||
/// Sets Angle value to this nsCSSValue.
|
||||
pub fn set_angle(&mut self, angle: Angle) {
|
||||
debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_Null);
|
||||
let (value, unit) = angle.to_gecko_values();
|
||||
self.mUnit = unit;
|
||||
self.mUnit = nsCSSUnit::eCSSUnit_Degree;
|
||||
unsafe {
|
||||
*self.mValue.mFloat.as_mut() = value;
|
||||
*self.mValue.mFloat.as_mut() = angle.degrees();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue