mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Don't duplicate specified and computed keywords
The previous code would generate two distinct types for specified and computed values if some variants had aliases.
This commit is contained in:
parent
1662fd7357
commit
ccc932ad10
1 changed files with 23 additions and 17 deletions
|
@ -596,33 +596,39 @@
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%def name="inner_body(keyword, extra_specified=None, needs_conversion=False)">
|
<%def name="inner_body(keyword, extra_specified=None, needs_conversion=False)">
|
||||||
% if extra_specified or keyword.aliases_for(product):
|
<%def name="variants(variants, include_aliases)">
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
% for variant in variants:
|
||||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
|
% if include_aliases:
|
||||||
pub enum SpecifiedValue {
|
|
||||||
% for value in keyword.values_for(product) + (extra_specified or "").split():
|
|
||||||
<%
|
<%
|
||||||
aliases = []
|
aliases = []
|
||||||
for alias, v in keyword.aliases_for(product).iteritems():
|
for alias, v in keyword.aliases_for(product).iteritems():
|
||||||
if value == v:
|
if variant == v:
|
||||||
aliases.append(alias)
|
aliases.append(alias)
|
||||||
%>
|
%>
|
||||||
% if aliases:
|
% if aliases:
|
||||||
#[css(aliases = "${','.join(aliases)}")]
|
#[css(aliases = "${','.join(aliases)}")]
|
||||||
% endif
|
% endif
|
||||||
${to_camel_case(value)},
|
% endif
|
||||||
|
${to_camel_case(variant)},
|
||||||
% endfor
|
% endfor
|
||||||
|
</%def>
|
||||||
|
% if extra_specified:
|
||||||
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
|
||||||
|
pub enum SpecifiedValue {
|
||||||
|
${variants(keyword.values_for(product) + extra_specified.split(), bool(extra_specified))}
|
||||||
}
|
}
|
||||||
% else:
|
% else:
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
% endif
|
% endif
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
|
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)]
|
||||||
|
% if not extra_specified:
|
||||||
|
#[derive(Parse)]
|
||||||
|
% endif
|
||||||
pub enum T {
|
pub enum T {
|
||||||
% for value in data.longhands_by_name[name].keyword.values_for(product):
|
${variants(data.longhands_by_name[name].keyword.values_for(product), not extra_specified)}
|
||||||
${to_camel_case(value)},
|
|
||||||
% endfor
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue