diff options
author | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-05-20 11:59:52 +0900 |
---|---|---|
committer | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-05-21 08:33:12 +0900 |
commit | d06af8971dd9954c7c3217778b8d73f51a658d57 (patch) | |
tree | a12f85abb116ccaaf17520edd8ad5c1af2dfcc78 /components/style | |
parent | 3a3bc03eb88827d4a4b83b4279c7e02655f4606c (diff) | |
download | servo-d06af8971dd9954c7c3217778b8d73f51a658d57.tar.gz servo-d06af8971dd9954c7c3217778b8d73f51a658d57.zip |
Support prefixed intrinsic size value for flex-basis.
auto() and zero() are used in the parser for flex shorthand property.
Diffstat (limited to 'components/style')
-rw-r--r-- | components/style/properties/helpers.mako.rs | 17 | ||||
-rw-r--r-- | components/style/properties/longhand/position.mako.rs | 29 | ||||
-rw-r--r-- | components/style/properties/shorthand/position.mako.rs | 2 |
3 files changed, 35 insertions, 13 deletions
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 23398a9729e..de63e97ee90 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -1090,6 +1090,23 @@ #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub ${length_type}); + % if length_type == "MozLength": + impl SpecifiedValue { + /// Returns the `auto` value. + pub fn auto() -> Self { + use values::specified::length::LengthOrPercentageOrAuto; + SpecifiedValue(MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)) + } + + /// Returns a value representing a `0` length. + pub fn zero() -> Self { + use values::specified::length::{LengthOrPercentageOrAuto, NoCalcLength}; + SpecifiedValue(MozLength::LengthOrPercentageOrAuto( + LengthOrPercentageOrAuto::Length(NoCalcLength::zero()))) + } + } + % endif + #[inline] pub fn get_initial_value() -> computed_value::T { use values::computed::${length_type}; diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 270430333cd..324b0112f02 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -134,18 +134,23 @@ ${helpers.predefined_type("order", "Integer", "0", animation_value_type="ComputedValue", spec="https://drafts.csswg.org/css-flexbox/#order-property")} -// FIXME: Gecko doesn't support content value yet. -// FIXME: This property should be animatable. -${helpers.predefined_type("flex-basis", - "LengthOrPercentageOrAuto" if product == "gecko" else - "LengthOrPercentageOrAutoOrContent", - "computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else - "computed::LengthOrPercentageOrAutoOrContent::Auto", - "parse_non_negative", - spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", - extra_prefixes="webkit", - animation_value_type="ComputedValue" if product == "gecko" else "none")} - +% if product == "gecko": + // FIXME: Gecko doesn't support content value yet. + ${helpers.gecko_size_type("flex-basis", "MozLength", "auto()", + logical=False, + spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", + extra_prefixes="webkit", + animation_value_type="ComputedValue")} +% else: + // FIXME: This property should be animatable. + ${helpers.predefined_type("flex-basis", + "LengthOrPercentageOrAutoOrContent", + "computed::LengthOrPercentageOrAutoOrContent::Auto", + "parse_non_negative", + spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", + extra_prefixes="webkit", + animation_value_type="none")} +% endif % for (size, logical) in ALL_SIZES: <% spec = "https://drafts.csswg.org/css-box/#propdef-%s" diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthand/position.mako.rs index 423e1657d9b..11b2cd41b0b 100644 --- a/components/style/properties/shorthand/position.mako.rs +++ b/components/style/properties/shorthand/position.mako.rs @@ -78,7 +78,7 @@ } } if basis.is_none() { - if let Ok(value) = input.try(|input| longhands::flex_basis::parse(context, input)) { + if let Ok(value) = input.try(|input| longhands::flex_basis::parse_specified(context, input)) { basis = Some(value); continue } |