Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: Source/core/dom/NodeTraversal.cpp

Issue 420323002: Move Node::lastDescendantOrSelf() to NodeTraversal and rename to lastWithinOrSelf() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/editing/DeleteSelectionCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/editing/DeleteSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698