mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move CSSStyleDeclaration.SetPropertyPriority logic to style
This commit is contained in:
parent
c740a76410
commit
0eed39c198
3 changed files with 30 additions and 49 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue