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

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

Issue 229213002: Make HTMLCollection / NodeList backward traversal consistent with forward one (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ASSERT(current != stayWithin); 89 ASSERT(current != stayWithin);
90 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { 90 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) {
91 if (parent == stayWithin) 91 if (parent == stayWithin)
92 return 0; 92 return 0;
93 if (parent->nextSibling()) 93 if (parent->nextSibling())
94 return parent->nextSibling(); 94 return parent->nextSibling();
95 } 95 }
96 return 0; 96 return 0;
97 } 97 }
98 98
99 Node* NodeTraversal::lastWithin(const ContainerNode& current)
100 {
101 Node* descendant = current.lastChild();
102 for (Node* child = descendant; child; child = child->lastChild())
103 descendant = child;
104 return descendant;
105 }
106
99 Node* NodeTraversal::previous(const Node& current, const Node* stayWithin) 107 Node* NodeTraversal::previous(const Node& current, const Node* stayWithin)
100 { 108 {
101 if (current == stayWithin) 109 if (current == stayWithin)
102 return 0; 110 return 0;
103 if (current.previousSibling()) { 111 if (current.previousSibling()) {
104 Node* previous = current.previousSibling(); 112 Node* previous = current.previousSibling();
105 while (previous->lastChild()) 113 while (previous->lastChild())
106 previous = previous->lastChild(); 114 previous = previous->lastChild();
107 return previous; 115 return previous;
108 } 116 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (current.lastChild()) 161 if (current.lastChild())
154 return current.lastChild(); 162 return current.lastChild();
155 if (current == stayWithin) 163 if (current == stayWithin)
156 return 0; 164 return 0;
157 if (current.previousSibling()) 165 if (current.previousSibling())
158 return current.previousSibling(); 166 return current.previousSibling();
159 return previousAncestorSiblingPostOrder(current, stayWithin); 167 return previousAncestorSiblingPostOrder(current, stayWithin);
160 } 168 }
161 169
162 } // namespace WebCore 170 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698