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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 protected: | 1037 protected: |
1038 StyleRelatedMainThreadScrollingReasonTest() { | 1038 StyleRelatedMainThreadScrollingReasonTest() { |
1039 registerMockedHttpURLLoad("two_scrollable_area.html"); | 1039 registerMockedHttpURLLoad("two_scrollable_area.html"); |
1040 navigateTo(m_baseURL + "two_scrollable_area.html"); | 1040 navigateTo(m_baseURL + "two_scrollable_area.html"); |
1041 m_LCDTextRelatedReasons = | |
1042 MainThreadScrollingReason::kHasOpacity | | |
1043 MainThreadScrollingReason::kHasTransform | | |
1044 MainThreadScrollingReason::kBackgroundNotOpaqueInRect; | |
1041 } | 1045 } |
1042 void testStyle(const std::string& target, const uint32_t reason) { | 1046 void testStyle(const std::string& target, const uint32_t reason) { |
1043 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1047 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1044 Document* document = frame()->document(); | 1048 Document* document = frame()->document(); |
1045 Element* container = document->getElementById("scroller1"); | 1049 Element* container = document->getElementById("scroller1"); |
1046 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1050 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1047 container = document->getElementById("scroller2"); | 1051 container = document->getElementById("scroller2"); |
1048 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1052 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1049 forceFullCompositingUpdate(); | 1053 forceFullCompositingUpdate(); |
1050 | 1054 |
(...skipping 20 matching lines...) Expand all Loading... | |
1071 forceFullCompositingUpdate(); | 1075 forceFullCompositingUpdate(); |
1072 | 1076 |
1073 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1077 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1074 | 1078 |
1075 // Add target attribute would again lead to scroll on main thread | 1079 // Add target attribute would again lead to scroll on main thread |
1076 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1080 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1077 forceFullCompositingUpdate(); | 1081 forceFullCompositingUpdate(); |
1078 | 1082 |
1079 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1083 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
1080 | 1084 |
1081 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | 1085 if ((reason & m_LCDTextRelatedReasons) && |
1082 forceFullCompositingUpdate(); | 1086 !(reason & ~m_LCDTextRelatedReasons)) { |
1087 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | |
1088 forceFullCompositingUpdate(); | |
1089 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | |
1090 } | |
1091 } | |
1083 | 1092 |
1084 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | 1093 private: |
1085 } | 1094 uint32_t m_LCDTextRelatedReasons; |
bokan
2017/01/05 14:52:41
nit: this can be a static constexpr I think.
yigu
2017/01/05 20:20:27
Done.
| |
1086 }; | 1095 }; |
1087 | 1096 |
1088 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { | 1097 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { |
1089 testStyle("transparent", MainThreadScrollingReason::kHasOpacity); | 1098 testStyle("transparent", MainThreadScrollingReason::kHasOpacity); |
1090 } | 1099 } |
1091 | 1100 |
1092 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { | 1101 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { |
1093 testStyle("transform", MainThreadScrollingReason::kHasTransform); | 1102 testStyle("transform", MainThreadScrollingReason::kHasTransform); |
1094 } | 1103 } |
1095 | 1104 |
1096 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { | 1105 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1097 testStyle("background-not-opaque", | 1106 testStyle("background-not-opaque", |
1098 MainThreadScrollingReason::kBackgroundNotOpaqueInRect); | 1107 MainThreadScrollingReason::kBackgroundNotOpaqueInRect); |
1099 } | 1108 } |
1100 | 1109 |
1110 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { | |
1111 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); | |
1112 } | |
1113 | |
1114 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { | |
1115 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); | |
1116 } | |
1117 | |
1118 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { | |
1119 testStyle("clip-path", MainThreadScrollingReason::kHasClipRelatedProperty); | |
1120 } | |
1121 | |
1122 TEST_F(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { | |
1123 testStyle("transparent border-radius", | |
1124 MainThreadScrollingReason::kHasOpacity | | |
1125 MainThreadScrollingReason::kHasBorderRadius); | |
1126 } | |
1127 | |
1101 } // namespace blink | 1128 } // namespace blink |
OLD | NEW |