mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
style: Move shorthand IDL order stuff out of animated_properties.
Doesn't really need to be in a mako file. Differential Revision: https://phabricator.services.mozilla.com/D10839
This commit is contained in:
parent
d035d02517
commit
282edf1a13
2 changed files with 30 additions and 26 deletions
|
@ -3057,32 +3057,17 @@ pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Orderin
|
||||||
return a_category.cmp(&b_category);
|
return a_category.cmp(&b_category);
|
||||||
}
|
}
|
||||||
|
|
||||||
if a_category == PropertyCategory::Shorthand {
|
if a_category != PropertyCategory::Shorthand {
|
||||||
let a = a.as_shorthand().unwrap();
|
return cmp::Ordering::Equal;
|
||||||
let b = b.as_shorthand().unwrap();
|
|
||||||
// Within shorthands, sort by the number of subproperties, then by IDL
|
|
||||||
// name.
|
|
||||||
let subprop_count_a = a.longhands().count();
|
|
||||||
let subprop_count_b = b.longhands().count();
|
|
||||||
return subprop_count_a.cmp(&subprop_count_b).then_with(|| {
|
|
||||||
get_idl_name_sort_order(a).cmp(&get_idl_name_sort_order(b))
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmp::Ordering::Equal
|
let a = a.as_shorthand().unwrap();
|
||||||
}
|
let b = b.as_shorthand().unwrap();
|
||||||
|
// Within shorthands, sort by the number of subproperties, then by IDL
|
||||||
fn get_idl_name_sort_order(shorthand: ShorthandId) -> u32 {
|
// name.
|
||||||
<%
|
let subprop_count_a = a.longhands().count();
|
||||||
# Sort by IDL name.
|
let subprop_count_b = b.longhands().count();
|
||||||
sorted_shorthands = sorted(data.shorthands, key=lambda p: to_idl_name(p.ident))
|
subprop_count_a.cmp(&subprop_count_b).then_with(|| {
|
||||||
|
a.idl_name_sort_order().cmp(&b.idl_name_sort_order())
|
||||||
# Annotate with sorted position
|
})
|
||||||
sorted_shorthands = [(p, position) for position, p in enumerate(sorted_shorthands)]
|
|
||||||
%>
|
|
||||||
match shorthand {
|
|
||||||
% for property, position in sorted_shorthands:
|
|
||||||
ShorthandId::${property.camel_case} => ${position},
|
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1453,6 +1453,25 @@ impl ShorthandId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the order in which this property appears relative to other
|
||||||
|
/// shorthands in idl-name-sorting order.
|
||||||
|
#[inline]
|
||||||
|
pub fn idl_name_sort_order(self) -> u32 {
|
||||||
|
<%
|
||||||
|
from data import to_idl_name
|
||||||
|
ordered = {}
|
||||||
|
sorted_shorthands = sorted(data.shorthands, key=lambda p: to_idl_name(p.ident))
|
||||||
|
for order, shorthand in enumerate(sorted_shorthands):
|
||||||
|
ordered[shorthand.ident] = order
|
||||||
|
%>
|
||||||
|
static IDL_NAME_SORT_ORDER: [u32; ${len(data.shorthands)}] = [
|
||||||
|
% for property in data.shorthands:
|
||||||
|
${ordered[property.ident]},
|
||||||
|
% endfor
|
||||||
|
];
|
||||||
|
IDL_NAME_SORT_ORDER[self as usize]
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_into<'i, 't>(
|
fn parse_into<'i, 't>(
|
||||||
&self,
|
&self,
|
||||||
declarations: &mut SourcePropertyDeclaration,
|
declarations: &mut SourcePropertyDeclaration,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue