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 keep unaffected. | |
bokan
2017/04/07 17:39:03
nit: keep -> remain
yigu
2017/04/07 19:26:27
Done.
| |
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)) { |
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()); |
1105 | |
1106 // With "will-change:transform" we composite elements with | |
1107 // LCDTextRelatedReasons only. For elements with other | |
1108 // NonCompositedReasons, we don't create scrollingLayer for their | |
1109 // CompositedLayerMapping therefore they don't get composited. | |
1110 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | |
1111 forceFullCompositingUpdate(); | |
1112 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1113 reason); | |
1114 container->setAttribute("style", "will-change:transform"); | |
bokan
2017/04/07 17:39:03
Again, split this out into a separate test that ru
yigu
2017/04/07 19:26:27
Done.
| |
1115 forceFullCompositingUpdate(); | |
1116 ASSERT_FALSE( | |
1117 scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1118 reason); | |
1098 } | 1119 } |
1099 } | 1120 } |
1100 }; | 1121 }; |
1101 | 1122 |
1102 INSTANTIATE_TEST_CASE_P(All, | 1123 INSTANTIATE_TEST_CASE_P(All, |
1103 StyleRelatedMainThreadScrollingReasonTest, | 1124 NonCompositedMainThreadScrollingReasonTest, |
1104 ::testing::Bool()); | 1125 ::testing::Bool()); |
1105 | 1126 |
1106 // TODO(yigu): This test and all other style realted main thread scrolling | 1127 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransparentTest) { |
1107 // reason tests below have been disabled due to https://crbug.com/701355. | 1128 testNonCompositedReasons("transparent", |
1108 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransparentTest) { | 1129 MainThreadScrollingReason::kHasOpacityAndLCDText); |
1109 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); | |
1110 } | 1130 } |
1111 | 1131 |
1112 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransformTest) { | 1132 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { |
1113 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); | 1133 testNonCompositedReasons("transform", |
1134 MainThreadScrollingReason::kHasTransformAndLCDText); | |
1114 } | 1135 } |
1115 | 1136 |
1116 TEST_P(StyleRelatedMainThreadScrollingReasonTest, | 1137 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1117 DISABLED_BackgroundNotOpaqueTest) { | 1138 testNonCompositedReasons( |
1118 testStyle("background-not-opaque", | 1139 "background-not-opaque", |
1119 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); | 1140 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
1120 } | 1141 } |
1121 | 1142 |
1122 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BorderRadiusTest) { | 1143 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { |
1123 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); | 1144 testNonCompositedReasons("border-radius", |
1145 MainThreadScrollingReason::kHasBorderRadius); | |
1124 } | 1146 } |
1125 | 1147 |
1126 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipTest) { | 1148 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { |
1127 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); | 1149 testNonCompositedReasons("clip", |
1150 MainThreadScrollingReason::kHasClipRelatedProperty); | |
1128 } | 1151 } |
1129 | 1152 |
1130 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { | 1153 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipPathTest) { |
1131 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; | 1154 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
1132 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1155 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1133 Document* document = frame()->document(); | 1156 Document* document = frame()->document(); |
1134 // Test ancestor with ClipPath | 1157 // Test ancestor with ClipPath |
1135 Element* element = document->body(); | 1158 Element* element = document->body(); |
1136 DCHECK(element); | 1159 DCHECK(element); |
1137 element->setAttribute(HTMLNames::styleAttr, | 1160 element->setAttribute(HTMLNames::styleAttr, |
1138 "clip-path:circle(115px at 20px 20px);"); | 1161 "clip-path:circle(115px at 20px 20px);"); |
1162 Element* container = document->getElementById("scroller1"); | |
1163 DCHECK(container); | |
1139 forceFullCompositingUpdate(); | 1164 forceFullCompositingUpdate(); |
1140 | 1165 |
1166 PaintLayerScrollableArea* scrollableArea = | |
1167 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); | |
1168 ASSERT_TRUE(scrollableArea); | |
1169 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1170 reason); | |
1171 | |
1141 FrameView* frameView = frame()->view(); | 1172 FrameView* frameView = frame()->view(); |
1142 ASSERT_TRUE(frameView); | 1173 ASSERT_TRUE(frameView); |
1143 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1174 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1144 | 1175 |
1145 // Remove clip path from ancestor. | 1176 // Remove clip path from ancestor. |
1146 element->removeAttribute(HTMLNames::styleAttr); | 1177 element->removeAttribute(HTMLNames::styleAttr); |
1147 forceFullCompositingUpdate(); | 1178 forceFullCompositingUpdate(); |
1148 | 1179 |
1180 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1181 reason); | |
1149 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1182 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1150 | 1183 |
1151 // Test descendant with ClipPath | 1184 // Test descendant with ClipPath |
1152 element = document->getElementById("content1"); | 1185 element = document->getElementById("content1"); |
1153 DCHECK(element); | 1186 DCHECK(element); |
1154 element->setAttribute(HTMLNames::styleAttr, | 1187 element->setAttribute(HTMLNames::styleAttr, |
1155 "clip-path:circle(115px at 20px 20px);"); | 1188 "clip-path:circle(115px at 20px 20px);"); |
1156 forceFullCompositingUpdate(); | 1189 forceFullCompositingUpdate(); |
1157 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1190 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
1191 reason); | |
1192 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | |
1158 | 1193 |
1159 // Remove clip path from descendant. | 1194 // Remove clip path from descendant. |
1160 element->removeAttribute(HTMLNames::styleAttr); | 1195 element->removeAttribute(HTMLNames::styleAttr); |
1161 forceFullCompositingUpdate(); | 1196 forceFullCompositingUpdate(); |
1197 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & | |
1198 reason); | |
1162 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1199 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1163 } | 1200 } |
1164 | 1201 |
1165 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_LCDTextEnabledTest) { | 1202 TEST_P(NonCompositedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
1166 testStyle("transparent border-radius", | 1203 testNonCompositedReasons("transparent border-radius", |
1167 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1204 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1168 MainThreadScrollingReason::kHasBorderRadius); | 1205 MainThreadScrollingReason::kHasBorderRadius); |
1169 } | 1206 } |
1170 | 1207 |
1171 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BoxShadowTest) { | 1208 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { |
1172 testStyle("box-shadow", | 1209 testNonCompositedReasons( |
1173 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1210 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1174 } | 1211 } |
1175 | 1212 |
1176 } // namespace blink | 1213 } // namespace blink |
OLD | NEW |