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

@ -5,7 +5,7 @@
//! Element nodes.
use app_units::Au;
use cssparser::{Color, ToCss};
use cssparser::Color;
use devtools_traits::AttrInfo;
use dom::activation::Activatable;
use dom::attr::{Attr, AttrHelpersForLayout};
@ -735,15 +735,6 @@ impl Element {
// this sync method is called upon modification of the style_attribute property,
// therefore, it should not trigger subsequent mutation events
pub fn sync_property_with_attrs_style(&self) {
let style_str = if let &Some(ref declarations) = &*self.style_attribute().borrow() {
declarations.read().to_css_string()
} else {
String::new()
};
self.set_style_attr(style_str)
}
pub fn set_style_attr(&self, new_value: String) {
let mut new_style = AttrValue::String(new_value);
@ -767,35 +758,6 @@ impl Element {
self.attrs.borrow_mut().push(JS::from_ref(&attr));
}
pub fn set_inline_style_property_priority(&self,
properties: &[&str],
new_importance: Importance) {
{
let mut inline_declarations = self.style_attribute().borrow_mut();
if let &mut Some(ref mut block) = &mut *inline_declarations {
let mut block = block.write();
let block = &mut *block;
let declarations = &mut block.declarations;
for &mut (ref declaration, ref mut importance) in declarations {
if properties.iter().any(|p| declaration.name() == **p) {
match (*importance, new_importance) {
(Importance::Normal, Importance::Important) => {
block.important_count += 1;
}
(Importance::Important, Importance::Normal) => {
block.important_count -= 1;
}
_ => {}
}
*importance = new_importance;
}
}
}
}
self.sync_property_with_attrs_style();
}
pub fn serialize(&self, traversal_scope: TraversalScope) -> Fallible<DOMString> {
let mut writer = vec![];
match serialize(&mut writer,