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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 class ScrollingCoordinatorTest : public ::testing::Test, | 58 class ScrollingCoordinatorTest : public ::testing::Test, |
59 public ::testing::WithParamInterface<bool>, | 59 public ::testing::WithParamInterface<bool>, |
60 private ScopedRootLayerScrollingForTest { | 60 private ScopedRootLayerScrollingForTest { |
61 public: | 61 public: |
62 ScrollingCoordinatorTest() | 62 ScrollingCoordinatorTest() |
63 : ScopedRootLayerScrollingForTest(GetParam()), | 63 : ScopedRootLayerScrollingForTest(GetParam()), |
64 base_url_("http://www.test.com/") { | 64 base_url_("http://www.test.com/") { |
65 helper_.Initialize(true, nullptr, &mock_web_view_client_, nullptr, | 65 helper_.Initialize(true, nullptr, &mock_web_view_client_, nullptr, |
66 &ConfigureSettings); | 66 &ConfigureSettings); |
67 GetWebViewImpl()->Resize(IntSize(320, 240)); | 67 GetWebView()->Resize(IntSize(320, 240)); |
68 | 68 |
69 // macOS attaches main frame scrollbars to the VisualViewport so the | 69 // macOS attaches main frame scrollbars to the VisualViewport so the |
70 // VisualViewport layers need to be initialized. | 70 // VisualViewport layers need to be initialized. |
71 GetWebViewImpl()->UpdateAllLifecyclePhases(); | 71 GetWebView()->UpdateAllLifecyclePhases(); |
72 WebFrameWidgetBase* main_frame_widget = | 72 WebFrameWidgetBase* main_frame_widget = |
73 GetWebViewImpl()->MainFrameImpl()->FrameWidget(); | 73 GetWebView()->MainFrameImpl()->FrameWidget(); |
74 main_frame_widget->SetRootGraphicsLayer(GetWebViewImpl() | 74 main_frame_widget->SetRootGraphicsLayer(GetWebView() |
75 ->MainFrameImpl() | 75 ->MainFrameImpl() |
76 ->GetFrame() | 76 ->GetFrame() |
77 ->View() | 77 ->View() |
78 ->GetLayoutViewItem() | 78 ->GetLayoutViewItem() |
79 .Compositor() | 79 .Compositor() |
80 ->RootGraphicsLayer()); | 80 ->RootGraphicsLayer()); |
81 } | 81 } |
82 | 82 |
83 ~ScrollingCoordinatorTest() override { | 83 ~ScrollingCoordinatorTest() override { |
84 Platform::Current() | 84 Platform::Current() |
85 ->GetURLLoaderMockFactory() | 85 ->GetURLLoaderMockFactory() |
86 ->UnregisterAllURLsAndClearMemoryCache(); | 86 ->UnregisterAllURLsAndClearMemoryCache(); |
87 } | 87 } |
88 | 88 |
89 void NavigateTo(const std::string& url) { | 89 void NavigateTo(const std::string& url) { |
90 FrameTestHelpers::LoadFrame(GetWebViewImpl()->MainFrame(), url); | 90 FrameTestHelpers::LoadFrame(GetWebView()->MainFrame(), url); |
91 } | 91 } |
92 | 92 |
93 void LoadHTML(const std::string& html) { | 93 void LoadHTML(const std::string& html) { |
94 FrameTestHelpers::LoadHTMLString(GetWebViewImpl()->MainFrame(), html, | 94 FrameTestHelpers::LoadHTMLString(GetWebView()->MainFrame(), html, |
95 URLTestHelpers::ToKURL("about:blank")); | 95 URLTestHelpers::ToKURL("about:blank")); |
96 } | 96 } |
97 | 97 |
98 void ForceFullCompositingUpdate() { | 98 void ForceFullCompositingUpdate() { |
99 GetWebViewImpl()->UpdateAllLifecyclePhases(); | 99 GetWebView()->UpdateAllLifecyclePhases(); |
100 } | 100 } |
101 | 101 |
102 void RegisterMockedHttpURLLoad(const std::string& file_name) { | 102 void RegisterMockedHttpURLLoad(const std::string& file_name) { |
103 URLTestHelpers::RegisterMockedURLLoadFromBase( | 103 URLTestHelpers::RegisterMockedURLLoadFromBase( |
104 WebString::FromUTF8(base_url_), testing::WebTestDataPath(), | 104 WebString::FromUTF8(base_url_), testing::WebTestDataPath(), |
105 WebString::FromUTF8(file_name)); | 105 WebString::FromUTF8(file_name)); |
106 } | 106 } |
107 | 107 |
108 WebLayer* GetRootScrollLayer() { | 108 WebLayer* GetRootScrollLayer() { |
109 GraphicsLayer* layer = | 109 GraphicsLayer* layer = |
110 GetFrame()->View()->LayoutViewportScrollableArea()->LayerForScrolling(); | 110 GetFrame()->View()->LayoutViewportScrollableArea()->LayerForScrolling(); |
111 return layer ? layer->PlatformLayer() : nullptr; | 111 return layer ? layer->PlatformLayer() : nullptr; |
112 } | 112 } |
113 | 113 |
114 WebViewImpl* GetWebViewImpl() const { return helper_.WebView(); } | 114 WebViewBase* GetWebView() const { return helper_.WebView(); } |
115 LocalFrame* GetFrame() const { | 115 LocalFrame* GetFrame() const { |
116 return helper_.WebView()->MainFrameImpl()->GetFrame(); | 116 return helper_.WebView()->MainFrameImpl()->GetFrame(); |
117 } | 117 } |
118 | 118 |
119 WebLayerTreeView* GetWebLayerTreeView() const { | 119 WebLayerTreeView* GetWebLayerTreeView() const { |
120 return GetWebViewImpl()->LayerTreeView(); | 120 return GetWebView()->LayerTreeView(); |
121 } | 121 } |
122 | 122 |
123 protected: | 123 protected: |
124 std::string base_url_; | 124 std::string base_url_; |
125 FrameTestHelpers::TestWebViewClient mock_web_view_client_; | 125 FrameTestHelpers::TestWebViewClient mock_web_view_client_; |
126 | 126 |
127 private: | 127 private: |
128 static void ConfigureSettings(WebSettings* settings) { | 128 static void ConfigureSettings(WebSettings* settings) { |
129 settings->SetJavaScriptEnabled(true); | 129 settings->SetJavaScriptEnabled(true); |
130 settings->SetAcceleratedCompositingEnabled(true); | 130 settings->SetAcceleratedCompositingEnabled(true); |
131 settings->SetPreferCompositingToLCDTextEnabled(true); | 131 settings->SetPreferCompositingToLCDTextEnabled(true); |
132 } | 132 } |
133 | 133 |
134 FrameTestHelpers::WebViewHelper helper_; | 134 FrameTestHelpers::WebViewHelper helper_; |
135 }; | 135 }; |
136 | 136 |
137 INSTANTIATE_TEST_CASE_P(All, ScrollingCoordinatorTest, ::testing::Bool()); | 137 INSTANTIATE_TEST_CASE_P(All, ScrollingCoordinatorTest, ::testing::Bool()); |
138 | 138 |
139 TEST_P(ScrollingCoordinatorTest, fastScrollingByDefault) { | 139 TEST_P(ScrollingCoordinatorTest, fastScrollingByDefault) { |
140 GetWebViewImpl()->Resize(WebSize(800, 600)); | 140 GetWebView()->Resize(WebSize(800, 600)); |
141 LoadHTML("<div id='spacer' style='height: 1000px'></div>"); | 141 LoadHTML("<div id='spacer' style='height: 1000px'></div>"); |
142 ForceFullCompositingUpdate(); | 142 ForceFullCompositingUpdate(); |
143 | 143 |
144 // Make sure the scrolling coordinator is active. | 144 // Make sure the scrolling coordinator is active. |
145 FrameView* frame_view = GetFrame()->View(); | 145 FrameView* frame_view = GetFrame()->View(); |
146 Page* page = GetFrame()->GetPage(); | 146 Page* page = GetFrame()->GetPage(); |
147 ASSERT_TRUE(page->GetScrollingCoordinator()); | 147 ASSERT_TRUE(page->GetScrollingCoordinator()); |
148 ASSERT_TRUE(page->GetScrollingCoordinator()->CoordinatesScrollingForFrameView( | 148 ASSERT_TRUE(page->GetScrollingCoordinator()->CoordinatesScrollingForFrameView( |
149 frame_view)); | 149 frame_view)); |
150 | 150 |
151 // Fast scrolling should be enabled by default. | 151 // Fast scrolling should be enabled by default. |
152 WebLayer* root_scroll_layer = GetRootScrollLayer(); | 152 WebLayer* root_scroll_layer = GetRootScrollLayer(); |
153 ASSERT_TRUE(root_scroll_layer); | 153 ASSERT_TRUE(root_scroll_layer); |
154 ASSERT_TRUE(root_scroll_layer->Scrollable()); | 154 ASSERT_TRUE(root_scroll_layer->Scrollable()); |
155 ASSERT_FALSE(root_scroll_layer->ShouldScrollOnMainThread()); | 155 ASSERT_FALSE(root_scroll_layer->ShouldScrollOnMainThread()); |
156 ASSERT_EQ(WebEventListenerProperties::kNothing, | 156 ASSERT_EQ(WebEventListenerProperties::kNothing, |
157 GetWebLayerTreeView()->EventListenerProperties( | 157 GetWebLayerTreeView()->EventListenerProperties( |
158 WebEventListenerClass::kTouchStartOrMove)); | 158 WebEventListenerClass::kTouchStartOrMove)); |
159 ASSERT_EQ(WebEventListenerProperties::kNothing, | 159 ASSERT_EQ(WebEventListenerProperties::kNothing, |
160 GetWebLayerTreeView()->EventListenerProperties( | 160 GetWebLayerTreeView()->EventListenerProperties( |
161 WebEventListenerClass::kMouseWheel)); | 161 WebEventListenerClass::kMouseWheel)); |
162 | 162 |
163 WebLayer* inner_viewport_scroll_layer = | 163 WebLayer* inner_viewport_scroll_layer = |
164 page->GetVisualViewport().ScrollLayer()->PlatformLayer(); | 164 page->GetVisualViewport().ScrollLayer()->PlatformLayer(); |
165 ASSERT_TRUE(inner_viewport_scroll_layer->Scrollable()); | 165 ASSERT_TRUE(inner_viewport_scroll_layer->Scrollable()); |
166 ASSERT_FALSE(inner_viewport_scroll_layer->ShouldScrollOnMainThread()); | 166 ASSERT_FALSE(inner_viewport_scroll_layer->ShouldScrollOnMainThread()); |
167 } | 167 } |
168 | 168 |
169 TEST_P(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { | 169 TEST_P(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { |
170 GetWebViewImpl()->Resize(WebSize(800, 600)); | 170 GetWebView()->Resize(WebSize(800, 600)); |
171 LoadHTML("<div id='spacer' style='height: 1000px'></div>"); | 171 LoadHTML("<div id='spacer' style='height: 1000px'></div>"); |
172 GetWebViewImpl()->GetSettings()->SetThreadedScrollingEnabled(false); | 172 GetWebView()->GetSettings()->SetThreadedScrollingEnabled(false); |
173 ForceFullCompositingUpdate(); | 173 ForceFullCompositingUpdate(); |
174 | 174 |
175 // Make sure the scrolling coordinator is active. | 175 // Make sure the scrolling coordinator is active. |
176 FrameView* frame_view = GetFrame()->View(); | 176 FrameView* frame_view = GetFrame()->View(); |
177 Page* page = GetFrame()->GetPage(); | 177 Page* page = GetFrame()->GetPage(); |
178 ASSERT_TRUE(page->GetScrollingCoordinator()); | 178 ASSERT_TRUE(page->GetScrollingCoordinator()); |
179 ASSERT_TRUE(page->GetScrollingCoordinator()->CoordinatesScrollingForFrameView( | 179 ASSERT_TRUE(page->GetScrollingCoordinator()->CoordinatesScrollingForFrameView( |
180 frame_view)); | 180 frame_view)); |
181 | 181 |
182 // Main scrolling should be enabled with the setting override. | 182 // Main scrolling should be enabled with the setting override. |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 ASSERT_TRUE(contents_layer); | 809 ASSERT_TRUE(contents_layer); |
810 | 810 |
811 // After scrollableAreaScrollbarLayerDidChange, | 811 // After scrollableAreaScrollbarLayerDidChange, |
812 // if the main frame's scrollbarLayer is opaque, | 812 // if the main frame's scrollbarLayer is opaque, |
813 // contentsLayer should be opaque too. | 813 // contentsLayer should be opaque too. |
814 ASSERT_EQ(platform_layer->Opaque(), contents_layer->Opaque()); | 814 ASSERT_EQ(platform_layer->Opaque(), contents_layer->Opaque()); |
815 } | 815 } |
816 | 816 |
817 TEST_P(ScrollingCoordinatorTest, | 817 TEST_P(ScrollingCoordinatorTest, |
818 FixedPositionLosingBackingShouldTriggerMainThreadScroll) { | 818 FixedPositionLosingBackingShouldTriggerMainThreadScroll) { |
819 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 819 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
820 RegisterMockedHttpURLLoad("fixed-position-losing-backing.html"); | 820 RegisterMockedHttpURLLoad("fixed-position-losing-backing.html"); |
821 NavigateTo(base_url_ + "fixed-position-losing-backing.html"); | 821 NavigateTo(base_url_ + "fixed-position-losing-backing.html"); |
822 ForceFullCompositingUpdate(); | 822 ForceFullCompositingUpdate(); |
823 | 823 |
824 WebLayer* scroll_layer = GetRootScrollLayer(); | 824 WebLayer* scroll_layer = GetRootScrollLayer(); |
825 ASSERT_TRUE(scroll_layer); | 825 ASSERT_TRUE(scroll_layer); |
826 | 826 |
827 Document* document = GetFrame()->GetDocument(); | 827 Document* document = GetFrame()->GetDocument(); |
828 Element* fixed_pos = document->getElementById("fixed"); | 828 Element* fixed_pos = document->getElementById("fixed"); |
829 | 829 |
830 EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixed_pos->GetLayoutObject()) | 830 EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixed_pos->GetLayoutObject()) |
831 ->Layer() | 831 ->Layer() |
832 ->HasCompositedLayerMapping()); | 832 ->HasCompositedLayerMapping()); |
833 EXPECT_FALSE(scroll_layer->ShouldScrollOnMainThread()); | 833 EXPECT_FALSE(scroll_layer->ShouldScrollOnMainThread()); |
834 | 834 |
835 fixed_pos->SetInlineStyleProperty(CSSPropertyTransform, CSSValueNone); | 835 fixed_pos->SetInlineStyleProperty(CSSPropertyTransform, CSSValueNone); |
836 ForceFullCompositingUpdate(); | 836 ForceFullCompositingUpdate(); |
837 | 837 |
838 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixed_pos->GetLayoutObject()) | 838 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixed_pos->GetLayoutObject()) |
839 ->Layer() | 839 ->Layer() |
840 ->HasCompositedLayerMapping()); | 840 ->HasCompositedLayerMapping()); |
841 EXPECT_TRUE(scroll_layer->ShouldScrollOnMainThread()); | 841 EXPECT_TRUE(scroll_layer->ShouldScrollOnMainThread()); |
842 } | 842 } |
843 | 843 |
844 TEST_P(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { | 844 TEST_P(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { |
845 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true); | 845 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true); |
846 GetWebViewImpl()->SetDeviceScaleFactor(2.f); | 846 GetWebView()->SetDeviceScaleFactor(2.f); |
847 RegisterMockedHttpURLLoad("custom_scrollbar.html"); | 847 RegisterMockedHttpURLLoad("custom_scrollbar.html"); |
848 NavigateTo(base_url_ + "custom_scrollbar.html"); | 848 NavigateTo(base_url_ + "custom_scrollbar.html"); |
849 ForceFullCompositingUpdate(); | 849 ForceFullCompositingUpdate(); |
850 | 850 |
851 Document* document = GetFrame()->GetDocument(); | 851 Document* document = GetFrame()->GetDocument(); |
852 Element* container = document->getElementById("container"); | 852 Element* container = document->getElementById("container"); |
853 Element* content = document->getElementById("content"); | 853 Element* content = document->getElementById("content"); |
854 DCHECK_EQ(container->getAttribute(HTMLNames::classAttr), "custom_scrollbar"); | 854 DCHECK_EQ(container->getAttribute(HTMLNames::classAttr), "custom_scrollbar"); |
855 DCHECK(container); | 855 DCHECK(container); |
856 DCHECK(content); | 856 DCHECK(content); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 web_scroll_layer = scroll_layer->PlatformLayer(); | 964 web_scroll_layer = scroll_layer->PlatformLayer(); |
965 ASSERT_TRUE(web_scroll_layer->Scrollable()); | 965 ASSERT_TRUE(web_scroll_layer->Scrollable()); |
966 ASSERT_TRUE(web_scroll_layer->MainThreadScrollingReasons() & | 966 ASSERT_TRUE(web_scroll_layer->MainThreadScrollingReasons() & |
967 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 967 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
968 } | 968 } |
969 | 969 |
970 // Upon resizing the content size, the main thread scrolling reason | 970 // Upon resizing the content size, the main thread scrolling reason |
971 // kHasNonLayerViewportConstrainedObject should be updated on all frames | 971 // kHasNonLayerViewportConstrainedObject should be updated on all frames |
972 TEST_P(ScrollingCoordinatorTest, | 972 TEST_P(ScrollingCoordinatorTest, |
973 RecalculateMainThreadScrollingReasonsUponResize) { | 973 RecalculateMainThreadScrollingReasonsUponResize) { |
974 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 974 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
975 RegisterMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html"); | 975 RegisterMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html"); |
976 NavigateTo(base_url_ + "has-non-layer-viewport-constrained-objects.html"); | 976 NavigateTo(base_url_ + "has-non-layer-viewport-constrained-objects.html"); |
977 ForceFullCompositingUpdate(); | 977 ForceFullCompositingUpdate(); |
978 | 978 |
979 LOG(ERROR) << GetFrame()->View()->GetMainThreadScrollingReasons(); | 979 LOG(ERROR) << GetFrame()->View()->GetMainThreadScrollingReasons(); |
980 Element* element = GetFrame()->GetDocument()->getElementById("scrollable"); | 980 Element* element = GetFrame()->GetDocument()->getElementById("scrollable"); |
981 ASSERT_TRUE(element); | 981 ASSERT_TRUE(element); |
982 | 982 |
983 LayoutObject* layout_object = element->GetLayoutObject(); | 983 LayoutObject* layout_object = element->GetLayoutObject(); |
984 ASSERT_TRUE(layout_object); | 984 ASSERT_TRUE(layout_object); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText | | 1055 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText | |
1056 MainThreadScrollingReason::kIsNotStackingContextAndLCDText; | 1056 MainThreadScrollingReason::kIsNotStackingContextAndLCDText; |
1057 | 1057 |
1058 protected: | 1058 protected: |
1059 NonCompositedMainThreadScrollingReasonTest() { | 1059 NonCompositedMainThreadScrollingReasonTest() { |
1060 RegisterMockedHttpURLLoad("two_scrollable_area.html"); | 1060 RegisterMockedHttpURLLoad("two_scrollable_area.html"); |
1061 NavigateTo(base_url_ + "two_scrollable_area.html"); | 1061 NavigateTo(base_url_ + "two_scrollable_area.html"); |
1062 } | 1062 } |
1063 void TestNonCompositedReasons(const std::string& target, | 1063 void TestNonCompositedReasons(const std::string& target, |
1064 const uint32_t reason) { | 1064 const uint32_t reason) { |
1065 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled( | 1065 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
1066 false); | |
1067 Document* document = GetFrame()->GetDocument(); | 1066 Document* document = GetFrame()->GetDocument(); |
1068 Element* container = document->getElementById("scroller1"); | 1067 Element* container = document->getElementById("scroller1"); |
1069 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1068 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1070 ForceFullCompositingUpdate(); | 1069 ForceFullCompositingUpdate(); |
1071 | 1070 |
1072 PaintLayerScrollableArea* scrollable_area = | 1071 PaintLayerScrollableArea* scrollable_area = |
1073 ToLayoutBoxModelObject(container->GetLayoutObject()) | 1072 ToLayoutBoxModelObject(container->GetLayoutObject()) |
1074 ->GetScrollableArea(); | 1073 ->GetScrollableArea(); |
1075 ASSERT_TRUE(scrollable_area); | 1074 ASSERT_TRUE(scrollable_area); |
1076 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & | 1075 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & |
(...skipping 24 matching lines...) Expand all Loading... |
1101 // Add target attribute would again lead to scroll on main thread | 1100 // Add target attribute would again lead to scroll on main thread |
1102 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); | 1101 container->setAttribute("class", target.c_str(), ASSERT_NO_EXCEPTION); |
1103 ForceFullCompositingUpdate(); | 1102 ForceFullCompositingUpdate(); |
1104 | 1103 |
1105 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & | 1104 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & |
1106 reason); | 1105 reason); |
1107 EXPECT_FALSE(frame_view->GetMainThreadScrollingReasons() & reason); | 1106 EXPECT_FALSE(frame_view->GetMainThreadScrollingReasons() & reason); |
1108 | 1107 |
1109 if ((reason & kLCDTextRelatedReasons) && | 1108 if ((reason & kLCDTextRelatedReasons) && |
1110 !(reason & ~kLCDTextRelatedReasons)) { | 1109 !(reason & ~kLCDTextRelatedReasons)) { |
1111 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled( | 1110 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true); |
1112 true); | |
1113 ForceFullCompositingUpdate(); | 1111 ForceFullCompositingUpdate(); |
1114 EXPECT_FALSE( | 1112 EXPECT_FALSE( |
1115 scrollable_area->GetNonCompositedMainThreadScrollingReasons()); | 1113 scrollable_area->GetNonCompositedMainThreadScrollingReasons()); |
1116 EXPECT_FALSE(frame_view->GetMainThreadScrollingReasons()); | 1114 EXPECT_FALSE(frame_view->GetMainThreadScrollingReasons()); |
1117 } | 1115 } |
1118 } | 1116 } |
1119 }; | 1117 }; |
1120 | 1118 |
1121 INSTANTIATE_TEST_CASE_P(All, | 1119 INSTANTIATE_TEST_CASE_P(All, |
1122 NonCompositedMainThreadScrollingReasonTest, | 1120 NonCompositedMainThreadScrollingReasonTest, |
(...skipping 20 matching lines...) Expand all Loading... |
1143 MainThreadScrollingReason::kHasBorderRadius); | 1141 MainThreadScrollingReason::kHasBorderRadius); |
1144 } | 1142 } |
1145 | 1143 |
1146 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { | 1144 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipTest) { |
1147 TestNonCompositedReasons("clip", | 1145 TestNonCompositedReasons("clip", |
1148 MainThreadScrollingReason::kHasClipRelatedProperty); | 1146 MainThreadScrollingReason::kHasClipRelatedProperty); |
1149 } | 1147 } |
1150 | 1148 |
1151 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipPathTest) { | 1149 TEST_P(NonCompositedMainThreadScrollingReasonTest, ClipPathTest) { |
1152 uint32_t clip_reason = MainThreadScrollingReason::kHasClipRelatedProperty; | 1150 uint32_t clip_reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
1153 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 1151 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
1154 Document* document = GetFrame()->GetDocument(); | 1152 Document* document = GetFrame()->GetDocument(); |
1155 // Test ancestor with ClipPath | 1153 // Test ancestor with ClipPath |
1156 Element* element = document->body(); | 1154 Element* element = document->body(); |
1157 ASSERT_TRUE(element); | 1155 ASSERT_TRUE(element); |
1158 element->setAttribute(HTMLNames::styleAttr, | 1156 element->setAttribute(HTMLNames::styleAttr, |
1159 "clip-path:circle(115px at 20px 20px);"); | 1157 "clip-path:circle(115px at 20px 20px);"); |
1160 Element* container = document->getElementById("scroller1"); | 1158 Element* container = document->getElementById("scroller1"); |
1161 ASSERT_TRUE(container); | 1159 ASSERT_TRUE(container); |
1162 ForceFullCompositingUpdate(); | 1160 ForceFullCompositingUpdate(); |
1163 | 1161 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1200 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1203 MainThreadScrollingReason::kHasBorderRadius); | 1201 MainThreadScrollingReason::kHasBorderRadius); |
1204 } | 1202 } |
1205 | 1203 |
1206 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { | 1204 TEST_P(NonCompositedMainThreadScrollingReasonTest, BoxShadowTest) { |
1207 TestNonCompositedReasons( | 1205 TestNonCompositedReasons( |
1208 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1206 "box-shadow", MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1209 } | 1207 } |
1210 | 1208 |
1211 TEST_P(NonCompositedMainThreadScrollingReasonTest, StackingContextTest) { | 1209 TEST_P(NonCompositedMainThreadScrollingReasonTest, StackingContextTest) { |
1212 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 1210 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
1213 | 1211 |
1214 Document* document = GetFrame()->GetDocument(); | 1212 Document* document = GetFrame()->GetDocument(); |
1215 Element* container = document->getElementById("scroller1"); | 1213 Element* container = document->getElementById("scroller1"); |
1216 ASSERT_TRUE(container); | 1214 ASSERT_TRUE(container); |
1217 | 1215 |
1218 ForceFullCompositingUpdate(); | 1216 ForceFullCompositingUpdate(); |
1219 | 1217 |
1220 // If a scroller contains all its children, it's not a stacking context. | 1218 // If a scroller contains all its children, it's not a stacking context. |
1221 PaintLayerScrollableArea* scrollable_area = | 1219 PaintLayerScrollableArea* scrollable_area = |
1222 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea(); | 1220 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea(); |
1223 ASSERT_TRUE(scrollable_area); | 1221 ASSERT_TRUE(scrollable_area); |
1224 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & | 1222 EXPECT_TRUE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & |
1225 MainThreadScrollingReason::kIsNotStackingContextAndLCDText); | 1223 MainThreadScrollingReason::kIsNotStackingContextAndLCDText); |
1226 | 1224 |
1227 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true); | 1225 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(true); |
1228 ForceFullCompositingUpdate(); | 1226 ForceFullCompositingUpdate(); |
1229 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & | 1227 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons() & |
1230 MainThreadScrollingReason::kIsNotStackingContextAndLCDText); | 1228 MainThreadScrollingReason::kIsNotStackingContextAndLCDText); |
1231 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 1229 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
1232 | 1230 |
1233 // Adding "contain: paint" to force a stacking context leads to promotion. | 1231 // Adding "contain: paint" to force a stacking context leads to promotion. |
1234 container->setAttribute("style", "contain: paint", ASSERT_NO_EXCEPTION); | 1232 container->setAttribute("style", "contain: paint", ASSERT_NO_EXCEPTION); |
1235 ForceFullCompositingUpdate(); | 1233 ForceFullCompositingUpdate(); |
1236 | 1234 |
1237 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons()); | 1235 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons()); |
1238 } | 1236 } |
1239 | 1237 |
1240 TEST_P(NonCompositedMainThreadScrollingReasonTest, | 1238 TEST_P(NonCompositedMainThreadScrollingReasonTest, |
1241 CompositedWithLCDTextRelatedReasonsTest) { | 1239 CompositedWithLCDTextRelatedReasonsTest) { |
1242 // With "will-change:transform" we composite elements with | 1240 // With "will-change:transform" we composite elements with |
1243 // LCDTextRelatedReasons only. For elements with other | 1241 // LCDTextRelatedReasons only. For elements with other |
1244 // NonCompositedReasons, we don't create scrollingLayer for their | 1242 // NonCompositedReasons, we don't create scrollingLayer for their |
1245 // CompositedLayerMapping therefore they don't get composited. | 1243 // CompositedLayerMapping therefore they don't get composited. |
1246 GetWebViewImpl()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); | 1244 GetWebView()->GetSettings()->SetPreferCompositingToLCDTextEnabled(false); |
1247 Document* document = GetFrame()->GetDocument(); | 1245 Document* document = GetFrame()->GetDocument(); |
1248 Element* container = document->getElementById("scroller1"); | 1246 Element* container = document->getElementById("scroller1"); |
1249 ASSERT_TRUE(container); | 1247 ASSERT_TRUE(container); |
1250 container->setAttribute("class", "composited transparent", | 1248 container->setAttribute("class", "composited transparent", |
1251 ASSERT_NO_EXCEPTION); | 1249 ASSERT_NO_EXCEPTION); |
1252 ForceFullCompositingUpdate(); | 1250 ForceFullCompositingUpdate(); |
1253 | 1251 |
1254 PaintLayerScrollableArea* scrollable_area = | 1252 PaintLayerScrollableArea* scrollable_area = |
1255 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea(); | 1253 ToLayoutBoxModelObject(container->GetLayoutObject())->GetScrollableArea(); |
1256 ASSERT_TRUE(scrollable_area); | 1254 ASSERT_TRUE(scrollable_area); |
1257 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons()); | 1255 EXPECT_FALSE(scrollable_area->GetNonCompositedMainThreadScrollingReasons()); |
1258 | 1256 |
1259 Element* container2 = document->getElementById("scroller2"); | 1257 Element* container2 = document->getElementById("scroller2"); |
1260 ASSERT_TRUE(container2); | 1258 ASSERT_TRUE(container2); |
1261 container2->setAttribute("class", "composited border-radius", | 1259 container2->setAttribute("class", "composited border-radius", |
1262 ASSERT_NO_EXCEPTION); | 1260 ASSERT_NO_EXCEPTION); |
1263 ForceFullCompositingUpdate(); | 1261 ForceFullCompositingUpdate(); |
1264 PaintLayerScrollableArea* scrollable_area2 = | 1262 PaintLayerScrollableArea* scrollable_area2 = |
1265 ToLayoutBoxModelObject(container2->GetLayoutObject()) | 1263 ToLayoutBoxModelObject(container2->GetLayoutObject()) |
1266 ->GetScrollableArea(); | 1264 ->GetScrollableArea(); |
1267 ASSERT_TRUE(scrollable_area2); | 1265 ASSERT_TRUE(scrollable_area2); |
1268 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() & | 1266 EXPECT_TRUE(scrollable_area2->GetNonCompositedMainThreadScrollingReasons() & |
1269 MainThreadScrollingReason::kHasBorderRadius); | 1267 MainThreadScrollingReason::kHasBorderRadius); |
1270 } | 1268 } |
1271 | 1269 |
1272 } // namespace blink | 1270 } // namespace blink |
OLD | NEW |