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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 | 1027 |
1028 webScrollLayer = scrollLayer->platformLayer(); | 1028 webScrollLayer = scrollLayer->platformLayer(); |
1029 ASSERT_TRUE(webScrollLayer->scrollable()); | 1029 ASSERT_TRUE(webScrollLayer->scrollable()); |
1030 ASSERT_FALSE( | 1030 ASSERT_FALSE( |
1031 webScrollLayer->mainThreadScrollingReasons() & | 1031 webScrollLayer->mainThreadScrollingReasons() & |
1032 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 1032 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
1033 } | 1033 } |
1034 | 1034 |
1035 class StyleRelatedMainThreadScrollingReasonTest | 1035 class StyleRelatedMainThreadScrollingReasonTest |
1036 : public ScrollingCoordinatorTest { | 1036 : public ScrollingCoordinatorTest { |
| 1037 static const uint32_t m_LCDTextRelatedReasons = |
| 1038 MainThreadScrollingReason::kHasOpacity | |
| 1039 MainThreadScrollingReason::kHasTransform | |
| 1040 MainThreadScrollingReason::kBackgroundNotOpaqueInRect; |
| 1041 |
1037 protected: | 1042 protected: |
1038 StyleRelatedMainThreadScrollingReasonTest() { | 1043 StyleRelatedMainThreadScrollingReasonTest() { |
1039 registerMockedHttpURLLoad("two_scrollable_area.html"); | 1044 registerMockedHttpURLLoad("two_scrollable_area.html"); |
1040 navigateTo(m_baseURL + "two_scrollable_area.html"); | 1045 navigateTo(m_baseURL + "two_scrollable_area.html"); |
1041 } | 1046 } |
1042 void testStyle(const std::string& target, const uint32_t reason) { | 1047 void testStyle(const std::string& target, const uint32_t reason) { |
1043 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1048 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1044 Document* document = frame()->document(); | 1049 Document* document = frame()->document(); |
1045 Element* container = document->getElementById("scroller1"); | 1050 Element* container = document->getElementById("scroller1"); |
1046 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1051 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
(...skipping 24 matching lines...) Expand all Loading... |
1071 forceFullCompositingUpdate(); | 1076 forceFullCompositingUpdate(); |
1072 | 1077 |
1073 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1078 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1074 | 1079 |
1075 // Add target attribute would again lead to scroll on main thread | 1080 // Add target attribute would again lead to scroll on main thread |
1076 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1081 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1077 forceFullCompositingUpdate(); | 1082 forceFullCompositingUpdate(); |
1078 | 1083 |
1079 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1084 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
1080 | 1085 |
1081 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | 1086 if ((reason & m_LCDTextRelatedReasons) && |
1082 forceFullCompositingUpdate(); | 1087 !(reason & ~m_LCDTextRelatedReasons)) { |
1083 | 1088 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
1084 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | 1089 forceFullCompositingUpdate(); |
| 1090 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); |
| 1091 } |
1085 } | 1092 } |
1086 }; | 1093 }; |
1087 | 1094 |
1088 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { | 1095 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { |
1089 testStyle("transparent", MainThreadScrollingReason::kHasOpacity); | 1096 testStyle("transparent", MainThreadScrollingReason::kHasOpacity); |
1090 } | 1097 } |
1091 | 1098 |
1092 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { | 1099 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { |
1093 testStyle("transform", MainThreadScrollingReason::kHasTransform); | 1100 testStyle("transform", MainThreadScrollingReason::kHasTransform); |
1094 } | 1101 } |
1095 | 1102 |
1096 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { | 1103 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1097 testStyle("background-not-opaque", | 1104 testStyle("background-not-opaque", |
1098 MainThreadScrollingReason::kBackgroundNotOpaqueInRect); | 1105 MainThreadScrollingReason::kBackgroundNotOpaqueInRect); |
1099 } | 1106 } |
1100 | 1107 |
| 1108 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { |
| 1109 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); |
| 1110 } |
| 1111 |
| 1112 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { |
| 1113 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); |
| 1114 } |
| 1115 |
| 1116 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { |
| 1117 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
| 1118 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| 1119 Document* document = frame()->document(); |
| 1120 // Test ancestor with ClipPath |
| 1121 Element* element = document->body(); |
| 1122 DCHECK(element); |
| 1123 element->setAttribute(HTMLNames::styleAttr, |
| 1124 "clip-path:circle(115px at 20px 20px);"); |
| 1125 forceFullCompositingUpdate(); |
| 1126 |
| 1127 FrameView* frameView = frame()->view(); |
| 1128 ASSERT_TRUE(frameView); |
| 1129 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| 1130 |
| 1131 // Remove clip path from ancestor. |
| 1132 element->removeAttribute(HTMLNames::styleAttr); |
| 1133 forceFullCompositingUpdate(); |
| 1134 |
| 1135 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| 1136 |
| 1137 // Test descendant with ClipPath |
| 1138 element = document->getElementById("content1"); |
| 1139 DCHECK(element); |
| 1140 element->setAttribute(HTMLNames::styleAttr, |
| 1141 "clip-path:circle(115px at 20px 20px);"); |
| 1142 forceFullCompositingUpdate(); |
| 1143 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
| 1144 |
| 1145 // Remove clip path from descendant. |
| 1146 element->removeAttribute(HTMLNames::styleAttr); |
| 1147 forceFullCompositingUpdate(); |
| 1148 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| 1149 } |
| 1150 |
| 1151 TEST_F(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
| 1152 testStyle("transparent border-radius", |
| 1153 MainThreadScrollingReason::kHasOpacity | |
| 1154 MainThreadScrollingReason::kHasBorderRadius); |
| 1155 } |
| 1156 |
1101 } // namespace blink | 1157 } // namespace blink |
OLD | NEW |