aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/main/layout/construct.rs4
-rw-r--r--src/components/script/dom/bindings/codegen/Bindings.conf4
-rw-r--r--src/components/script/dom/document.rs180
-rw-r--r--src/components/script/dom/domimplementation.rs12
-rw-r--r--src/components/script/dom/domparser.rs6
-rw-r--r--src/components/script/dom/element.rs5
-rw-r--r--src/components/script/dom/htmldocument.rs93
-rw-r--r--src/components/script/dom/htmlserializer.rs2
-rw-r--r--src/components/script/dom/node.rs34
-rw-r--r--src/components/script/dom/webidls/Document.webidl11
-rw-r--r--src/components/script/dom/webidls/HTMLDocument.webidl17
-rw-r--r--src/components/script/script.rs1
-rw-r--r--src/components/script/script_task.rs7
-rw-r--r--src/test/html/content/test_documentElement.html1
-rw-r--r--src/test/html/content/test_document_contenttype.html4
-rw-r--r--src/test/html/content/test_document_implementation.html1
-rw-r--r--src/test/html/content/test_parentnodes.html2
-rw-r--r--src/test/html/content/test_prototypes.html1
18 files changed, 135 insertions, 250 deletions
diff --git a/src/components/main/layout/construct.rs b/src/components/main/layout/construct.rs
index 7ca32d95f64..66192647bcd 100644
--- a/src/components/main/layout/construct.rs
+++ b/src/components/main/layout/construct.rs
@@ -644,7 +644,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
CommentNodeTypeId |
DoctypeNodeTypeId |
DocumentFragmentNodeTypeId |
- DocumentNodeTypeId(_) |
+ DocumentNodeTypeId |
ProcessingInstructionNodeTypeId => (display::none, float::none, position::static_),
};
@@ -717,7 +717,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
CommentNodeTypeId |
DoctypeNodeTypeId |
DocumentFragmentNodeTypeId |
- DocumentNodeTypeId(_) |
+ DocumentNodeTypeId |
ElementNodeTypeId(HTMLImageElementTypeId) => true,
ElementNodeTypeId(HTMLObjectElementTypeId) => self.has_object_data(),
ElementNodeTypeId(_) => false,
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf
index cc4a5996865..8485377ed8b 100644
--- a/src/components/script/dom/bindings/codegen/Bindings.conf
+++ b/src/components/script/dom/bindings/codegen/Bindings.conf
@@ -224,10 +224,6 @@ DOMInterfaces = {
{
}],
-'HTMLDocument': {
- 'customTrace': 'trace'
-},
-
'HTMLOptionsCollection': [
{
'nativeType': 'nsHTMLOptionCollection',
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index f699c859d74..e839e4aa233 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -13,7 +13,7 @@ use dom::bindings::utils::{ErrorResult, Fallible, NotSupported, InvalidCharacter
use dom::bindings::utils::{xml_name_type, InvalidXMLName};
use dom::comment::Comment;
use dom::documentfragment::DocumentFragment;
-use dom::documenttype;
+use dom::documenttype::DocumentType;
use dom::domimplementation::DOMImplementation;
use dom::element::{Element};
use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId};
@@ -45,16 +45,9 @@ use std::hashmap::HashMap;
use extra::serialize::{Encoder, Encodable};
#[deriving(Eq,Encodable)]
-pub enum DocumentTypeId {
- PlainDocumentTypeId,
- HTMLDocumentTypeId
-}
-
-#[deriving(Eq,Encodable)]
-pub enum DocumentType {
- HTML,
- SVG,
- XML
+pub enum IsHTMLDocument {
+ HTMLDocument,
+ NonHTMLDocument,
}
#[deriving(Encodable)]
@@ -62,11 +55,11 @@ pub struct Document {
node: Node,
reflector_: Reflector,
window: JS<Window>,
- doctype: DocumentType,
idmap: HashMap<DOMString, JS<Element>>,
implementation: Option<JS<DOMImplementation>>,
content_type: DOMString,
encoding_name: DOMString,
+ is_html_document: bool,
extra: Untraceable,
}
@@ -83,7 +76,7 @@ impl<S: Encoder> Encodable<S> for Untraceable {
impl DocumentDerived for EventTarget {
fn is_document(&self) -> bool {
match self.type_id {
- NodeTargetTypeId(DocumentNodeTypeId(_)) => true,
+ NodeTargetTypeId(DocumentNodeTypeId) => true,
_ => false
}
}
@@ -105,25 +98,23 @@ impl Document {
raw_doc
}
- pub fn new_inherited(window: JS<Window>, url: Option<Url>, doctype: DocumentType, content_type: Option<DOMString>) -> Document {
- let node_type = match doctype {
- HTML => HTMLDocumentTypeId,
- SVG | XML => PlainDocumentTypeId
- };
+ pub fn new_inherited(window: JS<Window>,
+ url: Option<Url>,
+ is_html_document: IsHTMLDocument,
+ content_type: Option<DOMString>) -> Document {
Document {
- node: Node::new_without_doc(DocumentNodeTypeId(node_type)),
+ node: Node::new_without_doc(DocumentNodeTypeId),
reflector_: Reflector::new(),
window: window,
- doctype: doctype,
idmap: HashMap::new(),
implementation: None,
content_type: match content_type {
Some(string) => string.clone(),
- None => match doctype {
+ None => match is_html_document {
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
- HTML => ~"text/html",
+ HTMLDocument => ~"text/html",
// http://dom.spec.whatwg.org/#concept-document-content-type
- SVG | XML => ~"application/xml"
+ NonHTMLDocument => ~"application/xml"
}
},
extra: Untraceable {
@@ -136,10 +127,11 @@ impl Document {
},
// http://dom.spec.whatwg.org/#concept-document-encoding
encoding_name: ~"utf-8",
+ is_html_document: is_html_document == HTMLDocument,
}
}
- pub fn new(window: &JS<Window>, url: Option<Url>, doctype: DocumentType, content_type: Option<DOMString>) -> JS<Document> {
+ pub fn new(window: &JS<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> JS<Document> {
let document = Document::new_inherited(window.clone(), url, doctype, content_type);
Document::reflect_document(~document, window, DocumentBinding::Wrap)
}
@@ -148,7 +140,7 @@ impl Document {
impl Document {
// http://dom.spec.whatwg.org/#dom-document
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<Document>> {
- Ok(Document::new(owner, None, XML, None))
+ Ok(Document::new(owner, None, NonHTMLDocument, None))
}
}
@@ -208,7 +200,7 @@ impl Document {
}
// http://dom.spec.whatwg.org/#dom-document-doctype
- pub fn GetDoctype(&self) -> Option<JS<documenttype::DocumentType>> {
+ pub fn GetDoctype(&self) -> Option<JS<DocumentType>> {
self.node.children().find(|child| child.is_doctype())
.map(|node| DocumentTypeCast::to(&node))
}
@@ -223,16 +215,6 @@ impl Document {
self.createHTMLCollection(|elem| elem.tag_name == tag)
}
- // http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens
- pub fn GetElementsByTagNameNS(&self, _ns: Option<DOMString>, _tag: DOMString) -> JS<HTMLCollection> {
- HTMLCollection::new(&self.window, ~[])
- }
-
- // http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname
- pub fn GetElementsByClassName(&self, _class: DOMString) -> JS<HTMLCollection> {
- HTMLCollection::new(&self.window, ~[])
- }
-
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
pub fn GetElementById(&self, id: DOMString) -> Option<JS<Element>> {
// TODO: "in tree order, within the context object's tree"
@@ -300,24 +282,17 @@ impl Document {
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
pub fn Title(&self, _: &JS<Document>) -> DOMString {
let mut title = ~"";
- match self.doctype {
- SVG => {
- fail!("no SVG document yet")
- },
- _ => {
- self.GetDocumentElement().map(|root| {
- let root: JS<Node> = NodeCast::from(&root);
- root.traverse_preorder()
- .find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId))
- .map(|title_elem| {
- for child in title_elem.children() {
- let text: JS<Text> = TextCast::to(&child);
- title.push_str(text.get().characterdata.data.as_slice());
- }
- });
+ self.GetDocumentElement().map(|root| {
+ let root: JS<Node> = NodeCast::from(&root);
+ root.traverse_preorder()
+ .find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId))
+ .map(|title_elem| {
+ for child in title_elem.children() {
+ let text: JS<Text> = TextCast::to(&child);
+ title.push_str(text.get().characterdata.data.as_slice());
+ }
});
- }
- }
+ });
let v: ~[&str] = title.words().collect();
title = v.connect(" ");
title = title.trim().to_owned();
@@ -326,41 +301,34 @@ impl Document {
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
pub fn SetTitle(&self, abstract_self: &JS<Document>, title: DOMString) -> ErrorResult {
- match self.doctype {
- SVG => {
- fail!("no SVG document yet")
- },
- _ => {
- self.GetDocumentElement().map(|root| {
- let root: JS<Node> = NodeCast::from(&root);
- let mut head_node = root.traverse_preorder().find(|child| {
- child.get().type_id == ElementNodeTypeId(HTMLHeadElementTypeId)
- });
- head_node.as_mut().map(|head| {
-
- let mut title_node = head.children().find(|child| {
- child.get().type_id == ElementNodeTypeId(HTMLTitleElementTypeId)
- });
-
- title_node.as_mut().map(|title_node| {
- for mut title_child in title_node.children() {
- title_node.RemoveChild(&mut title_child);
- }
- let new_text = self.CreateTextNode(abstract_self, title.clone());
- title_node.AppendChild(&mut NodeCast::from(&new_text));
- });
-
- if title_node.is_none() {
- let mut new_title: JS<Node> =
- NodeCast::from(&HTMLTitleElement::new(~"title", abstract_self));
- let new_text = self.CreateTextNode(abstract_self, title.clone());
- new_title.AppendChild(&mut NodeCast::from(&new_text));
- head.AppendChild(&mut new_title);
- }
- });
+ self.GetDocumentElement().map(|root| {
+ let root: JS<Node> = NodeCast::from(&root);
+ let mut head_node = root.traverse_preorder().find(|child| {
+ child.get().type_id == ElementNodeTypeId(HTMLHeadElementTypeId)
+ });
+ head_node.as_mut().map(|head| {
+
+ let mut title_node = head.children().find(|child| {
+ child.get().type_id == ElementNodeTypeId(HTMLTitleElementTypeId)
});
- }
- }
+
+ title_node.as_mut().map(|title_node| {
+ for mut title_child in title_node.children() {
+ title_node.RemoveChild(&mut title_child);
+ }
+ let new_text = self.CreateTextNode(abstract_self, title.clone());
+ title_node.AppendChild(&mut NodeCast::from(&new_text));
+ });
+
+ if title_node.is_none() {
+ let mut new_title: JS<Node> =
+ NodeCast::from(&HTMLTitleElement::new(~"title", abstract_self));
+ let new_text = self.CreateTextNode(abstract_self, title.clone());
+ new_title.AppendChild(&mut NodeCast::from(&new_text));
+ head.AppendChild(&mut new_title);
+ }
+ });
+ });
Ok(())
}
@@ -441,6 +409,44 @@ impl Document {
})
}
+ pub fn Images(&self) -> JS<HTMLCollection> {
+ self.createHTMLCollection(|elem| "img" == elem.tag_name)
+ }
+
+ pub fn Embeds(&self) -> JS<HTMLCollection> {
+ self.createHTMLCollection(|elem| "embed" == elem.tag_name)
+ }
+
+ pub fn Plugins(&self) -> JS<HTMLCollection> {
+ self.Embeds()
+ }
+
+ pub fn Links(&self) -> JS<HTMLCollection> {
+ self.createHTMLCollection(|elem| {
+ ("a" == elem.tag_name || "area" == elem.tag_name) &&
+ elem.get_attribute(Null, "href").is_some()
+ })
+ }
+
+ pub fn Forms(&self) -> JS<HTMLCollection> {
+ self.createHTMLCollection(|elem| "form" == elem.tag_name)
+ }
+
+ pub fn Scripts(&self) -> JS<HTMLCollection> {
+ self.createHTMLCollection(|elem| "script" == elem.tag_name)
+ }
+
+ pub fn Anchors(&self) -> JS<HTMLCollection> {
+ self.createHTMLCollection(|elem| {
+ "a" == elem.tag_name && elem.get_attribute(Null, "name").is_some()
+ })
+ }
+
+ pub fn Applets(&self) -> JS<HTMLCollection> {
+ // FIXME: This should be return OBJECT elements containing applets.
+ self.createHTMLCollection(|elem| "applet" == elem.tag_name)
+ }
+
pub fn createHTMLCollection(&self, callback: |elem: &Element| -> bool) -> JS<HTMLCollection> {
let mut elements = ~[];
match self.GetDocumentElement() {
diff --git a/src/components/script/dom/domimplementation.rs b/src/components/script/dom/domimplementation.rs
index 48c26ff4871..86968680741 100644
--- a/src/components/script/dom/domimplementation.rs
+++ b/src/components/script/dom/domimplementation.rs
@@ -3,19 +3,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::DOMImplementationBinding;
-use dom::bindings::codegen::InheritTypes::{NodeCast, DocumentCast};
+use dom::bindings::codegen::InheritTypes::NodeCast;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
-use dom::document::{Document, HTML, HTMLDocumentTypeId};
+use dom::document::{Document, HTMLDocument};
use dom::documenttype::DocumentType;
-use dom::htmldocument::HTMLDocument;
use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlheadelement::HTMLHeadElement;
use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmltitleelement::HTMLTitleElement;
-use dom::node::{Node, DocumentNodeTypeId, NodeHelpers, INode};
+use dom::node::{Node, INode};
use dom::text::Text;
use dom::window::Window;
use servo_util::str::DOMString;
@@ -67,11 +66,8 @@ impl DOMImplementation {
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> {
// Step 1-2.
- let doc: JS<Document> = DocumentCast::from(&HTMLDocument::new(&self.owner, None));
- assert!(doc.get().doctype == HTML);
-
+ let doc = Document::new(&self.owner, None, HTMLDocument, None);
let mut doc_node: JS<Node> = NodeCast::from(&doc);
- assert!(doc_node.type_id() == DocumentNodeTypeId(HTMLDocumentTypeId));
{
// Step 3.
diff --git a/src/components/script/dom/domparser.rs b/src/components/script/dom/domparser.rs
index 3b545e0be62..f66e737a5f8 100644
--- a/src/components/script/dom/domparser.rs
+++ b/src/components/script/dom/domparser.rs
@@ -4,13 +4,11 @@
use dom::bindings::codegen::DOMParserBinding;
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
-use dom::bindings::codegen::InheritTypes::DocumentCast;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::utils::Fallible;
use dom::bindings::utils::FailureUnknown;
-use dom::document::Document;
-use dom::htmldocument::HTMLDocument;
+use dom::document::{Document, HTMLDocument};
use dom::window::Window;
use servo_util::str::DOMString;
@@ -43,7 +41,7 @@ impl DOMParser {
-> Fallible<JS<Document>> {
match ty {
Text_html => {
- Ok(DocumentCast::from(&HTMLDocument::new(&self.owner, None)))
+ Ok(Document::new(&self.owner, None, HTMLDocument, None))
}
Text_xml => {
Document::Constructor(&self.owner)
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index f9b7c67d372..d7bbaa065a6 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -22,7 +22,6 @@ use dom::htmlimageelement::HTMLImageElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlobjectelement::HTMLObjectElement;
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator};
-use dom::document;
use dom::htmlserializer::serialize;
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
@@ -153,10 +152,8 @@ impl Element {
}
pub fn html_element_in_html_document(&self) -> bool {
- let owner = self.node.owner_doc();
self.namespace == namespace::HTML &&
- // FIXME: check that this matches what the spec calls "is in an HTML document"
- owner.get().doctype == document::HTML
+ self.node.owner_doc().get().is_html_document
}
pub fn get_attribute(&self,
diff --git a/src/components/script/dom/htmldocument.rs b/src/components/script/dom/htmldocument.rs
deleted file mode 100644
index 7b967d68bea..00000000000
--- a/src/components/script/dom/htmldocument.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-/* 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::HTMLDocumentBinding;
-use dom::bindings::codegen::InheritTypes::HTMLDocumentDerived;
-use dom::bindings::js::JS;
-use dom::bindings::utils::{Reflectable, Reflector};
-use dom::document::{Document, HTML, HTMLDocumentTypeId};
-use dom::eventtarget::{EventTarget, NodeTargetTypeId};
-use dom::htmlcollection::HTMLCollection;
-use dom::node::DocumentNodeTypeId;
-use dom::window::Window;
-use servo_util::namespace::Null;
-
-use extra::url::Url;
-
-#[deriving(Encodable)]
-pub struct HTMLDocument {
- parent: Document
-}
-
-impl HTMLDocumentDerived for EventTarget {
- fn is_htmldocument(&self) -> bool {
- match self.type_id {
- NodeTargetTypeId(DocumentNodeTypeId(HTMLDocumentTypeId)) => true,
- _ => false
- }
- }
-}
-
-impl HTMLDocument {
- pub fn new_inherited(window: JS<Window>, url: Option<Url>) -> HTMLDocument {
- HTMLDocument {
- parent: Document::new_inherited(window, url, HTML, None)
- }
- }
-
- pub fn new(window: &JS<Window>, url: Option<Url>) -> JS<HTMLDocument> {
- let document = HTMLDocument::new_inherited(window.clone(), url);
- Document::reflect_document(~document, window, HTMLDocumentBinding::Wrap)
- }
-}
-
-impl HTMLDocument {
- pub fn Images(&self) -> JS<HTMLCollection> {
- self.parent.createHTMLCollection(|elem| "img" == elem.tag_name)
- }
-
- pub fn Embeds(&self) -> JS<HTMLCollection> {
- self.parent.createHTMLCollection(|elem| "embed" == elem.tag_name)
- }
-
- pub fn Plugins(&self) -> JS<HTMLCollection> {
- self.Embeds()
- }
-
- pub fn Links(&self) -> JS<HTMLCollection> {
- self.parent.createHTMLCollection(|elem| {
- ("a" == elem.tag_name || "area" == elem.tag_name) &&
- elem.get_attribute(Null, "href").is_some()
- })
- }
-
- pub fn Forms(&self) -> JS<HTMLCollection> {
- self.parent.createHTMLCollection(|elem| "form" == elem.tag_name)
- }
-
- pub fn Scripts(&self) -> JS<HTMLCollection> {
- self.parent.createHTMLCollection(|elem| "script" == elem.tag_name)
- }
-
- pub fn Anchors(&self) -> JS<HTMLCollection> {
- self.parent.createHTMLCollection(|elem| {
- "a" == elem.tag_name && elem.get_attribute(Null, "name").is_some()
- })
- }
-
- pub fn Applets(&self) -> JS<HTMLCollection> {
- // FIXME: This should be return OBJECT elements containing applets.
- self.parent.createHTMLCollection(|elem| "applet" == elem.tag_name)
- }
-}
-
-impl Reflectable for HTMLDocument {
- fn reflector<'a>(&'a self) -> &'a Reflector {
- self.parent.reflector()
- }
-
- fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
- self.parent.mut_reflector()
- }
-}
diff --git a/src/components/script/dom/htmlserializer.rs b/src/components/script/dom/htmlserializer.rs
index 17e1b099b41..482c724666b 100644
--- a/src/components/script/dom/htmlserializer.rs
+++ b/src/components/script/dom/htmlserializer.rs
@@ -52,7 +52,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
DocumentFragmentNodeTypeId => {
~""
}
- DocumentNodeTypeId(_) => {
+ DocumentNodeTypeId => {
fail!("It shouldn't be possible to serialize a document node")
}
}
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 4526b45dd8b..a0357c92ab4 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -12,7 +12,7 @@ use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::utils::{ErrorResult, Fallible, NotFound, HierarchyRequest};
use dom::bindings::utils;
use dom::characterdata::CharacterData;
-use dom::document::{Document, DocumentTypeId};
+use dom::document::Document;
use dom::documenttype::DocumentType;
use dom::element::{Element, ElementTypeId, HTMLAnchorElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@@ -101,7 +101,7 @@ impl NodeFlags {
pub fn new(type_id: NodeTypeId) -> NodeFlags {
let mut flags = NodeFlags(0);
match type_id {
- DocumentNodeTypeId(_) => { flags.set_is_in_doc(true); }
+ DocumentNodeTypeId => { flags.set_is_in_doc(true); }
_ => {}
}
flags
@@ -208,7 +208,7 @@ pub enum NodeTypeId {
DoctypeNodeTypeId,
DocumentFragmentNodeTypeId,
CommentNodeTypeId,
- DocumentNodeTypeId(DocumentTypeId),
+ DocumentNodeTypeId,
ElementNodeTypeId(ElementTypeId),
TextNodeTypeId,
ProcessingInstructionNodeTypeId,
@@ -362,7 +362,7 @@ impl NodeHelpers for JS<Node> {
#[inline]
fn is_document(&self) -> bool {
match self.type_id() {
- DocumentNodeTypeId(..) => true,
+ DocumentNodeTypeId => true,
_ => false
}
}
@@ -804,7 +804,7 @@ impl Node {
TextNodeTypeId => 3,
ProcessingInstructionNodeTypeId => 7,
CommentNodeTypeId => 8,
- DocumentNodeTypeId(_) => 9,
+ DocumentNodeTypeId => 9,
DoctypeNodeTypeId => 10,
DocumentFragmentNodeTypeId => 11,
}
@@ -829,7 +829,7 @@ impl Node {
doctype.get().name.clone()
},
DocumentFragmentNodeTypeId => ~"#document-fragment",
- DocumentNodeTypeId(_) => ~"#document"
+ DocumentNodeTypeId => ~"#document"
}
}
@@ -847,7 +847,7 @@ impl Node {
ProcessingInstructionNodeTypeId |
DoctypeNodeTypeId |
DocumentFragmentNodeTypeId => Some(self.owner_doc()),
- DocumentNodeTypeId(_) => None
+ DocumentNodeTypeId => None
}
}
@@ -931,7 +931,7 @@ impl Node {
Some(characterdata.get().Data())
}
DoctypeNodeTypeId |
- DocumentNodeTypeId(_) => {
+ DocumentNodeTypeId => {
None
}
}
@@ -975,7 +975,7 @@ impl Node {
-> Fallible<JS<Node>> {
// Step 1.
match parent.type_id() {
- DocumentNodeTypeId(..) |
+ DocumentNodeTypeId |
DocumentFragmentNodeTypeId |
ElementNodeTypeId(..) => (),
_ => return Err(HierarchyRequest)
@@ -1010,12 +1010,12 @@ impl Node {
ElementNodeTypeId(_) |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(..) => return Err(HierarchyRequest)
+ DocumentNodeTypeId => return Err(HierarchyRequest)
}
// Step 6.
match parent.type_id() {
- DocumentNodeTypeId(_) => {
+ DocumentNodeTypeId => {
match node.type_id() {
// Step 6.1
DocumentFragmentNodeTypeId => {
@@ -1084,7 +1084,7 @@ impl Node {
TextNodeTypeId |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(_) => unreachable!(),
+ DocumentNodeTypeId => unreachable!(),
}
},
_ => (),
@@ -1252,7 +1252,7 @@ impl Node {
document.get().content_changed();
}
DoctypeNodeTypeId |
- DocumentNodeTypeId(_) => {}
+ DocumentNodeTypeId => {}
}
Ok(())
}
@@ -1279,7 +1279,7 @@ impl Node {
-> Fallible<JS<Node>> {
// Step 1.
match parent.type_id() {
- DocumentNodeTypeId(..) |
+ DocumentNodeTypeId |
DocumentFragmentNodeTypeId |
ElementNodeTypeId(..) => (),
_ => return Err(HierarchyRequest)
@@ -1305,12 +1305,12 @@ impl Node {
TextNodeTypeId |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(..) => return Err(HierarchyRequest)
+ DocumentNodeTypeId => return Err(HierarchyRequest)
}
// Step 6.
match parent.type_id() {
- DocumentNodeTypeId(..) => {
+ DocumentNodeTypeId => {
match node.type_id() {
// Step 6.1
DocumentFragmentNodeTypeId => {
@@ -1358,7 +1358,7 @@ impl Node {
TextNodeTypeId |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(..) => unreachable!()
+ DocumentNodeTypeId => unreachable!()
}
},
_ => ()
diff --git a/src/components/script/dom/webidls/Document.webidl b/src/components/script/dom/webidls/Document.webidl
index 12769016f38..daa91f540fb 100644
--- a/src/components/script/dom/webidls/Document.webidl
+++ b/src/components/script/dom/webidls/Document.webidl
@@ -21,8 +21,6 @@ interface Document : Node {
readonly attribute DocumentType? doctype;
readonly attribute Element? documentElement;
HTMLCollection getElementsByTagName(DOMString localName);
- HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
- HTMLCollection getElementsByClassName(DOMString classNames);
Element? getElementById(DOMString elementId);
[Creator, Throws]
@@ -47,4 +45,13 @@ partial interface Document {
attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
/*NodeList*/ HTMLCollection getElementsByName(DOMString elementName);
+
+ readonly attribute HTMLCollection images;
+ readonly attribute HTMLCollection embeds;
+ readonly attribute HTMLCollection plugins;
+ readonly attribute HTMLCollection links;
+ readonly attribute HTMLCollection forms;
+ readonly attribute HTMLCollection scripts;
+ readonly attribute HTMLCollection anchors;
+ readonly attribute HTMLCollection applets;
};
diff --git a/src/components/script/dom/webidls/HTMLDocument.webidl b/src/components/script/dom/webidls/HTMLDocument.webidl
deleted file mode 100644
index b899a46678f..00000000000
--- a/src/components/script/dom/webidls/HTMLDocument.webidl
+++ /dev/null
@@ -1,17 +0,0 @@
-/* -*- 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/.
- */
-
-/* http://www.whatwg.org/specs/web-apps/current-work/#the-document-object */
-interface HTMLDocument : Document {
- readonly attribute HTMLCollection images;
- readonly attribute HTMLCollection embeds;
- readonly attribute HTMLCollection plugins;
- readonly attribute HTMLCollection links;
- readonly attribute HTMLCollection forms;
- readonly attribute HTMLCollection scripts;
- readonly attribute HTMLCollection anchors;
- readonly attribute HTMLCollection applets;
-};
diff --git a/src/components/script/script.rs b/src/components/script/script.rs
index d85df63ba08..8cfbc737255 100644
--- a/src/components/script/script.rs
+++ b/src/components/script/script.rs
@@ -81,7 +81,6 @@ pub mod dom {
pub mod htmldirectoryelement;
pub mod htmldivelement;
pub mod htmldlistelement;
- pub mod htmldocument;
pub mod htmlelement;
pub mod htmlembedelement;
pub mod htmlfieldsetelement;
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index d0c53384231..a9a284ad21f 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -6,15 +6,14 @@
//! and layout tasks.
use dom::bindings::codegen::RegisterBindings;
-use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, DocumentCast, ElementCast};
+use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCast};
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
-use dom::document::Document;
+use dom::document::{Document, HTMLDocument};
use dom::element::Element;
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use dom::event::Event;
use dom::eventtarget::EventTarget;
-use dom::htmldocument::HTMLDocument;
use dom::node::{Node, NodeHelpers};
use dom::window::{TimerData, TimerHandle, Window};
use html::hubbub_html_parser::HtmlParserResult;
@@ -718,7 +717,7 @@ impl ScriptTask {
// Parse HTML.
//
// Note: We can parse the next document in parallel with any previous documents.
- let mut document = DocumentCast::from(&HTMLDocument::new(&window, Some(url.clone())));
+ let mut document = Document::new(&window, Some(url.clone()), HTMLDocument, None);
let html_parsing_result = hubbub_html_parser::parse_html(cx.ptr,
&mut document,
url.clone(),
diff --git a/src/test/html/content/test_documentElement.html b/src/test/html/content/test_documentElement.html
index eea379456b1..efe68e086d0 100644
--- a/src/test/html/content/test_documentElement.html
+++ b/src/test/html/content/test_documentElement.html
@@ -6,7 +6,6 @@ is_a(window, Window);
is_a(document.documentElement, HTMLHtmlElement);
is_a(document.documentElement.firstChild, HTMLHeadElement);
is(document.documentElement.nextSibling, null);
-is_a(document, HTMLDocument);
is_a(document, Document);
finish();
</script>
diff --git a/src/test/html/content/test_document_contenttype.html b/src/test/html/content/test_document_contenttype.html
index ede2696f98a..4a63a654547 100644
--- a/src/test/html/content/test_document_contenttype.html
+++ b/src/test/html/content/test_document_contenttype.html
@@ -5,14 +5,14 @@
<script>
// test1: HTML document
{
- is_a(document, HTMLDocument, "test1-0, HTML document");
+ is_a(document, Document, "test1-0, HTML document");
is(document.contentType, "text/html", "test1-1, HTML document");
}
// test2: XML document
{
var doc = new Document;
- is_not_a(doc, HTMLDocument, "test2-0, XML document");
+ is_a(doc, Document, "test2-0, XML document");
is(doc.contentType, "application/xml", "test2-1, XML document");
}
diff --git a/src/test/html/content/test_document_implementation.html b/src/test/html/content/test_document_implementation.html
index 6f7ac8a89ab..57dabd13e71 100644
--- a/src/test/html/content/test_document_implementation.html
+++ b/src/test/html/content/test_document_implementation.html
@@ -27,7 +27,6 @@
var htmldoc = document.implementation.createHTMLDocument("example title");
isnot(htmldoc, null, "test3-0, createHTMLDocument");
is_a(htmldoc, Document, "test3-1, createHTMLDocument");
- is_a(htmldoc, HTMLDocument, "test3-2, createHTMLDocument");
is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument");
diff --git a/src/test/html/content/test_parentnodes.html b/src/test/html/content/test_parentnodes.html
index 0b1bb610414..2131b7270b2 100644
--- a/src/test/html/content/test_parentnodes.html
+++ b/src/test/html/content/test_parentnodes.html
@@ -6,7 +6,7 @@
<body>
<div id="div1"></div>
<script>
- is_a(document.documentElement.parentNode, HTMLDocument);
+ is_a(document.documentElement.parentNode, Document);
is(document.documentElement.parentElement, null);
var elem = document.createElement("p");
diff --git a/src/test/html/content/test_prototypes.html b/src/test/html/content/test_prototypes.html
index cdcc0b9f4ab..93019abe424 100644
--- a/src/test/html/content/test_prototypes.html
+++ b/src/test/html/content/test_prototypes.html
@@ -14,7 +14,6 @@ is_a(window.document.documentElement, Element);
is_a(window.document.documentElement, HTMLElement);
is_a(window.document.documentElement, HTMLHtmlElement);
is_a(window.document, Document);
-is_a(window.document, HTMLDocument);
is(window.document.documentElement.tagName, "HTML");
is_a(window.document.getElementsByTagName('foo-á')[0], HTMLUnknownElement);
is(window.document.getElementsByTagName('foo-á')[0].tagName, "FOO-á");