OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layout/LayoutObject.h" | 5 #include "core/layout/LayoutObject.h" |
6 | 6 |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 " <span><img style='width: 20px; height: 100px'></span>" | 117 " <span><img style='width: 20px; height: 100px'></span>" |
118 " text text text text text text text" | 118 " text text text text text text text" |
119 "</div>"); | 119 "</div>"); |
120 | 120 |
121 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container
")); | 121 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container
")); |
122 LayoutText* text = toLayoutText(container->lastChild()); | 122 LayoutText* text = toLayoutText(container->lastChild()); |
123 | 123 |
124 container->setScrollTop(LayoutUnit(50)); | 124 container->setScrollTop(LayoutUnit(50)); |
125 LayoutRect rect(0, 60, 20, 80); | 125 LayoutRect rect(0, 60, 20, 80); |
126 EXPECT_TRUE(text->mapToVisibleRectInAncestorSpace(container, rect)); | 126 EXPECT_TRUE(text->mapToVisibleRectInAncestorSpace(container, rect)); |
127 EXPECT_EQ(rect, LayoutRect(0, 10, 20, 80)); | 127 EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40)); |
128 | 128 |
129 rect = LayoutRect(0, 60, 80, 0); | 129 rect = LayoutRect(0, 60, 80, 0); |
130 EXPECT_TRUE(text->mapToVisibleRectInAncestorSpace(container, rect, EdgeInclu
sive)); | 130 EXPECT_TRUE(text->mapToVisibleRectInAncestorSpace(container, rect, EdgeInclu
sive)); |
131 EXPECT_EQ(rect, LayoutRect(0, 10, 80, 0)); | 131 EXPECT_EQ(rect, LayoutRect(0, 10, 50, 0)); |
132 } | 132 } |
133 | 133 |
134 TEST_F(LayoutObjectTest, LayoutInlineMapToVisibleRectInAncestorSpace) | 134 TEST_F(LayoutObjectTest, LayoutInlineMapToVisibleRectInAncestorSpace) |
135 { | 135 { |
136 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | 136 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
137 setBodyInnerHTML( | 137 setBodyInnerHTML( |
138 "<style>body { margin: 0; }</style>" | 138 "<style>body { margin: 0; }</style>" |
139 "<div id='container' style='overflow: scroll; width: 50px; height: 50px'
>" | 139 "<div id='container' style='overflow: scroll; width: 50px; height: 50px'
>" |
140 " <span><img style='width: 20px; height: 100px'></span>" | 140 " <span><img style='width: 20px; height: 100px'></span>" |
141 " <span id=leaf></span></div>"); | 141 " <span id=leaf></span></div>"); |
142 | 142 |
143 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container
")); | 143 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container
")); |
144 LayoutObject* leaf = container->lastChild(); | 144 LayoutObject* leaf = container->lastChild(); |
145 | 145 |
146 container->setScrollTop(LayoutUnit(50)); | 146 container->setScrollTop(LayoutUnit(50)); |
147 LayoutRect rect(0, 60, 20, 80); | 147 LayoutRect rect(0, 60, 20, 80); |
148 EXPECT_TRUE(leaf->mapToVisibleRectInAncestorSpace(container, rect)); | 148 EXPECT_TRUE(leaf->mapToVisibleRectInAncestorSpace(container, rect)); |
149 EXPECT_EQ(rect, LayoutRect(0, 10, 20, 80)); | 149 EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40)); |
150 | 150 |
151 rect = LayoutRect(0, 60, 80, 0); | 151 rect = LayoutRect(0, 60, 80, 0); |
152 EXPECT_TRUE(leaf->mapToVisibleRectInAncestorSpace(container, rect, EdgeInclu
sive)); | 152 EXPECT_TRUE(leaf->mapToVisibleRectInAncestorSpace(container, rect, EdgeInclu
sive)); |
153 EXPECT_EQ(rect, LayoutRect(0, 10, 80, 0)); | 153 EXPECT_EQ(rect, LayoutRect(0, 10, 50, 0)); |
154 } | 154 } |
155 | 155 |
156 TEST_F(LayoutObjectTest, LayoutViewMapToVisibleRectInAncestorSpace) | 156 TEST_F(LayoutObjectTest, LayoutViewMapToVisibleRectInAncestorSpace) |
157 { | 157 { |
158 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | 158 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
159 setBodyInnerHTML( | 159 setBodyInnerHTML( |
160 "<style>body { margin: 0; }</style>" | 160 "<style>body { margin: 0; }</style>" |
161 "<div id=frameContainer>" | 161 "<div id=frameContainer>" |
162 " <iframe id=frame src='http://test.com' width='50' height='50' frameBo
rder='0'></iframe>" | 162 " <iframe id=frame src='http://test.com' width='50' height='50' frameBo
rder='0'></iframe>" |
163 "</div>"); | 163 "</div>"); |
(...skipping 11 matching lines...) Expand all Loading... |
175 LayoutRect rect(4, 60, 20, 80); | 175 LayoutRect rect(4, 60, 20, 80); |
176 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect)
); | 176 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect)
); |
177 EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37)); | 177 EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37)); |
178 | 178 |
179 rect = LayoutRect(4, 60, 0, 80); | 179 rect = LayoutRect(4, 60, 0, 80); |
180 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect,
EdgeInclusive)); | 180 EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect,
EdgeInclusive)); |
181 EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37)); | 181 EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37)); |
182 } | 182 } |
183 | 183 |
184 } // namespace blink | 184 } // namespace blink |
OLD | NEW |