#[derive(Debug, Clone)]
pub struct SimplePropertyValuePropertyDeclarationAutoprefixer
{
propertyName: &'static str,
propertyValue: &'static str,
removeUnprefixedProperty: bool,
vendorPrefixes: BTreeSet<VendorPrefix>,
}
impl PropertyDeclarationAutoprefixer for SimplePropertyValuePropertyDeclarationAutoprefixer
{
fn autoprefix<H: HasPropertyDeclarations<I>, I: HasImportance>(&self, property_declarations: &mut H, parent_vendor_prefix: Option<&VendorPrefix>)
{
let list = property_declarations.property_declarations_vec_mut();
let mut index = 0;
while index != list.len()
{
let vendorPrefixed =
{
let propertyDeclaration = list.get(index).unwrap();
if propertyDeclaration.hasAsciiNameIgnoringCase(&self.propertyName)
{
let mut vendorPrefixed = Vec::with_capacity(self.vendorPrefixes.len());
for vendorPrefix in self.vendorPrefixes.iter().rev()
{
let include = if let Some(parentVendorPrefix) = parent_vendor_prefix
{
parentVendorPrefix == vendorPrefix
}
else
{
true
};
if include
{
vendorPrefixed.push(PropertyDeclaration
{
vendor_prefix: Some(vendorPrefix.clone()),
name: propertyDeclaration.name.clone(),
value: match &propertyDeclaration.value
{
value @ &UnparsedPropertyValue::CssWideKeyword(_) => value.clone(),
&UnparsedPropertyValue::SpecifiedValue(ref specifiedValue) => if &specifiedValue.originalCss == self.propertyValue
{
UnparsedPropertyValue::SpecifiedValue(SpecifiedValue
{
originalCss: vendorPrefix.prefix(&specifiedValue.originalCss)
})
}
else
{
UnparsedPropertyValue::SpecifiedValue(SpecifiedValue
{
originalCss: specifiedValue.originalCss.clone()
})
},
},
importance: propertyDeclaration.importance,
});
}
}
Some(vendorPrefixed)
}
else
{
None
}
};
index += if let Some(mut vendorPrefixed) = vendorPrefixed
{
let indexIncrement = vendorPrefixed.len();
for propertyDeclaration in vendorPrefixed.drain(..)
{
list.insert(index, propertyDeclaration);
}
if self.removeUnprefixedProperty
{
list.remove(index + indexIncrement);
indexIncrement
}
else
{
indexIncrement + 1
}
}
else
{
1
};
}
}
}