| 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 a502a25952b6965290486d37a9b59ef866ced8bc..1fbcd95490067677982190a038e87e00e395861a 100644
|
| --- a/third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/LayoutTreeBuilderTraversal.cpp
|
| @@ -234,45 +234,32 @@ Node* LayoutTreeBuilderTraversal::next(const Node& node,
|
| return nextSkippingChildren(node, stayWithin);
|
| }
|
|
|
| -static LayoutObject* nextSiblingLayoutObjectInternal(Node* node,
|
| - int32_t& limit) {
|
| +static Node* nextLayoutSiblingInternal(Node* node, int32_t& limit) {
|
| for (Node* sibling = node; sibling && limit-- != 0;
|
| sibling = LayoutTreeBuilderTraversal::nextSibling(*sibling)) {
|
| - LayoutObject* layoutObject = sibling->layoutObject();
|
| + if (!hasDisplayContentsStyle(*sibling))
|
| + return sibling;
|
|
|
| -#if DCHECK_IS_ON()
|
| - if (hasDisplayContentsStyle(*sibling))
|
| - DCHECK(!layoutObject);
|
| -#endif
|
| -
|
| - if (!layoutObject && hasDisplayContentsStyle(*sibling)) {
|
| - layoutObject = nextSiblingLayoutObjectInternal(
|
| - pseudoAwareFirstChild(*sibling), limit);
|
| - if (layoutObject)
|
| - return layoutObject;
|
| - if (limit == -1)
|
| - return nullptr;
|
| - }
|
| + if (Node* inner =
|
| + nextLayoutSiblingInternal(pseudoAwareFirstChild(*sibling), limit))
|
| + return inner;
|
|
|
| - if (layoutObject && !isLayoutObjectReparented(layoutObject))
|
| - return layoutObject;
|
| + if (limit == -1)
|
| + return nullptr;
|
| }
|
|
|
| return nullptr;
|
| }
|
|
|
| -LayoutObject* LayoutTreeBuilderTraversal::nextSiblingLayoutObject(
|
| - const Node& node,
|
| - int32_t limit) {
|
| - DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
|
| - if (LayoutObject* sibling =
|
| - nextSiblingLayoutObjectInternal(nextSibling(node), limit))
|
| +Node* LayoutTreeBuilderTraversal::nextLayoutSibling(const Node& node,
|
| + int32_t& limit) {
|
| + DCHECK_NE(limit, -1);
|
| + if (Node* sibling = nextLayoutSiblingInternal(nextSibling(node), limit))
|
| return sibling;
|
|
|
| Node* parent = LayoutTreeBuilderTraversal::parent(node);
|
| while (limit != -1 && parent && hasDisplayContentsStyle(*parent)) {
|
| - if (LayoutObject* sibling =
|
| - nextSiblingLayoutObjectInternal(nextSibling(*parent), limit))
|
| + if (Node* sibling = nextLayoutSiblingInternal(nextSibling(*parent), limit))
|
| return sibling;
|
| parent = LayoutTreeBuilderTraversal::parent(*parent);
|
| }
|
| @@ -280,45 +267,34 @@ LayoutObject* LayoutTreeBuilderTraversal::nextSiblingLayoutObject(
|
| return nullptr;
|
| }
|
|
|
| -static LayoutObject* previousSiblingLayoutObjectInternal(Node* node,
|
| - int32_t& limit) {
|
| +static Node* previousLayoutSiblingInternal(Node* node, int32_t& limit) {
|
| for (Node* sibling = node; sibling && limit-- != 0;
|
| sibling = LayoutTreeBuilderTraversal::previousSibling(*sibling)) {
|
| - LayoutObject* layoutObject = sibling->layoutObject();
|
| + if (!hasDisplayContentsStyle(*sibling))
|
| + return sibling;
|
|
|
| -#if DCHECK_IS_ON()
|
| - if (hasDisplayContentsStyle(*sibling))
|
| - DCHECK(!layoutObject);
|
| -#endif
|
| -
|
| - if (!layoutObject && hasDisplayContentsStyle(*sibling)) {
|
| - layoutObject = previousSiblingLayoutObjectInternal(
|
| - pseudoAwareLastChild(*sibling), limit);
|
| - if (layoutObject)
|
| - return layoutObject;
|
| - if (limit == -1)
|
| - return nullptr;
|
| - }
|
| + if (Node* inner = previousLayoutSiblingInternal(
|
| + pseudoAwareLastChild(*sibling), limit))
|
| + return inner;
|
|
|
| - if (layoutObject && !isLayoutObjectReparented(layoutObject))
|
| - return layoutObject;
|
| + if (limit == -1)
|
| + return nullptr;
|
| }
|
|
|
| return nullptr;
|
| }
|
|
|
| -LayoutObject* LayoutTreeBuilderTraversal::previousSiblingLayoutObject(
|
| - const Node& node,
|
| - int32_t limit) {
|
| - DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
|
| - if (LayoutObject* sibling =
|
| - previousSiblingLayoutObjectInternal(previousSibling(node), limit))
|
| +Node* LayoutTreeBuilderTraversal::previousLayoutSibling(const Node& node,
|
| + int32_t& limit) {
|
| + DCHECK_NE(limit, -1);
|
| + if (Node* sibling =
|
| + previousLayoutSiblingInternal(previousSibling(node), limit))
|
| return sibling;
|
|
|
| Node* parent = LayoutTreeBuilderTraversal::parent(node);
|
| while (limit != -1 && parent && hasDisplayContentsStyle(*parent)) {
|
| - if (LayoutObject* sibling = previousSiblingLayoutObjectInternal(
|
| - previousSibling(*parent), limit))
|
| + if (Node* sibling =
|
| + previousLayoutSiblingInternal(previousSibling(*parent), limit))
|
| return sibling;
|
| parent = LayoutTreeBuilderTraversal::parent(*parent);
|
| }
|
| @@ -326,6 +302,33 @@ LayoutObject* LayoutTreeBuilderTraversal::previousSiblingLayoutObject(
|
| return nullptr;
|
| }
|
|
|
| +LayoutObject* LayoutTreeBuilderTraversal::nextSiblingLayoutObject(
|
| + const Node& node,
|
| + int32_t limit) {
|
| + DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
|
| + for (Node* sibling = nextLayoutSibling(node, limit); sibling && limit != -1;
|
| + sibling = nextLayoutSibling(*sibling, limit)) {
|
| + LayoutObject* layoutObject = sibling->layoutObject();
|
| + if (layoutObject && !isLayoutObjectReparented(layoutObject))
|
| + return layoutObject;
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| +LayoutObject* LayoutTreeBuilderTraversal::previousSiblingLayoutObject(
|
| + const Node& node,
|
| + int32_t limit) {
|
| + DCHECK(limit == kTraverseAllSiblings || limit >= 0) << limit;
|
| + for (Node* sibling = previousLayoutSibling(node, limit);
|
| + sibling && limit != -1;
|
| + sibling = previousLayoutSibling(*sibling, limit)) {
|
| + LayoutObject* layoutObject = sibling->layoutObject();
|
| + if (layoutObject && !isLayoutObjectReparented(layoutObject))
|
| + return layoutObject;
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| LayoutObject* LayoutTreeBuilderTraversal::nextInTopLayer(
|
| const Element& element) {
|
| if (!element.isInTopLayer())
|
|
|