style: Cleanup PrioritizedPropertyIter.

This commit is contained in:
Emilio Cobos Álvarez 2018-02-20 15:36:43 +01:00
parent 0b1f78275c
commit a4c7728062
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -3797,24 +3797,23 @@ struct PropertyAndIndex {
}
struct PrioritizedPropertyIter<'a> {
properties: &'a nsTArray<PropertyValuePair>,
properties: &'a [PropertyValuePair],
sorted_property_indices: Vec<PropertyAndIndex>,
curr: usize,
}
impl<'a> PrioritizedPropertyIter<'a> {
pub fn new(properties: &'a nsTArray<PropertyValuePair>) -> PrioritizedPropertyIter {
// If we fail to convert a nsCSSPropertyID into a PropertyId we shouldn't fail outright
// but instead by treating that property as the 'all' property we make it sort last.
let all = PropertyId::Shorthand(ShorthandId::All);
fn new(properties: &'a [PropertyValuePair]) -> PrioritizedPropertyIter {
// If we fail to convert a nsCSSPropertyID into a PropertyId we
// shouldn't fail outright but instead by treating that property as the
// 'all' property we make it sort last.
let mut sorted_property_indices: Vec<PropertyAndIndex> =
properties.iter().enumerate().map(|(index, pair)| {
PropertyAndIndex {
property: PropertyId::from_nscsspropertyid(pair.mProperty)
.unwrap_or(all.clone()),
index,
}
let property =
PropertyId::from_nscsspropertyid(pair.mProperty)
.unwrap_or(PropertyId::Shorthand(ShorthandId::All));
PropertyAndIndex { property, index }
}).collect();
sorted_property_indices.sort_by(|a, b| compare_property_priority(&a.property, &b.property));