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

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: Only keep the NonStackingContext reason 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;
1056 1057
1057 protected: 1058 protected:
1058 NonCompositedMainThreadScrollingReasonTest() { 1059 NonCompositedMainThreadScrollingReasonTest() {
1059 RegisterMockedHttpURLLoad("two_scrollable_area.html"); 1060 RegisterMockedHttpURLLoad("two_scrollable_area.html");
1060 NavigateTo(base_url_ + "two_scrollable_area.html"); 1061 NavigateTo(base_url_ + "two_scrollable_area.html");
1061 } 1062 }
1062 void TestNonCompositedReasons(const std::string& target, 1063 void TestNonCompositedReasons(const std::string& target,
1063 const uint32_t reason) { 1064 const uint32_t reason) {
1064 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled( 1065 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(
1065 false); 1066 false);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 TestNonCompositedReasons("transparent border-radius", 1201 TestNonCompositedReasons("transparent border-radius",
1201 MainThreadScrollingReason::kHasOpacityAndLCDText | 1202 MainThreadScrollingReason::kHasOpacityAndLCDText |
1202 MainThreadScrollingReason::kHasBorderRadius); 1203 MainThreadScrollingReason::kHasBorderRadius);
1203 } 1204 }
1204 1205
1205 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { 1206 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) {
1206 TestNonCompositedReasons( 1207 TestNonCompositedReasons(
1207 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); 1208 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer);
1208 } 1209 }
1209 1210
1211 TEST_P(NonCompositedMainThreadScrollingReasonTest, StackingContextTest) {
1212 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false);
1213
1214 Document* document = GetFrame()->GetDocument();
1215 Element* container = document->getElementById("scroller1");
1216 ASSERT_TRUE(container);
1217
1218 ForceFullCompositingUpdate();
1219
1220 // If a scroller contains all its children, it's not a stacking context.
1221 PaintLayerScrollableArea* scrollable_area =
1222 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea();
1223 ASSERT_TRUE(scrollable_area);
1224 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() &
1225 MainThreadScrollingReason::kIsNotStackingContextAndLCDText);
1226
1227 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true);
1228 ForceFullCompositingUpdate();
1229 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() &
1230 MainThreadScrollingReason::kIsNotStackingContextAndLCDText);
1231 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false);
1232
1233 // Adding "contain: paint" to force a stacking context leads to promotion.
1234 container->setAttribute("style", "contain: paint", ASSERT_NO_EXCEPTION);
1235 ForceFullCompositingUpdate();
1236
1237 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons());
1238 }
1239
1210 TEST_P(NonCompositedMainThreadScrollingReasonTest, 1240 TEST_P(NonCompositedMainThreadScrollingReasonTest,
1211 CompositedWithLCDTextRelatedReasonsTest) { 1241 CompositedWithLCDTextRelatedReasonsTest) {
1212 // With "will-change:transform" we composite elements with 1242 // With "will-change:transform" we composite elements with
1213 // LCDTextRelatedReasons only. For elements with other 1243 // LCDTextRelatedReasons only. For elements with other
1214 // NonCompositedReasons, we don't create scrollingLayer for their 1244 // NonCompositedReasons, we don't create scrollingLayer for their
1215 // CompositedLayerMapping therefore they don't get composited. 1245 // CompositedLayerMapping therefore they don't get composited.
1216 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); 1246 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false);
1217 Document* document = GetFrame()->GetDocument(); 1247 Document* document = GetFrame()->GetDocument();
1218 Element* container = document->getElementById("scroller1"); 1248 Element* container = document->getElementById("scroller1");
1219 ASSERT_TRUE(container); 1249 ASSERT_TRUE(container);
(...skipping 13 matching lines...) Expand all
1233 ForceFullCompositingUpdate(); 1263 ForceFullCompositingUpdate();
1234 PaintLayerScrollableArea* scrollable_area2 = 1264 PaintLayerScrollableArea* scrollable_area2 =
1235 ToLayoutBoxModelObject(container2->GetLayoutObject()) 1265 ToLayoutBoxModelObject(container2->GetLayoutObject())
1236 ->GetScrollableArea(); 1266 ->GetScrollableArea();
1237 ASSERT_TRUE(scrollable_area2); 1267 ASSERT_TRUE(scrollable_area2);
1238 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() & 1268 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() &
1239 MainThreadScrollingReason::kHasBorderRadius); 1269 MainThreadScrollingReason::kHasBorderRadius);
1240 } 1270 }
1241 1271
1242 } // namespace blink 1272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698