Chromium Code Reviews| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 descendant = child; | 103 descendant = child; |
| 104 return descendant; | 104 return descendant; |
| 105 } | 105 } |
| 106 | 106 |
| 107 Node* NodeTraversal::previous(const Node& current, const Node* stayWithin) | 107 Node* NodeTraversal::previous(const Node& current, const Node* stayWithin) |
| 108 { | 108 { |
| 109 if (current == stayWithin) | 109 if (current == stayWithin) |
| 110 return 0; | 110 return 0; |
| 111 if (current.previousSibling()) { | 111 if (current.previousSibling()) { |
| 112 Node* previous = current.previousSibling(); | 112 Node* previous = current.previousSibling(); |
| 113 while (previous->lastChild()) | 113 while (previous->lastChild()) |
|
esprehn
2014/06/02 19:03:37
This is silly, don't call it twice.
while (Node*
Inactive
2014/06/02 20:46:25
Done.
| |
| 114 previous = previous->lastChild(); | 114 previous = toContainerNode(previous)->lastChild(); |
| 115 return previous; | 115 return previous; |
| 116 } | 116 } |
| 117 return current.parentNode(); | 117 return current.parentNode(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 Node* NodeTraversal::previousSkippingChildren(const Node& current, const Node* s tayWithin) | 120 Node* NodeTraversal::previousSkippingChildren(const Node& current, const Node* s tayWithin) |
| 121 { | 121 { |
| 122 if (current == stayWithin) | 122 if (current == stayWithin) |
| 123 return 0; | 123 return 0; |
| 124 if (current.previousSibling()) | 124 if (current.previousSibling()) |
| 125 return current.previousSibling(); | 125 return current.previousSibling(); |
| 126 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { | 126 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { |
| 127 if (parent == stayWithin) | 127 if (parent == stayWithin) |
| 128 return 0; | 128 return 0; |
| 129 if (parent->previousSibling()) | 129 if (parent->previousSibling()) |
| 130 return parent->previousSibling(); | 130 return parent->previousSibling(); |
| 131 } | 131 } |
| 132 return 0; | 132 return 0; |
| 133 } | 133 } |
| 134 | 134 |
| 135 Node* NodeTraversal::nextPostOrder(const Node& current, const Node* stayWithin) | 135 Node* NodeTraversal::nextPostOrder(const Node& current, const Node* stayWithin) |
| 136 { | 136 { |
| 137 if (current == stayWithin) | 137 if (current == stayWithin) |
| 138 return 0; | 138 return 0; |
| 139 if (!current.nextSibling()) | 139 if (!current.nextSibling()) |
| 140 return current.parentNode(); | 140 return current.parentNode(); |
| 141 Node* next = current.nextSibling(); | 141 Node* next = current.nextSibling(); |
| 142 while (next->firstChild()) | 142 while (next->firstChild()) |
| 143 next = next->firstChild(); | 143 next = toContainerNode(next)->firstChild(); |
|
esprehn
2014/06/02 19:03:37
dito.
Inactive
2014/06/02 20:46:25
Done.
| |
| 144 return next; | 144 return next; |
| 145 } | 145 } |
| 146 | 146 |
| 147 static Node* previousAncestorSiblingPostOrder(const Node& current, const Node* s tayWithin) | 147 static Node* previousAncestorSiblingPostOrder(const Node& current, const Node* s tayWithin) |
| 148 { | 148 { |
| 149 ASSERT(!current.previousSibling()); | 149 ASSERT(!current.previousSibling()); |
| 150 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { | 150 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { |
| 151 if (parent == stayWithin) | 151 if (parent == stayWithin) |
| 152 return 0; | 152 return 0; |
| 153 if (parent->previousSibling()) | 153 if (parent->previousSibling()) |
| 154 return parent->previousSibling(); | 154 return parent->previousSibling(); |
| 155 } | 155 } |
| 156 return 0; | 156 return 0; |
| 157 } | 157 } |
| 158 | 158 |
| 159 Node* NodeTraversal::previousPostOrder(const Node& current, const Node* stayWith in) | 159 Node* NodeTraversal::previousPostOrder(const Node& current, const Node* stayWith in) |
| 160 { | 160 { |
| 161 if (current.lastChild()) | 161 if (Node* lastChild = current.lastChild()) |
| 162 return current.lastChild(); | 162 return lastChild; |
| 163 if (current == stayWithin) | 163 if (current == stayWithin) |
| 164 return 0; | 164 return 0; |
| 165 if (current.previousSibling()) | 165 if (current.previousSibling()) |
| 166 return current.previousSibling(); | 166 return current.previousSibling(); |
| 167 return previousAncestorSiblingPostOrder(current, stayWithin); | 167 return previousAncestorSiblingPostOrder(current, stayWithin); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace WebCore | 170 } // namespace WebCore |
| OLD | NEW |