Move is_root() into AbstractNode

This commit is contained in:
Keegan McAllister 2013-07-23 13:51:53 -07:00
parent ae79f5351d
commit a9a5e90787
2 changed files with 6 additions and 7 deletions

View file

@ -356,14 +356,8 @@ impl LayoutTreeBuilder {
sibling_generator: Option<@mut BoxGenerator>) sibling_generator: Option<@mut BoxGenerator>)
-> Option<(@mut BoxGenerator, @mut BoxGenerator)> { -> Option<(@mut BoxGenerator, @mut BoxGenerator)> {
fn is_root(node: AbstractNode<LayoutView>) -> bool {
match node.parent_node() {
None => true,
Some(_) => false
}
}
let display = if node.is_element() { let display = if node.is_element() {
match node.style().display(is_root(node)) { match node.style().display(node.is_root()) {
CSSDisplayNone => return None, // tree ends here if 'display: none' CSSDisplayNone => return None, // tree ends here if 'display: none'
// TODO(eatkinson) these are hacks so that the code doesn't crash // TODO(eatkinson) these are hacks so that the code doesn't crash
// when unsupported display values are used. They should be deleted // when unsupported display values are used. They should be deleted

View file

@ -264,6 +264,11 @@ impl<'self, View> AbstractNode<View> {
self.with_base(|b| b.next_sibling) self.with_base(|b| b.next_sibling)
} }
/// Is this node a root?
pub fn is_root(self) -> bool {
self.parent_node().is_none()
}
// //
// Downcasting borrows // Downcasting borrows
// //