From 133d7c14a86b0f44087108b4e28efdccb3b63ecb Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 21 Aug 2015 21:44:26 +0200 Subject: [PATCH] Make `display: flex` experimental. --- components/style/properties.mako.rs | 67 +++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 2e449dc112d..33508b4220a 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -407,15 +407,66 @@ pub mod longhands { ${new_style_struct("Box", is_inherited=False)} // TODO(SimonSapin): don't parse `inline-table`, since we don't support it - <%self:single_keyword_computed name="display" - custom_cascade="True" - values="inline block inline-block - table inline-table table-row-group table-header-group table-footer-group - table-row table-column-group table-column table-cell table-caption - list-item flex - none"> + <%self:longhand name="display" custom_cascade="True"> + <% + values = """inline block inline-block + table inline-table table-row-group table-header-group table-footer-group + table-row table-column-group table-column table-cell table-caption + list-item flex + none + """.split() + experimental_values = set("flex".split()) + %> + pub use self::computed_value::T as SpecifiedValue; use values::computed::Context; + pub mod computed_value { + #[allow(non_camel_case_types)] + #[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug, HeapSizeOf)] + #[derive(Deserialize, Serialize)] + pub enum T { + % for value in values: + ${to_rust_ident(value)}, + % endfor + } + + impl ::cssparser::ToCss for T { + fn to_css(&self, dest: &mut W) -> ::std::fmt::Result + where W: ::std::fmt::Write { + match self { + % for value in values: + &T::${to_rust_ident(value)} => dest.write_str("${value}"), + % endfor + } + } + } + } + #[inline] pub fn get_initial_value() -> computed_value::T { + computed_value::T::${to_rust_ident(values[0])} + } + pub fn parse(_context: &ParserContext, input: &mut Parser) + -> Result { + match_ignore_ascii_case! { try!(input.expect_ident()), + % for value in values[:-1]: + "${value}" => { + % if value in experimental_values: + if !::util::opts::experimental_enabled() { return Err(()) } + % endif + Ok(computed_value::T::${to_rust_ident(value)}) + }, + % endfor + % for value in values[-1:]: + "${value}" => { + % if value in experimental_values: + if !::util::opts::experimental_enabled() { return Err(()) } + % endif + Ok(computed_value::T::${to_rust_ident(value)}) + } + % endfor + _ => Err(()) + } + } + impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -457,7 +508,7 @@ pub mod longhands { longhands::_servo_text_decorations_in_effect::derive_from_display(*computed_value, &context); } - + ${single_keyword("position", "static absolute relative fixed")} ${single_keyword("float", "none left right")}