diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-22 01:46:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-22 01:46:01 -0500 |
commit | b428a94326322c88da4c32e56ee753ceeffca7d1 (patch) | |
tree | 0ada03d8ed4d26bcf50e39e54df439986e3e8f97 /components/style/values/specified/length.rs | |
parent | 8cd4330b2afdaf6f5a1724539a25a27850d41e29 (diff) | |
parent | d06af8971dd9954c7c3217778b8d73f51a658d57 (diff) | |
download | servo-selectors-v0.18.0.tar.gz servo-selectors-v0.18.0.zip |
Auto merge of #16962 - hiikezoe:prefixed-intrinsic-size-value, r=Manishearthselectors-v0.18.0
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 -->
Diffstat (limited to 'components/style/values/specified/length.rs')
-rw-r--r-- | components/style/values/specified/length.rs | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 56b1d903d9a..e37aad81f0e 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1183,45 +1183,41 @@ impl LengthOrNumber { } /// A value suitable for a `min-width` or `min-height` property. -/// Unlike `max-width` or `max-height` properties, a MinLength can be +/// Unlike `max-width` or `max-height` properties, a MozLength can be /// `auto`, and cannot be `none`. #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[allow(missing_docs)] -pub enum MinLength { - LengthOrPercentage(LengthOrPercentage), - Auto, +pub enum MozLength { + LengthOrPercentageOrAuto(LengthOrPercentageOrAuto), ExtremumLength(ExtremumLength), } -impl ToCss for MinLength { +impl ToCss for MozLength { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { - MinLength::LengthOrPercentage(ref lop) => - lop.to_css(dest), - MinLength::Auto => - dest.write_str("auto"), - MinLength::ExtremumLength(ref ext) => + MozLength::LengthOrPercentageOrAuto(ref lopoa) => + lopoa.to_css(dest), + MozLength::ExtremumLength(ref ext) => ext.to_css(dest), } } } -impl Parse for MinLength { +impl Parse for MozLength { fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> { - MinLength::parse_quirky(context, input, AllowQuirks::No) + MozLength::parse_quirky(context, input, AllowQuirks::No) } } -impl MinLength { +impl MozLength { /// Parses, with quirks. pub fn parse_quirky(context: &ParserContext, input: &mut Parser, allow_quirks: AllowQuirks) -> Result<Self, ()> { - input.try(ExtremumLength::parse).map(MinLength::ExtremumLength) - .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) - .map(MinLength::LengthOrPercentage)) - .or_else(|()| input.expect_ident_matching("auto").map(|()| MinLength::Auto)) + input.try(ExtremumLength::parse).map(MozLength::ExtremumLength) + .or_else(|()| input.try(|i| LengthOrPercentageOrAuto::parse_non_negative_quirky(context, i, allow_quirks)) + .map(MozLength::LengthOrPercentageOrAuto)) } } @@ -1230,19 +1226,15 @@ impl MinLength { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[allow(missing_docs)] pub enum MaxLength { - LengthOrPercentage(LengthOrPercentage), - None, + LengthOrPercentageOrNone(LengthOrPercentageOrNone), ExtremumLength(ExtremumLength), } - impl ToCss for MaxLength { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { - MaxLength::LengthOrPercentage(ref lop) => - lop.to_css(dest), - MaxLength::None => - dest.write_str("none"), + MaxLength::LengthOrPercentageOrNone(ref lopon) => + lopon.to_css(dest), MaxLength::ExtremumLength(ref ext) => ext.to_css(dest), } @@ -1261,14 +1253,7 @@ impl MaxLength { input: &mut Parser, allow_quirks: AllowQuirks) -> Result<Self, ()> { input.try(ExtremumLength::parse).map(MaxLength::ExtremumLength) - .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) - .map(MaxLength::LengthOrPercentage)) - .or_else(|()| { - match_ignore_ascii_case! { &try!(input.expect_ident()), - "none" => - Ok(MaxLength::None), - _ => Err(()) - } - }) + .or_else(|()| input.try(|i| LengthOrPercentageOrNone::parse_non_negative_quirky(context, i, allow_quirks)) + .map(MaxLength::LengthOrPercentageOrNone)) } } |