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

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

Issue 68523014: Update remaining NodeTraversal / ElementTraversal methods to take references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix build Created 7 years, 1 month 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
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/dom/Text.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 24 matching lines...) Expand all
35 if (current == stayWithin) 35 if (current == stayWithin)
36 return 0; 36 return 0;
37 if (Node* previous = current.pseudoAwarePreviousSibling()) { 37 if (Node* previous = current.pseudoAwarePreviousSibling()) {
38 while (previous->pseudoAwareLastChild()) 38 while (previous->pseudoAwareLastChild())
39 previous = previous->pseudoAwareLastChild(); 39 previous = previous->pseudoAwareLastChild();
40 return previous; 40 return previous;
41 } 41 }
42 return current.parentNode(); 42 return current.parentNode();
43 } 43 }
44 44
45 Node* nextIncludingPseudo(const Node* current, const Node* stayWithin) 45 Node* nextIncludingPseudo(const Node& current, const Node* stayWithin)
46 { 46 {
47 if (Node* next = current->pseudoAwareFirstChild()) 47 if (Node* next = current.pseudoAwareFirstChild())
48 return next; 48 return next;
49 if (current == stayWithin) 49 if (current == stayWithin)
50 return 0; 50 return 0;
51 if (Node* next = current->pseudoAwareNextSibling()) 51 if (Node* next = current.pseudoAwareNextSibling())
52 return next; 52 return next;
53 for (current = current->parentNode(); current; current = current->parentNode ()) { 53 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) {
54 if (current == stayWithin) 54 if (parent == stayWithin)
55 return 0; 55 return 0;
56 if (Node* next = current->pseudoAwareNextSibling()) 56 if (Node* next = parent->pseudoAwareNextSibling())
57 return next; 57 return next;
58 } 58 }
59 return 0; 59 return 0;
60 } 60 }
61 61
62 Node* nextIncludingPseudoSkippingChildren(const Node* current, const Node* stayW ithin) 62 Node* nextIncludingPseudoSkippingChildren(const Node& current, const Node* stayW ithin)
63 { 63 {
64 if (current == stayWithin) 64 if (current == stayWithin)
65 return 0; 65 return 0;
66 if (Node* next = current->pseudoAwareNextSibling()) 66 if (Node* next = current.pseudoAwareNextSibling())
67 return next; 67 return next;
68 for (current = current->parentNode(); current; current = current->parentNode ()) { 68 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) {
69 if (current == stayWithin) 69 if (parent == stayWithin)
70 return 0; 70 return 0;
71 if (Node* next = current->pseudoAwareNextSibling()) 71 if (Node* next = parent->pseudoAwareNextSibling())
72 return next; 72 return next;
73 } 73 }
74 return 0; 74 return 0;
75 } 75 }
76 76
77 Node* nextAncestorSibling(const Node& current) 77 Node* nextAncestorSibling(const Node& current)
78 { 78 {
79 ASSERT(!current.nextSibling()); 79 ASSERT(!current.nextSibling());
80 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { 80 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) {
81 if (parent->nextSibling()) 81 if (parent->nextSibling())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return current.previousSibling(); 118 return current.previousSibling();
119 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { 119 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) {
120 if (parent == stayWithin) 120 if (parent == stayWithin)
121 return 0; 121 return 0;
122 if (parent->previousSibling()) 122 if (parent->previousSibling())
123 return parent->previousSibling(); 123 return parent->previousSibling();
124 } 124 }
125 return 0; 125 return 0;
126 } 126 }
127 127
128 Node* nextPostOrder(const Node* current, const Node* stayWithin) 128 Node* nextPostOrder(const Node& current, const Node* stayWithin)
129 { 129 {
130 if (current == stayWithin) 130 if (current == stayWithin)
131 return 0; 131 return 0;
132 if (!current->nextSibling()) 132 if (!current.nextSibling())
133 return current->parentNode(); 133 return current.parentNode();
134 Node* next = current->nextSibling(); 134 Node* next = current.nextSibling();
135 while (next->firstChild()) 135 while (next->firstChild())
136 next = next->firstChild(); 136 next = next->firstChild();
137 return next; 137 return next;
138 } 138 }
139 139
140 static Node* previousAncestorSiblingPostOrder(const Node& current, const Node* s tayWithin) 140 static Node* previousAncestorSiblingPostOrder(const Node& current, const Node* s tayWithin)
141 { 141 {
142 ASSERT(!current.previousSibling()); 142 ASSERT(!current.previousSibling());
143 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) { 143 for (Node* parent = current.parentNode(); parent; parent = parent->parentNod e()) {
144 if (parent == stayWithin) 144 if (parent == stayWithin)
(...skipping 19 matching lines...) Expand all
164 { 164 {
165 if (current == stayWithin) 165 if (current == stayWithin)
166 return 0; 166 return 0;
167 if (current.previousSibling()) 167 if (current.previousSibling())
168 return current.previousSibling(); 168 return current.previousSibling();
169 return previousAncestorSiblingPostOrder(current, stayWithin); 169 return previousAncestorSiblingPostOrder(current, stayWithin);
170 } 170 }
171 171
172 } 172 }
173 } 173 }
OLDNEW
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/dom/Text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698