mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Cleanup PrioritizedPropertyIter.
This commit is contained in:
parent
0b1f78275c
commit
a4c7728062
1 changed files with 10 additions and 11 deletions
|
@ -3797,24 +3797,23 @@ struct PropertyAndIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PrioritizedPropertyIter<'a> {
|
struct PrioritizedPropertyIter<'a> {
|
||||||
properties: &'a nsTArray<PropertyValuePair>,
|
properties: &'a [PropertyValuePair],
|
||||||
sorted_property_indices: Vec<PropertyAndIndex>,
|
sorted_property_indices: Vec<PropertyAndIndex>,
|
||||||
curr: usize,
|
curr: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PrioritizedPropertyIter<'a> {
|
impl<'a> PrioritizedPropertyIter<'a> {
|
||||||
pub fn new(properties: &'a nsTArray<PropertyValuePair>) -> PrioritizedPropertyIter {
|
fn new(properties: &'a [PropertyValuePair]) -> PrioritizedPropertyIter {
|
||||||
// If we fail to convert a nsCSSPropertyID into a PropertyId we shouldn't fail outright
|
// If we fail to convert a nsCSSPropertyID into a PropertyId we
|
||||||
// but instead by treating that property as the 'all' property we make it sort last.
|
// shouldn't fail outright but instead by treating that property as the
|
||||||
let all = PropertyId::Shorthand(ShorthandId::All);
|
// 'all' property we make it sort last.
|
||||||
|
|
||||||
let mut sorted_property_indices: Vec<PropertyAndIndex> =
|
let mut sorted_property_indices: Vec<PropertyAndIndex> =
|
||||||
properties.iter().enumerate().map(|(index, pair)| {
|
properties.iter().enumerate().map(|(index, pair)| {
|
||||||
PropertyAndIndex {
|
let property =
|
||||||
property: PropertyId::from_nscsspropertyid(pair.mProperty)
|
PropertyId::from_nscsspropertyid(pair.mProperty)
|
||||||
.unwrap_or(all.clone()),
|
.unwrap_or(PropertyId::Shorthand(ShorthandId::All));
|
||||||
index,
|
|
||||||
}
|
PropertyAndIndex { property, index }
|
||||||
}).collect();
|
}).collect();
|
||||||
sorted_property_indices.sort_by(|a, b| compare_property_priority(&a.property, &b.property));
|
sorted_property_indices.sort_by(|a, b| compare_property_priority(&a.property, &b.property));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue