OLD | NEW |
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 Loading... |
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::kHasOverflowClipAndLCDText; |
1056 | 1058 |
1057 protected: | 1059 protected: |
1058 NonCompositedMainThreadScrollingReasonTest() { | 1060 NonCompositedMainThreadScrollingReasonTest() { |
1059 RegisterMockedHttpURLLoad("two_scrollable_area.html"); | 1061 RegisterMockedHttpURLLoad("two_scrollable_area.html"); |
1060 NavigateTo(base_url_ + "two_scrollable_area.html"); | 1062 NavigateTo(base_url_ + "two_scrollable_area.html"); |
1061 } | 1063 } |
1062 void TestNonCompositedReasons(const std::string& target, | 1064 void TestNonCompositedReasons(const std::string& target, |
1063 const uint32_t reason) { | 1065 const uint32_t reason) { |
1064 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled( | 1066 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled( |
1065 false); | 1067 false); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 } | 1129 } |
1128 | 1130 |
1129 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { | 1131 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { |
1130 TestNonCompositedReasons("transform", | 1132 TestNonCompositedReasons("transform", |
1131 MainThreadScrollingReason::kHasTransformAndLCDText); | 1133 MainThreadScrollingReason::kHasTransformAndLCDText); |
1132 } | 1134 } |
1133 | 1135 |
1134 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { | 1136 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1135 TestNonCompositedReasons( | 1137 TestNonCompositedReasons( |
1136 "background-not-opaque", | 1138 "background-not-opaque", |
1137 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); | 1139 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText | |
| 1140 MainThreadScrollingReason::kHasOverflowClipAndLCDText); |
1138 } | 1141 } |
1139 | 1142 |
1140 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { | 1143 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { |
1141 TestNonCompositedReasons("border-radius", | 1144 TestNonCompositedReasons("border-radius", |
1142 MainThreadScrollingReason::kHasBorderRadius); | 1145 MainThreadScrollingReason::kHasBorderRadius); |
1143 } | 1146 } |
1144 | 1147 |
1145 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { | 1148 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { |
1146 TestNonCompositedReasons("clip", | 1149 TestNonCompositedReasons("clip", |
1147 MainThreadScrollingReason::kHasClipRelatedProperty); | 1150 MainThreadScrollingReason::kHasClipRelatedProperty); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 TestNonCompositedReasons("transparent border-radius", | 1203 TestNonCompositedReasons("transparent border-radius", |
1201 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1204 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1202 MainThreadScrollingReason::kHasBorderRadius); | 1205 MainThreadScrollingReason::kHasBorderRadius); |
1203 } | 1206 } |
1204 | 1207 |
1205 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { | 1208 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { |
1206 TestNonCompositedReasons( | 1209 TestNonCompositedReasons( |
1207 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1210 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1208 } | 1211 } |
1209 | 1212 |
| 1213 TEST_P(NonCompositedMainThreadScrollingReasonTest, StackingContextTest) { |
| 1214 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
| 1215 |
| 1216 Document* document = GetFrame()->GetDocument(); |
| 1217 Element* container = document->getElementById("scroller1"); |
| 1218 ASSERT_TRUE(container); |
| 1219 |
| 1220 ForceFullCompositingUpdate(); |
| 1221 |
| 1222 // If a scroller contains all its children, it's not a stacking context. |
| 1223 PaintLayerScrollableArea* scrollable_area = |
| 1224 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea(); |
| 1225 ASSERT_TRUE(scrollable_area); |
| 1226 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & |
| 1227 MainThreadScrollingReason::kIsNotStackingContextAndLCDText); |
| 1228 |
| 1229 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true); |
| 1230 ForceFullCompositingUpdate(); |
| 1231 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & |
| 1232 MainThreadScrollingReason::kIsNotStackingContextAndLCDText); |
| 1233 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
| 1234 |
| 1235 // Adding "contain: paint" to force a stacking context leads to promotion. |
| 1236 container->setAttribute("style", "contain: paint", ASSERT_NO_EXCEPTION); |
| 1237 ForceFullCompositingUpdate(); |
| 1238 |
| 1239 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons()); |
| 1240 } |
| 1241 |
1210 TEST_P(NonCompositedMainThreadScrollingReasonTest, | 1242 TEST_P(NonCompositedMainThreadScrollingReasonTest, |
1211 CompositedWithLCDTextRelatedReasonsTest) { | 1243 CompositedWithLCDTextRelatedReasonsTest) { |
1212 // With "will-change:transform" we composite elements with | 1244 // With "will-change:transform" we composite elements with |
1213 // LCDTextRelatedReasons only. For elements with other | 1245 // LCDTextRelatedReasons only. For elements with other |
1214 // NonCompositedReasons, we don't create scrollingLayer for their | 1246 // NonCompositedReasons, we don't create scrollingLayer for their |
1215 // CompositedLayerMapping therefore they don't get composited. | 1247 // CompositedLayerMapping therefore they don't get composited. |
1216 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 1248 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
1217 Document* document = GetFrame()->GetDocument(); | 1249 Document* document = GetFrame()->GetDocument(); |
1218 Element* container = document->getElementById("scroller1"); | 1250 Element* container = document->getElementById("scroller1"); |
1219 ASSERT_TRUE(container); | 1251 ASSERT_TRUE(container); |
(...skipping 13 matching lines...) Expand all Loading... |
1233 ForceFullCompositingUpdate(); | 1265 ForceFullCompositingUpdate(); |
1234 PaintLayerScrollableArea* scrollable_area2 = | 1266 PaintLayerScrollableArea* scrollable_area2 = |
1235 ToLayoutBoxModelObject(container2->GetLayoutObject()) | 1267 ToLayoutBoxModelObject(container2->GetLayoutObject()) |
1236 ->GetScrollableArea(); | 1268 ->GetScrollableArea(); |
1237 ASSERT_TRUE(scrollable_area2); | 1269 ASSERT_TRUE(scrollable_area2); |
1238 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() & | 1270 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() & |
1239 MainThreadScrollingReason::kHasBorderRadius); | 1271 MainThreadScrollingReason::kHasBorderRadius); |
1240 } | 1272 } |
1241 | 1273 |
1242 } // namespace blink | 1274 } // namespace blink |
OLD | NEW |