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