mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Handle properly potentially-disabled longhands in a shorthand.
This commit is contained in:
parent
15b0a32035
commit
3fd5f796f0
2 changed files with 24 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue