diff options
author | bors-servo <metajack+bors@gmail.com> | 2014-12-24 10:45:45 -0700 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2014-12-24 10:45:45 -0700 |
commit | c35a18e81f943ae09db50afdf54a03dece153615 (patch) | |
tree | 2f14602c8a4b408a6d4d21fe48b82c60ade1c343 /components/script/dom | |
parent | 194ce20969f04bf2d077ebed106fc1bfb5eb32ee (diff) | |
parent | eacbe331c9a4c427f164e773199c4137d1687728 (diff) | |
download | servo-c35a18e81f943ae09db50afdf54a03dece153615.tar.gz servo-c35a18e81f943ae09db50afdf54a03dece153615.zip |
auto merge of #4477 : thiagopnts/servo/descriptive-enum, r=jdm
refs #4472
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/cssstyledeclaration.rs | 8 | ||||
-rw-r--r-- | components/script/dom/element.rs | 14 |
2 files changed, 15 insertions, 7 deletions
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index cacb5afb1a7..7d4feeb40ab 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -9,7 +9,7 @@ use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, JSRef, OptionalRootedRootable, Temporary}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::document::DocumentHelpers; -use dom::element::{Element, ElementHelpers}; +use dom::element::{Element, ElementHelpers, StylePriority}; use dom::htmlelement::HTMLElement; use dom::node::{window_from_node, document_from_node, NodeDamage, Node}; use dom::window::Window; @@ -222,7 +222,8 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> { // Step 8 for decl in decl_block.normal.iter() { // Step 9 - element.update_inline_style(decl.clone(), !priority.is_empty()); + let style_priority = if priority.is_empty() { StylePriority::Normal } else { StylePriority::Important }; + element.update_inline_style(decl.clone(), style_priority); } let document = document_from_node(element).root(); @@ -259,7 +260,8 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> { // Step 5 for decl in decl_block.normal.iter() { // Step 6 - element.update_inline_style(decl.clone(), !priority.is_empty()); + let style_priority = if priority.is_empty() { StylePriority::Normal } else { StylePriority::Important }; + element.update_inline_style(decl.clone(), style_priority); } let document = document_from_node(element).root(); diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index b1d85ef8c74..ca2d6109f12 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -456,6 +456,12 @@ impl LayoutElementHelpers for JS<Element> { } } +#[deriving(PartialEq)] +pub enum StylePriority { + Important, + Normal, +} + pub trait ElementHelpers<'a> { fn html_element_in_html_document(self) -> bool; fn local_name(self) -> &'a Atom; @@ -467,7 +473,7 @@ pub trait ElementHelpers<'a> { fn summarize(self) -> Vec<AttrInfo>; fn is_void(self) -> bool; fn remove_inline_style_property(self, property: DOMString); - fn update_inline_style(self, property_decl: style::PropertyDeclaration, important: bool); + fn update_inline_style(self, property_decl: style::PropertyDeclaration, style_priority: StylePriority); fn get_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration>; fn get_important_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration>; } @@ -555,10 +561,10 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { }); } - fn update_inline_style(self, property_decl: style::PropertyDeclaration, important: bool) { + fn update_inline_style(self, property_decl: style::PropertyDeclaration, style_priority: StylePriority) { let mut inline_declarations = self.style_attribute().borrow_mut(); if let Some(ref mut declarations) = *inline_declarations.deref_mut() { - let existing_declarations = if important { + let existing_declarations = if style_priority == StylePriority::Important { declarations.important.make_unique() } else { declarations.normal.make_unique() @@ -574,7 +580,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> { return; } - let (important, normal) = if important { + let (important, normal) = if style_priority == StylePriority::Important { (vec!(property_decl), vec!()) } else { (vec!(), vec!(property_decl)) |