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

Side by Side Diff: Source/core/rendering/RenderListItem.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/rendering/RenderCounter.cpp ('k') | Source/core/rendering/RenderObject.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 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 return firstNode; 119 return firstNode;
120 } 120 }
121 121
122 // Returns the next list item with respect to the DOM order. 122 // Returns the next list item with respect to the DOM order.
123 static RenderListItem* nextListItem(const Node* listNode, const RenderListItem* item = 0) 123 static RenderListItem* nextListItem(const Node* listNode, const RenderListItem* item = 0)
124 { 124 {
125 if (!listNode) 125 if (!listNode)
126 return 0; 126 return 0;
127 127
128 const Node* current = item ? item->node() : listNode; 128 const Node* current = item ? item->node() : listNode;
129 current = ElementTraversal::nextIncludingPseudo(current, listNode); 129 ASSERT(current);
130 current = ElementTraversal::nextIncludingPseudo(*current, listNode);
130 131
131 while (current) { 132 while (current) {
132 if (isList(current)) { 133 if (isList(current)) {
133 // We've found a nested, independent list: nothing to do here. 134 // We've found a nested, independent list: nothing to do here.
134 current = ElementTraversal::nextIncludingPseudoSkippingChildren(curr ent, listNode); 135 current = ElementTraversal::nextIncludingPseudoSkippingChildren(*cur rent, listNode);
135 continue; 136 continue;
136 } 137 }
137 138
138 RenderObject* renderer = current->renderer(); 139 RenderObject* renderer = current->renderer();
139 if (renderer && renderer->isListItem()) 140 if (renderer && renderer->isListItem())
140 return toRenderListItem(renderer); 141 return toRenderListItem(renderer);
141 142
142 // FIXME: Can this be optimized to skip the children of the elements wit hout a renderer? 143 // FIXME: Can this be optimized to skip the children of the elements wit hout a renderer?
143 current = ElementTraversal::nextIncludingPseudo(current, listNode); 144 current = ElementTraversal::nextIncludingPseudo(*current, listNode);
144 } 145 }
145 146
146 return 0; 147 return 0;
147 } 148 }
148 149
149 // Returns the previous list item with respect to the DOM order. 150 // Returns the previous list item with respect to the DOM order.
150 static RenderListItem* previousListItem(const Node* listNode, const RenderListIt em* item) 151 static RenderListItem* previousListItem(const Node* listNode, const RenderListIt em* item)
151 { 152 {
152 Node* current = item->node(); 153 Node* current = item->node();
153 ASSERT(current); 154 ASSERT(current);
154 for (current = ElementTraversal::previousIncludingPseudo(*current, listNode) ; current; current = ElementTraversal::previousIncludingPseudo(*current, listNod e)) { 155 for (current = ElementTraversal::previousIncludingPseudo(*current, listNode) ; current; current = ElementTraversal::previousIncludingPseudo(*current, listNod e)) {
155 RenderObject* renderer = current->renderer(); 156 RenderObject* renderer = current->renderer();
156 if (!renderer || (renderer && !renderer->isListItem())) 157 if (!renderer || (renderer && !renderer->isListItem()))
157 continue; 158 continue;
158 Node* otherList = enclosingList(toRenderListItem(renderer)); 159 Node* otherList = enclosingList(toRenderListItem(renderer));
159 // This item is part of our current list, so it's what we're looking for . 160 // This item is part of our current list, so it's what we're looking for .
160 if (listNode == otherList) 161 if (listNode == otherList)
161 return toRenderListItem(renderer); 162 return toRenderListItem(renderer);
162 // We found ourself inside another list; lets skip the rest of it. 163 // We found ourself inside another list; lets skip the rest of it.
163 // Use nextIncludingPseudo() here because the other list itself may actu ally 164 // Use nextIncludingPseudo() here because the other list itself may actu ally
164 // be a list item itself. We need to examine it, so we do this to counte ract 165 // be a list item itself. We need to examine it, so we do this to counte ract
165 // the previousIncludingPseudo() that will be done by the loop. 166 // the previousIncludingPseudo() that will be done by the loop.
166 if (otherList) 167 if (otherList)
167 current = ElementTraversal::nextIncludingPseudo(otherList); 168 current = ElementTraversal::nextIncludingPseudo(*otherList);
168 } 169 }
169 return 0; 170 return 0;
170 } 171 }
171 172
172 void RenderListItem::updateItemValuesForOrderedList(const HTMLOListElement* list Node) 173 void RenderListItem::updateItemValuesForOrderedList(const HTMLOListElement* list Node)
173 { 174 {
174 ASSERT(listNode); 175 ASSERT(listNode);
175 176
176 for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, listItem)) 177 for (RenderListItem* listItem = nextListItem(listNode); listItem; listItem = nextListItem(listNode, listItem))
177 listItem->updateValue(); 178 listItem->updateValue();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // assume that all the following ones have too. 517 // assume that all the following ones have too.
517 // This gives us the opportunity to stop here and avoid 518 // This gives us the opportunity to stop here and avoid
518 // marking the same nodes again. 519 // marking the same nodes again.
519 break; 520 break;
520 } 521 }
521 item->updateValue(); 522 item->updateValue();
522 } 523 }
523 } 524 }
524 525
525 } // namespace WebCore 526 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderCounter.cpp ('k') | Source/core/rendering/RenderObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698