Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp b/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| index 416f838353bb0cb319c2973c21e37aaac2de3f59..322efd1da7da44d96e4157f2f82d3953d9d43494 100644 |
| --- a/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| +++ b/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| @@ -171,11 +171,18 @@ TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) |
| EXPECT_EQ(LayoutRect(-40, 0, 140, 70), overflowRect); |
| LayoutRect rect = overflowRect; |
| + // TODO(wkorman): The calls to flipForWritingMode() here and in other test |
| + // cases below are necessary because mapToVisualRectInAncestorSpace() |
| + // currently expects the input rect to be in "physical coordinates with |
|
chrishtr
2016/07/11 22:35:11
It's the other way around. They are expected to be
wkorman
2016/07/11 22:46:17
Ah, yes, I wrote as if documenting slowMapToVisual
|
| + // flipped block-flow direction" (see LayoutBoxModelObject.h). If we rework |
| + // to take them as physical, we can remove these flips. |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| // This rect is in physical coordinates of target. |
| EXPECT_EQ(LayoutRect(0, 0, 140, 70), rect); |
| rect = overflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(222, 111, 140, 70), rect); |
| checkPaintInvalidationStateRectMapping(rect, overflowRect, *target, layoutView(), layoutView()); |
| @@ -197,16 +204,19 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) |
| EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); |
| LayoutRect rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| // This rect is in physical coordinates of target. |
| EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container")); |
| rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| // 100 is the physical x location of target in container. |
| EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect); |
| rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect); |
| checkPaintInvalidationStateRectMapping(rect, targetOverflowRect, *target, layoutView(), layoutView()); |
| @@ -214,9 +224,11 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) |
| LayoutRect containerOverflowRect = container->localOverflowRectForPaintInvalidation(); |
| EXPECT_EQ(LayoutRect(0, 0, 200, 100), containerOverflowRect); |
| rect = containerOverflowRect; |
| + container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 200, 100), rect); |
| rect = containerOverflowRect; |
| + container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(222, 111, 200, 100), rect); |
| checkPaintInvalidationStateRectMapping(rect, containerOverflowRect, *container, layoutView(), layoutView()); |
| @@ -303,11 +315,13 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) |
| EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); |
| LayoutRect rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| // This rect is in physical coordinates of target. |
| EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142) |
| // 3 = target_y(0) + container_border_top(10) - scroll_top(7) |
| @@ -315,6 +329,7 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) |
| EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); |
| rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| // (-2, 3, 140, 100) is first clipped by container's overflow clip, to (40, 10, 50, 80), |
| // then is added by container's offset in LayoutView (111, 222). |
| @@ -330,10 +345,12 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) |
| EXPECT_EQ(LayoutRect(0, 0, 110, 120), containerOverflowRect); |
| rect = containerOverflowRect; |
| + container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 110, 120), rect); |
| rect = containerOverflowRect; |
| + container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| // TODO(crbug.com/600039): rect.x() should be 222 (left), but is offset by extra horizontal |
| // border-widths because of layout error. |
| @@ -398,11 +415,13 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) |
| EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect); |
| LayoutRect rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| // This rect is in physical coordinates of target. |
| EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| rect = targetOverflowRect; |
| + target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| // 58 = target_physical_x(100) + container_border_left(40) - scroll_left(58) |
| // The other sides of the rect are clipped by container's overflow clip. |