From 3fd5f796f0415b5cd83f02d33809a3a65e0837e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 28 Feb 2018 00:43:54 +0100 Subject: [PATCH] style: Handle properly potentially-disabled longhands in a shorthand. --- components/style/properties/data.py | 5 +++++ components/style/properties/helpers.mako.rs | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/style/properties/data.py b/components/style/properties/data.py index e2c68964cb0..5340e6afadf 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -229,6 +229,11 @@ class Longhand(object): def enabled_in_content(self): return self.enabled_in == "content" + def may_be_disabled_in(self, shorthand, product): + if product == "gecko": + return self.gecko_pref and self.gecko_pref != shorthand.gecko_pref + return self.servo_pref and self.servo_pref != shorthand.servo_pref + def base_type(self): if self.predefined_type and not self.is_vector: return "::values::specified::{}".format(self.predefined_type) diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index b1bdbf95453..060d4010e21 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -688,7 +688,13 @@ pub struct LonghandsToSerialize<'a> { % for sub_property in shorthand.sub_properties: pub ${sub_property.ident}: + % if sub_property.may_be_disabled_in(shorthand, product): + Option< + % endif &'a longhands::${sub_property.ident}::SpecifiedValue, + % if sub_property.may_be_disabled_in(shorthand, product): + >, + % endif % endfor } @@ -725,12 +731,16 @@ ( % for sub_property in shorthand.sub_properties: + % if sub_property.may_be_disabled_in(shorthand, product): + ${sub_property.ident}, + % else: Some(${sub_property.ident}), + % endif % endfor ) => Ok(LonghandsToSerialize { % for sub_property in shorthand.sub_properties: - ${sub_property.ident}: ${sub_property.ident}, + ${sub_property.ident}, % endfor }), _ => Err(()) @@ -745,11 +755,19 @@ context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<(), ParseError<'i>> { + #[allow(unused_imports)] + use properties::{NonCustomPropertyId, LonghandId}; input.parse_entirely(|input| parse_value(context, input)).map(|longhands| { % for sub_property in shorthand.sub_properties: + % if sub_property.may_be_disabled_in(shorthand, product): + if NonCustomPropertyId::from(LonghandId::${sub_property.camel_case}).allowed_in(context) { + % endif declarations.push(PropertyDeclaration::${sub_property.camel_case}( longhands.${sub_property.ident} )); + % if sub_property.may_be_disabled_in(shorthand, product): + } + % endif % endfor }) }