Chromium Code Reviews| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 rect = targetOverflowRect; | 240 rect = targetOverflowRect; |
| 241 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 241 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| 242 EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect); | 242 EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect); |
| 243 rect = targetOverflowRect; | 243 rect = targetOverflowRect; |
| 244 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 244 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 245 EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect); | 245 EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect); |
| 246 | 246 |
| 247 LayoutRect containerOverflowRect = container->localOverflowRectForPaintInval idation(); | 247 LayoutRect containerOverflowRect = container->localOverflowRectForPaintInval idation(); |
| 248 EXPECT_EQ(LayoutRect(-40, 0, 240, 110), containerOverflowRect); | 248 EXPECT_EQ(LayoutRect(-40, 0, 240, 110), containerOverflowRect); |
| 249 rect = containerOverflowRect; | 249 rect = containerOverflowRect; |
| 250 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | 250 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
|
chrishtr
2016/04/04 16:33:16
Why did you change two call sites in this test?
Xianzhu
2016/04/04 17:46:58
The previous code was incorrect. We should never m
| |
| 251 EXPECT_EQ(LayoutRect(0, 0, 240, 110), rect); | 251 EXPECT_EQ(LayoutRect(0, 0, 240, 110), rect); |
| 252 rect = containerOverflowRect; | 252 rect = containerOverflowRect; |
| 253 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | 253 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| 254 EXPECT_EQ(LayoutRect(222, 111, 240, 110), rect); | 254 EXPECT_EQ(LayoutRect(222, 111, 240, 110), rect); |
| 255 } | 255 } |
| 256 | 256 |
| 257 TEST_F(LayoutObjectTest, OverflowRectMappingWithContainerOverflowClip) | |
| 258 { | |
| 259 setBodyInnerHTML( | |
| 260 "<div id='container' style='position: absolute; top: 111px; left: 222px; " | |
| 261 " border: 10px solid red; overflow: hidden; width: 50px; height: 80px ;'>" | |
| 262 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" | |
| 263 "</div>"); | |
| 264 | |
| 265 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); | |
| 266 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); | |
| 267 EXPECT_EQ(LayoutUnit(0), container->scrollLeft()); | |
| 268 container->setScrollTop(LayoutUnit(7)); | |
| 269 container->setScrollLeft(LayoutUnit(8)); | |
| 270 | |
| 271 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | |
| 272 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); | |
| 273 LayoutRect rect = targetOverflowRect; | |
|
chrishtr
2016/04/04 16:33:16
Add an assert about what targetOverflowRect is equ
Xianzhu
2016/04/04 17:46:58
Done.
| |
| 274 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | |
| 275 EXPECT_EQ(LayoutRect(2, 3, 140, 110), rect); | |
|
chrishtr
2016/04/04 16:33:15
Why 2,3?
Add a quick note that this is 140x110 be
Xianzhu
2016/04/04 17:46:58
Done.
| |
| 276 rect = targetOverflowRect; | |
| 277 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | |
| 278 EXPECT_EQ(LayoutRect(232, 121, 50, 80), rect); | |
|
chrishtr
2016/04/04 16:33:16
Add a quick note that this adjusts for the top/lef
Xianzhu
2016/04/04 17:46:58
Done.
| |
| 279 | |
| 280 LayoutRect containerOverflowRect = container->localOverflowRectForPaintInval idation(); | |
| 281 EXPECT_EQ(LayoutRect(0, 0, 70, 100), containerOverflowRect); | |
|
chrishtr
2016/04/04 16:33:16
Why 70x100? Doesn't it include the overflow from '
Xianzhu
2016/04/04 17:46:58
No. The container has overflow clip, so its visual
| |
| 282 rect = containerOverflowRect; | |
| 283 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); | |
| 284 EXPECT_EQ(LayoutRect(0, 0, 70, 100), rect); | |
| 285 rect = containerOverflowRect; | |
| 286 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | |
| 287 EXPECT_EQ(LayoutRect(222, 111, 70, 100), rect); | |
|
chrishtr
2016/04/04 16:33:15
No clip applied?
Xianzhu
2016/04/04 17:46:58
Right. We should not apply container's overflow cl
| |
| 288 } | |
| 289 | |
| 290 TEST_F(LayoutObjectTest, OverflowRectMappingWithContainerFlippedWritingModeAndOv erflowClip) | |
| 291 { | |
| 292 setBodyInnerHTML( | |
| 293 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;" | |
| 294 " border: solid red; border-width: 10px 20px 30px 40px;" | |
| 295 " overflow: hidden; width: 50px; height: 80px'>" | |
| 296 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" | |
| 297 " <div style='width: 100px; height: 100px'></div>" | |
| 298 "</div>"); | |
| 299 | |
| 300 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); | |
| 301 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); | |
| 302 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); | |
| 303 container->setScrollTop(LayoutUnit(7)); | |
| 304 container->setScrollLeft(container->scrollLeft() - 8); | |
| 305 | |
| 306 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); | |
| 307 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); | |
| 308 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); | |
| 309 LayoutRect rect = targetOverflowRect; | |
| 310 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); | |
| 311 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); | |
| 312 | |
| 313 rect = targetOverflowRect; | |
| 314 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); | |
| 315 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); | |
| 316 rect = targetOverflowRect; | |
| 317 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | |
| 318 // TODO(crbug.com/600039): rect.x() should be 262 (left + border-left), but is offset | |
| 319 // by extra horizontal border-widths because of layout error. | |
| 320 EXPECT_EQ(LayoutRect(322, 121, 50, 80), rect); | |
| 321 | |
| 322 LayoutRect containerOverflowRect = container->localOverflowRectForPaintInval idation(); | |
| 323 EXPECT_EQ(LayoutRect(0, 0, 110, 120), containerOverflowRect); | |
| 324 rect = containerOverflowRect; | |
| 325 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); | |
| 326 EXPECT_EQ(LayoutRect(0, 0, 110, 120), rect); | |
| 327 rect = containerOverflowRect; | |
| 328 EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); | |
| 329 // TODO(crbug.com/600039): rect.x() should be 222 (left), but is offset by e xtra horizontal | |
| 330 // border-widths because of layout error. | |
| 331 EXPECT_EQ(LayoutRect(282, 111, 110, 120), rect); | |
| 332 } | |
| 333 | |
| 257 } // namespace blink | 334 } // namespace blink |
| OLD | NEW |