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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1032 } else { | 1032 } else { |
1033 ASSERT_TRUE(scrollLayer); | 1033 ASSERT_TRUE(scrollLayer); |
1034 webScrollLayer = scrollLayer->platformLayer(); | 1034 webScrollLayer = scrollLayer->platformLayer(); |
1035 ASSERT_TRUE(webScrollLayer->scrollable()); | 1035 ASSERT_TRUE(webScrollLayer->scrollable()); |
1036 ASSERT_FALSE( | 1036 ASSERT_FALSE( |
1037 webScrollLayer->mainThreadScrollingReasons() & | 1037 webScrollLayer->mainThreadScrollingReasons() & |
1038 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 1038 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
1039 } | 1039 } |
1040 } | 1040 } |
1041 | 1041 |
1042 class StyleRelatedMainThreadScrollingReasonTest | 1042 class NonCompositedMainThreadScrollingReasonTest |
1043 : public ScrollingCoordinatorTest { | 1043 : public ScrollingCoordinatorTest { |
1044 static const uint32_t m_LCDTextRelatedReasons = | 1044 static const uint32_t m_LCDTextRelatedReasons = |
1045 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1045 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1046 MainThreadScrollingReason::kHasTransformAndLCDText | | 1046 MainThreadScrollingReason::kHasTransformAndLCDText | |
1047 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; | 1047 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
1048 | 1048 |
1049 protected: | 1049 protected: |
1050 StyleRelatedMainThreadScrollingReasonTest() { | 1050 NonCompositedMainThreadScrollingReasonTest() { |
1051 registerMockedHttpURLLoad("two_scrollable_area.html"); | 1051 registerMockedHttpURLLoad("two_scrollable_area.html"); |
1052 navigateTo(m_baseURL + "two_scrollable_area.html"); | 1052 navigateTo(m_baseURL + "two_scrollable_area.html"); |
1053 } | 1053 } |
1054 void testStyle(const std::string& target, const uint32_t reason) { | 1054 void testNonCompositedReasons(const std::string& target, |
1055 const uint32_t reason) { | |
1055 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1056 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1056 Document* document = frame()->document(); | 1057 Document* document = frame()->document(); |
1057 Element* container = document->getElementById("scroller1"); | 1058 Element* container = document->getElementById("scroller1"); |
1058 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1059 DCHECK(container); |
1059 container = document->getElementById("scroller2"); | |
1060 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1060 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1061 forceFullCompositingUpdate(); | 1061 forceFullCompositingUpdate(); |
1062 | 1062 |
1063 PaintLayerScrollableArea* scrollableArea = | |
1064 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); | |
1065 ASSERT_TRUE(scrollableArea); | |
1066 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1067 reason); | |
1068 | |
1069 Element* container2 = document->getElementById("scroller2"); | |
1070 PaintLayerScrollableArea* scrollableArea2 = | |
1071 toLayoutBoxModelObject(container2->layoutObject())->getScrollableArea(); | |
1072 ASSERT_TRUE(scrollableArea2); | |
1073 // Different scrollable area should remain unaffected. | |
1074 ASSERT_FALSE(scrollableArea2->getNonCompositedMainThreadScrollingReasons() & | |
1075 reason); | |
1076 | |
1063 FrameView* frameView = frame()->view(); | 1077 FrameView* frameView = frame()->view(); |
1064 ASSERT_TRUE(frameView); | 1078 ASSERT_TRUE(frameView); |
1065 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1079 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1066 | 1080 |
1067 // Remove the target attribute from one of the scrollers. | 1081 // Remove attribute from the scroller 1 would lead to scroll on impl. |
1068 // Still need to scroll on main thread. | |
1069 container = document->getElementById("scroller1"); | |
1070 DCHECK(container); | |
1071 | |
1072 container->removeAttribute("class"); | 1082 container->removeAttribute("class"); |
1073 forceFullCompositingUpdate(); | 1083 forceFullCompositingUpdate(); |
1074 | 1084 |
1075 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1085 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
1076 | 1086 reason); |
1077 // Remove attribute from the other scroller would lead to | |
1078 // scroll on impl. | |
1079 container = document->getElementById("scroller2"); | |
1080 DCHECK(container); | |
1081 | |
1082 container->removeAttribute("class"); | |
1083 forceFullCompositingUpdate(); | |
1084 | |
1085 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1087 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1086 | 1088 |
1087 // Add target attribute would again lead to scroll on main thread | 1089 // Add target attribute would again lead to scroll on main thread |
1088 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1090 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1089 forceFullCompositingUpdate(); | 1091 forceFullCompositingUpdate(); |
1090 | 1092 |
1091 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1093 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
1094 reason); | |
1095 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | |
1092 | 1096 |
1093 if ((reason & m_LCDTextRelatedReasons) && | 1097 if ((reason & m_LCDTextRelatedReasons) && |
1094 !(reason & ~m_LCDTextRelatedReasons)) { | 1098 !(reason & ~m_LCDTextRelatedReasons)) { |
bokan
2017/04/07 21:05:57
We always provide just one reason right? This if c
yigu
2017/04/10 20:39:05
We may pass multiple reasons like the test LCDText
| |
1095 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | 1099 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
1096 forceFullCompositingUpdate(); | 1100 forceFullCompositingUpdate(); |
1101 ASSERT_FALSE( | |
1102 scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1103 reason); | |
1097 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | 1104 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); |
1098 } | 1105 } |
1099 } | 1106 } |
1100 }; | 1107 }; |
1101 | 1108 |
1102 INSTANTIATE_TEST_CASE_P(All, | 1109 INSTANTIATE_TEST_CASE_P(All, |
1103 StyleRelatedMainThreadScrollingReasonTest, | 1110 NonCompositedMainThreadScrollingReasonTest, |
1104 ::testing::Bool()); | 1111 ::testing::Bool()); |
1105 | 1112 |
1106 // TODO(yigu): This test and all other style realted main thread scrolling | 1113 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransparentTest) { |
1107 // reason tests below have been disabled due to https://crbug.com/701355. | 1114 testNonCompositedReasons("transparent", |
1108 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransparentTest) { | 1115 MainThreadScrollingReason::kHasOpacityAndLCDText); |
1109 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); | |
1110 } | 1116 } |
1111 | 1117 |
1112 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransformTest) { | 1118 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { |
1113 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); | 1119 testNonCompositedReasons("transform", |
1120 MainThreadScrollingReason::kHasTransformAndLCDText); | |
1114 } | 1121 } |
1115 | 1122 |
1116 TEST_P(StyleRelatedMainThreadScrollingReasonTest, | 1123 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1117 DISABLED_BackgroundNotOpaqueTest) { | 1124 testNonCompositedReasons( |
1118 testStyle("background-not-opaque", | 1125 "background-not-opaque", |
1119 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); | 1126 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
1120 } | 1127 } |
1121 | 1128 |
1122 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BorderRadiusTest) { | 1129 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { |
1123 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); | 1130 testNonCompositedReasons("border-radius", |
1131 MainThreadScrollingReason::kHasBorderRadius); | |
1124 } | 1132 } |
1125 | 1133 |
1126 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipTest) { | 1134 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { |
1127 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); | 1135 testNonCompositedReasons("clip", |
1136 MainThreadScrollingReason::kHasClipRelatedProperty); | |
1128 } | 1137 } |
1129 | 1138 |
1130 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { | 1139 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipPathTest) { |
1131 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; | 1140 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
bokan
2017/04/07 21:05:57
reason -> clipReason or similar.
yigu
2017/04/10 20:39:05
Done.
| |
1132 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1141 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1133 Document* document = frame()->document(); | 1142 Document* document = frame()->document(); |
1134 // Test ancestor with ClipPath | 1143 // Test ancestor with ClipPath |
1135 Element* element = document->body(); | 1144 Element* element = document->body(); |
1136 DCHECK(element); | 1145 DCHECK(element); |
1137 element->setAttribute(HTMLNames::styleAttr, | 1146 element->setAttribute(HTMLNames::styleAttr, |
1138 "clip-path:circle(115px at 20px 20px);"); | 1147 "clip-path:circle(115px at 20px 20px);"); |
1148 Element* container = document->getElementById("scroller1"); | |
1149 DCHECK(container); | |
1139 forceFullCompositingUpdate(); | 1150 forceFullCompositingUpdate(); |
1140 | 1151 |
1152 PaintLayerScrollableArea* scrollableArea = | |
1153 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); | |
1154 ASSERT_TRUE(scrollableArea); | |
1155 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1156 reason); | |
1157 | |
1141 FrameView* frameView = frame()->view(); | 1158 FrameView* frameView = frame()->view(); |
1142 ASSERT_TRUE(frameView); | 1159 ASSERT_TRUE(frameView); |
1143 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1160 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1144 | 1161 |
1145 // Remove clip path from ancestor. | 1162 // Remove clip path from ancestor. |
1146 element->removeAttribute(HTMLNames::styleAttr); | 1163 element->removeAttribute(HTMLNames::styleAttr); |
1147 forceFullCompositingUpdate(); | 1164 forceFullCompositingUpdate(); |
1148 | 1165 |
1166 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1167 reason); | |
1149 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1168 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1150 | 1169 |
1151 // Test descendant with ClipPath | 1170 // Test descendant with ClipPath |
1152 element = document->getElementById("content1"); | 1171 element = document->getElementById("content1"); |
1153 DCHECK(element); | 1172 DCHECK(element); |
1154 element->setAttribute(HTMLNames::styleAttr, | 1173 element->setAttribute(HTMLNames::styleAttr, |
1155 "clip-path:circle(115px at 20px 20px);"); | 1174 "clip-path:circle(115px at 20px 20px);"); |
1156 forceFullCompositingUpdate(); | 1175 forceFullCompositingUpdate(); |
1157 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1176 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
1177 reason); | |
1178 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | |
1158 | 1179 |
1159 // Remove clip path from descendant. | 1180 // Remove clip path from descendant. |
1160 element->removeAttribute(HTMLNames::styleAttr); | 1181 element->removeAttribute(HTMLNames::styleAttr); |
1161 forceFullCompositingUpdate(); | 1182 forceFullCompositingUpdate(); |
1183 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1184 reason); | |
1162 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1185 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1163 } | 1186 } |
1164 | 1187 |
1165 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_LCDTextEnabledTest) { | 1188 TEST_P(NonCompositedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
1166 testStyle("transparent border-radius", | 1189 testNonCompositedReasons("transparent border-radius", |
1167 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1190 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1168 MainThreadScrollingReason::kHasBorderRadius); | 1191 MainThreadScrollingReason::kHasBorderRadius); |
1169 } | 1192 } |
1170 | 1193 |
1171 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BoxShadowTest) { | 1194 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { |
1172 testStyle("box-shadow", | 1195 testNonCompositedReasons( |
1173 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1196 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1197 } | |
1198 | |
1199 TEST_P(NonCompositedMainThreadScrollingReasonTest, | |
1200 CompositedWithLCDTextRelatedReasonsTest) { | |
1201 // With "will-change:transform" we composite elements with | |
1202 // LCDTextRelatedReasons only. For elements with other | |
1203 // NonCompositedReasons, we don't create scrollingLayer for their | |
1204 // CompositedLayerMapping therefore they don't get composited. | |
1205 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | |
1206 Document* document = frame()->document(); | |
1207 Element* container = document->getElementById("scroller1"); | |
1208 DCHECK(container); | |
1209 container->setAttribute("class", "composited transparent", | |
1210 ASSERT_NO_EXCEPTION); | |
1211 forceFullCompositingUpdate(); | |
1212 | |
1213 PaintLayerScrollableArea* scrollableArea = | |
1214 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); | |
1215 ASSERT_TRUE(scrollableArea); | |
1216 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
bokan
2017/04/07 21:05:57
Just ASSERT_FALSE(getNonCompositedMainThreadScroll
yigu
2017/04/10 20:39:05
Done.
| |
1217 MainThreadScrollingReason::kHasOpacityAndLCDText); | |
1218 | |
1219 Element* container2 = document->getElementById("scroller2"); | |
1220 DCHECK(container); | |
1221 container2->setAttribute("class", "composited border-radius", | |
1222 ASSERT_NO_EXCEPTION); | |
1223 forceFullCompositingUpdate(); | |
1224 PaintLayerScrollableArea* scrollableArea2 = | |
1225 toLayoutBoxModelObject(container2->layoutObject())->getScrollableArea(); | |
1226 ASSERT_TRUE(scrollableArea2); | |
1227 ASSERT_TRUE(scrollableArea2->getNonCompositedMainThreadScrollingReasons() & | |
1228 MainThreadScrollingReason::kHasBorderRadius); | |
1174 } | 1229 } |
1175 | 1230 |
1176 } // namespace blink | 1231 } // namespace blink |
OLD | NEW |