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

Side by Side Diff: third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp

Issue 2379483002: Use the sibling limit to decide whether to create layout for whitespace (Closed)
Patch Set: Bring patch to head. Created 4 years, 2 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
OLDNEW
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return nextNode; 207 return nextNode;
208 return nextAncestorSibling(node, stayWithin); 208 return nextAncestorSibling(node, stayWithin);
209 } 209 }
210 210
211 Node* next(const Node& node, const Node* stayWithin) { 211 Node* next(const Node& node, const Node* stayWithin) {
212 if (Node* child = pseudoAwareFirstChild(node)) 212 if (Node* child = pseudoAwareFirstChild(node))
213 return child; 213 return child;
214 return nextSkippingChildren(node, stayWithin); 214 return nextSkippingChildren(node, stayWithin);
215 } 215 }
216 216
217 LayoutObject* nextSiblingLayoutObject(const Node& node) { 217 LayoutObject* nextSiblingLayoutObject(const Node& node, int32_t limit) {
218 for (Node* sibling = LayoutTreeBuilderTraversal::nextSibling(node); sibling; 218 DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
219 for (Node* sibling = LayoutTreeBuilderTraversal::nextSibling(node);
220 sibling && limit-- != 0;
219 sibling = LayoutTreeBuilderTraversal::nextSibling(*sibling)) { 221 sibling = LayoutTreeBuilderTraversal::nextSibling(*sibling)) {
220 LayoutObject* layoutObject = sibling->layoutObject(); 222 LayoutObject* layoutObject = sibling->layoutObject();
221 if (layoutObject && !isLayoutObjectReparented(layoutObject)) 223 if (layoutObject && !isLayoutObjectReparented(layoutObject))
222 return layoutObject; 224 return layoutObject;
223 } 225 }
224 return 0; 226 return 0;
225 } 227 }
226 228
227 LayoutObject* previousSiblingLayoutObject(const Node& node) { 229 LayoutObject* previousSiblingLayoutObject(const Node& node, int32_t limit) {
230 DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
228 for (Node* sibling = LayoutTreeBuilderTraversal::previousSibling(node); 231 for (Node* sibling = LayoutTreeBuilderTraversal::previousSibling(node);
229 sibling; 232 sibling && limit-- != 0;
230 sibling = LayoutTreeBuilderTraversal::previousSibling(*sibling)) { 233 sibling = LayoutTreeBuilderTraversal::previousSibling(*sibling)) {
231 LayoutObject* layoutObject = sibling->layoutObject(); 234 LayoutObject* layoutObject = sibling->layoutObject();
232 if (layoutObject && !isLayoutObjectReparented(layoutObject)) 235 if (layoutObject && !isLayoutObjectReparented(layoutObject))
233 return layoutObject; 236 return layoutObject;
234 } 237 }
235 return 0; 238 return 0;
236 } 239 }
237 240
238 LayoutObject* nextInTopLayer(const Element& element) { 241 LayoutObject* nextInTopLayer(const Element& element) {
239 if (!element.isInTopLayer()) 242 if (!element.isInTopLayer())
240 return 0; 243 return 0;
241 const HeapVector<Member<Element>>& topLayerElements = 244 const HeapVector<Member<Element>>& topLayerElements =
242 element.document().topLayerElements(); 245 element.document().topLayerElements();
243 size_t position = topLayerElements.find(&element); 246 size_t position = topLayerElements.find(&element);
244 DCHECK_NE(position, kNotFound); 247 DCHECK_NE(position, kNotFound);
245 for (size_t i = position + 1; i < topLayerElements.size(); ++i) { 248 for (size_t i = position + 1; i < topLayerElements.size(); ++i) {
246 if (LayoutObject* layoutObject = topLayerElements[i]->layoutObject()) 249 if (LayoutObject* layoutObject = topLayerElements[i]->layoutObject())
247 return layoutObject; 250 return layoutObject;
248 } 251 }
249 return 0; 252 return 0;
250 } 253 }
251 254
252 } // namespace LayoutTreeBuilderTraversal 255 } // namespace LayoutTreeBuilderTraversal
253 256
254 } // namespace blink 257 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698