aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/cssstyledeclaration.rs41
-rw-r--r--components/script/dom/element.rs2
-rw-r--r--components/script/dom/webidls/CSSStyleDeclaration.webidl4
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/computed-style-001.htm.ini5
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-csstext.htm.ini9
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-mutability.htm.ini3
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/index-002.htm.ini12
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/interfaces.htm.ini3
8 files changed, 42 insertions, 37 deletions
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 4da0b1a019c..101ac3ef252 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use cssparser::ToCss;
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{self, CSSStyleDeclarationMethods};
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::global::GlobalRef;
@@ -18,7 +19,7 @@ use std::slice;
use string_cache::Atom;
use style::parser::ParserContextExtraData;
use style::properties::{PropertyDeclaration, Shorthand};
-use style::properties::{is_supported_property, parse_one_declaration};
+use style::properties::{is_supported_property, parse_one_declaration, parse_style_attribute};
use style::selector_impl::PseudoElement;
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
@@ -339,6 +340,42 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
rval
}
- // https://drafts.csswg.org/cssom/#cssstyledeclaration
+ // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext
+ fn CssText(&self) -> DOMString {
+ let elem = self.owner.upcast::<Element>();
+ let style_attribute = elem.style_attribute().borrow();
+
+ if let Some(declarations) = style_attribute.as_ref() {
+ DOMString::from(declarations.to_css_string())
+ } else {
+ DOMString::new()
+ }
+ }
+
+ // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext
+ fn SetCssText(&self, value: DOMString) -> ErrorResult {
+ let window = window_from_node(self.owner.upcast::<Node>());
+ let element = self.owner.upcast::<Element>();
+
+ // Step 1
+ if self.readonly {
+ return Err(Error::NoModificationAllowed);
+ }
+
+ // Step 3
+ let decl_block = parse_style_attribute(&value, &window.get_url(), window.css_error_reporter(),
+ ParserContextExtraData::default());
+ *element.style_attribute().borrow_mut() = if decl_block.normal.is_empty() && decl_block.important.is_empty() {
+ None // Step 2
+ } else {
+ Some(decl_block)
+ };
+ element.sync_property_with_attrs_style();
+ let node = element.upcast::<Node>();
+ node.dirty(NodeDamage::NodeStyleDamaged);
+ Ok(())
+ }
+
+ // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-_camel_cased_attribute
css_properties_accessors!(css_properties);
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 2d92c5995e3..bb97931a9d9 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -700,7 +700,7 @@ impl Element {
// this sync method is called upon modification of the style_attribute property,
// therefore, it should not trigger subsequent mutation events
- fn sync_property_with_attrs_style(&self) {
+ pub fn sync_property_with_attrs_style(&self) {
let style_str = if let &Some(ref declarations) = &*self.style_attribute().borrow() {
declarations.to_css_string()
} else {
diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl
index 1d1d5223183..cf7c3ade7f2 100644
--- a/components/script/dom/webidls/CSSStyleDeclaration.webidl
+++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl
@@ -9,8 +9,8 @@
*/
interface CSSStyleDeclaration {
- //[SetterThrows]
- // attribute DOMString cssText;
+ [SetterThrows]
+ attribute DOMString cssText;
readonly attribute unsigned long length;
getter DOMString item(unsigned long index);
DOMString getPropertyValue(DOMString property);
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/computed-style-001.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/computed-style-001.htm.ini
deleted file mode 100644
index 778339718e4..00000000000
--- a/tests/wpt/metadata-css/cssom-1_dev/html/computed-style-001.htm.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[computed-style-001.htm]
- type: testharness
- [read_only]
- expected: FAIL
-
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-csstext.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-csstext.htm.ini
index fcde8e8f0f0..f0db23cead6 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-csstext.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-csstext.htm.ini
@@ -1,17 +1,8 @@
[cssstyledeclaration-csstext.htm]
type: testharness
- [uppercase property]
- expected: FAIL
-
[uppercase value]
expected: FAIL
- [overwriting with invalid value]
- expected: FAIL
-
- [use rgb]
- expected: FAIL
-
[cssText order]
expected: FAIL
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-mutability.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-mutability.htm.ini
index 6e8935f7e76..de66afda62d 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-mutability.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/cssstyledeclaration-mutability.htm.ini
@@ -1,8 +1,5 @@
[cssstyledeclaration-mutability.htm]
type: testharness
- [HTMLElement's CSSStyleDeclaration is mutable]
- expected: FAIL
-
[StyleSheet's CSSStyleDeclaration is mutable]
expected: FAIL
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/index-002.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/index-002.htm.ini
index 81db38b45b1..7ce14ad73ce 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/index-002.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/index-002.htm.ini
@@ -30,27 +30,15 @@
[border is expected to be border-width: 1px;]
expected: FAIL
- [overflow is expected to be overflow: scroll hidden;]
- expected: FAIL
-
[overflow is expected to be overflow: scroll;]
expected: FAIL
[outline is expected to be outline: blue dotted 2px;]
expected: FAIL
- [margin is expected to be margin: 1px 2px 3px 4px;]
- expected: FAIL
-
[list is expected to be list-style: circle inside;]
expected: FAIL
- [list is expected to be list-style-type: lower-alpha;]
- expected: FAIL
-
[font-family is expected to be font-family: sans-serif; line-height: 2em; font-size: 3em; font-style: italic; font-weight: bold;]
expected: FAIL
- [padding is expected to be padding: 1px 2px 3px 4px;]
- expected: FAIL
-
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/interfaces.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/interfaces.htm.ini
index 4bc468b1b14..828fc2e43c8 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/interfaces.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/interfaces.htm.ini
@@ -474,9 +474,6 @@
[CSSNamespaceRule interface: attribute prefix]
expected: FAIL
- [CSSStyleDeclaration interface: attribute cssText]
- expected: FAIL
-
[CSSStyleDeclaration interface: attribute parentRule]
expected: FAIL