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

Side by Side Diff: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp

Issue 2841603003: Record non-stacking-context as main thread scrolling reasons (Closed)
Patch Set: Update reason name Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 web_scroll_layer->MainThreadScrollingReasons() & 1045 web_scroll_layer->MainThreadScrollingReasons() &
1046 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); 1046 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects);
1047 } 1047 }
1048 } 1048 }
1049 1049
1050 class NonCompositedMainThreadScrollingReasonTest 1050 class NonCompositedMainThreadScrollingReasonTest
1051 : public ScrollingCoordinatorTest { 1051 : public ScrollingCoordinatorTest {
1052 static const uint32_t kLCDTextRelatedReasons = 1052 static const uint32_t kLCDTextRelatedReasons =
1053 MainThreadScrollingReason::kHasOpacityAndLCDText | 1053 MainThreadScrollingReason::kHasOpacityAndLCDText |
1054 MainThreadScrollingReason::kHasTransformAndLCDText | 1054 MainThreadScrollingReason::kHasTransformAndLCDText |
1055 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; 1055 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText |
1056 MainThreadScrollingReason::kIsNotStackingContextAndLCDText |
1057 MainThreadScrollingReason::
1058 kHasOverflowClipAndLayoutObjectBackgroundNotOpaqueAndLCDText;
1056 1059
1057 protected: 1060 protected:
1058 NonCompositedMainThreadScrollingReasonTest() { 1061 NonCompositedMainThreadScrollingReasonTest() {
1059 RegisterMockedHttpURLLoad("two_scrollable_area.html"); 1062 RegisterMockedHttpURLLoad("two_scrollable_area.html");
1060 NavigateTo(base_url_ + "two_scrollable_area.html"); 1063 NavigateTo(base_url_ + "two_scrollable_area.html");
1061 } 1064 }
1062 void TestNonCompositedReasons(const std::string& target, 1065 void TestNonCompositedReasons(const std::string& target,
1063 const uint32_t reason) { 1066 const uint32_t reason) {
1064 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled( 1067 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(
1065 false); 1068 false);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 } 1130 }
1128 1131
1129 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { 1132 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) {
1130 TestNonCompositedReasons("transform", 1133 TestNonCompositedReasons("transform",
1131 MainThreadScrollingReason::kHasTransformAndLCDText); 1134 MainThreadScrollingReason::kHasTransformAndLCDText);
1132 } 1135 }
1133 1136
1134 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { 1137 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) {
1135 TestNonCompositedReasons( 1138 TestNonCompositedReasons(
1136 "background-not-opaque", 1139 "background-not-opaque",
1137 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); 1140 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText |
1141 MainThreadScrollingReason::
1142 kHasOverflowClipAndLayoutObjectBackgroundNotOpaqueAndLCDText);
1138 } 1143 }
1139 1144
1140 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { 1145 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) {
1141 TestNonCompositedReasons("border-radius", 1146 TestNonCompositedReasons("border-radius",
1142 MainThreadScrollingReason::kHasBorderRadius); 1147 MainThreadScrollingReason::kHasBorderRadius);
1143 } 1148 }
1144 1149
1145 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { 1150 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) {
1146 TestNonCompositedReasons("clip", 1151 TestNonCompositedReasons("clip",
1147 MainThreadScrollingReason::kHasClipRelatedProperty); 1152 MainThreadScrollingReason::kHasClipRelatedProperty);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 TestNonCompositedReasons("transparent border-radius", 1205 TestNonCompositedReasons("transparent border-radius",
1201 MainThreadScrollingReason::kHasOpacityAndLCDText | 1206 MainThreadScrollingReason::kHasOpacityAndLCDText |
1202 MainThreadScrollingReason::kHasBorderRadius); 1207 MainThreadScrollingReason::kHasBorderRadius);
1203 } 1208 }
1204 1209
1205 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { 1210 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) {
1206 TestNonCompositedReasons( 1211 TestNonCompositedReasons(
1207 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); 1212 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer);
1208 } 1213 }
1209 1214
1215 TEST_P(NonCompositedMainThreadScrollingReasonTest, StackingContextTest) {
1216 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false);
1217
1218 Document* document = GetFrame()->GetDocument();
1219 Element* container = document->getElementById("scroller1");
1220 ASSERT_TRUE(container);
1221
1222 ForceFullCompositingUpdate();
1223
1224 // If a scroller contains all its children, it's not a stacking context.
1225 PaintLayerScrollableArea* scrollable_area =
1226 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea();
1227 ASSERT_TRUE(scrollable_area);
1228 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() &
1229 MainThreadScrollingReason::kIsNotStackingContextAndLCDText);
1230
1231 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true);
1232 ForceFullCompositingUpdate();
1233 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() &
1234 MainThreadScrollingReason::kIsNotStackingContextAndLCDText);
1235 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false);
1236
1237 // Adding "contain: paint" to force a stacking context leads to promotion.
1238 container->setAttribute("style", "contain: paint", ASSERT_NO_EXCEPTION);
1239 ForceFullCompositingUpdate();
1240
1241 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons());
1242 }
1243
1210 TEST_P(NonCompositedMainThreadScrollingReasonTest, 1244 TEST_P(NonCompositedMainThreadScrollingReasonTest,
1211 CompositedWithLCDTextRelatedReasonsTest) { 1245 CompositedWithLCDTextRelatedReasonsTest) {
1212 // With "will-change:transform" we composite elements with 1246 // With "will-change:transform" we composite elements with
1213 // LCDTextRelatedReasons only. For elements with other 1247 // LCDTextRelatedReasons only. For elements with other
1214 // NonCompositedReasons, we don't create scrollingLayer for their 1248 // NonCompositedReasons, we don't create scrollingLayer for their
1215 // CompositedLayerMapping therefore they don't get composited. 1249 // CompositedLayerMapping therefore they don't get composited.
1216 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); 1250 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false);
1217 Document* document = GetFrame()->GetDocument(); 1251 Document* document = GetFrame()->GetDocument();
1218 Element* container = document->getElementById("scroller1"); 1252 Element* container = document->getElementById("scroller1");
1219 ASSERT_TRUE(container); 1253 ASSERT_TRUE(container);
(...skipping 13 matching lines...) Expand all
1233 ForceFullCompositingUpdate(); 1267 ForceFullCompositingUpdate();
1234 PaintLayerScrollableArea* scrollable_area2 = 1268 PaintLayerScrollableArea* scrollable_area2 =
1235 ToLayoutBoxModelObject(container2->GetLayoutObject()) 1269 ToLayoutBoxModelObject(container2->GetLayoutObject())
1236 ->GetScrollableArea(); 1270 ->GetScrollableArea();
1237 ASSERT_TRUE(scrollable_area2); 1271 ASSERT_TRUE(scrollable_area2);
1238 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() & 1272 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() &
1239 MainThreadScrollingReason::kHasBorderRadius); 1273 MainThreadScrollingReason::kHasBorderRadius);
1240 } 1274 }
1241 1275
1242 } // namespace blink 1276 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698