OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/LayoutTreeBuilderTraversal.h" | 5 #include "core/dom/LayoutTreeBuilderTraversal.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/dom/Node.h" | 9 #include "core/dom/Node.h" |
10 #include "core/dom/NodeComputedStyle.h" | 10 #include "core/dom/NodeComputedStyle.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*inner)); | 129 LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*inner)); |
130 EXPECT_EQ(inner->layoutObject(), | 130 EXPECT_EQ(inner->layoutObject(), |
131 LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*sibling)); | 131 LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*sibling)); |
132 | 132 |
133 EXPECT_EQ(last->layoutObject(), | 133 EXPECT_EQ(last->layoutObject(), |
134 LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*sibling)); | 134 LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*sibling)); |
135 EXPECT_EQ(sibling->layoutObject(), | 135 EXPECT_EQ(sibling->layoutObject(), |
136 LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*last)); | 136 LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*last)); |
137 } | 137 } |
138 | 138 |
| 139 TEST_F(LayoutTreeBuilderTraversalTest, limits) { |
| 140 const char* const html = |
| 141 "<div></div>" |
| 142 "<div style='display: contents'></div>" |
| 143 "<div style='display: contents'>" |
| 144 "<div style='display: contents'>" |
| 145 "</div>" |
| 146 "</div>" |
| 147 "<div id='shouldNotBeFound'></div>"; |
| 148 |
| 149 setupSampleHTML(html); |
| 150 |
| 151 Element* first = document().querySelector("div"); |
| 152 |
| 153 EXPECT_TRUE(first->layoutObject()); |
| 154 LayoutObject* nextSibling = |
| 155 LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*first, 2); |
| 156 EXPECT_FALSE(nextSibling); // Should not overrecurse |
| 157 } |
| 158 |
139 } // namespace blink | 159 } // namespace blink |
OLD | NEW |