Move CSSStyleDeclaration.SetPropertyPriority logic to style

This commit is contained in:
Simon Sapin 2016-10-07 19:20:05 +02:00
parent c740a76410
commit 0eed39c198
3 changed files with 30 additions and 49 deletions

View file

@ -154,6 +154,23 @@ impl PropertyDeclarationBlock {
}
}
pub fn set_importance(&mut self, property_names: &[&str], new_importance: Importance) {
for &mut (ref declaration, ref mut importance) in &mut self.declarations {
if property_names.iter().any(|p| declaration.matches(p)) {
match (*importance, new_importance) {
(Importance::Normal, Importance::Important) => {
self.important_count += 1;
}
(Importance::Important, Importance::Normal) => {
self.important_count -= 1;
}
_ => {}
}
*importance = new_importance;
}
}
}
/// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
pub fn remove_property(&mut self, property_name: &str) {
// Step 2