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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 | 1158 |
1159 ASSERT_TRUE(scrollingLayer2); | 1159 ASSERT_TRUE(scrollingLayer2); |
1160 ASSERT_FALSE(mapping2->childTransformLayer()); | 1160 ASSERT_FALSE(mapping2->childTransformLayer()); |
1161 | 1161 |
1162 EXPECT_FLOAT_EQ(30, mainGraphicsLayer2->position().x()); | 1162 EXPECT_FLOAT_EQ(30, mainGraphicsLayer2->position().x()); |
1163 EXPECT_FLOAT_EQ(390, mainGraphicsLayer2->position().y()); | 1163 EXPECT_FLOAT_EQ(390, mainGraphicsLayer2->position().y()); |
1164 EXPECT_FLOAT_EQ(20, scrollingLayer2->position().x()); | 1164 EXPECT_FLOAT_EQ(20, scrollingLayer2->position().x()); |
1165 EXPECT_FLOAT_EQ(10, scrollingLayer2->position().y()); | 1165 EXPECT_FLOAT_EQ(10, scrollingLayer2->position().y()); |
1166 } | 1166 } |
1167 | 1167 |
| 1168 TEST_P(CompositedLayerMappingTest, AncestorClippingMaskLayerUpdates) { |
| 1169 setBodyInnerHTML( |
| 1170 "<style>" |
| 1171 "#ancestor { width: 100px; height: 100px; overflow: hidden; }" |
| 1172 "#child { width: 120px; height: 120px; background-color: green; }" |
| 1173 "</style>" |
| 1174 "<div id='ancestor'><div id='child'></div></div>"); |
| 1175 document().view()->updateAllLifecyclePhases(); |
| 1176 |
| 1177 Element* ancestor = document().getElementById("ancestor"); |
| 1178 ASSERT_TRUE(ancestor); |
| 1179 PaintLayer* ancestorPaintLayer = |
| 1180 toLayoutBoxModelObject(ancestor->layoutObject())->layer(); |
| 1181 ASSERT_TRUE(ancestorPaintLayer); |
| 1182 |
| 1183 CompositedLayerMapping* ancestorMapping = |
| 1184 ancestorPaintLayer->compositedLayerMapping(); |
| 1185 ASSERT_FALSE(ancestorMapping); |
| 1186 |
| 1187 Element* child = document().getElementById("child"); |
| 1188 ASSERT_TRUE(child); |
| 1189 PaintLayer* childPaintLayer = |
| 1190 toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1191 ASSERT_FALSE(childPaintLayer); |
| 1192 |
| 1193 // Making the child conposited causes creation of an AncestorClippingLayer. |
| 1194 child->setAttribute(HTMLNames::styleAttr, "will-change: transform"); |
| 1195 document().view()->updateAllLifecyclePhases(); |
| 1196 |
| 1197 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1198 ASSERT_TRUE(childPaintLayer); |
| 1199 CompositedLayerMapping* childMapping = |
| 1200 childPaintLayer->compositedLayerMapping(); |
| 1201 ASSERT_TRUE(childMapping); |
| 1202 EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
| 1203 EXPECT_FALSE(childMapping->ancestorClippingLayer()->maskLayer()); |
| 1204 EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
| 1205 |
| 1206 // Adding border radius to the ancestor requires an |
| 1207 // ancestorClippingMaskLayer for the child |
| 1208 ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 40px;"); |
| 1209 document().view()->updateAllLifecyclePhases(); |
| 1210 |
| 1211 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1212 ASSERT_TRUE(childPaintLayer); |
| 1213 childMapping = childPaintLayer->compositedLayerMapping(); |
| 1214 ASSERT_TRUE(childMapping); |
| 1215 EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
| 1216 EXPECT_TRUE(childMapping->ancestorClippingLayer()->maskLayer()); |
| 1217 EXPECT_TRUE(childMapping->ancestorClippingMaskLayer()); |
| 1218 |
| 1219 // Removing the border radius should remove the ancestorClippingMaskLayer |
| 1220 // for the child |
| 1221 ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 0px;"); |
| 1222 document().view()->updateAllLifecyclePhases(); |
| 1223 |
| 1224 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1225 ASSERT_TRUE(childPaintLayer); |
| 1226 childMapping = childPaintLayer->compositedLayerMapping(); |
| 1227 ASSERT_TRUE(childMapping); |
| 1228 EXPECT_TRUE(childMapping->ancestorClippingLayer()); |
| 1229 EXPECT_FALSE(childMapping->ancestorClippingLayer()->maskLayer()); |
| 1230 EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
| 1231 |
| 1232 // Add border radius back so we can test one more case |
| 1233 ancestor->setAttribute(HTMLNames::styleAttr, "border-radius: 40px;"); |
| 1234 document().view()->updateAllLifecyclePhases(); |
| 1235 |
| 1236 // Now change the overflow to remove the need for an ancestor clip |
| 1237 // on the child |
| 1238 ancestor->setAttribute(HTMLNames::styleAttr, "overflow: visible"); |
| 1239 document().view()->updateAllLifecyclePhases(); |
| 1240 |
| 1241 childPaintLayer = toLayoutBoxModelObject(child->layoutObject())->layer(); |
| 1242 ASSERT_TRUE(childPaintLayer); |
| 1243 childMapping = childPaintLayer->compositedLayerMapping(); |
| 1244 ASSERT_TRUE(childMapping); |
| 1245 EXPECT_FALSE(childMapping->ancestorClippingLayer()); |
| 1246 EXPECT_FALSE(childMapping->ancestorClippingMaskLayer()); |
| 1247 } |
| 1248 |
1168 } // namespace blink | 1249 } // namespace blink |
OLD | NEW |