style: Other minor properties.mako.rs cleanups and improvements.

Also, add an is_logical method, which we'll use in a bit.

Bug: 1473793
Reviewed-by: heycam
MozReview-Commit-ID: Hq63wgbiRRu
This commit is contained in:
Emilio Cobos Álvarez 2018-07-06 05:13:28 +02:00
parent 263d4258ea
commit 6518b0adfa
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -946,25 +946,17 @@ impl LonghandId {
} }
/// Returns whether this property is animatable. /// Returns whether this property is animatable.
#[inline]
pub fn is_animatable(self) -> bool { pub fn is_animatable(self) -> bool {
match self { ${static_longhand_id_set("ANIMATABLE", lambda p: p.animatable)}
% for property in data.longhands: ANIMATABLE.contains(self)
LonghandId::${property.camel_case} => {
${str(property.animatable).lower()}
}
% endfor
}
} }
/// Returns whether this property is animatable in a discrete way. /// Returns whether this property is animatable in a discrete way.
#[inline]
pub fn is_discrete_animatable(self) -> bool { pub fn is_discrete_animatable(self) -> bool {
match self { ${static_longhand_id_set("DISCRETE_ANIMATABLE", lambda p: p.animation_value_type == "discrete")}
% for property in data.longhands: DISCRETE_ANIMATABLE.contains(self)
LonghandId::${property.camel_case} => {
${str(property.animation_value_type == "discrete").lower()}
}
% endfor
}
} }
/// Converts from a LonghandId to an adequate nsCSSPropertyID. /// Converts from a LonghandId to an adequate nsCSSPropertyID.
@ -985,20 +977,30 @@ impl LonghandId {
} }
} }
/// If this is a logical property, return the corresponding physical one in the given writing mode. /// Return whether this property is logical.
#[inline]
pub fn is_logical(&self) -> bool {
${static_longhand_id_set("LOGICAL", lambda p: p.logical)}
LOGICAL.contains(*self)
}
/// If this is a logical property, return the corresponding physical one in
/// the given writing mode.
///
/// Otherwise, return unchanged. /// Otherwise, return unchanged.
#[inline]
pub fn to_physical(&self, wm: WritingMode) -> Self { pub fn to_physical(&self, wm: WritingMode) -> Self {
match *self { match *self {
% for property in data.longhands: % for property in data.longhands:
% if property.logical: % if property.logical:
LonghandId::${property.camel_case} => { LonghandId::${property.camel_case} => {
<%helpers:logical_setter_helper name="${property.name}"> <%helpers:logical_setter_helper name="${property.name}">
<%def name="inner(physical_ident)"> <%def name="inner(physical_ident)">
LonghandId::${to_camel_case(physical_ident)} LonghandId::${to_camel_case(physical_ident)}
</%def> </%def>
</%helpers:logical_setter_helper> </%helpers:logical_setter_helper>
} }
% endif % endif
% endfor % endfor
_ => *self _ => *self
} }
@ -1937,14 +1939,15 @@ impl PropertyDeclaration {
} }
/// Returns whether or not the property is set by a system font /// Returns whether or not the property is set by a system font
#[cfg(feature = "gecko")]
pub fn get_system(&self) -> Option<SystemFont> { pub fn get_system(&self) -> Option<SystemFont> {
match *self { match *self {
% if product == "gecko":
% for prop in SYSTEM_FONT_LONGHANDS: % for prop in SYSTEM_FONT_LONGHANDS:
PropertyDeclaration::${to_camel_case(prop)}(ref prop) => { PropertyDeclaration::${to_camel_case(prop)}(ref prop) => {
prop.get_system() prop.get_system()
} }
% endfor % endfor
% endif
_ => None, _ => None,
} }
} }
@ -1957,12 +1960,6 @@ impl PropertyDeclaration {
} }
} }
#[cfg(feature = "servo")]
/// Dummy method to avoid cfg()s
pub fn get_system(&self) -> Option<()> {
None
}
/// Returns whether the declaration may be serialized as part of a shorthand. /// Returns whether the declaration may be serialized as part of a shorthand.
/// ///
/// This method returns false if this declaration contains variable or has a /// This method returns false if this declaration contains variable or has a