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

Unified Diff: third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp

Issue 2719713002: Simplify whitespace layout object creation.
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp
diff --git a/third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp b/third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp
index a9a0a1965dee92ade95f1b764876bf2e9a11a4b6..048e58567be297b494319a8a537471e206c3a632 100644
--- a/third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp
+++ b/third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp
@@ -250,7 +250,7 @@ static LayoutObject* nextSiblingLayoutObjectInternal(Node* node,
pseudoAwareFirstChild(*sibling), limit);
if (layoutObject)
return layoutObject;
- if (!limit)
+ if (limit == -1)
return nullptr;
}
@@ -270,7 +270,7 @@ LayoutObject* LayoutTreeBuilderTraversal::nextSiblingLayoutObject(
return sibling;
Node* parent = LayoutTreeBuilderTraversal::parent(node);
- while (limit && parent && hasDisplayContentsStyle(*parent)) {
+ while (limit != -1 && parent && hasDisplayContentsStyle(*parent)) {
if (LayoutObject* sibling =
nextSiblingLayoutObjectInternal(nextSibling(*parent), limit))
return sibling;
@@ -296,7 +296,7 @@ static LayoutObject* previousSiblingLayoutObjectInternal(Node* node,
pseudoAwareLastChild(*sibling), limit);
if (layoutObject)
return layoutObject;
- if (!limit)
+ if (limit == -1)
return nullptr;
}
@@ -309,20 +309,31 @@ static LayoutObject* previousSiblingLayoutObjectInternal(Node* node,
LayoutObject* LayoutTreeBuilderTraversal::previousSiblingLayoutObject(
const Node& node,
- int32_t limit) {
+ int32_t limit,
+ bool* ranOutOfSiblings) {
DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
+ DCHECK(!ranOutOfSiblings || limit >= 0) << limit;
+ if (ranOutOfSiblings)
+ *ranOutOfSiblings = false;
+
if (LayoutObject* sibling =
- previousSiblingLayoutObjectInternal(previousSibling(node), limit))
+ previousSiblingLayoutObjectInternal(previousSibling(node), limit)) {
return sibling;
+ }
Node* parent = LayoutTreeBuilderTraversal::parent(node);
- while (limit && parent && hasDisplayContentsStyle(*parent)) {
+ while (limit != -1 && parent && hasDisplayContentsStyle(*parent)) {
if (LayoutObject* sibling = previousSiblingLayoutObjectInternal(
previousSibling(*parent), limit))
return sibling;
parent = LayoutTreeBuilderTraversal::parent(*parent);
}
+ if (ranOutOfSiblings) {
+ DCHECK_GE(limit, -1);
+ *ranOutOfSiblings = limit == -1;
+ }
+
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698