diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index dccd8a2e9a8..fdf0530bdee 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -110,7 +110,7 @@ pub enum DocumentType { } pub struct Document { - root: Option>, + priv root: Option>, reflector_: Reflector, window: Option<@mut Window>, doctype: DocumentType, @@ -337,7 +337,7 @@ impl Document { fail!("no SVG document yet") }, _ => { - match self.root { + match self.GetDocumentElement() { None => {}, Some(root) => { for node in root.traverse_preorder() { @@ -353,7 +353,7 @@ impl Document { } } break; - }; + } } } } @@ -371,7 +371,7 @@ impl Document { }, _ => { let (_scope, cx) = self.get_scope_and_cx(); - match self.root { + match self.GetDocumentElement() { None => {}, Some(root) => { for node in root.traverse_preorder() { @@ -401,7 +401,7 @@ impl Document { node.add_child(new_title); } break; - }; + } } } } @@ -499,7 +499,7 @@ impl Document { pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection { let mut elements = ~[]; - match self.root { + match self.GetDocumentElement() { None => {}, Some(root) => { for child in root.traverse_preorder() { @@ -510,7 +510,7 @@ impl Document { } } } - }; + } } } let (scope, cx) = self.get_scope_and_cx(); diff --git a/src/components/script/dom/htmldocument.rs b/src/components/script/dom/htmldocument.rs index c455bd41c7e..32abdd29ed9 100644 --- a/src/components/script/dom/htmldocument.rs +++ b/src/components/script/dom/htmldocument.rs @@ -61,18 +61,11 @@ impl HTMLDocument { } pub fn GetHead(&self) -> Option> { - match self.parent.root { + match self.parent.GetDocumentElement() { None => None, - Some(root) => { - let mut headNode: Option> = None; - let _ = for child in root.traverse_preorder() { - if child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) { - headNode = Some(child); - break; - } - }; - headNode - } + Some(root) => root.traverse_preorder().find(|child| { + child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) + }) } } diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 2812b4c538d..ac0d1e72d35 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -418,7 +418,7 @@ impl<'self, View> AbstractNode { pub fn is_in_doc(&self) -> bool { do self.with_base |node| { do node.owner_doc.with_base |document| { - match document.root { + match document.GetDocumentElement() { None => false, Some(root) => { let mut node = *self; diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index c29a2d3c599..ca3a04910bc 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -217,7 +217,9 @@ impl<'self> Iterator<@mut Page> for PageTreeIterator<'self> { impl Page { /// Adds the given damage. fn damage(&mut self, level: DocumentDamageLevel) { - let root = do self.frame.get_ref().document.with_base |doc| { doc.root }; + let root = do self.frame.get_ref().document.with_base |doc| { + doc.GetDocumentElement() + }; match root { None => {}, Some(root) => { @@ -279,7 +281,7 @@ impl Page { None => fail!(~"Tried to relayout with no root frame!"), Some(ref frame) => { do frame.document.with_base |doc| { - doc.root + doc.GetDocumentElement() } } }; @@ -829,7 +831,7 @@ impl ScriptTask { debug!("ClickEvent: clicked at %?", point); let root = do page.frame.expect("root frame is None").document.with_base |doc| { - doc.root + doc.GetDocumentElement() }; if root.is_none() { return;