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 {
root: Option<AbstractNode<ScriptView>>,
priv root: Option<AbstractNode<ScriptView>>,
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();

View file

@ -61,18 +61,11 @@ impl HTMLDocument {
}
pub fn GetHead(&self) -> Option<AbstractNode<ScriptView>> {
match self.parent.root {
match self.parent.GetDocumentElement() {
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
}
Some(root) => root.traverse_preorder().find(|child| {
child.type_id() == ElementNodeTypeId(HTMLHeadElementTypeId)
})
}
}

View file

@ -418,7 +418,7 @@ impl<'self, View> AbstractNode<View> {
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;

View file

@ -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;