mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Represent the percentage in LengthPercentage with something other than an option.
Not the prettiest, but it will work, and LengthPercentage will be 12 bytes which is pretty good (we could do better if wanted I guess): * Au(i32) length; * f32 percentage; * AllowedNumericType(u8) clamping_mode; * bool has_percentage; * bool was_calc; This will allow me to start moving C++ stuff to use this representation. Differential Revision: https://phabricator.services.mozilla.com/D16929
This commit is contained in:
parent
e27c15e2f9
commit
05881b5ab4
7 changed files with 68 additions and 52 deletions
|
@ -151,9 +151,9 @@ impl GeckoStyleCoordConvertible for LengthPercentage {
|
|||
if self.was_calc {
|
||||
return coord.set_value(CoordDataValue::Calc((*self).into()));
|
||||
}
|
||||
debug_assert!(self.percentage.is_none() || self.unclamped_length() == Length::zero());
|
||||
if let Some(p) = self.percentage {
|
||||
return coord.set_value(CoordDataValue::Percent(p.0));
|
||||
debug_assert!(!self.has_percentage || self.unclamped_length() == Length::zero());
|
||||
if self.has_percentage {
|
||||
return coord.set_value(CoordDataValue::Percent(self.percentage()));
|
||||
}
|
||||
coord.set_value(CoordDataValue::Coord(self.unclamped_length().to_i32_au()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue