mirror of
https://github.com/servo/servo.git
synced 2025-06-21 07:38:59 +01:00
Make Document::root private, in preparation for removing it as part of making Document a Node.
This commit is contained in:
parent
fc9fdf30a6
commit
b6b2606c96
4 changed files with 17 additions and 22 deletions
|
@ -104,7 +104,7 @@ pub enum DocumentType {
|
|||
}
|
||||
|
||||
pub struct Document {
|
||||
root: Option<AbstractNode<ScriptView>>,
|
||||
priv root: Option<AbstractNode<ScriptView>>,
|
||||
reflector_: Reflector,
|
||||
window: Option<@mut Window>,
|
||||
doctype: DocumentType,
|
||||
|
@ -322,7 +322,7 @@ impl Document {
|
|||
fail!("no SVG document yet")
|
||||
},
|
||||
_ => {
|
||||
match self.root {
|
||||
match self.GetDocumentElement() {
|
||||
None => {},
|
||||
Some(root) => {
|
||||
for node in root.traverse_preorder() {
|
||||
|
@ -338,7 +338,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +356,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() {
|
||||
|
@ -386,7 +386,7 @@ impl Document {
|
|||
node.add_child(new_title);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +484,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() {
|
||||
|
@ -495,7 +495,7 @@ impl Document {
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
let (scope, cx) = self.get_scope_and_cx();
|
||||
|
|
|
@ -62,18 +62,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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -417,7 +417,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue