aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko/values.rs
diff options
context:
space:
mode:
authorEthan Glasser-Camp <ethan@betacantrips.com>2017-02-17 12:09:00 -0500
committerEthan Glasser-Camp <ethan@betacantrips.com>2017-02-24 15:44:49 -0500
commitdd4f33160360664dd68ac44da15fcce94ce7411c (patch)
treee2b2212db06229594fd4637b3e5c44c49050c63e /components/style/gecko/values.rs
parent76de9792314c3a9156daa28b398db51fe392dac8 (diff)
downloadservo-dd4f33160360664dd68ac44da15fcce94ce7411c.tar.gz
servo-dd4f33160360664dd68ac44da15fcce94ce7411c.zip
Add support for MaxLength
This builds on the ExtremumLength type from the previous commit.
Diffstat (limited to 'components/style/gecko/values.rs')
-rw-r--r--components/style/gecko/values.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs
index 814633e4517..cccb5ca697f 100644
--- a/components/style/gecko/values.rs
+++ b/components/style/gecko/values.rs
@@ -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) |