auto merge of #1051 : Ms2ger/servo/private-root, r=jdm

In preparation for removing it as part of making Document a Node.
This commit is contained in:
bors-servo 2013-10-14 10:22:00 -07:00
commit 8d3c7a2ded
4 changed files with 17 additions and 22 deletions

View file

@ -110,7 +110,7 @@ pub enum DocumentType {
} }
pub struct Document { pub struct Document {
root: Option<AbstractNode<ScriptView>>, priv root: Option<AbstractNode<ScriptView>>,
reflector_: Reflector, reflector_: Reflector,
window: Option<@mut Window>, window: Option<@mut Window>,
doctype: DocumentType, doctype: DocumentType,
@ -337,7 +337,7 @@ impl Document {
fail!("no SVG document yet") fail!("no SVG document yet")
}, },
_ => { _ => {
match self.root { match self.GetDocumentElement() {
None => {}, None => {},
Some(root) => { Some(root) => {
for node in root.traverse_preorder() { for node in root.traverse_preorder() {
@ -353,7 +353,7 @@ impl Document {
} }
} }
break; break;
}; }
} }
} }
} }
@ -371,7 +371,7 @@ impl Document {
}, },
_ => { _ => {
let (_scope, cx) = self.get_scope_and_cx(); let (_scope, cx) = self.get_scope_and_cx();
match self.root { match self.GetDocumentElement() {
None => {}, None => {},
Some(root) => { Some(root) => {
for node in root.traverse_preorder() { for node in root.traverse_preorder() {
@ -401,7 +401,7 @@ impl Document {
node.add_child(new_title); node.add_child(new_title);
} }
break; break;
}; }
} }
} }
} }
@ -499,7 +499,7 @@ impl Document {
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection { pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
let mut elements = ~[]; let mut elements = ~[];
match self.root { match self.GetDocumentElement() {
None => {}, None => {},
Some(root) => { Some(root) => {
for child in root.traverse_preorder() { for child in root.traverse_preorder() {
@ -510,7 +510,7 @@ impl Document {
} }
} }
} }
}; }
} }
} }
let (scope, cx) = self.get_scope_and_cx(); let (scope, cx) = self.get_scope_and_cx();

View file

@ -61,18 +61,11 @@ impl HTMLDocument {
} }
pub fn GetHead(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetHead(&self) -> Option<AbstractNode<ScriptView>> {
match self.parent.root { match self.parent.GetDocumentElement() {
None => None, None => None,
Some(root) => { Some(root) => root.traverse_preorder().find(|child| {
let mut headNode: Option<AbstractNode<ScriptView>> = None; child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
let _ = for child in root.traverse_preorder() { })
if child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId) {
headNode = Some(child);
break;
}
};
headNode
}
} }
} }

View file

@ -418,7 +418,7 @@ impl<'self, View> AbstractNode<View> {
pub fn is_in_doc(&self) -> bool { pub fn is_in_doc(&self) -> bool {
do self.with_base |node| { do self.with_base |node| {
do node.owner_doc.with_base |document| { do node.owner_doc.with_base |document| {
match document.root { match document.GetDocumentElement() {
None => false, None => false,
Some(root) => { Some(root) => {
let mut node = *self; let mut node = *self;

View file

@ -217,7 +217,9 @@ impl<'self> Iterator<@mut Page> for PageTreeIterator<'self> {
impl Page { impl Page {
/// Adds the given damage. /// Adds the given damage.
fn damage(&mut self, level: DocumentDamageLevel) { 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 { match root {
None => {}, None => {},
Some(root) => { Some(root) => {
@ -279,7 +281,7 @@ impl Page {
None => fail!(~"Tried to relayout with no root frame!"), None => fail!(~"Tried to relayout with no root frame!"),
Some(ref frame) => { Some(ref frame) => {
do frame.document.with_base |doc| { do frame.document.with_base |doc| {
doc.root doc.GetDocumentElement()
} }
} }
}; };
@ -829,7 +831,7 @@ impl ScriptTask {
debug!("ClickEvent: clicked at %?", point); debug!("ClickEvent: clicked at %?", point);
let root = do page.frame.expect("root frame is None").document.with_base |doc| { let root = do page.frame.expect("root frame is None").document.with_base |doc| {
doc.root doc.GetDocumentElement()
}; };
if root.is_none() { if root.is_none() {
return; return;