Skip to content

Commit

Permalink
style: Cleanup PrioritizedPropertyIter.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Feb 20, 2018
1 parent 820e940 commit 4d6c24d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ports/geckolib/glue.rs
Expand Up @@ -3797,23 +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));

Expand Down

0 comments on commit 4d6c24d

Please sign in to comment.