| 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 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 Node* NodeTraversal::lastWithin(const ContainerNode& current) | 99 Node* NodeTraversal::lastWithin(const ContainerNode& current) |
| 100 { | 100 { |
| 101 Node* descendant = current.lastChild(); | 101 Node* descendant = current.lastChild(); |
| 102 for (Node* child = descendant; child; child = child->lastChild()) | 102 for (Node* child = descendant; child; child = child->lastChild()) |
| 103 descendant = child; | 103 descendant = child; |
| 104 return descendant; | 104 return descendant; |
| 105 } | 105 } |
| 106 | 106 |
| 107 Node& NodeTraversal::lastWithinOrSelf(Node& current) |
| 108 { |
| 109 Node* lastDescendant = current.isContainerNode() ? NodeTraversal::lastWithin
(toContainerNode(current)) : 0; |
| 110 return lastDescendant ? *lastDescendant : current; |
| 111 } |
| 112 |
| 107 Node* NodeTraversal::previous(const Node& current, const Node* stayWithin) | 113 Node* NodeTraversal::previous(const Node& current, const Node* stayWithin) |
| 108 { | 114 { |
| 109 if (current == stayWithin) | 115 if (current == stayWithin) |
| 110 return 0; | 116 return 0; |
| 111 if (current.previousSibling()) { | 117 if (current.previousSibling()) { |
| 112 Node* previous = current.previousSibling(); | 118 Node* previous = current.previousSibling(); |
| 113 while (Node* child = previous->lastChild()) | 119 while (Node* child = previous->lastChild()) |
| 114 previous = child; | 120 previous = child; |
| 115 return previous; | 121 return previous; |
| 116 } | 122 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (Node* lastChild = current.lastChild()) | 167 if (Node* lastChild = current.lastChild()) |
| 162 return lastChild; | 168 return lastChild; |
| 163 if (current == stayWithin) | 169 if (current == stayWithin) |
| 164 return 0; | 170 return 0; |
| 165 if (current.previousSibling()) | 171 if (current.previousSibling()) |
| 166 return current.previousSibling(); | 172 return current.previousSibling(); |
| 167 return previousAncestorSiblingPostOrder(current, stayWithin); | 173 return previousAncestorSiblingPostOrder(current, stayWithin); |
| 168 } | 174 } |
| 169 | 175 |
| 170 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |