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; |
} |