mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Make Document a Node.
This commit is contained in:
parent
cc76a2188e
commit
99a36cbeb6
10 changed files with 96 additions and 120 deletions
|
@ -5,12 +5,9 @@
|
|||
use dom::bindings::codegen::DOMParserBinding;
|
||||
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
||||
use dom::bindings::utils::{DOMString, Fallible, Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::bindings::utils::FailureUnknown;
|
||||
use dom::document::{AbstractDocument, Document, XML};
|
||||
use dom::element::HTMLHtmlElementTypeId;
|
||||
use dom::htmldocument::HTMLDocument;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::htmlhtmlelement::HTMLHtmlElement;
|
||||
use dom::node::Node;
|
||||
use dom::window::Window;
|
||||
|
||||
use js::jsapi::{JSContext, JSObject};
|
||||
|
@ -42,25 +39,17 @@ impl DOMParser {
|
|||
ty: DOMParserBinding::SupportedType)
|
||||
-> Fallible<AbstractDocument> {
|
||||
let cx = self.owner.get_cx();
|
||||
let document = match ty {
|
||||
match ty {
|
||||
Text_html => {
|
||||
HTMLDocument::new(self.owner)
|
||||
Ok(HTMLDocument::new(self.owner))
|
||||
}
|
||||
Text_xml => {
|
||||
AbstractDocument::as_abstract(cx, @mut Document::new(self.owner, XML))
|
||||
Ok(AbstractDocument::as_abstract(cx, @mut Document::new(self.owner, XML)))
|
||||
}
|
||||
_ => {
|
||||
fail!("unsupported document type")
|
||||
Err(FailureUnknown)
|
||||
}
|
||||
};
|
||||
|
||||
let root = @HTMLHtmlElement {
|
||||
htmlelement: HTMLElement::new(HTMLHtmlElementTypeId, ~"html", document)
|
||||
};
|
||||
let root = unsafe { Node::as_abstract_node(cx, root) };
|
||||
document.set_root(root);
|
||||
|
||||
Ok(document)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue