Auto merge of #16962 - hiikezoe:prefixed-intrinsic-size-value, r=Manishearth

Prefixed intrinsic size value

<!-- Please describe your changes on the following line: -->

This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1355402
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #16788
- [X] These changes do not require tests because it's for stylo

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16962)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-22 01:46:01 -05:00 committed by GitHub
commit b428a94326
11 changed files with 240 additions and 226 deletions

View file

@ -14,7 +14,7 @@ use std::cmp::max;
use values::{Auto, Either, ExtremumLength, None_, Normal};
use values::computed::{Angle, LengthOrPercentage, LengthOrPercentageOrAuto};
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use values::computed::{MaxLength, MinLength};
use values::computed::{MaxLength, MozLength};
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use values::generics::basic_shape::ShapeRadius;
use values::specified::Percentage;
@ -335,41 +335,31 @@ impl GeckoStyleCoordConvertible for ExtremumLength {
}
}
impl GeckoStyleCoordConvertible for MinLength {
impl GeckoStyleCoordConvertible for MozLength {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
match *self {
MinLength::LengthOrPercentage(ref lop) => lop.to_gecko_style_coord(coord),
MinLength::Auto => coord.set_value(CoordDataValue::Auto),
MinLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
MozLength::LengthOrPercentageOrAuto(ref lopoa) => lopoa.to_gecko_style_coord(coord),
MozLength::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(MinLength::LengthOrPercentage)
.or_else(|| ExtremumLength::from_gecko_style_coord(coord).map(MinLength::ExtremumLength))
.or_else(|| match coord.as_value() {
CoordDataValue::Auto => Some(MinLength::Auto),
_ => None,
})
LengthOrPercentageOrAuto::from_gecko_style_coord(coord).map(MozLength::LengthOrPercentageOrAuto)
.or_else(|| ExtremumLength::from_gecko_style_coord(coord).map(MozLength::ExtremumLength))
}
}
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::LengthOrPercentageOrNone(ref lopon) => lopon.to_gecko_style_coord(coord),
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)
LengthOrPercentageOrNone::from_gecko_style_coord(coord).map(MaxLength::LengthOrPercentageOrNone)
.or_else(|| ExtremumLength::from_gecko_style_coord(coord).map(MaxLength::ExtremumLength))
.or_else(|| match coord.as_value() {
CoordDataValue::None => Some(MaxLength::None),
_ => None,
})
}
}