Simplify LayoutDocument::root_node.

This commit is contained in:
Ms2ger 2015-10-29 16:54:20 +01:00
parent ee0b0c81d1
commit 1eb8900f48

View file

@ -369,11 +369,7 @@ impl<'le> LayoutDocument<'le> {
} }
pub fn root_node(&self) -> Option<LayoutNode<'le>> { pub fn root_node(&self) -> Option<LayoutNode<'le>> {
let mut node = self.as_node().first_child(); self.as_node().children().find(LayoutNode::is_element)
while node.is_some() && !node.unwrap().is_element() {
node = node.unwrap().next_sibling();
}
node
} }
pub fn drain_event_state_changes(&self) -> Vec<(LayoutElement, EventState)> { pub fn drain_event_state_changes(&self) -> Vec<(LayoutElement, EventState)> {