OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * All rights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 8 * (http://www.torchmobile.com/) |
7 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 9 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
8 * | 10 * |
9 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
13 * | 15 * |
14 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 30 matching lines...) Expand all Loading... |
47 class TraversalInclusiveDescendantIterator; | 49 class TraversalInclusiveDescendantIterator; |
48 template <class TraversalNext> | 50 template <class TraversalNext> |
49 class TraversalNextIterator; | 51 class TraversalNextIterator; |
50 | 52 |
51 class NodeTraversal { | 53 class NodeTraversal { |
52 STATIC_ONLY(NodeTraversal); | 54 STATIC_ONLY(NodeTraversal); |
53 | 55 |
54 public: | 56 public: |
55 using TraversalNodeType = Node; | 57 using TraversalNodeType = Node; |
56 | 58 |
57 // Does a pre-order traversal of the tree to find the next node after this one
. | 59 // Does a pre-order traversal of the tree to find the next node after this |
58 // This uses the same order that tags appear in the source file. If the stayWi
thin | 60 // one. This uses the same order that tags appear in the source file. If the |
59 // argument is non-null, the traversal will stop once the specified node is re
ached. | 61 // stayWithin argument is non-null, the traversal will stop once the specified |
60 // This can be used to restrict traversal to a particular sub-tree. | 62 // node is reached. This can be used to restrict traversal to a particular |
| 63 // sub-tree. |
61 static Node* next(const Node& current) { | 64 static Node* next(const Node& current) { |
62 return traverseNextTemplate(current); | 65 return traverseNextTemplate(current); |
63 } | 66 } |
64 static Node* next(const ContainerNode& current) { | 67 static Node* next(const ContainerNode& current) { |
65 return traverseNextTemplate(current); | 68 return traverseNextTemplate(current); |
66 } | 69 } |
67 static Node* next(const Node& current, const Node* stayWithin) { | 70 static Node* next(const Node& current, const Node* stayWithin) { |
68 return traverseNextTemplate(current, stayWithin); | 71 return traverseNextTemplate(current, stayWithin); |
69 } | 72 } |
70 static Node* next(const ContainerNode& current, const Node* stayWithin) { | 73 static Node* next(const ContainerNode& current, const Node* stayWithin) { |
71 return traverseNextTemplate(current, stayWithin); | 74 return traverseNextTemplate(current, stayWithin); |
72 } | 75 } |
73 | 76 |
74 // Like next, but skips children and starts with the next sibling. | 77 // Like next, but skips children and starts with the next sibling. |
75 static Node* nextSkippingChildren(const Node&); | 78 static Node* nextSkippingChildren(const Node&); |
76 static Node* nextSkippingChildren(const Node&, const Node* stayWithin); | 79 static Node* nextSkippingChildren(const Node&, const Node* stayWithin); |
77 | 80 |
78 static Node* firstWithin(const Node& current) { return current.firstChild(); } | 81 static Node* firstWithin(const Node& current) { return current.firstChild(); } |
79 | 82 |
80 static Node* lastWithin(const ContainerNode&); | 83 static Node* lastWithin(const ContainerNode&); |
81 static Node& lastWithinOrSelf(Node&); | 84 static Node& lastWithinOrSelf(Node&); |
82 | 85 |
83 // Does a reverse pre-order traversal to find the node that comes before the c
urrent one in document order | 86 // Does a reverse pre-order traversal to find the node that comes before the |
| 87 // current one in document order |
84 static Node* previous(const Node&, const Node* stayWithin = 0); | 88 static Node* previous(const Node&, const Node* stayWithin = 0); |
85 | 89 |
86 // Like previous, but skips children and starts with the next sibling. | 90 // Like previous, but skips children and starts with the next sibling. |
87 static Node* previousSkippingChildren(const Node&, | 91 static Node* previousSkippingChildren(const Node&, |
88 const Node* stayWithin = 0); | 92 const Node* stayWithin = 0); |
89 | 93 |
90 // Like next, but visits parents after their children. | 94 // Like next, but visits parents after their children. |
91 static Node* nextPostOrder(const Node&, const Node* stayWithin = 0); | 95 static Node* nextPostOrder(const Node&, const Node* stayWithin = 0); |
92 | 96 |
93 // Like previous, but visits parents before their children. | 97 // Like previous, but visits parents before their children. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 inline Node* NodeTraversal::childAtTemplate(NodeType& parent, unsigned index) { | 392 inline Node* NodeTraversal::childAtTemplate(NodeType& parent, unsigned index) { |
389 Node* child = parent.firstChild(); | 393 Node* child = parent.firstChild(); |
390 while (child && index--) | 394 while (child && index--) |
391 child = child->nextSibling(); | 395 child = child->nextSibling(); |
392 return child; | 396 return child; |
393 } | 397 } |
394 | 398 |
395 } // namespace blink | 399 } // namespace blink |
396 | 400 |
397 #endif | 401 #endif |
OLD | NEW |