mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +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
|
@ -24,9 +24,9 @@ pub struct HTMLDocument {
|
|||
}
|
||||
|
||||
impl HTMLDocument {
|
||||
pub fn new(root: AbstractNode<ScriptView>, window: Option<@mut Window>) -> AbstractDocument {
|
||||
pub fn new(window: Option<@mut Window>) -> AbstractDocument {
|
||||
let doc = @mut HTMLDocument {
|
||||
parent: Document::new(root, window, HTML)
|
||||
parent: Document::new(window, HTML)
|
||||
};
|
||||
|
||||
let compartment = window.get_ref().page.js_info.get_ref().js_compartment;
|
||||
|
@ -70,14 +70,19 @@ impl HTMLDocument {
|
|||
}
|
||||
|
||||
pub fn GetHead(&self) -> Option<AbstractNode<ScriptView>> {
|
||||
let mut headNode: Option<AbstractNode<ScriptView>> = None;
|
||||
let _ = for child in self.parent.root.traverse_preorder() {
|
||||
if child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) {
|
||||
headNode = Some(child);
|
||||
break;
|
||||
match self.parent.root {
|
||||
None => None,
|
||||
Some(root) => {
|
||||
let mut headNode: Option<AbstractNode<ScriptView>> = None;
|
||||
let _ = for child in root.traverse_preorder() {
|
||||
if child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) {
|
||||
headNode = Some(child);
|
||||
break;
|
||||
}
|
||||
};
|
||||
headNode
|
||||
}
|
||||
};
|
||||
headNode
|
||||
}
|
||||
}
|
||||
|
||||
pub fn Images(&self) -> @mut HTMLCollection {
|
||||
|
@ -216,4 +221,4 @@ impl Traceable for HTMLDocument {
|
|||
fn trace(&self, tracer: *mut JSTracer) {
|
||||
self.parent.trace(tracer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue