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. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
6 * All rights reserved. | 6 * All rights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
8 * (http://www.torchmobile.com/) | 8 * (http://www.torchmobile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (current == stayWithin) | 145 if (current == stayWithin) |
146 return 0; | 146 return 0; |
147 if (!current.nextSibling()) | 147 if (!current.nextSibling()) |
148 return current.parentNode(); | 148 return current.parentNode(); |
149 Node* next = current.nextSibling(); | 149 Node* next = current.nextSibling(); |
150 while (Node* child = next->firstChild()) | 150 while (Node* child = next->firstChild()) |
151 next = child; | 151 next = child; |
152 return next; | 152 return next; |
153 } | 153 } |
154 | 154 |
155 static Node* previousAncestorSiblingPostOrder(const Node& current, | 155 Node* NodeTraversal::previousAncestorSiblingPostOrder(const Node& current, |
156 const Node* stayWithin) { | 156 const Node* stayWithin) { |
157 DCHECK(!current.previousSibling()); | 157 DCHECK(!current.previousSibling()); |
158 for (Node& parent : NodeTraversal::ancestorsOf(current)) { | 158 for (Node& parent : NodeTraversal::ancestorsOf(current)) { |
159 if (parent == stayWithin) | 159 if (parent == stayWithin) |
160 return 0; | 160 return 0; |
161 if (parent.previousSibling()) | 161 if (parent.previousSibling()) |
162 return parent.previousSibling(); | 162 return parent.previousSibling(); |
163 } | 163 } |
164 return 0; | 164 return 0; |
165 } | 165 } |
166 | 166 |
167 Node* NodeTraversal::previousPostOrder(const Node& current, | 167 Node* NodeTraversal::previousPostOrder(const Node& current, |
168 const Node* stayWithin) { | 168 const Node* stayWithin) { |
169 if (Node* lastChild = current.lastChild()) | 169 if (Node* lastChild = current.lastChild()) |
170 return lastChild; | 170 return lastChild; |
171 if (current == stayWithin) | 171 if (current == stayWithin) |
172 return 0; | 172 return 0; |
173 if (current.previousSibling()) | 173 if (current.previousSibling()) |
174 return current.previousSibling(); | 174 return current.previousSibling(); |
175 return previousAncestorSiblingPostOrder(current, stayWithin); | 175 return previousAncestorSiblingPostOrder(current, stayWithin); |
176 } | 176 } |
177 | 177 |
178 Node* NodeTraversal::commonAncestor(const Node& nodeA, const Node& nodeB) { | 178 Node* NodeTraversal::commonAncestor(const Node& nodeA, const Node& nodeB) { |
179 return Range::commonAncestorContainer(&nodeA, &nodeB); | 179 return Range::commonAncestorContainer(&nodeA, &nodeB); |
180 } | 180 } |
181 | 181 |
182 } // namespace blink | 182 } // namespace blink |
OLD | NEW |