mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Don't require passing a root element to Document::new (needed for issue #888).
This commit is contained in:
parent
f13438d012
commit
c93d13b0da
4 changed files with 183 additions and 127 deletions
|
@ -41,26 +41,26 @@ impl DOMParser {
|
|||
_s: &DOMString,
|
||||
ty: DOMParserBinding::SupportedType)
|
||||
-> Fallible<AbstractDocument> {
|
||||
unsafe {
|
||||
let root = @HTMLHtmlElement {
|
||||
htmlelement: HTMLElement::new(HTMLHtmlElementTypeId, ~"html")
|
||||
};
|
||||
|
||||
let root = Node::as_abstract_node((*self.owner.page).js_info.get_ref().js_compartment.cx.ptr, root);
|
||||
let cx = (*self.owner.page).js_info.get_ref().js_compartment.cx.ptr;
|
||||
|
||||
match ty {
|
||||
Text_html => {
|
||||
Ok(HTMLDocument::new(root, None))
|
||||
}
|
||||
Text_xml => {
|
||||
Ok(AbstractDocument::as_abstract(cx, @mut Document::new(root, None, XML)))
|
||||
}
|
||||
_ => {
|
||||
fail!("unsupported document type")
|
||||
}
|
||||
let cx = (*self.owner.page).js_info.get_ref().js_compartment.cx.ptr;
|
||||
let mut document = match ty {
|
||||
Text_html => {
|
||||
HTMLDocument::new(None)
|
||||
}
|
||||
}
|
||||
Text_xml => {
|
||||
AbstractDocument::as_abstract(cx, @mut Document::new(None, XML))
|
||||
}
|
||||
_ => {
|
||||
fail!("unsupported document type")
|
||||
}
|
||||
};
|
||||
|
||||
let root = @HTMLHtmlElement {
|
||||
htmlelement: HTMLElement::new(HTMLHtmlElementTypeId, ~"html")
|
||||
};
|
||||
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