aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/cssstyledeclaration.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2016-12-08 16:17:04 -1000
committerSimon Sapin <simon.sapin@exyr.org>2016-12-09 17:06:50 -1000
commit58d452fa4e7b4b426925fe3bc525251048ae2830 (patch)
tree01254b66afc1576d4c3b0c85316253c7f972f53c /components/script/dom/cssstyledeclaration.rs
parentfdc40592ded819bb546da8f844f236323eed1738 (diff)
downloadservo-58d452fa4e7b4b426925fe3bc525251048ae2830.tar.gz
servo-58d452fa4e7b4b426925fe3bc525251048ae2830.zip
Use PropertyId instead of Atom for CSSStyleDeclaration::get_computed_style
Diffstat (limited to 'components/script/dom/cssstyledeclaration.rs')
-rw-r--r--components/script/dom/cssstyledeclaration.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index c119f8a70e6..c8be4f560a6 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -12,7 +12,6 @@ use dom::element::Element;
use dom::node::{Node, NodeDamage, window_from_node};
use dom::window::Window;
use parking_lot::RwLock;
-use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::sync::Arc;
use style::parser::ParserContextExtraData;
@@ -74,12 +73,12 @@ impl CSSStyleDeclaration {
CSSStyleDeclarationBinding::Wrap)
}
- fn get_computed_style(&self, property: &Atom) -> Option<DOMString> {
+ fn get_computed_style(&self, property: PropertyId) -> DOMString {
let node = self.owner.upcast::<Node>();
if !node.is_in_doc() {
// TODO: Node should be matched against the style rules of this window.
// Firefox is currently the only browser to implement this.
- return None;
+ return DOMString::new();
}
let addr = node.to_trusted_node_address();
window_from_node(&*self.owner).resolved_style_query(addr, self.pseudo.clone(), property)
@@ -103,14 +102,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
}
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
- fn GetPropertyValue(&self, mut property: DOMString) -> DOMString {
- if self.readonly {
- // Readonly style declarations are used for getComputedStyle.
- property.make_ascii_lowercase();
- let property = Atom::from(property);
- return self.get_computed_style(&property).unwrap_or(DOMString::new());
- }
-
+ fn GetPropertyValue(&self, property: DOMString) -> DOMString {
let id = if let Ok(id) = PropertyId::parse(property.into()) {
id
} else {
@@ -118,6 +110,11 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
return DOMString::new()
};
+ if self.readonly {
+ // Readonly style declarations are used for getComputedStyle.
+ return self.get_computed_style(id);
+ }
+
let style_attribute = self.owner.style_attribute().borrow();
let style_attribute = if let Some(ref lock) = *style_attribute {
lock.read()