Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp |
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp |
index b5087ac67a04668b91bed6601e7e977b96697c71..f20e8160fbf2881374367e680c24213c6652d88f 100644 |
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp |
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp |
@@ -1084,4 +1084,85 @@ TEST_P(CompositedLayerMappingTest, RootScrollerAncestorsNotClipped) { |
} |
} |
+TEST_P(CompositedLayerMappingTest, AncestorClippingMaskLayerUpdates) { |
+ setBodyInnerHTML( |
+ "<style>" |
+ "#ancestor { width: 100px; height: 100px; overflow: hidden; }" |
+ "#child { width: 120px; height: 120px; background-color: green; }" |
+ "</style>" |
+ "<div id='ancestor'><div id='child'></div></div>"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ Element* ancestor = document().getElementById("ancestor"); |
+ ASSERT_TRUE(ancestor); |
+ PaintLayer* ancestorPaintLayer = |
+ toLayoutBoxModelObject(ancestor->layoutObject())->layer(); |
+ ASSERT_TRUE(ancestorPaintLayer); |
+ |
+ CompositedLayerMapping* ancestorMapping = |
+ ancestorPaintLayer->compositedLayerMapping(); |
+ ASSERT_FALSE(ancestorMapping); |
+ |
+ Element* child = document().getElementById("child"); |
+ ASSERT_TRUE(child); |
+ PaintLayer* childPaintLayer = |
+ toLayoutBoxModelObject(child->layoutObject())->layer(); |
+ ASSERT_FALSE(childPaintLayer); |
+ |
+ // Making the child conposited causes creation of an AncestorClippingLayer. |
+ child->setAttribute(HTMLNames::styleAttr, "will-change: transform"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
+ ASSERT_TRUE(childPaintLayer); |
+ CompositedLayerMapping* childMapping = |
+ childPaintLayer->compositedLayerMapping(); |
+ ASSERT_TRUE(childMapping); |
+ EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
+ EXPECT_FALSE(childMapping->ancestorClippingLayer()->maskLayer()); |
+ EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
+ |
+ // Adding border radius to the ancestor requires an |
+ // ancestorClippingMaskLayer for the child |
+ ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 40px;"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
+ ASSERT_TRUE(childPaintLayer); |
+ childMapping = childPaintLayer->compositedLayerMapping(); |
+ ASSERT_TRUE(childMapping); |
+ EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
+ EXPECT_TRUE(childMapping->ancestorClippingLayer()->maskLayer()); |
+ EXPECT_TRUE(childMapping->ancestorClippingMaskLayer()); |
+ |
+ // Removing the border radius should remove the ancestorClippingMaskLayer |
+ // for the child |
+ ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 0px;"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
+ ASSERT_TRUE(childPaintLayer); |
+ childMapping = childPaintLayer->compositedLayerMapping(); |
+ ASSERT_TRUE(childMapping); |
+ EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
+ EXPECT_FALSE(childMapping->ancestorClippingLayer()->maskLayer()); |
+ EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
+ |
+ // Add border radius back so we can test one more case |
+ ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 40px;"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ // Now change the overflow to remove the need for an ancestor clip |
+ // on the child |
+ ancestor->setAttribute(HTMLNames::styleAttr, "overflow: visible"); |
+ document().view()->updateAllLifecyclePhases(); |
+ |
+ childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
+ ASSERT_TRUE(childPaintLayer); |
+ childMapping = childPaintLayer->compositedLayerMapping(); |
+ ASSERT_TRUE(childMapping); |
+ EXPECT_FALSE(childMapping->ancestorClippingLayer()); |
+ EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
+} |
+ |
} // namespace blink |