| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 // Composed tree version of |NodeTraversal::previousSkippingChildren()| | 78 // Composed tree version of |NodeTraversal::previousSkippingChildren()| |
| 79 // similar to |previous()| but skipping child nodes of the specified node. | 79 // similar to |previous()| but skipping child nodes of the specified node. |
| 80 static Node* previousSkippingChildren(const Node&); | 80 static Node* previousSkippingChildren(const Node&); |
| 81 | 81 |
| 82 // Composed tree version of |Node::isDescendantOf(other)|. This function | 82 // Composed tree version of |Node::isDescendantOf(other)|. This function |
| 83 // returns true if |other| contains |node|, otherwise returns | 83 // returns true if |other| contains |node|, otherwise returns |
| 84 // false. If |other| is |node|, this function returns false. | 84 // false. If |other| is |node|, this function returns false. |
| 85 static bool isDescendantOf(const Node& /*node*/, const Node& other); | 85 static bool isDescendantOf(const Node& /*node*/, const Node& other); |
| 86 | 86 |
| 87 static bool contains(const ContainerNode& container, const Node& node) |
| 88 { |
| 89 assertPrecondition(container); |
| 90 assertPrecondition(node); |
| 91 return container == node || isDescendantOf(node, container); |
| 92 } |
| 93 |
| 87 // Returns a common ancestor of |nodeA| and |nodeB| if exists, otherwise | 94 // Returns a common ancestor of |nodeA| and |nodeB| if exists, otherwise |
| 88 // returns |nullptr|. | 95 // returns |nullptr|. |
| 89 static Node* commonAncestor(const Node& nodeA, const Node& nodeB); | 96 static Node* commonAncestor(const Node& nodeA, const Node& nodeB); |
| 90 | 97 |
| 91 // Composed tree version of |Node::nodeIndex()|. This function returns a | 98 // Composed tree version of |Node::nodeIndex()|. This function returns a |
| 92 // zero base position number of the specified node in child nodes list, or | 99 // zero base position number of the specified node in child nodes list, or |
| 93 // zero if the specified node has no parent. | 100 // zero if the specified node has no parent. |
| 94 static unsigned index(const Node&); | 101 static unsigned index(const Node&); |
| 95 | 102 |
| 96 // Composed tree version of |ContainerNode::countChildren()|. This function | 103 // Composed tree version of |ContainerNode::countChildren()|. This function |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 298 } |
| 292 | 299 |
| 293 inline Node* ComposedTreeTraversal::traverseLastChild(const Node& node) | 300 inline Node* ComposedTreeTraversal::traverseLastChild(const Node& node) |
| 294 { | 301 { |
| 295 return traverseChild(node, TraversalDirectionBackward); | 302 return traverseChild(node, TraversalDirectionBackward); |
| 296 } | 303 } |
| 297 | 304 |
| 298 } // namespace | 305 } // namespace |
| 299 | 306 |
| 300 #endif | 307 #endif |
| OLD | NEW |