From a9a5e9078712ff93064ff87adb2a593b04981ff9 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 23 Jul 2013 13:51:53 -0700 Subject: [PATCH] Move is_root() into AbstractNode --- src/components/main/layout/box_builder.rs | 8 +------- src/components/script/dom/node.rs | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/main/layout/box_builder.rs b/src/components/main/layout/box_builder.rs index ff9457f69d4..fd5dfd5bbc1 100644 --- a/src/components/main/layout/box_builder.rs +++ b/src/components/main/layout/box_builder.rs @@ -356,14 +356,8 @@ impl LayoutTreeBuilder { sibling_generator: Option<@mut BoxGenerator>) -> Option<(@mut BoxGenerator, @mut BoxGenerator)> { - fn is_root(node: AbstractNode) -> bool { - match node.parent_node() { - None => true, - Some(_) => false - } - } 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' // TODO(eatkinson) these are hacks so that the code doesn't crash // when unsupported display values are used. They should be deleted diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 8757f08d5d3..edd108e6881 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -264,6 +264,11 @@ impl<'self, View> AbstractNode { 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 //