| 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.
All rights reserved. |
| 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 7 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 7 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Does a pre-order traversal of the tree to find the next node after this o
ne. | 35 // Does a pre-order traversal of the tree to find the next node after this o
ne. |
| 36 // This uses the same order that tags appear in the source file. If the stay
Within | 36 // This uses the same order that tags appear in the source file. If the stay
Within |
| 37 // argument is non-null, the traversal will stop once the specified node is
reached. | 37 // argument is non-null, the traversal will stop once the specified node is
reached. |
| 38 // This can be used to restrict traversal to a particular sub-tree. | 38 // This can be used to restrict traversal to a particular sub-tree. |
| 39 static Node* next(const Node& current) { return traverseNextTemplate(current
); } | 39 static Node* next(const Node& current) { return traverseNextTemplate(current
); } |
| 40 static Node* next(const ContainerNode& current) { return traverseNextTemplat
e(current); } | 40 static Node* next(const ContainerNode& current) { return traverseNextTemplat
e(current); } |
| 41 static Node* next(const Node& current, const Node* stayWithin) { return trav
erseNextTemplate(current, stayWithin); } | 41 static Node* next(const Node& current, const Node* stayWithin) { return trav
erseNextTemplate(current, stayWithin); } |
| 42 static Node* next(const ContainerNode& current, const Node* stayWithin) { re
turn traverseNextTemplate(current, stayWithin); } | 42 static Node* next(const ContainerNode& current, const Node* stayWithin) { re
turn traverseNextTemplate(current, stayWithin); } |
| 43 | 43 |
| 44 // Like next, but skips children and starts with the next sibling. | 44 // Like next, but skips children and starts with the next sibling. |
| 45 static Node* nextSkippingChildren(const Node& current) { return traverseNext
SkippingChildrenTemplate(current); } | 45 static Node* nextSkippingChildren(const Node&); |
| 46 static Node* nextSkippingChildren(const ContainerNode& current) { return tra
verseNextSkippingChildrenTemplate(current); } | 46 static Node* nextSkippingChildren(const Node&, const Node* stayWithin); |
| 47 static Node* nextSkippingChildren(const Node& current, const Node* stayWithi
n) { return traverseNextSkippingChildrenTemplate(current, stayWithin); } | |
| 48 static Node* nextSkippingChildren(const ContainerNode& current, const Node*
stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin);
} | |
| 49 | 47 |
| 50 // Does a reverse pre-order traversal to find the node that comes before the
current one in document order | 48 // Does a reverse pre-order traversal to find the node that comes before the
current one in document order |
| 51 static Node* lastWithin(const ContainerNode&); | 49 static Node* lastWithin(const ContainerNode&); |
| 52 static Node* previous(const Node&, const Node* stayWithin = 0); | 50 static Node* previous(const Node&, const Node* stayWithin = 0); |
| 53 | 51 |
| 54 // Like previous, but skips children and starts with the next sibling. | 52 // Like previous, but skips children and starts with the next sibling. |
| 55 static Node* previousSkippingChildren(const Node&, const Node* stayWithin =
0); | 53 static Node* previousSkippingChildren(const Node&, const Node* stayWithin =
0); |
| 56 | 54 |
| 57 // Like next, but visits parents after their children. | 55 // Like next, but visits parents after their children. |
| 58 static Node* nextPostOrder(const Node&, const Node* stayWithin = 0); | 56 static Node* nextPostOrder(const Node&, const Node* stayWithin = 0); |
| 59 | 57 |
| 60 // Like previous, but visits parents before their children. | 58 // Like previous, but visits parents before their children. |
| 61 static Node* previousPostOrder(const Node&, const Node* stayWithin = 0); | 59 static Node* previousPostOrder(const Node&, const Node* stayWithin = 0); |
| 62 | 60 |
| 63 // Pre-order traversal including the pseudo-elements. | 61 // Pre-order traversal including the pseudo-elements. |
| 64 static Node* previousIncludingPseudo(const Node&, const Node* stayWithin = 0
); | 62 static Node* previousIncludingPseudo(const Node&, const Node* stayWithin = 0
); |
| 65 static Node* nextIncludingPseudo(const Node&, const Node* stayWithin = 0); | 63 static Node* nextIncludingPseudo(const Node&, const Node* stayWithin = 0); |
| 66 static Node* nextIncludingPseudoSkippingChildren(const Node&, const Node* st
ayWithin = 0); | 64 static Node* nextIncludingPseudoSkippingChildren(const Node&, const Node* st
ayWithin = 0); |
| 67 | 65 |
| 68 static Node* nextAncestorSibling(const Node&); | 66 static Node* nextAncestorSibling(const Node&); |
| 69 static Node* nextAncestorSibling(const Node&, const Node* stayWithin); | 67 static Node* nextAncestorSibling(const Node&, const Node* stayWithin); |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 template <class NodeType> | 70 template <class NodeType> |
| 73 static Node* traverseNextTemplate(NodeType&); | 71 static Node* traverseNextTemplate(NodeType&); |
| 74 template <class NodeType> | 72 template <class NodeType> |
| 75 static Node* traverseNextTemplate(NodeType&, const Node* stayWithin); | 73 static Node* traverseNextTemplate(NodeType&, const Node* stayWithin); |
| 76 template <class NodeType> | |
| 77 static Node* traverseNextSkippingChildrenTemplate(NodeType&); | |
| 78 template <class NodeType> | |
| 79 static Node* traverseNextSkippingChildrenTemplate(NodeType&, const Node* sta
yWithin); | |
| 80 }; | 74 }; |
| 81 | 75 |
| 82 template <class NodeType> | 76 template <class NodeType> |
| 83 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current) | 77 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current) |
| 84 { | 78 { |
| 85 if (current.firstChild()) | 79 if (current.firstChild()) |
| 86 return current.firstChild(); | 80 return current.firstChild(); |
| 87 if (current.nextSibling()) | 81 if (current.nextSibling()) |
| 88 return current.nextSibling(); | 82 return current.nextSibling(); |
| 89 return nextAncestorSibling(current); | 83 return nextAncestorSibling(current); |
| 90 } | 84 } |
| 91 | 85 |
| 92 template <class NodeType> | 86 template <class NodeType> |
| 93 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current, const Node*
stayWithin) | 87 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current, const Node*
stayWithin) |
| 94 { | 88 { |
| 95 if (current.firstChild()) | 89 if (current.firstChild()) |
| 96 return current.firstChild(); | 90 return current.firstChild(); |
| 97 if (current == stayWithin) | 91 if (current == stayWithin) |
| 98 return 0; | 92 return 0; |
| 99 if (current.nextSibling()) | 93 if (current.nextSibling()) |
| 100 return current.nextSibling(); | 94 return current.nextSibling(); |
| 101 return nextAncestorSibling(current, stayWithin); | 95 return nextAncestorSibling(current, stayWithin); |
| 102 } | 96 } |
| 103 | 97 |
| 104 template <class NodeType> | 98 inline Node* NodeTraversal::nextSkippingChildren(const Node& current) |
| 105 inline Node* NodeTraversal::traverseNextSkippingChildrenTemplate(NodeType& curre
nt) | |
| 106 { | 99 { |
| 107 if (current.nextSibling()) | 100 if (current.nextSibling()) |
| 108 return current.nextSibling(); | 101 return current.nextSibling(); |
| 109 return nextAncestorSibling(current); | 102 return nextAncestorSibling(current); |
| 110 } | 103 } |
| 111 | 104 |
| 112 template <class NodeType> | 105 inline Node* NodeTraversal::nextSkippingChildren(const Node& current, const Node
* stayWithin) |
| 113 inline Node* NodeTraversal::traverseNextSkippingChildrenTemplate(NodeType& curre
nt, const Node* stayWithin) | |
| 114 { | 106 { |
| 115 if (current == stayWithin) | 107 if (current == stayWithin) |
| 116 return 0; | 108 return 0; |
| 117 if (current.nextSibling()) | 109 if (current.nextSibling()) |
| 118 return current.nextSibling(); | 110 return current.nextSibling(); |
| 119 return nextAncestorSibling(current, stayWithin); | 111 return nextAncestorSibling(current, stayWithin); |
| 120 } | 112 } |
| 121 | 113 |
| 122 } // namespace blink | 114 } // namespace blink |
| 123 | 115 |
| 124 #endif | 116 #endif |
| OLD | NEW |