Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 | 234 |
| 235 unsigned ComposedTreeTraversal::countChildren(const Node& node) | 235 unsigned ComposedTreeTraversal::countChildren(const Node& node) |
| 236 { | 236 { |
| 237 assertPrecondition(node); | 237 assertPrecondition(node); |
| 238 unsigned count = 0; | 238 unsigned count = 0; |
| 239 for (Node* runner = traverseFirstChild(node); runner; runner = traverseNextS ibling(*runner)) | 239 for (Node* runner = traverseFirstChild(node); runner; runner = traverseNextS ibling(*runner)) |
| 240 ++count; | 240 ++count; |
| 241 return count; | 241 return count; |
| 242 } | 242 } |
| 243 | 243 |
| 244 Node* ComposedTreeTraversal::lastWithin(const Node& current) | |
| 245 { | |
|
hayato
2015/03/26 03:28:27
Could you insert assertions like other public func
hajimehoshi
2015/03/26 03:43:26
Done.
| |
| 246 Node* descendant = lastChild(current); | |
| 247 for (Node* child = descendant; child; child = lastChild(*child)) | |
| 248 descendant = child; | |
| 249 return descendant; | |
| 250 } | |
| 251 | |
| 252 Node& ComposedTreeTraversal::lastWithinOrSelf(Node& current) | |
| 253 { | |
| 254 Node* lastDescendant = ComposedTreeTraversal::lastWithin(current); | |
| 255 return lastDescendant ? *lastDescendant : current; | |
| 256 } | |
| 257 | |
| 244 } // namespace | 258 } // namespace |
| OLD | NEW |