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

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

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

Powered by Google App Engine
This is Rietveld 408576698