Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp

Issue 2194273002: Fix border radius on composited children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update the comment on why we say an empty div can paint Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698