OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/compositing/CompositedLayerMapping.h" | 5 #include "core/layout/compositing/CompositedLayerMapping.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "core/layout/api/LayoutViewItem.h" | 10 #include "core/layout/api/LayoutViewItem.h" |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 document().setRootScroller(nullptr, nonThrow); | 1077 document().setRootScroller(nullptr, nonThrow); |
1078 document().view()->updateAllLifecyclePhases(); | 1078 document().view()->updateAllLifecyclePhases(); |
1079 ASSERT_EQ(document().documentElement(), | 1079 ASSERT_EQ(document().documentElement(), |
1080 rootScrollerController.globalRootScroller()); | 1080 rootScrollerController.globalRootScroller()); |
1081 | 1081 |
1082 EXPECT_TRUE(mapping3->clippingLayer()); | 1082 EXPECT_TRUE(mapping3->clippingLayer()); |
1083 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); | 1083 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); |
1084 } | 1084 } |
1085 } | 1085 } |
1086 | 1086 |
| 1087 TEST_P(CompositedLayerMappingTest, AncestorClippingMaskLayerUpdates) { |
| 1088 setBodyInnerHTML( |
| 1089 "<style>" |
| 1090 "#ancestor { width: 100px; height: 100px; overflow: hidden; }" |
| 1091 "#child { width: 120px; height: 120px; background-color: green; }" |
| 1092 "</style>" |
| 1093 "<div id='ancestor'><div id='child'></div></div>"); |
| 1094 document().view()->updateAllLifecyclePhases(); |
| 1095 |
| 1096 Element* ancestor = document().getElementById("ancestor"); |
| 1097 ASSERT_TRUE(ancestor); |
| 1098 PaintLayer* ancestorPaintLayer = |
| 1099 toLayoutBoxModelObject(ancestor->layoutObject())->layer(); |
| 1100 ASSERT_TRUE(ancestorPaintLayer); |
| 1101 |
| 1102 CompositedLayerMapping* ancestorMapping = |
| 1103 ancestorPaintLayer->compositedLayerMapping(); |
| 1104 ASSERT_FALSE(ancestorMapping); |
| 1105 |
| 1106 Element* child = document().getElementById("child"); |
| 1107 ASSERT_TRUE(child); |
| 1108 PaintLayer* childPaintLayer = |
| 1109 toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1110 ASSERT_FALSE(childPaintLayer); |
| 1111 |
| 1112 // Making the child conposited causes creation of an AncestorClippingLayer. |
| 1113 child->setAttribute(HTMLNames::styleAttr, "will-change: transform"); |
| 1114 document().view()->updateAllLifecyclePhases(); |
| 1115 |
| 1116 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1117 ASSERT_TRUE(childPaintLayer); |
| 1118 CompositedLayerMapping* childMapping = |
| 1119 childPaintLayer->compositedLayerMapping(); |
| 1120 ASSERT_TRUE(childMapping); |
| 1121 EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
| 1122 EXPECT_FALSE(childMapping->ancestorClippingLayer()->maskLayer()); |
| 1123 EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
| 1124 |
| 1125 // Adding border radius to the ancestor requires an |
| 1126 // ancestorClippingMaskLayer for the child |
| 1127 ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 40px;"); |
| 1128 document().view()->updateAllLifecyclePhases(); |
| 1129 |
| 1130 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1131 ASSERT_TRUE(childPaintLayer); |
| 1132 childMapping = childPaintLayer->compositedLayerMapping(); |
| 1133 ASSERT_TRUE(childMapping); |
| 1134 EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
| 1135 EXPECT_TRUE(childMapping->ancestorClippingLayer()->maskLayer()); |
| 1136 EXPECT_TRUE(childMapping->ancestorClippingMaskLayer()); |
| 1137 |
| 1138 // Removing the border radius should remove the ancestorClippingMaskLayer |
| 1139 // for the child |
| 1140 ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 0px;"); |
| 1141 document().view()->updateAllLifecyclePhases(); |
| 1142 |
| 1143 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1144 ASSERT_TRUE(childPaintLayer); |
| 1145 childMapping = childPaintLayer->compositedLayerMapping(); |
| 1146 ASSERT_TRUE(childMapping); |
| 1147 EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
| 1148 EXPECT_FALSE(childMapping->ancestorClippingLayer()->maskLayer()); |
| 1149 EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
| 1150 |
| 1151 // Add border radius back so we can test one more case |
| 1152 ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 40px;"); |
| 1153 document().view()->updateAllLifecyclePhases(); |
| 1154 |
| 1155 // Now change the overflow to remove the need for an ancestor clip |
| 1156 // on the child |
| 1157 ancestor->setAttribute(HTMLNames::styleAttr, "overflow: visible"); |
| 1158 document().view()->updateAllLifecyclePhases(); |
| 1159 |
| 1160 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1161 ASSERT_TRUE(childPaintLayer); |
| 1162 childMapping = childPaintLayer->compositedLayerMapping(); |
| 1163 ASSERT_TRUE(childMapping); |
| 1164 EXPECT_FALSE(childMapping->ancestorClippingLayer()); |
| 1165 EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
| 1166 } |
| 1167 |
1087 } // namespace blink | 1168 } // namespace blink |
OLD | NEW |