aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/document.rs6
-rw-r--r--components/script/dom/mod.rs2
-rw-r--r--components/script/dom/stylesheet.rs60
-rw-r--r--components/script/dom/stylesheetlist.rs54
-rw-r--r--components/script/dom/webidls/Document.webidl5
-rw-r--r--components/script/dom/webidls/StyleSheet.webidl17
-rw-r--r--components/script/dom/webidls/StyleSheetList.webidl11
-rw-r--r--python/tidy.py1
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/interfaces.htm.ini57
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-count.htm.ini7
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-tree-order.htm.ini3
-rw-r--r--tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-document-extension.htm.ini2
-rw-r--r--tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini4
-rw-r--r--tests/wpt/metadata/html/dom/interfaces.html.ini5
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.html2
15 files changed, 159 insertions, 77 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index f05ed60739f..a24580d0f95 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -69,6 +69,7 @@ use dom::nodelist::NodeList;
use dom::processinginstruction::ProcessingInstruction;
use dom::range::Range;
use dom::servohtmlparser::{ParserRoot, ParserRef, MutNullableParserField};
+use dom::stylesheetlist::StyleSheetList;
use dom::text::Text;
use dom::touch::Touch;
use dom::touchevent::TouchEvent;
@@ -1724,6 +1725,11 @@ impl Element {
}
impl DocumentMethods for Document {
+ // https://drafts.csswg.org/cssom/#dom-document-stylesheets
+ fn StyleSheets(&self) -> Root<StyleSheetList> {
+ StyleSheetList::new(&self.window, JS::from_ref(&self))
+ }
+
// https://dom.spec.whatwg.org/#dom-document-implementation
fn Implementation(&self) -> Root<DOMImplementation> {
self.implementation.or_init(|| DOMImplementation::new(self))
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index ebb8fe91291..662f41dc7a9 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -359,6 +359,8 @@ pub mod servohtmlparser;
pub mod servoxmlparser;
pub mod storage;
pub mod storageevent;
+pub mod stylesheet;
+pub mod stylesheetlist;
pub mod testbinding;
pub mod testbindingproxy;
pub mod text;
diff --git a/components/script/dom/stylesheet.rs b/components/script/dom/stylesheet.rs
new file mode 100644
index 00000000000..490acd997ed
--- /dev/null
+++ b/components/script/dom/stylesheet.rs
@@ -0,0 +1,60 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 dom::bindings::codegen::Bindings::StyleSheetBinding;
+use dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{Root};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::window::Window;
+use util::str::DOMString;
+
+
+#[dom_struct]
+pub struct StyleSheet {
+ reflector_: Reflector,
+ type_: DOMString,
+ href: Option<DOMString>,
+ title: Option<DOMString>,
+}
+
+impl StyleSheet {
+ #[allow(unrooted_must_root)]
+ fn new_inherited(type_: DOMString, href: Option<DOMString>, title: Option<DOMString>) -> StyleSheet {
+ StyleSheet {
+ reflector_: Reflector::new(),
+ type_: type_,
+ href: href,
+ title: title
+ }
+ }
+
+ #[allow(unrooted_must_root)]
+ pub fn new(window: &Window, type_: DOMString,
+ href: Option<DOMString>,
+ title: Option<DOMString>) -> Root<StyleSheet> {
+ reflect_dom_object(box StyleSheet::new_inherited(type_, href, title),
+ GlobalRef::Window(window),
+ StyleSheetBinding::Wrap)
+ }
+}
+
+
+impl StyleSheetMethods for StyleSheet {
+ // https://drafts.csswg.org/cssom/#dom-stylesheet-type
+ fn Type_(&self) -> DOMString {
+ self.type_.clone()
+ }
+
+ // https://drafts.csswg.org/cssom/#dom-stylesheet-href
+ fn GetHref(&self) -> Option<DOMString> {
+ self.href.clone()
+ }
+
+ // https://drafts.csswg.org/cssom/#dom-stylesheet-title
+ fn GetTitle(&self) -> Option<DOMString> {
+ self.title.clone()
+ }
+}
+
diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs
new file mode 100644
index 00000000000..d6c58256dc2
--- /dev/null
+++ b/components/script/dom/stylesheetlist.rs
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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 dom::bindings::codegen::Bindings::StyleSheetListBinding;
+use dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JS, Root};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::document::Document;
+use dom::stylesheet::StyleSheet;
+use dom::window::Window;
+
+#[dom_struct]
+pub struct StyleSheetList {
+ reflector_: Reflector,
+ document: JS<Document>,
+}
+
+impl StyleSheetList {
+ #[allow(unrooted_must_root)]
+ fn new_inherited(doc: JS<Document>) -> StyleSheetList {
+ StyleSheetList {
+ reflector_: Reflector::new(),
+ document: doc
+ }
+ }
+
+ #[allow(unrooted_must_root)]
+ pub fn new(window: &Window, document: JS<Document>) -> Root<StyleSheetList> {
+ reflect_dom_object(box StyleSheetList::new_inherited(document),
+ GlobalRef::Window(window), StyleSheetListBinding::Wrap)
+ }
+}
+
+impl StyleSheetListMethods for StyleSheetList {
+ // https://drafts.csswg.org/cssom/#dom-stylesheetlist-length
+ fn Length(&self) -> u32 {
+ self.document.stylesheets().len() as u32
+ }
+
+ // https://drafts.csswg.org/cssom/#dom-stylesheetlist-item
+ fn Item(&self, index: u32) -> Option<Root<StyleSheet>> {
+ None
+ //TODO Create a new StyleSheet object and return it
+ }
+
+ // check-tidy: no specs after this line
+ fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<StyleSheet>>{
+ let item = self.Item(index);
+ *found = item.is_some();
+ item
+ }
+}
diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl
index 6c1814fa43b..845037e430c 100644
--- a/components/script/dom/webidls/Document.webidl
+++ b/components/script/dom/webidls/Document.webidl
@@ -185,3 +185,8 @@ partial interface Document {
partial interface Document {
Element? elementFromPoint(double x, double y);
};
+
+// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface
+partial interface Document {
+ [SameObject] readonly attribute StyleSheetList styleSheets;
+};
diff --git a/components/script/dom/webidls/StyleSheet.webidl b/components/script/dom/webidls/StyleSheet.webidl
new file mode 100644
index 00000000000..fdb4e875ce2
--- /dev/null
+++ b/components/script/dom/webidls/StyleSheet.webidl
@@ -0,0 +1,17 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+// https://drafts.csswg.org/cssom/#the-stylesheet-interface
+interface StyleSheet {
+ readonly attribute DOMString type_;
+ readonly attribute DOMString? href;
+
+ // readonly attribute (Element or ProcessingInstruction)? ownerNode;
+ // readonly attribute StyleSheet? parentStyleSheet;
+ readonly attribute DOMString? title;
+
+ // [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
+ // attribute boolean disabled;
+};
diff --git a/components/script/dom/webidls/StyleSheetList.webidl b/components/script/dom/webidls/StyleSheetList.webidl
new file mode 100644
index 00000000000..e743653fde3
--- /dev/null
+++ b/components/script/dom/webidls/StyleSheetList.webidl
@@ -0,0 +1,11 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+// https://drafts.csswg.org/cssom/#the-stylesheetlist-interface
+// [ArrayClass]
+interface StyleSheetList {
+ getter StyleSheet? item(unsigned long index);
+ readonly attribute unsigned long length;
+};
diff --git a/python/tidy.py b/python/tidy.py
index 8954201c92f..89b8b6db4e8 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -479,6 +479,7 @@ def check_webidl_spec(file_name, contents):
"//dvcs.w3.org/hg",
"//dom.spec.whatwg.org",
"//domparsing.spec.whatwg.org",
+ "//drafts.csswg.org/cssom",
"//drafts.fxtf.org",
"//encoding.spec.whatwg.org",
"//html.spec.whatwg.org",
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 a604b0e3718..4bc468b1b14 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
@@ -1,8 +1,5 @@
[interfaces.htm]
type: testharness
- [Document interface: attribute styleSheets]
- expected: FAIL
-
[Document interface: attribute selectedStyleSheetSet]
expected: FAIL
@@ -18,9 +15,6 @@
[Document interface: operation enableStyleSheetsForSet(DOMString)]
expected: FAIL
- [Document interface: document must inherit property "styleSheets" with the proper type (0)]
- expected: FAIL
-
[Document interface: document must inherit property "selectedStyleSheetSet" with the proper type (1)]
expected: FAIL
@@ -39,9 +33,6 @@
[Document interface: calling enableStyleSheetsForSet(DOMString) on document with too few arguments must throw TypeError]
expected: FAIL
- [Document interface: new Document() must inherit property "styleSheets" with the proper type (0)]
- expected: FAIL
-
[Document interface: new Document() must inherit property "selectedStyleSheetSet" with the proper type (1)]
expected: FAIL
@@ -114,33 +105,15 @@
[MediaList interface: operation deleteMedium(DOMString)]
expected: FAIL
- [StyleSheet interface: existence and properties of interface object]
- expected: FAIL
-
- [StyleSheet interface object length]
- expected: FAIL
-
- [StyleSheet interface: existence and properties of interface prototype object]
- expected: FAIL
-
- [StyleSheet interface: existence and properties of interface prototype object's "constructor" property]
- expected: FAIL
-
[StyleSheet interface: attribute type]
expected: FAIL
- [StyleSheet interface: attribute href]
- expected: FAIL
-
[StyleSheet interface: attribute ownerNode]
expected: FAIL
[StyleSheet interface: attribute parentStyleSheet]
expected: FAIL
- [StyleSheet interface: attribute title]
- expected: FAIL
-
[StyleSheet interface: attribute media]
expected: FAIL
@@ -216,39 +189,9 @@
[StyleSheet interface: style_element.sheet must inherit property "disabled" with the proper type (6)]
expected: FAIL
- [StyleSheetList interface: existence and properties of interface object]
- expected: FAIL
-
- [StyleSheetList interface object length]
- expected: FAIL
-
[StyleSheetList interface: existence and properties of interface prototype object]
expected: FAIL
- [StyleSheetList interface: existence and properties of interface prototype object's "constructor" property]
- expected: FAIL
-
- [StyleSheetList interface: operation item(unsigned long)]
- expected: FAIL
-
- [StyleSheetList interface: attribute length]
- expected: FAIL
-
- [StyleSheetList must be primary interface of document.styleSheets]
- expected: FAIL
-
- [Stringification of document.styleSheets]
- expected: FAIL
-
- [StyleSheetList interface: document.styleSheets must inherit property "item" with the proper type (0)]
- expected: FAIL
-
- [StyleSheetList interface: calling item(unsigned long) on document.styleSheets with too few arguments must throw TypeError]
- expected: FAIL
-
- [StyleSheetList interface: document.styleSheets must inherit property "length" with the proper type (1)]
- expected: FAIL
-
[CSSRuleList interface: existence and properties of interface object]
expected: FAIL
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-count.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-count.htm.ini
index 3df04e1bafe..b92ad6f3deb 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-count.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-count.htm.ini
@@ -1,11 +1,4 @@
[ttwf-cssom-doc-ext-load-count.htm]
type: testharness
- [stylesheet.css should be loaded and styleSheets.length === 1]
- expected: FAIL
-
[stylesheet.css should be unloaded and styleSheets.length === 0]
expected: FAIL
-
- [stylesheet-1.css should be loaded and styleSheets.length === 1]
- expected: FAIL
-
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-tree-order.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-tree-order.htm.ini
index 287e9353c75..f290cfd6613 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-tree-order.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-doc-ext-load-tree-order.htm.ini
@@ -1,8 +1,5 @@
[ttwf-cssom-doc-ext-load-tree-order.htm]
type: testharness
- [styleSheets.length must be 5]
- expected: FAIL
-
[styleSheets item 0 title must be aaa]
expected: FAIL
diff --git a/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-document-extension.htm.ini b/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-document-extension.htm.ini
index d4c8ee42f9c..bad97814ac1 100644
--- a/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-document-extension.htm.ini
+++ b/tests/wpt/metadata-css/cssom-1_dev/html/ttwf-cssom-document-extension.htm.ini
@@ -1,5 +1,3 @@
[ttwf-cssom-document-extension.htm]
type: testharness
- [CSSOM - Extensions to the Document Interface: StyleSheetList length is 0 when no sheets loaded]
- expected: FAIL
diff --git a/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini b/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini
index 32ef6273117..400a5857cec 100644
--- a/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini
+++ b/tests/wpt/metadata/XMLHttpRequest/responsexml-document-properties.htm.ini
@@ -29,7 +29,3 @@
[lastModified set according to HTTP header]
expected: FAIL
-
- [styleSheets]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index e7e1067c2fd..94960ecdf5b 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -8036,7 +8036,7 @@
[Document interface: iframe.contentDocument must inherit property "createTreeWalker" with the proper type (27)]
expected: FAIL
-
+
[Document interface: iframe.contentDocument must inherit property "styleSheets" with the proper type (28)]
expected: FAIL
@@ -8415,9 +8415,6 @@
[Document interface: iframe.contentDocument must inherit property "onwaiting" with the proper type (156)]
expected: FAIL
- [Document interface: document.implementation.createDocument(null, "", null) must inherit property "styleSheets" with the proper type (28)]
- expected: FAIL
-
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "selectedStyleSheetSet" with the proper type (29)]
expected: FAIL
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html
index eaa0bdadcd1..ececea5e35e 100644
--- a/tests/wpt/mozilla/tests/mozilla/interfaces.html
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html
@@ -208,6 +208,8 @@ var interfaceNamesInGlobalScope = [
"Screen",
"Storage",
"StorageEvent",
+ "StyleSheet",
+ "StyleSheetList",
"TestBinding", // XXX
"TestBindingProxy", // XXX
"Text",