#[derive(Debug, Clone)]
pub struct PropertyNamePropertyDeclarationAutoprefixer
{
propertyName: &'static str,
removeUnprefixedPropertyName: bool,
vendorPrefixes: Rc<BTreeSet<VendorPrefix>>,
isMicrosoftMasqueradingAsWebkit: bool,
}
impl PropertyDeclarationAutoprefixer for PropertyNamePropertyDeclarationAutoprefixer
{
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.isNotVendorPrefixed() && 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
{
if self.isMicrosoftMasqueradingAsWebkit
{
true
}
else
{
parentVendorPrefix == vendorPrefix
}
}
else
{
true
};
if include
{
vendorPrefixed.push(PropertyDeclaration
{
vendor_prefix: Some(vendorPrefix.clone()),
name: propertyDeclaration.name.clone(),
value: propertyDeclaration.value.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.removeUnprefixedPropertyName
{
list.remove(index + indexIncrement);
indexIncrement
}
else
{
indexIncrement + 1
}
}
else
{
1
};
}
}
}