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

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

Issue 2588853002: Fix border radius on composited children. (Closed)
Patch Set: SPV2 expectations Created 3 years, 11 months 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 907db3618e0834202e0bb3469db553b0e771a063..c063e364e4744c5fb2fd2fc10c97c0a5d0a1a826 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
@@ -1165,4 +1165,85 @@ TEST_P(CompositedLayerMappingTest,
EXPECT_FLOAT_EQ(10, scrollingLayer2->position().y());
}
+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