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 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 | 1049 |
1050 protected: | 1050 protected: |
1051 StyleRelatedMainThreadScrollingReasonTest() { | 1051 StyleRelatedMainThreadScrollingReasonTest() { |
1052 registerMockedHttpURLLoad("two_scrollable_area.html"); | 1052 registerMockedHttpURLLoad("two_scrollable_area.html"); |
1053 navigateTo(m_baseURL + "two_scrollable_area.html"); | 1053 navigateTo(m_baseURL + "two_scrollable_area.html"); |
1054 } | 1054 } |
1055 void testStyle(const std::string& target, const uint32_t reason) { | 1055 void testStyle(const std::string& target, const uint32_t reason) { |
1056 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1056 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1057 Document* document = frame()->document(); | 1057 Document* document = frame()->document(); |
1058 Element* container = document->getElementById("scroller1"); | 1058 Element* container = document->getElementById("scroller1"); |
1059 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1059 DCHECK(container); |
1060 container = document->getElementById("scroller2"); | |
1061 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1060 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1062 forceFullCompositingUpdate(); | 1061 forceFullCompositingUpdate(); |
1063 | 1062 |
| 1063 // Add or remove style related attribute from a scroller shouldn't |
| 1064 // affect the main frame which is supposed to scroll on impl during |
| 1065 // this test. |
| 1066 PaintLayerScrollableArea* scrollableArea = |
| 1067 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
| 1068 ASSERT_TRUE(scrollableArea); |
| 1069 ASSERT_TRUE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1070 reason); |
| 1071 |
| 1072 container = document->getElementById("scroller2"); |
| 1073 scrollableArea = |
| 1074 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
| 1075 ASSERT_TRUE(scrollableArea); |
| 1076 // Different scrollable area should keep unaffected. |
| 1077 ASSERT_FALSE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1078 reason); |
| 1079 |
1064 FrameView* frameView = frame()->view(); | 1080 FrameView* frameView = frame()->view(); |
1065 ASSERT_TRUE(frameView); | 1081 ASSERT_TRUE(frameView); |
1066 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1082 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1067 | 1083 |
1068 // Remove the target attribute from one of the scrollers. | 1084 // Remove attribute from the scroller would lead to scroll on impl. |
1069 // Still need to scroll on main thread. | |
1070 container = document->getElementById("scroller1"); | 1085 container = document->getElementById("scroller1"); |
1071 DCHECK(container); | |
1072 | |
1073 container->removeAttribute("class"); | 1086 container->removeAttribute("class"); |
1074 forceFullCompositingUpdate(); | 1087 forceFullCompositingUpdate(); |
1075 | 1088 |
1076 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1089 scrollableArea = |
1077 | 1090 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
1078 // Remove attribute from the other scroller would lead to | 1091 ASSERT_TRUE(scrollableArea); |
1079 // scroll on impl. | 1092 ASSERT_FALSE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
1080 container = document->getElementById("scroller2"); | 1093 reason); |
1081 DCHECK(container); | |
1082 | |
1083 container->removeAttribute("class"); | |
1084 forceFullCompositingUpdate(); | |
1085 | |
1086 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1094 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1087 | 1095 |
1088 // Add target attribute would again lead to scroll on main thread | 1096 // Add target attribute would again lead to scroll on main thread |
1089 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1097 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1090 forceFullCompositingUpdate(); | 1098 forceFullCompositingUpdate(); |
1091 | 1099 |
1092 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1100 ASSERT_TRUE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1101 reason); |
| 1102 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1093 | 1103 |
1094 if ((reason & m_LCDTextRelatedReasons) && | 1104 if ((reason & m_LCDTextRelatedReasons) && |
1095 !(reason & ~m_LCDTextRelatedReasons)) { | 1105 !(reason & ~m_LCDTextRelatedReasons)) { |
1096 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | 1106 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
1097 forceFullCompositingUpdate(); | 1107 forceFullCompositingUpdate(); |
| 1108 ASSERT_FALSE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1109 reason); |
1098 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | 1110 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); |
1099 } | 1111 } |
1100 } | 1112 } |
1101 }; | 1113 }; |
1102 | 1114 |
1103 INSTANTIATE_TEST_CASE_P(All, | 1115 INSTANTIATE_TEST_CASE_P(All, |
1104 StyleRelatedMainThreadScrollingReasonTest, | 1116 StyleRelatedMainThreadScrollingReasonTest, |
1105 ::testing::Bool()); | 1117 ::testing::Bool()); |
1106 | 1118 |
1107 // TODO(yigu): This test and all other style realted main thread scrolling | 1119 TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { |
1108 // reason tests below have been disabled due to https://crbug.com/701355. | |
1109 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransparentTest) { | |
1110 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); | 1120 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); |
1111 } | 1121 } |
1112 | 1122 |
1113 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransformTest) { | 1123 TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { |
1114 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); | 1124 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); |
1115 } | 1125 } |
1116 | 1126 |
1117 TEST_P(StyleRelatedMainThreadScrollingReasonTest, | 1127 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1118 DISABLED_BackgroundNotOpaqueTest) { | |
1119 testStyle("background-not-opaque", | 1128 testStyle("background-not-opaque", |
1120 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); | 1129 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
1121 } | 1130 } |
1122 | 1131 |
1123 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BorderRadiusTest) { | 1132 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { |
1124 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); | 1133 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); |
1125 } | 1134 } |
1126 | 1135 |
1127 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipTest) { | 1136 TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { |
1128 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); | 1137 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); |
1129 } | 1138 } |
1130 | 1139 |
1131 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { | 1140 TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { |
1132 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; | 1141 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
1133 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1142 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1134 Document* document = frame()->document(); | 1143 Document* document = frame()->document(); |
1135 // Test ancestor with ClipPath | 1144 // Test ancestor with ClipPath |
1136 Element* element = document->body(); | 1145 Element* element = document->body(); |
1137 DCHECK(element); | 1146 DCHECK(element); |
1138 element->setAttribute(HTMLNames::styleAttr, | 1147 element->setAttribute(HTMLNames::styleAttr, |
1139 "clip-path:circle(115px at 20px 20px);"); | 1148 "clip-path:circle(115px at 20px 20px);"); |
| 1149 Element* container = document->getElementById("scroller1"); |
| 1150 DCHECK(container); |
1140 forceFullCompositingUpdate(); | 1151 forceFullCompositingUpdate(); |
1141 | 1152 |
| 1153 PaintLayerScrollableArea* scrollableArea = |
| 1154 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
| 1155 ASSERT_TRUE(scrollableArea); |
| 1156 ASSERT_TRUE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1157 reason); |
| 1158 |
1142 FrameView* frameView = frame()->view(); | 1159 FrameView* frameView = frame()->view(); |
1143 ASSERT_TRUE(frameView); | 1160 ASSERT_TRUE(frameView); |
1144 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1161 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1145 | 1162 |
1146 // Remove clip path from ancestor. | 1163 // Remove clip path from ancestor. |
1147 element->removeAttribute(HTMLNames::styleAttr); | 1164 element->removeAttribute(HTMLNames::styleAttr); |
1148 forceFullCompositingUpdate(); | 1165 forceFullCompositingUpdate(); |
1149 | 1166 |
| 1167 ASSERT_FALSE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1168 reason); |
1150 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1169 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1151 | 1170 |
1152 // Test descendant with ClipPath | 1171 // Test descendant with ClipPath |
1153 element = document->getElementById("content1"); | 1172 element = document->getElementById("content1"); |
1154 DCHECK(element); | 1173 DCHECK(element); |
1155 element->setAttribute(HTMLNames::styleAttr, | 1174 element->setAttribute(HTMLNames::styleAttr, |
1156 "clip-path:circle(115px at 20px 20px);"); | 1175 "clip-path:circle(115px at 20px 20px);"); |
1157 forceFullCompositingUpdate(); | 1176 forceFullCompositingUpdate(); |
1158 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1177 ASSERT_TRUE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1178 reason); |
| 1179 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1159 | 1180 |
1160 // Remove clip path from descendant. | 1181 // Remove clip path from descendant. |
1161 element->removeAttribute(HTMLNames::styleAttr); | 1182 element->removeAttribute(HTMLNames::styleAttr); |
1162 forceFullCompositingUpdate(); | 1183 forceFullCompositingUpdate(); |
| 1184 ASSERT_FALSE(scrollableArea->getStyleRelatedMainThreadScrollingReasons() & |
| 1185 reason); |
1163 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1186 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1164 } | 1187 } |
1165 | 1188 |
1166 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_LCDTextEnabledTest) { | 1189 TEST_P(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
1167 testStyle("transparent border-radius", | 1190 testStyle("transparent border-radius", |
1168 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1191 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1169 MainThreadScrollingReason::kHasBorderRadius); | 1192 MainThreadScrollingReason::kHasBorderRadius); |
1170 } | 1193 } |
1171 | 1194 |
1172 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BoxShadowTest) { | 1195 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) { |
1173 testStyle("box-shadow", | 1196 testStyle("box-shadow", |
1174 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1197 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1175 } | 1198 } |
1176 | 1199 |
1177 } // namespace blink | 1200 } // namespace blink |
OLD | NEW |