mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1504536 - Move shorthand IDL order stuff out of animated_properties. r=hiro
Doesn't really need to be in a mako file. Differential Revision: https://phabricator.services.mozilla.com/D10839 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3a9e249141
commit
d6b32c443b
@ -3057,32 +3057,17 @@ pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Orderin
|
||||
return a_category.cmp(&b_category);
|
||||
}
|
||||
|
||||
if a_category == PropertyCategory::Shorthand {
|
||||
let a = a.as_shorthand().unwrap();
|
||||
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))
|
||||
});
|
||||
if a_category != PropertyCategory::Shorthand {
|
||||
return cmp::Ordering::Equal;
|
||||
}
|
||||
|
||||
cmp::Ordering::Equal
|
||||
}
|
||||
|
||||
fn get_idl_name_sort_order(shorthand: ShorthandId) -> u32 {
|
||||
<%
|
||||
# Sort by IDL name.
|
||||
sorted_shorthands = sorted(data.shorthands, key=lambda p: to_idl_name(p.ident))
|
||||
|
||||
# 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
|
||||
}
|
||||
let a = a.as_shorthand().unwrap();
|
||||
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();
|
||||
subprop_count_a.cmp(&subprop_count_b).then_with(|| {
|
||||
a.idl_name_sort_order().cmp(&b.idl_name_sort_order())
|
||||
})
|
||||
}
|
||||
|
@ -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>(
|
||||
&self,
|
||||
declarations: &mut SourcePropertyDeclaration,
|
||||
|
Loading…
Reference in New Issue
Block a user