aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/htmldocument.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2013-10-05 21:42:13 +0200
committerMs2ger <ms2ger@gmail.com>2013-10-05 21:42:13 +0200
commitc93d13b0da1bc423ccff2520da01a558c6b3d8ec (patch)
treed6cf411690678dca884f4f9330479b53c29c46e1 /src/components/script/dom/htmldocument.rs
parentf13438d012363eef5d65cb32ffe2d1aab28ec07f (diff)
downloadservo-c93d13b0da1bc423ccff2520da01a558c6b3d8ec.tar.gz
servo-c93d13b0da1bc423ccff2520da01a558c6b3d8ec.zip
Don't require passing a root element to Document::new (needed for issue #888).
Diffstat (limited to 'src/components/script/dom/htmldocument.rs')
-rw-r--r--src/components/script/dom/htmldocument.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/components/script/dom/htmldocument.rs b/src/components/script/dom/htmldocument.rs
index 6e70ad236a5..c96785bdc99 100644
--- a/src/components/script/dom/htmldocument.rs
+++ b/src/components/script/dom/htmldocument.rs
@@ -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);
}
-} \ No newline at end of file
+}