mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
auto merge of #1739 : Ms2ger/servo/document-cleanup, r=jdm
The specs currently have only Document; this may well change, but the split won't be along the lines we've implemented right now. In the meantime, this simplifies our code quite a bit.
This commit is contained in:
commit
22760b6665
18 changed files with 134 additions and 249 deletions
|
@ -644,7 +644,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
CommentNodeTypeId |
|
CommentNodeTypeId |
|
||||||
DoctypeNodeTypeId |
|
DoctypeNodeTypeId |
|
||||||
DocumentFragmentNodeTypeId |
|
DocumentFragmentNodeTypeId |
|
||||||
DocumentNodeTypeId(_) |
|
DocumentNodeTypeId |
|
||||||
ProcessingInstructionNodeTypeId => (display::none, float::none, position::static_),
|
ProcessingInstructionNodeTypeId => (display::none, float::none, position::static_),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -717,7 +717,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
||||||
CommentNodeTypeId |
|
CommentNodeTypeId |
|
||||||
DoctypeNodeTypeId |
|
DoctypeNodeTypeId |
|
||||||
DocumentFragmentNodeTypeId |
|
DocumentFragmentNodeTypeId |
|
||||||
DocumentNodeTypeId(_) |
|
DocumentNodeTypeId |
|
||||||
ElementNodeTypeId(HTMLImageElementTypeId) => true,
|
ElementNodeTypeId(HTMLImageElementTypeId) => true,
|
||||||
ElementNodeTypeId(HTMLObjectElementTypeId) => self.has_object_data(),
|
ElementNodeTypeId(HTMLObjectElementTypeId) => self.has_object_data(),
|
||||||
ElementNodeTypeId(_) => false,
|
ElementNodeTypeId(_) => false,
|
||||||
|
|
|
@ -224,10 +224,6 @@ DOMInterfaces = {
|
||||||
{
|
{
|
||||||
}],
|
}],
|
||||||
|
|
||||||
'HTMLDocument': {
|
|
||||||
'customTrace': 'trace'
|
|
||||||
},
|
|
||||||
|
|
||||||
'HTMLOptionsCollection': [
|
'HTMLOptionsCollection': [
|
||||||
{
|
{
|
||||||
'nativeType': 'nsHTMLOptionCollection',
|
'nativeType': 'nsHTMLOptionCollection',
|
||||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::utils::{ErrorResult, Fallible, NotSupported, InvalidCharacter
|
||||||
use dom::bindings::utils::{xml_name_type, InvalidXMLName};
|
use dom::bindings::utils::{xml_name_type, InvalidXMLName};
|
||||||
use dom::comment::Comment;
|
use dom::comment::Comment;
|
||||||
use dom::documentfragment::DocumentFragment;
|
use dom::documentfragment::DocumentFragment;
|
||||||
use dom::documenttype;
|
use dom::documenttype::DocumentType;
|
||||||
use dom::domimplementation::DOMImplementation;
|
use dom::domimplementation::DOMImplementation;
|
||||||
use dom::element::{Element};
|
use dom::element::{Element};
|
||||||
use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId};
|
use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId};
|
||||||
|
@ -45,16 +45,9 @@ use std::hashmap::HashMap;
|
||||||
use extra::serialize::{Encoder, Encodable};
|
use extra::serialize::{Encoder, Encodable};
|
||||||
|
|
||||||
#[deriving(Eq,Encodable)]
|
#[deriving(Eq,Encodable)]
|
||||||
pub enum DocumentTypeId {
|
pub enum IsHTMLDocument {
|
||||||
PlainDocumentTypeId,
|
HTMLDocument,
|
||||||
HTMLDocumentTypeId
|
NonHTMLDocument,
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Eq,Encodable)]
|
|
||||||
pub enum DocumentType {
|
|
||||||
HTML,
|
|
||||||
SVG,
|
|
||||||
XML
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
|
@ -62,11 +55,11 @@ pub struct Document {
|
||||||
node: Node,
|
node: Node,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
window: JS<Window>,
|
window: JS<Window>,
|
||||||
doctype: DocumentType,
|
|
||||||
idmap: HashMap<DOMString, JS<Element>>,
|
idmap: HashMap<DOMString, JS<Element>>,
|
||||||
implementation: Option<JS<DOMImplementation>>,
|
implementation: Option<JS<DOMImplementation>>,
|
||||||
content_type: DOMString,
|
content_type: DOMString,
|
||||||
encoding_name: DOMString,
|
encoding_name: DOMString,
|
||||||
|
is_html_document: bool,
|
||||||
extra: Untraceable,
|
extra: Untraceable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +76,7 @@ impl<S: Encoder> Encodable<S> for Untraceable {
|
||||||
impl DocumentDerived for EventTarget {
|
impl DocumentDerived for EventTarget {
|
||||||
fn is_document(&self) -> bool {
|
fn is_document(&self) -> bool {
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
NodeTargetTypeId(DocumentNodeTypeId(_)) => true,
|
NodeTargetTypeId(DocumentNodeTypeId) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,25 +98,23 @@ impl Document {
|
||||||
raw_doc
|
raw_doc
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_inherited(window: JS<Window>, url: Option<Url>, doctype: DocumentType, content_type: Option<DOMString>) -> Document {
|
pub fn new_inherited(window: JS<Window>,
|
||||||
let node_type = match doctype {
|
url: Option<Url>,
|
||||||
HTML => HTMLDocumentTypeId,
|
is_html_document: IsHTMLDocument,
|
||||||
SVG | XML => PlainDocumentTypeId
|
content_type: Option<DOMString>) -> Document {
|
||||||
};
|
|
||||||
Document {
|
Document {
|
||||||
node: Node::new_without_doc(DocumentNodeTypeId(node_type)),
|
node: Node::new_without_doc(DocumentNodeTypeId),
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
window: window,
|
window: window,
|
||||||
doctype: doctype,
|
|
||||||
idmap: HashMap::new(),
|
idmap: HashMap::new(),
|
||||||
implementation: None,
|
implementation: None,
|
||||||
content_type: match content_type {
|
content_type: match content_type {
|
||||||
Some(string) => string.clone(),
|
Some(string) => string.clone(),
|
||||||
None => match doctype {
|
None => match is_html_document {
|
||||||
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||||
HTML => ~"text/html",
|
HTMLDocument => ~"text/html",
|
||||||
// http://dom.spec.whatwg.org/#concept-document-content-type
|
// http://dom.spec.whatwg.org/#concept-document-content-type
|
||||||
SVG | XML => ~"application/xml"
|
NonHTMLDocument => ~"application/xml"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extra: Untraceable {
|
extra: Untraceable {
|
||||||
|
@ -136,10 +127,11 @@ impl Document {
|
||||||
},
|
},
|
||||||
// http://dom.spec.whatwg.org/#concept-document-encoding
|
// http://dom.spec.whatwg.org/#concept-document-encoding
|
||||||
encoding_name: ~"utf-8",
|
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);
|
let document = Document::new_inherited(window.clone(), url, doctype, content_type);
|
||||||
Document::reflect_document(~document, window, DocumentBinding::Wrap)
|
Document::reflect_document(~document, window, DocumentBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -148,7 +140,7 @@ impl Document {
|
||||||
impl Document {
|
impl Document {
|
||||||
// http://dom.spec.whatwg.org/#dom-document
|
// http://dom.spec.whatwg.org/#dom-document
|
||||||
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<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
|
// 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())
|
self.node.children().find(|child| child.is_doctype())
|
||||||
.map(|node| DocumentTypeCast::to(&node))
|
.map(|node| DocumentTypeCast::to(&node))
|
||||||
}
|
}
|
||||||
|
@ -223,16 +215,6 @@ impl Document {
|
||||||
self.createHTMLCollection(|elem| elem.tag_name == tag)
|
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
|
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
pub fn GetElementById(&self, id: DOMString) -> Option<JS<Element>> {
|
pub fn GetElementById(&self, id: DOMString) -> Option<JS<Element>> {
|
||||||
// TODO: "in tree order, within the context object's tree"
|
// 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
|
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
|
||||||
pub fn Title(&self, _: &JS<Document>) -> DOMString {
|
pub fn Title(&self, _: &JS<Document>) -> DOMString {
|
||||||
let mut title = ~"";
|
let mut title = ~"";
|
||||||
match self.doctype {
|
self.GetDocumentElement().map(|root| {
|
||||||
SVG => {
|
let root: JS<Node> = NodeCast::from(&root);
|
||||||
fail!("no SVG document yet")
|
root.traverse_preorder()
|
||||||
},
|
.find(|node| node.type_id() == ElementNodeTypeId(HTMLTitleElementTypeId))
|
||||||
_ => {
|
.map(|title_elem| {
|
||||||
self.GetDocumentElement().map(|root| {
|
for child in title_elem.children() {
|
||||||
let root: JS<Node> = NodeCast::from(&root);
|
let text: JS<Text> = TextCast::to(&child);
|
||||||
root.traverse_preorder()
|
title.push_str(text.get().characterdata.data.as_slice());
|
||||||
.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();
|
let v: ~[&str] = title.words().collect();
|
||||||
title = v.connect(" ");
|
title = v.connect(" ");
|
||||||
title = title.trim().to_owned();
|
title = title.trim().to_owned();
|
||||||
|
@ -326,41 +301,34 @@ impl Document {
|
||||||
|
|
||||||
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
|
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
|
||||||
pub fn SetTitle(&self, abstract_self: &JS<Document>, title: DOMString) -> ErrorResult {
|
pub fn SetTitle(&self, abstract_self: &JS<Document>, title: DOMString) -> ErrorResult {
|
||||||
match self.doctype {
|
self.GetDocumentElement().map(|root| {
|
||||||
SVG => {
|
let root: JS<Node> = NodeCast::from(&root);
|
||||||
fail!("no SVG document yet")
|
let mut head_node = root.traverse_preorder().find(|child| {
|
||||||
},
|
child.get().type_id == ElementNodeTypeId(HTMLHeadElementTypeId)
|
||||||
_ => {
|
});
|
||||||
self.GetDocumentElement().map(|root| {
|
head_node.as_mut().map(|head| {
|
||||||
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| {
|
let mut title_node = head.children().find(|child| {
|
||||||
child.get().type_id == ElementNodeTypeId(HTMLTitleElementTypeId)
|
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
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(())
|
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> {
|
pub fn createHTMLCollection(&self, callback: |elem: &Element| -> bool) -> JS<HTMLCollection> {
|
||||||
let mut elements = ~[];
|
let mut elements = ~[];
|
||||||
match self.GetDocumentElement() {
|
match self.GetDocumentElement() {
|
||||||
|
|
|
@ -3,19 +3,18 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::DOMImplementationBinding;
|
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::js::JS;
|
||||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
|
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
|
||||||
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
|
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::documenttype::DocumentType;
|
||||||
use dom::htmldocument::HTMLDocument;
|
|
||||||
use dom::htmlbodyelement::HTMLBodyElement;
|
use dom::htmlbodyelement::HTMLBodyElement;
|
||||||
use dom::htmlheadelement::HTMLHeadElement;
|
use dom::htmlheadelement::HTMLHeadElement;
|
||||||
use dom::htmlhtmlelement::HTMLHtmlElement;
|
use dom::htmlhtmlelement::HTMLHtmlElement;
|
||||||
use dom::htmltitleelement::HTMLTitleElement;
|
use dom::htmltitleelement::HTMLTitleElement;
|
||||||
use dom::node::{Node, DocumentNodeTypeId, NodeHelpers, INode};
|
use dom::node::{Node, INode};
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
@ -67,11 +66,8 @@ impl DOMImplementation {
|
||||||
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||||
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> {
|
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> {
|
||||||
// Step 1-2.
|
// Step 1-2.
|
||||||
let doc: JS<Document> = DocumentCast::from(&HTMLDocument::new(&self.owner, None));
|
let doc = Document::new(&self.owner, None, HTMLDocument, None);
|
||||||
assert!(doc.get().doctype == HTML);
|
|
||||||
|
|
||||||
let mut doc_node: JS<Node> = NodeCast::from(&doc);
|
let mut doc_node: JS<Node> = NodeCast::from(&doc);
|
||||||
assert!(doc_node.type_id() == DocumentNodeTypeId(HTMLDocumentTypeId));
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Step 3.
|
// Step 3.
|
||||||
|
|
|
@ -4,13 +4,11 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::DOMParserBinding;
|
use dom::bindings::codegen::DOMParserBinding;
|
||||||
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
||||||
use dom::bindings::codegen::InheritTypes::DocumentCast;
|
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::utils::Fallible;
|
use dom::bindings::utils::Fallible;
|
||||||
use dom::bindings::utils::FailureUnknown;
|
use dom::bindings::utils::FailureUnknown;
|
||||||
use dom::document::Document;
|
use dom::document::{Document, HTMLDocument};
|
||||||
use dom::htmldocument::HTMLDocument;
|
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
|
@ -43,7 +41,7 @@ impl DOMParser {
|
||||||
-> Fallible<JS<Document>> {
|
-> Fallible<JS<Document>> {
|
||||||
match ty {
|
match ty {
|
||||||
Text_html => {
|
Text_html => {
|
||||||
Ok(DocumentCast::from(&HTMLDocument::new(&self.owner, None)))
|
Ok(Document::new(&self.owner, None, HTMLDocument, None))
|
||||||
}
|
}
|
||||||
Text_xml => {
|
Text_xml => {
|
||||||
Document::Constructor(&self.owner)
|
Document::Constructor(&self.owner)
|
||||||
|
|
|
@ -22,7 +22,6 @@ use dom::htmlimageelement::HTMLImageElement;
|
||||||
use dom::htmliframeelement::HTMLIFrameElement;
|
use dom::htmliframeelement::HTMLIFrameElement;
|
||||||
use dom::htmlobjectelement::HTMLObjectElement;
|
use dom::htmlobjectelement::HTMLObjectElement;
|
||||||
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator};
|
use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator};
|
||||||
use dom::document;
|
|
||||||
use dom::htmlserializer::serialize;
|
use dom::htmlserializer::serialize;
|
||||||
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
||||||
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
|
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
|
||||||
|
@ -153,10 +152,8 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn html_element_in_html_document(&self) -> bool {
|
pub fn html_element_in_html_document(&self) -> bool {
|
||||||
let owner = self.node.owner_doc();
|
|
||||||
self.namespace == namespace::HTML &&
|
self.namespace == namespace::HTML &&
|
||||||
// FIXME: check that this matches what the spec calls "is in an HTML document"
|
self.node.owner_doc().get().is_html_document
|
||||||
owner.get().doctype == document::HTML
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_attribute(&self,
|
pub fn get_attribute(&self,
|
||||||
|
|
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,7 +52,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
||||||
DocumentFragmentNodeTypeId => {
|
DocumentFragmentNodeTypeId => {
|
||||||
~""
|
~""
|
||||||
}
|
}
|
||||||
DocumentNodeTypeId(_) => {
|
DocumentNodeTypeId => {
|
||||||
fail!("It shouldn't be possible to serialize a document node")
|
fail!("It shouldn't be possible to serialize a document node")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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::{ErrorResult, Fallible, NotFound, HierarchyRequest};
|
||||||
use dom::bindings::utils;
|
use dom::bindings::utils;
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
use dom::document::{Document, DocumentTypeId};
|
use dom::document::Document;
|
||||||
use dom::documenttype::DocumentType;
|
use dom::documenttype::DocumentType;
|
||||||
use dom::element::{Element, ElementTypeId, HTMLAnchorElementTypeId};
|
use dom::element::{Element, ElementTypeId, HTMLAnchorElementTypeId};
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
|
@ -101,7 +101,7 @@ impl NodeFlags {
|
||||||
pub fn new(type_id: NodeTypeId) -> NodeFlags {
|
pub fn new(type_id: NodeTypeId) -> NodeFlags {
|
||||||
let mut flags = NodeFlags(0);
|
let mut flags = NodeFlags(0);
|
||||||
match type_id {
|
match type_id {
|
||||||
DocumentNodeTypeId(_) => { flags.set_is_in_doc(true); }
|
DocumentNodeTypeId => { flags.set_is_in_doc(true); }
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
flags
|
flags
|
||||||
|
@ -208,7 +208,7 @@ pub enum NodeTypeId {
|
||||||
DoctypeNodeTypeId,
|
DoctypeNodeTypeId,
|
||||||
DocumentFragmentNodeTypeId,
|
DocumentFragmentNodeTypeId,
|
||||||
CommentNodeTypeId,
|
CommentNodeTypeId,
|
||||||
DocumentNodeTypeId(DocumentTypeId),
|
DocumentNodeTypeId,
|
||||||
ElementNodeTypeId(ElementTypeId),
|
ElementNodeTypeId(ElementTypeId),
|
||||||
TextNodeTypeId,
|
TextNodeTypeId,
|
||||||
ProcessingInstructionNodeTypeId,
|
ProcessingInstructionNodeTypeId,
|
||||||
|
@ -362,7 +362,7 @@ impl NodeHelpers for JS<Node> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_document(&self) -> bool {
|
fn is_document(&self) -> bool {
|
||||||
match self.type_id() {
|
match self.type_id() {
|
||||||
DocumentNodeTypeId(..) => true,
|
DocumentNodeTypeId => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -804,7 +804,7 @@ impl Node {
|
||||||
TextNodeTypeId => 3,
|
TextNodeTypeId => 3,
|
||||||
ProcessingInstructionNodeTypeId => 7,
|
ProcessingInstructionNodeTypeId => 7,
|
||||||
CommentNodeTypeId => 8,
|
CommentNodeTypeId => 8,
|
||||||
DocumentNodeTypeId(_) => 9,
|
DocumentNodeTypeId => 9,
|
||||||
DoctypeNodeTypeId => 10,
|
DoctypeNodeTypeId => 10,
|
||||||
DocumentFragmentNodeTypeId => 11,
|
DocumentFragmentNodeTypeId => 11,
|
||||||
}
|
}
|
||||||
|
@ -829,7 +829,7 @@ impl Node {
|
||||||
doctype.get().name.clone()
|
doctype.get().name.clone()
|
||||||
},
|
},
|
||||||
DocumentFragmentNodeTypeId => ~"#document-fragment",
|
DocumentFragmentNodeTypeId => ~"#document-fragment",
|
||||||
DocumentNodeTypeId(_) => ~"#document"
|
DocumentNodeTypeId => ~"#document"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ impl Node {
|
||||||
ProcessingInstructionNodeTypeId |
|
ProcessingInstructionNodeTypeId |
|
||||||
DoctypeNodeTypeId |
|
DoctypeNodeTypeId |
|
||||||
DocumentFragmentNodeTypeId => Some(self.owner_doc()),
|
DocumentFragmentNodeTypeId => Some(self.owner_doc()),
|
||||||
DocumentNodeTypeId(_) => None
|
DocumentNodeTypeId => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,7 +931,7 @@ impl Node {
|
||||||
Some(characterdata.get().Data())
|
Some(characterdata.get().Data())
|
||||||
}
|
}
|
||||||
DoctypeNodeTypeId |
|
DoctypeNodeTypeId |
|
||||||
DocumentNodeTypeId(_) => {
|
DocumentNodeTypeId => {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -975,7 +975,7 @@ impl Node {
|
||||||
-> Fallible<JS<Node>> {
|
-> Fallible<JS<Node>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
match parent.type_id() {
|
match parent.type_id() {
|
||||||
DocumentNodeTypeId(..) |
|
DocumentNodeTypeId |
|
||||||
DocumentFragmentNodeTypeId |
|
DocumentFragmentNodeTypeId |
|
||||||
ElementNodeTypeId(..) => (),
|
ElementNodeTypeId(..) => (),
|
||||||
_ => return Err(HierarchyRequest)
|
_ => return Err(HierarchyRequest)
|
||||||
|
@ -1010,12 +1010,12 @@ impl Node {
|
||||||
ElementNodeTypeId(_) |
|
ElementNodeTypeId(_) |
|
||||||
ProcessingInstructionNodeTypeId |
|
ProcessingInstructionNodeTypeId |
|
||||||
CommentNodeTypeId => (),
|
CommentNodeTypeId => (),
|
||||||
DocumentNodeTypeId(..) => return Err(HierarchyRequest)
|
DocumentNodeTypeId => return Err(HierarchyRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
match parent.type_id() {
|
match parent.type_id() {
|
||||||
DocumentNodeTypeId(_) => {
|
DocumentNodeTypeId => {
|
||||||
match node.type_id() {
|
match node.type_id() {
|
||||||
// Step 6.1
|
// Step 6.1
|
||||||
DocumentFragmentNodeTypeId => {
|
DocumentFragmentNodeTypeId => {
|
||||||
|
@ -1084,7 +1084,7 @@ impl Node {
|
||||||
TextNodeTypeId |
|
TextNodeTypeId |
|
||||||
ProcessingInstructionNodeTypeId |
|
ProcessingInstructionNodeTypeId |
|
||||||
CommentNodeTypeId => (),
|
CommentNodeTypeId => (),
|
||||||
DocumentNodeTypeId(_) => unreachable!(),
|
DocumentNodeTypeId => unreachable!(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -1252,7 +1252,7 @@ impl Node {
|
||||||
document.get().content_changed();
|
document.get().content_changed();
|
||||||
}
|
}
|
||||||
DoctypeNodeTypeId |
|
DoctypeNodeTypeId |
|
||||||
DocumentNodeTypeId(_) => {}
|
DocumentNodeTypeId => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1279,7 +1279,7 @@ impl Node {
|
||||||
-> Fallible<JS<Node>> {
|
-> Fallible<JS<Node>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
match parent.type_id() {
|
match parent.type_id() {
|
||||||
DocumentNodeTypeId(..) |
|
DocumentNodeTypeId |
|
||||||
DocumentFragmentNodeTypeId |
|
DocumentFragmentNodeTypeId |
|
||||||
ElementNodeTypeId(..) => (),
|
ElementNodeTypeId(..) => (),
|
||||||
_ => return Err(HierarchyRequest)
|
_ => return Err(HierarchyRequest)
|
||||||
|
@ -1305,12 +1305,12 @@ impl Node {
|
||||||
TextNodeTypeId |
|
TextNodeTypeId |
|
||||||
ProcessingInstructionNodeTypeId |
|
ProcessingInstructionNodeTypeId |
|
||||||
CommentNodeTypeId => (),
|
CommentNodeTypeId => (),
|
||||||
DocumentNodeTypeId(..) => return Err(HierarchyRequest)
|
DocumentNodeTypeId => return Err(HierarchyRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
match parent.type_id() {
|
match parent.type_id() {
|
||||||
DocumentNodeTypeId(..) => {
|
DocumentNodeTypeId => {
|
||||||
match node.type_id() {
|
match node.type_id() {
|
||||||
// Step 6.1
|
// Step 6.1
|
||||||
DocumentFragmentNodeTypeId => {
|
DocumentFragmentNodeTypeId => {
|
||||||
|
@ -1358,7 +1358,7 @@ impl Node {
|
||||||
TextNodeTypeId |
|
TextNodeTypeId |
|
||||||
ProcessingInstructionNodeTypeId |
|
ProcessingInstructionNodeTypeId |
|
||||||
CommentNodeTypeId => (),
|
CommentNodeTypeId => (),
|
||||||
DocumentNodeTypeId(..) => unreachable!()
|
DocumentNodeTypeId => unreachable!()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
|
|
|
@ -21,8 +21,6 @@ interface Document : Node {
|
||||||
readonly attribute DocumentType? doctype;
|
readonly attribute DocumentType? doctype;
|
||||||
readonly attribute Element? documentElement;
|
readonly attribute Element? documentElement;
|
||||||
HTMLCollection getElementsByTagName(DOMString localName);
|
HTMLCollection getElementsByTagName(DOMString localName);
|
||||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
|
||||||
HTMLCollection getElementsByClassName(DOMString classNames);
|
|
||||||
Element? getElementById(DOMString elementId);
|
Element? getElementById(DOMString elementId);
|
||||||
|
|
||||||
[Creator, Throws]
|
[Creator, Throws]
|
||||||
|
@ -47,4 +45,13 @@ partial interface Document {
|
||||||
attribute HTMLElement? body;
|
attribute HTMLElement? body;
|
||||||
readonly attribute HTMLHeadElement? head;
|
readonly attribute HTMLHeadElement? head;
|
||||||
/*NodeList*/ HTMLCollection getElementsByName(DOMString elementName);
|
/*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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
|
||||||
};
|
|
|
@ -81,7 +81,6 @@ pub mod dom {
|
||||||
pub mod htmldirectoryelement;
|
pub mod htmldirectoryelement;
|
||||||
pub mod htmldivelement;
|
pub mod htmldivelement;
|
||||||
pub mod htmldlistelement;
|
pub mod htmldlistelement;
|
||||||
pub mod htmldocument;
|
|
||||||
pub mod htmlelement;
|
pub mod htmlelement;
|
||||||
pub mod htmlembedelement;
|
pub mod htmlembedelement;
|
||||||
pub mod htmlfieldsetelement;
|
pub mod htmlfieldsetelement;
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
//! and layout tasks.
|
//! and layout tasks.
|
||||||
|
|
||||||
use dom::bindings::codegen::RegisterBindings;
|
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::js::JS;
|
||||||
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
|
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
|
||||||
use dom::document::Document;
|
use dom::document::{Document, HTMLDocument};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::htmldocument::HTMLDocument;
|
|
||||||
use dom::node::{Node, NodeHelpers};
|
use dom::node::{Node, NodeHelpers};
|
||||||
use dom::window::{TimerData, TimerHandle, Window};
|
use dom::window::{TimerData, TimerHandle, Window};
|
||||||
use html::hubbub_html_parser::HtmlParserResult;
|
use html::hubbub_html_parser::HtmlParserResult;
|
||||||
|
@ -718,7 +717,7 @@ impl ScriptTask {
|
||||||
// Parse HTML.
|
// Parse HTML.
|
||||||
//
|
//
|
||||||
// Note: We can parse the next document in parallel with any previous documents.
|
// 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,
|
let html_parsing_result = hubbub_html_parser::parse_html(cx.ptr,
|
||||||
&mut document,
|
&mut document,
|
||||||
url.clone(),
|
url.clone(),
|
||||||
|
|
|
@ -6,7 +6,6 @@ is_a(window, Window);
|
||||||
is_a(document.documentElement, HTMLHtmlElement);
|
is_a(document.documentElement, HTMLHtmlElement);
|
||||||
is_a(document.documentElement.firstChild, HTMLHeadElement);
|
is_a(document.documentElement.firstChild, HTMLHeadElement);
|
||||||
is(document.documentElement.nextSibling, null);
|
is(document.documentElement.nextSibling, null);
|
||||||
is_a(document, HTMLDocument);
|
|
||||||
is_a(document, Document);
|
is_a(document, Document);
|
||||||
finish();
|
finish();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
<script>
|
<script>
|
||||||
// test1: HTML document
|
// 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");
|
is(document.contentType, "text/html", "test1-1, HTML document");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test2: XML document
|
// test2: XML document
|
||||||
{
|
{
|
||||||
var doc = new 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");
|
is(doc.contentType, "application/xml", "test2-1, XML document");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
var htmldoc = document.implementation.createHTMLDocument("example title");
|
var htmldoc = document.implementation.createHTMLDocument("example title");
|
||||||
isnot(htmldoc, null, "test3-0, createHTMLDocument");
|
isnot(htmldoc, null, "test3-0, createHTMLDocument");
|
||||||
is_a(htmldoc, Document, "test3-1, createHTMLDocument");
|
is_a(htmldoc, Document, "test3-1, createHTMLDocument");
|
||||||
is_a(htmldoc, HTMLDocument, "test3-2, createHTMLDocument");
|
|
||||||
is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
|
is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
|
||||||
|
|
||||||
is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument");
|
is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument");
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="div1"></div>
|
<div id="div1"></div>
|
||||||
<script>
|
<script>
|
||||||
is_a(document.documentElement.parentNode, HTMLDocument);
|
is_a(document.documentElement.parentNode, Document);
|
||||||
is(document.documentElement.parentElement, null);
|
is(document.documentElement.parentElement, null);
|
||||||
|
|
||||||
var elem = document.createElement("p");
|
var elem = document.createElement("p");
|
||||||
|
|
|
@ -14,7 +14,6 @@ is_a(window.document.documentElement, Element);
|
||||||
is_a(window.document.documentElement, HTMLElement);
|
is_a(window.document.documentElement, HTMLElement);
|
||||||
is_a(window.document.documentElement, HTMLHtmlElement);
|
is_a(window.document.documentElement, HTMLHtmlElement);
|
||||||
is_a(window.document, Document);
|
is_a(window.document, Document);
|
||||||
is_a(window.document, HTMLDocument);
|
|
||||||
is(window.document.documentElement.tagName, "HTML");
|
is(window.document.documentElement.tagName, "HTML");
|
||||||
is_a(window.document.getElementsByTagName('foo-á')[0], HTMLUnknownElement);
|
is_a(window.document.getElementsByTagName('foo-á')[0], HTMLUnknownElement);
|
||||||
is(window.document.getElementsByTagName('foo-á')[0].tagName, "FOO-á");
|
is(window.document.getElementsByTagName('foo-á')[0].tagName, "FOO-á");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue