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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 } else { | 1033 } else { |
1034 ASSERT_TRUE(scrollLayer); | 1034 ASSERT_TRUE(scrollLayer); |
1035 webScrollLayer = scrollLayer->platformLayer(); | 1035 webScrollLayer = scrollLayer->platformLayer(); |
1036 ASSERT_TRUE(webScrollLayer->scrollable()); | 1036 ASSERT_TRUE(webScrollLayer->scrollable()); |
1037 ASSERT_FALSE( | 1037 ASSERT_FALSE( |
1038 webScrollLayer->mainThreadScrollingReasons() & | 1038 webScrollLayer->mainThreadScrollingReasons() & |
1039 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 1039 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
1040 } | 1040 } |
1041 } | 1041 } |
1042 | 1042 |
1043 class StyleRelatedMainThreadScrollingReasonTest | 1043 class NonCompositedMainThreadScrollingReasonTest |
1044 : public ScrollingCoordinatorTest { | 1044 : public ScrollingCoordinatorTest { |
1045 static const uint32_t m_LCDTextRelatedReasons = | 1045 static const uint32_t m_LCDTextRelatedReasons = |
1046 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1046 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1047 MainThreadScrollingReason::kHasTransformAndLCDText | | 1047 MainThreadScrollingReason::kHasTransformAndLCDText | |
1048 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; | 1048 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
1049 | 1049 |
1050 protected: | 1050 protected: |
1051 StyleRelatedMainThreadScrollingReasonTest() { | 1051 NonCompositedMainThreadScrollingReasonTest() { |
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->getNonCompositedMainThreadScrollingReasons() & |
| 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->getNonCompositedMainThreadScrollingReasons() & |
| 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->getNonCompositedMainThreadScrollingReasons() & |
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->getNonCompositedMainThreadScrollingReasons() & |
| 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( |
| 1109 scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| 1110 reason); |
1098 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | 1111 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); |
1099 } | 1112 } |
1100 } | 1113 } |
1101 }; | 1114 }; |
1102 | 1115 |
1103 INSTANTIATE_TEST_CASE_P(All, | 1116 INSTANTIATE_TEST_CASE_P(All, |
1104 StyleRelatedMainThreadScrollingReasonTest, | 1117 NonCompositedMainThreadScrollingReasonTest, |
1105 ::testing::Bool()); | 1118 ::testing::Bool()); |
1106 | 1119 |
1107 // TODO(yigu): This test and all other style realted main thread scrolling | 1120 TEST_P(NonCompositedMainThreadScrollingReasonTest, 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); | 1121 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); |
1111 } | 1122 } |
1112 | 1123 |
1113 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_TransformTest) { | 1124 TEST_P(NonCompositedMainThreadScrollingReasonTest, TransformTest) { |
1114 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); | 1125 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); |
1115 } | 1126 } |
1116 | 1127 |
1117 TEST_P(StyleRelatedMainThreadScrollingReasonTest, | 1128 TEST_P(NonCompositedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1118 DISABLED_BackgroundNotOpaqueTest) { | |
1119 testStyle("background-not-opaque", | 1129 testStyle("background-not-opaque", |
1120 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); | 1130 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
1121 } | 1131 } |
1122 | 1132 |
1123 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BorderRadiusTest) { | 1133 TEST_P(NonCompositedMainThreadScrollingReasonTest, BorderRadiusTest) { |
1124 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); | 1134 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); |
1125 } | 1135 } |
1126 | 1136 |
1127 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipTest) { | 1137 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { |
1128 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); | 1138 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); |
1129 } | 1139 } |
1130 | 1140 |
1131 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_ClipPathTest) { | 1141 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipPathTest) { |
1132 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; | 1142 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
1133 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1143 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1134 Document* document = frame()->document(); | 1144 Document* document = frame()->document(); |
1135 // Test ancestor with ClipPath | 1145 // Test ancestor with ClipPath |
1136 Element* element = document->body(); | 1146 Element* element = document->body(); |
1137 DCHECK(element); | 1147 DCHECK(element); |
1138 element->setAttribute(HTMLNames::styleAttr, | 1148 element->setAttribute(HTMLNames::styleAttr, |
1139 "clip-path:circle(115px at 20px 20px);"); | 1149 "clip-path:circle(115px at 20px 20px);"); |
| 1150 Element* container = document->getElementById("scroller1"); |
| 1151 DCHECK(container); |
1140 forceFullCompositingUpdate(); | 1152 forceFullCompositingUpdate(); |
1141 | 1153 |
| 1154 PaintLayerScrollableArea* scrollableArea = |
| 1155 toLayoutBoxModelObject(container->layoutObject())->getScrollableArea(); |
| 1156 ASSERT_TRUE(scrollableArea); |
| 1157 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| 1158 reason); |
| 1159 |
1142 FrameView* frameView = frame()->view(); | 1160 FrameView* frameView = frame()->view(); |
1143 ASSERT_TRUE(frameView); | 1161 ASSERT_TRUE(frameView); |
1144 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1162 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1145 | 1163 |
1146 // Remove clip path from ancestor. | 1164 // Remove clip path from ancestor. |
1147 element->removeAttribute(HTMLNames::styleAttr); | 1165 element->removeAttribute(HTMLNames::styleAttr); |
1148 forceFullCompositingUpdate(); | 1166 forceFullCompositingUpdate(); |
1149 | 1167 |
| 1168 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| 1169 reason); |
1150 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1170 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1151 | 1171 |
1152 // Test descendant with ClipPath | 1172 // Test descendant with ClipPath |
1153 element = document->getElementById("content1"); | 1173 element = document->getElementById("content1"); |
1154 DCHECK(element); | 1174 DCHECK(element); |
1155 element->setAttribute(HTMLNames::styleAttr, | 1175 element->setAttribute(HTMLNames::styleAttr, |
1156 "clip-path:circle(115px at 20px 20px);"); | 1176 "clip-path:circle(115px at 20px 20px);"); |
1157 forceFullCompositingUpdate(); | 1177 forceFullCompositingUpdate(); |
1158 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1178 ASSERT_TRUE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| 1179 reason); |
| 1180 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1159 | 1181 |
1160 // Remove clip path from descendant. | 1182 // Remove clip path from descendant. |
1161 element->removeAttribute(HTMLNames::styleAttr); | 1183 element->removeAttribute(HTMLNames::styleAttr); |
1162 forceFullCompositingUpdate(); | 1184 forceFullCompositingUpdate(); |
| 1185 ASSERT_FALSE(scrollableArea->getNonCompositedMainThreadScrollingReasons() & |
| 1186 reason); |
1163 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1187 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1164 } | 1188 } |
1165 | 1189 |
1166 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_LCDTextEnabledTest) { | 1190 TEST_P(NonCompositedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
1167 testStyle("transparent border-radius", | 1191 testStyle("transparent border-radius", |
1168 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1192 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1169 MainThreadScrollingReason::kHasBorderRadius); | 1193 MainThreadScrollingReason::kHasBorderRadius); |
1170 } | 1194 } |
1171 | 1195 |
1172 TEST_P(StyleRelatedMainThreadScrollingReasonTest, DISABLED_BoxShadowTest) { | 1196 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { |
1173 testStyle("box-shadow", | 1197 testStyle("box-shadow", |
1174 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1198 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1175 } | 1199 } |
1176 | 1200 |
1177 } // namespace blink | 1201 } // namespace blink |
OLD | NEW |