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 c3d7eef11ca1e6626ed3c0c89ee9a7d33aaaf96d..0768488e5a9ee1639ac55c14c5afea12d15d2b4e 100644 |
| --- a/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| +++ b/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| @@ -18,40 +18,22 @@ class VisualRectMappingTest : public RenderingTest { |
| protected: |
| LayoutView& layoutView() const { return *document().layoutView(); } |
| - void checkPaintInvalidationStateRectMapping( |
|
chrishtr
2016/12/27 19:31:36
Looks like this CL got rebased wrong on top of the
Xianzhu
2016/12/28 02:47:02
Fixed.
|
| - const LayoutRect& expectedRect, |
| - const LayoutRect& rect, |
| - const LayoutObject& object, |
| - const LayoutView& layoutView, |
| - const LayoutObject& paintInvalidationContainer) { |
| - Vector<const LayoutObject*> ancestors; |
| - for (const LayoutObject* ancestor = &object; ancestor != layoutView; |
| - ancestor = ancestor->slowPaintInvalidationParentForTesting()) |
| - ancestors.append(ancestor); |
| - |
| - Vector<Optional<PaintInvalidationState>> paintInvalidationStates( |
| - ancestors.size() + 1); |
| - Vector<const LayoutObject*> pendingDelayedPaintInvalidations; |
| - paintInvalidationStates[0].emplace(layoutView, |
| - pendingDelayedPaintInvalidations); |
| - if (layoutView != object) |
| - paintInvalidationStates[0]->updateForChildren(PaintInvalidationFull); |
| - for (size_t i = 1; i < paintInvalidationStates.size(); ++i) { |
| - paintInvalidationStates[i].emplace(*paintInvalidationStates[i - 1], |
| - *ancestors[ancestors.size() - i]); |
| - if (paintInvalidationStates[i]->m_currentObject != object) |
| - paintInvalidationStates[i]->updateForChildren(PaintInvalidationFull); |
| + void checkPaintInvalidationVisualRect(const LayoutObject& object) { |
| + LayoutRect rect = object.localVisualRect(); |
| + if (object.isBox()) |
| + toLayoutBox(object).flipForWritingMode(rect); |
| + const LayoutBoxModelObject& paintInvalidationContainer = |
| + object.containerForPaintInvalidation(); |
| + object.mapToVisualRectInAncestorSpace(&paintInvalidationContainer, rect); |
| + if (rect.isEmpty() && object.visualRect().isEmpty()) |
| + return; |
| + // The following condition can be false if paintInvalidationContainer is |
| + // a LayoutView and compositing is not enabled. |
| + if (paintInvalidationContainer.isPaintInvalidationContainer()) { |
| + PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
| + paintInvalidationContainer, rect); |
| } |
| - |
| - const PaintInvalidationState& paintInvalidationState = |
| - *paintInvalidationStates.back(); |
| - ASSERT_EQ(paintInvalidationState.m_currentObject, object); |
| - ASSERT_EQ(&paintInvalidationState.paintInvalidationContainer(), |
| - &paintInvalidationContainer); |
| - |
| - LayoutRect r = rect; |
| - paintInvalidationState.mapLocalRectToPaintInvalidationContainer(r); |
| - EXPECT_EQ(expectedRect, r); |
| + EXPECT_EQ(rect, object.visualRect()); |
| } |
| }; |
| @@ -68,6 +50,8 @@ TEST_F(VisualRectMappingTest, LayoutText) { |
| LayoutText* text = toLayoutText(container->lastChild()); |
| container->setScrollTop(LayoutUnit(50)); |
| + document().view()->updateAllLifecyclePhases(); |
| + |
| LayoutRect originalRect(0, 60, 20, 80); |
| LayoutRect rect = originalRect; |
| EXPECT_TRUE(text->mapToVisualRectInAncestorSpace(container, rect)); |
| @@ -77,8 +61,8 @@ TEST_F(VisualRectMappingTest, LayoutText) { |
| rect = originalRect; |
| EXPECT_TRUE(text->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40)); |
| - checkPaintInvalidationStateRectMapping(rect, originalRect, *text, |
| - layoutView(), layoutView()); |
| + |
| + checkPaintInvalidationVisualRect(*text); |
| rect = LayoutRect(0, 60, 80, 0); |
| EXPECT_TRUE( |
| @@ -93,13 +77,16 @@ TEST_F(VisualRectMappingTest, LayoutInline) { |
| "<style>body { margin: 0; }</style>" |
| "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>" |
| " <span><img style='width: 20px; height: 100px'></span>" |
| - " <span id=leaf></span></div>"); |
| + " <span id='leaf'></span>" |
| + "</div>"); |
| LayoutBlock* container = |
| toLayoutBlock(getLayoutObjectByElementId("container")); |
| LayoutObject* leaf = container->lastChild(); |
| container->setScrollTop(LayoutUnit(50)); |
| + document().view()->updateAllLifecyclePhases(); |
| + |
| LayoutRect originalRect(0, 60, 20, 80); |
| LayoutRect rect = originalRect; |
| EXPECT_TRUE(leaf->mapToVisualRectInAncestorSpace(container, rect)); |
| @@ -109,8 +96,8 @@ TEST_F(VisualRectMappingTest, LayoutInline) { |
| rect = originalRect; |
| EXPECT_TRUE(leaf->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40)); |
| - checkPaintInvalidationStateRectMapping(rect, originalRect, *leaf, |
| - layoutView(), layoutView()); |
| + |
| + checkPaintInvalidationVisualRect(*leaf); |
| rect = LayoutRect(0, 60, 80, 0); |
| EXPECT_TRUE( |
| @@ -125,12 +112,11 @@ TEST_F(VisualRectMappingTest, LayoutView) { |
| "<style>body { margin: 0; }</style>" |
| "<div id=frameContainer>" |
| " <iframe src='http://test.com' width='50' height='50' " |
| - "frameBorder='0'></iframe>" |
| + " frameBorder='0'></iframe>" |
| "</div>"); |
| setChildFrameHTML( |
| - "<style>body { margin: 0; }</style><span><img style='width: 20px; " |
| - "height: 100px'></span>text text text"); |
| - |
| + "<style>body { margin: 0; }</style>" |
| + "<span><img style='width: 20px; height: 100px'></span>text text text"); |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* frameContainer = |
| @@ -143,6 +129,8 @@ TEST_F(VisualRectMappingTest, LayoutView) { |
| // rect is 13, so height should be clipped to (50 - 13) == 37. |
| childDocument().view()->setScrollOffset(ScrollOffset(0, 47), |
| ProgrammaticScroll); |
| + document().view()->updateAllLifecyclePhases(); |
| + |
| LayoutRect originalRect(4, 60, 20, 80); |
| LayoutRect rect = originalRect; |
| EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(frameContainer, rect)); |
| @@ -151,8 +139,8 @@ TEST_F(VisualRectMappingTest, LayoutView) { |
| rect = originalRect; |
| EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37)); |
| - checkPaintInvalidationStateRectMapping(rect, originalRect, *frameText, |
| - layoutView(), layoutView()); |
| + |
| + checkPaintInvalidationVisualRect(*frameText); |
| rect = LayoutRect(4, 60, 0, 80); |
| EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(frameContainer, rect, |
| @@ -165,12 +153,13 @@ TEST_F(VisualRectMappingTest, LayoutViewSubpixelRounding) { |
| setBodyInnerHTML( |
| "<style>body { margin: 0; }</style>" |
| "<div id=frameContainer style='position: relative; left: 0.5px'>" |
| - " <iframe style='position: relative; left: 0.5px' " |
| - "src='http://test.com' width='200' height='200' frameBorder='0'></iframe>" |
| + " <iframe style='position: relative; left: 0.5px' width='200'" |
| + " height='200' src='http://test.com' frameBorder='0'></iframe>" |
| "</div>"); |
| setChildFrameHTML( |
| - "<style>body { margin: 0; }</style><div id='target' style='position: " |
| - "relative; width: 100px; height: 100px; left: 0.5px'>"); |
| + "<style>body { margin: 0; }</style>" |
| + "<div id='target' style='position: relative; width: 100px; height: 100px;" |
| + " left: 0.5px'></div>"); |
| document().view()->updateAllLifecyclePhases(); |
| @@ -193,12 +182,11 @@ TEST_F(VisualRectMappingTest, LayoutViewDisplayNone) { |
| "<style>body { margin: 0; }</style>" |
| "<div id=frameContainer>" |
| " <iframe id='frame' src='http://test.com' width='50' height='50' " |
| - "frameBorder='0'></iframe>" |
| + " frameBorder='0'></iframe>" |
| "</div>"); |
| setChildFrameHTML( |
| - "<style>body { margin: 0; }</style><div " |
| - "style='width:100px;height:100px;'></div>"); |
| - |
| + "<style>body { margin: 0; }</style>" |
| + "<div style='width:100px;height:100px;'></div>"); |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* frameContainer = |
| @@ -211,6 +199,8 @@ TEST_F(VisualRectMappingTest, LayoutViewDisplayNone) { |
| // mapped rect is valid before display:none is set on the iframe. |
| childDocument().view()->setScrollOffset(ScrollOffset(0, 47), |
| ProgrammaticScroll); |
| + document().view()->updateAllLifecyclePhases(); |
| + |
| LayoutRect originalRect(4, 60, 20, 80); |
| LayoutRect rect = originalRect; |
| EXPECT_TRUE(frameDiv->mapToVisualRectInAncestorSpace(frameContainer, rect)); |
| @@ -227,21 +217,20 @@ TEST_F(VisualRectMappingTest, LayoutViewDisplayNone) { |
| TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) { |
| setBodyInnerHTML( |
| - "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px " |
| - "20px black;" |
| - " width: 100px; height: 50px; position: absolute; top: 111px; left: " |
| - "222px'>" |
| + "<div id='target' style='writing-mode: vertical-rl;" |
| + " box-shadow: 40px 20px black; width: 100px; height: 50px;" |
| + " position: absolute; top: 111px; left: 222px'>" |
| "</div>"); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect visualRect = target->localVisualRect(); |
| + LayoutRect localVisualRect = target->localVisualRect(); |
| // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| // origin) |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 70 = height(50) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(-40, 0, 140, 70), visualRect); |
| + EXPECT_EQ(LayoutRect(-40, 0, 140, 70), localVisualRect); |
| - LayoutRect rect = visualRect; |
| + LayoutRect rect = localVisualRect; |
| // 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" (*not* |
| @@ -252,32 +241,31 @@ TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) { |
| // This rect is in physical coordinates of target. |
| EXPECT_EQ(LayoutRect(0, 0, 140, 70), rect); |
| - rect = visualRect; |
| + rect = localVisualRect; |
| target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(222, 111, 140, 70), rect); |
| - checkPaintInvalidationStateRectMapping(rect, visualRect, *target, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, target->visualRect()); |
| } |
| TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) { |
| setBodyInnerHTML( |
| - "<div id='container' style='writing-mode: vertical-rl; position: " |
| - "absolute; top: 111px; left: 222px'>" |
| - " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| - "height: 90px'></div>" |
| - " <div style='width: 100px; height: 100px'></div>" |
| + "<div id='container' style='writing-mode: vertical-rl;" |
| + " position: absolute; top: 111px; left: 222px'>" |
| + " <div id='target' style='box-shadow: 40px 20px black; width: 100px;" |
| + " height: 90px'></div>" |
| + " <div style='width: 100px; height: 100px'></div>" |
| "</div>"); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| // origin) |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 110 = height(90) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect); |
| + EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetLocalVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + LayoutRect rect = targetLocalVisualRect; |
| target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| // This rect is in physical coordinates of target. |
| @@ -285,39 +273,37 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingMode) { |
| LayoutBlock* container = |
| toLayoutBlock(getLayoutObjectByElementId("container")); |
| - rect = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| 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 = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect); |
| - checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, target->visualRect()); |
| - LayoutRect containerVisualRect = container->localVisualRect(); |
| - EXPECT_EQ(LayoutRect(0, 0, 200, 100), containerVisualRect); |
| - rect = containerVisualRect; |
| + LayoutRect containerLocalVisualRect = container->localVisualRect(); |
| + EXPECT_EQ(LayoutRect(0, 0, 200, 100), containerLocalVisualRect); |
| + rect = containerLocalVisualRect; |
| container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 200, 100), rect); |
| - rect = containerVisualRect; |
| + rect = containerLocalVisualRect; |
| container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(222, 111, 200, 100), rect); |
| - checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, container->visualRect()); |
| } |
| TEST_F(VisualRectMappingTest, ContainerOverflowScroll) { |
| setBodyInnerHTML( |
| "<div id='container' style='position: absolute; top: 111px; left: 222px;" |
| - " border: 10px solid red; overflow: scroll; width: 50px; height: " |
| - "80px;'>" |
| - " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| - "height: 90px'></div>" |
| + " border: 10px solid red; overflow: scroll; width: 50px;" |
| + " height: 80px'>" |
| + " <div id='target' style='box-shadow: 40px 20px black; width: 100px;" |
| + " height: 90px'></div>" |
| "</div>"); |
| LayoutBlock* container = |
| @@ -329,15 +315,15 @@ TEST_F(VisualRectMappingTest, ContainerOverflowScroll) { |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 110 = height(90) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetLocalVisualRect); |
| + LayoutRect rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| - rect = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| rect.move(-container->scrolledContentOffset()); |
| // 2 = target_x(0) + container_border_left(10) - scroll_left(8) |
| @@ -346,42 +332,40 @@ TEST_F(VisualRectMappingTest, ContainerOverflowScroll) { |
| // overflow:scroll. |
| EXPECT_EQ(LayoutRect(2, 3, 140, 110), rect); |
| - rect = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| // (2, 3, 140, 100) is first clipped by container's overflow clip, to |
| // (10, 10, 50, 80), then is by added container's offset in LayoutView |
| // (111, 222). |
| EXPECT_EQ(LayoutRect(232, 121, 50, 80), rect); |
| - checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, target->visualRect()); |
| - LayoutRect containerVisualRect = container->localVisualRect(); |
| + LayoutRect containerLocalVisualRect = container->localVisualRect(); |
| // Because container has overflow clip, its visual overflow doesn't include |
| // overflow from children. |
| // 70 = width(50) + border_left_width(10) + border_right_width(10) |
| // 100 = height(80) + border_top_width(10) + border_bottom_width(10) |
| - EXPECT_EQ(LayoutRect(0, 0, 70, 100), containerVisualRect); |
| - rect = containerVisualRect; |
| + EXPECT_EQ(LayoutRect(0, 0, 70, 100), containerLocalVisualRect); |
| + rect = containerLocalVisualRect; |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| // Container should not apply overflow clip on its own overflow rect. |
| EXPECT_EQ(LayoutRect(0, 0, 70, 100), rect); |
| - rect = containerVisualRect; |
| + rect = containerLocalVisualRect; |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(222, 111, 70, 100), rect); |
| - checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, container->visualRect()); |
| } |
| TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) { |
| setBodyInnerHTML( |
| - "<div id='container' style='writing-mode: vertical-rl; position: " |
| - "absolute; top: 111px; left: 222px;" |
| - " border: solid red; border-width: 10px 20px 30px 40px;" |
| - " overflow: scroll; width: 50px; height: 80px'>" |
| - " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| - "height: 90px'></div>" |
| - " <div style='width: 100px; height: 100px'></div>" |
| + "<div id='container' style='writing-mode: vertical-rl;" |
| + " position: absolute; top: 111px; left: 222px; border: solid red;" |
| + " border-width: 10px 20px 30px 40px; overflow: scroll; width: 50px;" |
| + " height: 80px'>" |
| + " <div id='target' style='box-shadow: 40px 20px black; width: 100px;" |
| + " height: 90px'></div>" |
| + " <div style='width: 100px; height: 100px'></div>" |
| "</div>"); |
| LayoutBlock* container = |
| @@ -397,20 +381,20 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) { |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| // origin) |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 110 = height(90) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect); |
| + EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetLocalVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + LayoutRect rect = targetLocalVisualRect; |
| 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 = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| rect.move(-container->scrolledContentOffset()); |
| @@ -419,7 +403,7 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) { |
| // Rect is clipped by container's overflow clip because of overflow:scroll. |
| EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); |
| - rect = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| // (-2, 3, 140, 100) is first clipped by container's overflow clip, to |
| @@ -429,39 +413,37 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowScroll) { |
| // offset |
| // by extra horizontal border-widths because of layout error. |
| EXPECT_EQ(LayoutRect(322, 121, 50, 80), rect); |
| - checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, target->visualRect()); |
| - LayoutRect containerVisualRect = container->localVisualRect(); |
| + LayoutRect containerLocalVisualRect = container->localVisualRect(); |
| // Because container has overflow clip, its visual overflow doesn't include |
| // overflow from children. |
| // 110 = width(50) + border_left_width(40) + border_right_width(20) |
| // 120 = height(80) + border_top_width(10) + border_bottom_width(30) |
| - EXPECT_EQ(LayoutRect(0, 0, 110, 120), containerVisualRect); |
| + EXPECT_EQ(LayoutRect(0, 0, 110, 120), containerLocalVisualRect); |
| - rect = containerVisualRect; |
| + rect = containerLocalVisualRect; |
| container->flipForWritingMode(rect); |
| EXPECT_TRUE(container->mapToVisualRectInAncestorSpace(container, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 110, 120), rect); |
| - rect = containerVisualRect; |
| + rect = containerLocalVisualRect; |
| 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. |
| EXPECT_EQ(LayoutRect(282, 111, 110, 120), rect); |
| - checkPaintInvalidationStateRectMapping(rect, containerVisualRect, *container, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, container->visualRect()); |
| } |
| TEST_F(VisualRectMappingTest, ContainerOverflowHidden) { |
| setBodyInnerHTML( |
| "<div id='container' style='position: absolute; top: 111px; left: 222px;" |
| - " border: 10px solid red; overflow: hidden; width: 50px; height: " |
| - "80px;'>" |
| - " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| - "height: 90px'></div>" |
| + " border: 10px solid red; overflow: hidden; width: 50px;" |
| + " height: 80px;'>" |
| + " <div id='target' style='box-shadow: 40px 20px black; width: 100px;" |
| + " height: 90px'></div>" |
| "</div>"); |
| LayoutBlock* container = |
| @@ -473,15 +455,15 @@ TEST_F(VisualRectMappingTest, ContainerOverflowHidden) { |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 110 = height(90) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetLocalVisualRect); |
| + LayoutRect rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| - rect = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| // Rect is not clipped by container's overflow clip. |
| EXPECT_EQ(LayoutRect(10, 10, 140, 110), rect); |
| @@ -489,13 +471,13 @@ TEST_F(VisualRectMappingTest, ContainerOverflowHidden) { |
| TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) { |
| setBodyInnerHTML( |
| - "<div id='container' style='writing-mode: vertical-rl; position: " |
| - "absolute; top: 111px; left: 222px;" |
| - " border: solid red; border-width: 10px 20px 30px 40px;" |
| - " overflow: hidden; width: 50px; height: 80px'>" |
| - " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| - "height: 90px'></div>" |
| - " <div style='width: 100px; height: 100px'></div>" |
| + "<div id='container' style='writing-mode: vertical-rl; " |
| + " position: absolute; top: 111px; left: 222px; border: solid red; " |
| + " border-width: 10px 20px 30px 40px; overflow: hidden; width: 50px; " |
| + " height: 80px'>" |
| + " <div id='target' style='box-shadow: 40px 20px black; width: 100px; " |
| + " height: 90px'></div>" |
| + " <div style='width: 100px; height: 100px'></div>" |
| "</div>"); |
| LayoutBlock* container = |
| @@ -510,20 +492,20 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) { |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the |
| // origin) |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 110 = height(90) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetVisualRect); |
| + EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetLocalVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + LayoutRect rect = targetLocalVisualRect; |
| 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 = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| target->flipForWritingMode(rect); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| // 58 = target_physical_x(100) + container_border_left(40) - scroll_left(58) |
| @@ -532,13 +514,13 @@ TEST_F(VisualRectMappingTest, ContainerFlippedWritingModeAndOverflowHidden) { |
| TEST_F(VisualRectMappingTest, ContainerAndTargetDifferentFlippedWritingMode) { |
| setBodyInnerHTML( |
| - "<div id='container' style='writing-mode: vertical-rl; position: " |
| - "absolute; top: 111px; left: 222px;" |
| - " border: solid red; border-width: 10px 20px 30px 40px;" |
| - " overflow: scroll; width: 50px; height: 80px'>" |
| - " <div id='target' style='writing-mode: vertical-lr; box-shadow: 40px " |
| - "20px black; width: 100px; height: 90px'></div>" |
| - " <div style='width: 100px; height: 100px'></div>" |
| + "<div id='container' style='writing-mode: vertical-rl;" |
| + " position: absolute; top: 111px; left: 222px; border: solid red;" |
| + " border-width: 10px 20px 30px 40px; overflow: scroll; width: 50px;" |
| + " height: 80px'>" |
| + " <div id='target' style='writing-mode: vertical-lr; width: 100px;" |
| + " height: 90px; box-shadow: 40px 20px black'></div>" |
| + " <div style='width: 100px; height: 100px'></div>" |
| "</div>"); |
| LayoutBlock* container = |
| @@ -554,17 +536,17 @@ TEST_F(VisualRectMappingTest, ContainerAndTargetDifferentFlippedWritingMode) { |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| // 140 = width(100) + box_shadow_offset_x(40) |
| // 110 = height(90) + box_shadow_offset_y(20) |
| - EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect); |
| + EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetLocalVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + LayoutRect rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect)); |
| // This rect is in physical coordinates of target. |
| EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); |
| - rect = targetVisualRect; |
| + rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); |
| rect.move(-container->scrolledContentOffset()); |
| // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142) |
| @@ -579,15 +561,16 @@ TEST_F(VisualRectMappingTest, |
| document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| setBodyInnerHTML( |
| - "<div id='stacking-context' style='opacity: 0.9; background: blue; " |
| - "will-change: transform'>" |
| - " <div id='scroller' style='overflow: scroll; width: 80px; height: " |
| - "80px'>" |
| - " <div id='absolute' style='position: absolute; top: 111px; left: " |
| - "222px; width: 50px; height: 50px; background: green'></div>" |
| - " <div id='normal-flow' style='width: 2000px; height: 2000px; " |
| - "background: yellow'></div>" |
| + "<div id='stacking-context' style='opacity: 0.9; background: blue;" |
| + " will-change: transform'>" |
| + " <div id='scroller' style='overflow: scroll; width: 80px;" |
| + " height: 80px'>" |
| + " <div id='absolute' style='position: absolute; top: 111px;" |
| + " left: 222px; width: 50px; height: 50px; background: green'>" |
| " </div>" |
| + " <div id='normal-flow' style='width: 2000px; height: 2000px;" |
| + " background: yellow'></div>" |
| + " </div>" |
| "</div>"); |
| LayoutBlock* scroller = toLayoutBlock(getLayoutObjectByElementId("scroller")); |
| @@ -604,8 +587,7 @@ TEST_F(VisualRectMappingTest, |
| LayoutRect rect = normalFlowVisualRect; |
| EXPECT_TRUE(normalFlow->mapToVisualRectInAncestorSpace(scroller, rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), rect); |
| - checkPaintInvalidationStateRectMapping(rect, normalFlowVisualRect, |
| - *normalFlow, layoutView(), *scroller); |
| + EXPECT_EQ(rect, normalFlow->visualRect()); |
| LayoutBlock* stackingContext = |
| toLayoutBlock(getLayoutObjectByElementId("stacking-context")); |
| @@ -618,8 +600,7 @@ TEST_F(VisualRectMappingTest, |
| rect = absoluteVisualRect; |
| EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)); |
| EXPECT_EQ(LayoutRect(222, 111, 50, 50), rect); |
| - checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute, |
| - layoutView(), *stackingContext); |
| + EXPECT_EQ(rect, absolute->visualRect()); |
| } |
| TEST_F(VisualRectMappingTest, |
| @@ -629,16 +610,16 @@ TEST_F(VisualRectMappingTest, |
| setBodyInnerHTML( |
| "<div id='container' style='position: absolute; top: 88px; left: 99px'>" |
| - " <div style='height: 222px'></div>" |
| + " <div style='height: 222px'></div>" |
| // This div makes stacking-context composited. |
| - " <div style='position: absolute; width: 1px; height: 1px; " |
| - "background:yellow; will-change: transform'></div>" |
| + " <div style='position: absolute; width: 1px; height: 1px; " |
| + " background:yellow; will-change: transform'></div>" |
| // This stacking context is paintInvalidationContainer of the absolute |
| // child, but not a container of it. |
| - " <div id='stacking-context' style='opacity: 0.9'>" |
| - " <div id='absolute' style='position: absolute; top: 50px; left: " |
| - "50px; width: 50px; height: 50px; background: green'></div>" |
| - " </div>" |
| + " <div id='stacking-context' style='opacity: 0.9'>" |
| + " <div id='absolute' style='position: absolute; top: 50px; left: 50px;" |
| + " width: 50px; height: 50px; background: green'></div>" |
| + " </div>" |
| "</div>"); |
| LayoutBlock* stackingContext = |
| @@ -655,46 +636,42 @@ TEST_F(VisualRectMappingTest, |
| EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)); |
| // -172 = top(50) - y_offset_of_stacking_context(222) |
| EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); |
| - checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute, |
| - layoutView(), *stackingContext); |
| + // Use checkPaintInvalidationVisualRect to deals with layer squashing. |
| + checkPaintInvalidationVisualRect(*absolute); |
| } |
| TEST_F(VisualRectMappingTest, CSSClip) { |
| setBodyInnerHTML( |
| "<div id='container' style='position: absolute; top: 0px; left: 0px; " |
| - "clip: rect(0px, 200px, 200px, 0px)'>" |
| - " <div id='target' style='width: 400px; height: 400px'></div>" |
| - " </div>" |
| + " clip: rect(0px, 200px, 200px, 0px)'>" |
| + " <div id='target' style='width: 400px; height: 400px'></div>" |
| "</div>"); |
| LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| - EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| + EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetLocalVisualRect); |
| + LayoutRect rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect); |
| - checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, target->visualRect()); |
| } |
| TEST_F(VisualRectMappingTest, ContainPaint) { |
| setBodyInnerHTML( |
| "<div id='container' style='position: absolute; top: 0px; left: 0px; " |
| - "width: 200px; height: 200px; contain: paint'>" |
| - " <div id='target' style='width: 400px; height: 400px'></div>" |
| - " </div>" |
| + " width: 200px; height: 200px; contain: paint'>" |
| + " <div id='target' style='width: 400px; height: 400px'></div>" |
| "</div>"); |
| LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| - LayoutRect targetVisualRect = target->localVisualRect(); |
| - EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetVisualRect); |
| - LayoutRect rect = targetVisualRect; |
| + LayoutRect targetLocalVisualRect = target->localVisualRect(); |
| + EXPECT_EQ(LayoutRect(0, 0, 400, 400), targetLocalVisualRect); |
| + LayoutRect rect = targetLocalVisualRect; |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect)); |
| EXPECT_EQ(LayoutRect(0, 0, 200, 200), rect); |
| - checkPaintInvalidationStateRectMapping(rect, targetVisualRect, *target, |
| - layoutView(), layoutView()); |
| + EXPECT_EQ(rect, target->visualRect()); |
| } |
| } // namespace blink |