diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-11-02 18:04:03 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-11-02 21:28:06 +0100 |
commit | 68f3daa7ef9936ee57e12cf48c2dedf051fd3791 (patch) | |
tree | 354c04328db335165334be84eeaeb027082969e3 | |
parent | cb68fbd68e1baa1248a76cedafad076468747c6d (diff) | |
download | servo-68f3daa7ef9936ee57e12cf48c2dedf051fd3791.tar.gz servo-68f3daa7ef9936ee57e12cf48c2dedf051fd3791.zip |
Simplify the implementation of NodeIterator::next_child.
-rw-r--r-- | components/script/dom/node.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 28899bbd404..af1afccc3b1 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1050,15 +1050,13 @@ impl NodeIterator { } fn next_child<'b>(&self, node: JSRef<'b, Node>) -> Option<JSRef<'b, Node>> { - if !self.include_descendants_of_void && node.is_element() { - let elem: JSRef<Element> = ElementCast::to_ref(node).unwrap(); - if elem.is_void() { - None - } else { - node.first_child().map(|child| (*child.root()).clone()) - } - } else { - node.first_child().map(|child| (*child.root()).clone()) + let skip = |element: JSRef<Element>| { + !self.include_descendants_of_void && element.is_void() + }; + + match ElementCast::to_ref(node) { + Some(element) if skip(element) => None, + _ => node.first_child().map(|child| (*child.root()).clone()), } } } |