mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Add support for MaxLength
This builds on the ExtremumLength type from the previous commit.
This commit is contained in:
parent
76de979231
commit
dd4f331603
8 changed files with 154 additions and 11 deletions
|
@ -14,7 +14,7 @@ use std::cmp::max;
|
|||
use values::{Auto, Either, ExtremumLength, None_, Normal};
|
||||
use values::computed::{Angle, LengthOrPercentageOrNone, Number};
|
||||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::MinLength;
|
||||
use values::computed::{MaxLength, MinLength};
|
||||
use values::computed::basic_shape::ShapeRadius;
|
||||
use values::specified::grid::{TrackBreadth, TrackKeyword};
|
||||
|
||||
|
@ -321,6 +321,25 @@ impl GeckoStyleCoordConvertible for MinLength {
|
|||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for MaxLength {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
MaxLength::LengthOrPercentage(ref lop) => lop.to_gecko_style_coord(coord),
|
||||
MaxLength::None => coord.set_value(CoordDataValue::None),
|
||||
MaxLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
|
||||
}
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
LengthOrPercentage::from_gecko_style_coord(coord).map(MaxLength::LengthOrPercentage)
|
||||
.or_else(|| ExtremumLength::from_gecko_style_coord(coord).map(MaxLength::ExtremumLength))
|
||||
.or_else(|| match coord.as_value() {
|
||||
CoordDataValue::None => Some(MaxLength::None),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a given RGBA value to `nscolor`.
|
||||
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||
((rgba.alpha as u32) << 24) |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue