Implement :root pseudo-class. Fix #1263, fix #1265

This commit is contained in:
Daniel Glazman 2013-11-15 14:52:52 +01:00 committed by Simon Sapin
parent 45c0d0e17d
commit 9b691611ff
10 changed files with 123 additions and 20 deletions

View file

@ -242,8 +242,11 @@ impl<View> TreeNodeRef<Node<View>> for AbstractNode<View> {
}
}
fn is_root(&self) -> bool {
self.parent_node().is_none()
fn is_document(&self) -> bool {
match self.type_id() {
DocumentNodeTypeId(*) => true,
_ => false
}
}
}
@ -327,11 +330,6 @@ impl<'self, View> AbstractNode<View> {
self.node().next_sibling
}
/// Is this node a root?
pub fn is_root(self) -> bool {
self.parent_node().is_none()
}
//
// Downcasting borrows
//
@ -434,13 +432,6 @@ impl<'self, View> AbstractNode<View> {
self.transmute_mut(f)
}
pub fn is_document(self) -> bool {
match self.type_id() {
DocumentNodeTypeId(*) => true,
_ => false
}
}
// FIXME: This should be doing dynamic borrow checking for safety.
pub fn with_imm_element<R>(self, f: &fn(&Element) -> R) -> R {
if !self.is_element() {