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 20 matching lines...) Expand all Loading... | |
31 #include "core/frame/VisualViewport.h" | 31 #include "core/frame/VisualViewport.h" |
32 #include "core/html/HTMLIFrameElement.h" | 32 #include "core/html/HTMLIFrameElement.h" |
33 #include "core/layout/LayoutPart.h" | 33 #include "core/layout/LayoutPart.h" |
34 #include "core/layout/api/LayoutViewItem.h" | 34 #include "core/layout/api/LayoutViewItem.h" |
35 #include "core/layout/compositing/CompositedLayerMapping.h" | 35 #include "core/layout/compositing/CompositedLayerMapping.h" |
36 #include "core/layout/compositing/PaintLayerCompositor.h" | 36 #include "core/layout/compositing/PaintLayerCompositor.h" |
37 #include "core/page/Page.h" | 37 #include "core/page/Page.h" |
38 #include "platform/geometry/IntPoint.h" | 38 #include "platform/geometry/IntPoint.h" |
39 #include "platform/geometry/IntRect.h" | 39 #include "platform/geometry/IntRect.h" |
40 #include "platform/graphics/GraphicsLayer.h" | 40 #include "platform/graphics/GraphicsLayer.h" |
41 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | |
41 #include "platform/testing/URLTestHelpers.h" | 42 #include "platform/testing/URLTestHelpers.h" |
42 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
43 #include "public/platform/WebLayer.h" | 44 #include "public/platform/WebLayer.h" |
44 #include "public/platform/WebLayerPositionConstraint.h" | 45 #include "public/platform/WebLayerPositionConstraint.h" |
45 #include "public/platform/WebLayerTreeView.h" | 46 #include "public/platform/WebLayerTreeView.h" |
46 #include "public/platform/WebURLLoaderMockFactory.h" | 47 #include "public/platform/WebURLLoaderMockFactory.h" |
47 #include "public/web/WebCache.h" | 48 #include "public/web/WebCache.h" |
48 #include "public/web/WebSettings.h" | 49 #include "public/web/WebSettings.h" |
49 #include "public/web/WebViewClient.h" | 50 #include "public/web/WebViewClient.h" |
50 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
51 #include "web/WebLocalFrameImpl.h" | 52 #include "web/WebLocalFrameImpl.h" |
52 #include "web/WebViewImpl.h" | 53 #include "web/WebViewImpl.h" |
53 #include "web/tests/FrameTestHelpers.h" | 54 #include "web/tests/FrameTestHelpers.h" |
54 | 55 |
55 namespace blink { | 56 namespace blink { |
56 | 57 |
57 class ScrollingCoordinatorTest : public testing::Test { | 58 class ScrollingCoordinatorTest : public testing::Test, |
59 public testing::WithParamInterface<bool>, | |
60 private ScopedRootLayerScrollingForTest { | |
58 public: | 61 public: |
59 ScrollingCoordinatorTest() : m_baseURL("http://www.test.com/") { | 62 ScrollingCoordinatorTest() |
63 : ScopedRootLayerScrollingForTest(GetParam()), | |
64 m_baseURL("http://www.test.com/") { | |
60 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, | 65 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, |
61 &configureSettings); | 66 &configureSettings); |
62 webViewImpl()->resize(IntSize(320, 240)); | 67 webViewImpl()->resize(IntSize(320, 240)); |
63 | 68 |
64 // macOS attaches main frame scrollbars to the VisualViewport so the | 69 // macOS attaches main frame scrollbars to the VisualViewport so the |
65 // VisualViewport layers need to be initialized. | 70 // VisualViewport layers need to be initialized. |
66 webViewImpl()->updateAllLifecyclePhases(); | 71 webViewImpl()->updateAllLifecyclePhases(); |
67 WebFrameWidgetBase* mainFrameWidget = | 72 WebFrameWidgetBase* mainFrameWidget = |
68 webViewImpl()->mainFrameImpl()->frameWidget(); | 73 webViewImpl()->mainFrameImpl()->frameWidget(); |
69 mainFrameWidget->setRootGraphicsLayer(webViewImpl() | 74 mainFrameWidget->setRootGraphicsLayer(webViewImpl() |
70 ->mainFrameImpl() | 75 ->mainFrameImpl() |
71 ->frame() | 76 ->frame() |
72 ->view() | 77 ->view() |
73 ->layoutViewItem() | 78 ->layoutViewItem() |
74 .compositor() | 79 .compositor() |
75 ->rootGraphicsLayer()); | 80 ->rootGraphicsLayer()); |
76 } | 81 } |
77 | 82 |
78 ~ScrollingCoordinatorTest() override { | 83 ~ScrollingCoordinatorTest() override { |
79 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 84 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
80 WebCache::clear(); | 85 WebCache::clear(); |
81 } | 86 } |
82 | 87 |
83 void navigateTo(const std::string& url) { | 88 void navigateTo(const std::string& url) { |
84 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); | 89 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); |
85 } | 90 } |
86 | 91 |
92 void loadHTML(const std::string& html) { | |
93 FrameTestHelpers::loadHTMLString(webViewImpl()->mainFrame(), html, | |
94 URLTestHelpers::toKURL("about:blank")); | |
95 } | |
96 | |
87 void forceFullCompositingUpdate() { | 97 void forceFullCompositingUpdate() { |
88 webViewImpl()->updateAllLifecyclePhases(); | 98 webViewImpl()->updateAllLifecyclePhases(); |
89 } | 99 } |
90 | 100 |
91 void registerMockedHttpURLLoad(const std::string& fileName) { | 101 void registerMockedHttpURLLoad(const std::string& fileName) { |
92 URLTestHelpers::registerMockedURLFromBaseURL( | 102 URLTestHelpers::registerMockedURLFromBaseURL( |
93 WebString::fromUTF8(m_baseURL.c_str()), | 103 WebString::fromUTF8(m_baseURL.c_str()), |
94 WebString::fromUTF8(fileName.c_str())); | 104 WebString::fromUTF8(fileName.c_str())); |
95 } | 105 } |
96 | 106 |
107 GraphicsLayer* getFrameScrollLayer(LocalFrame& localFrame) { | |
skobes
2017/01/28 01:07:45
This looks unused.
szager1
2017/01/31 00:00:28
Removed.
| |
108 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
109 LayoutView* layoutView = localFrame.contentLayoutObject(); | |
110 DCHECK(layoutView); | |
111 DCHECK(layoutView->layer()); | |
112 auto* mapping = layoutView->layer()->compositedLayerMapping(); | |
113 return mapping ? mapping->scrollingContentsLayer() : nullptr; | |
114 } | |
115 | |
116 PaintLayerCompositor* compositor = | |
117 localFrame.contentLayoutItem().compositor(); | |
118 DCHECK(compositor); | |
119 return compositor->scrollLayer(); | |
120 } | |
121 | |
97 WebLayer* getRootScrollLayer() { | 122 WebLayer* getRootScrollLayer() { |
98 PaintLayerCompositor* compositor = | 123 GraphicsLayer* layer = |
99 frame()->contentLayoutItem().compositor(); | 124 frame()->view()->layoutViewportScrollableArea()->layerForScrolling(); |
100 DCHECK(compositor); | 125 return layer ? layer->platformLayer() : nullptr; |
101 DCHECK(compositor->scrollLayer()); | |
102 | |
103 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); | |
104 return webScrollLayer; | |
105 } | 126 } |
106 | 127 |
107 WebViewImpl* webViewImpl() const { return m_helper.webView(); } | 128 WebViewImpl* webViewImpl() const { return m_helper.webView(); } |
108 LocalFrame* frame() const { | 129 LocalFrame* frame() const { |
109 return m_helper.webView()->mainFrameImpl()->frame(); | 130 return m_helper.webView()->mainFrameImpl()->frame(); |
110 } | 131 } |
111 | 132 |
112 WebLayerTreeView* webLayerTreeView() const { | 133 WebLayerTreeView* webLayerTreeView() const { |
113 return webViewImpl()->layerTreeView(); | 134 return webViewImpl()->layerTreeView(); |
114 } | 135 } |
115 | 136 |
116 void styleRelatedMainThreadScrollingReasonTest(const std::string&, | |
117 const uint32_t); | |
118 | |
119 protected: | 137 protected: |
120 std::string m_baseURL; | 138 std::string m_baseURL; |
121 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; | 139 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
122 | 140 |
123 private: | 141 private: |
124 static void configureSettings(WebSettings* settings) { | 142 static void configureSettings(WebSettings* settings) { |
125 settings->setJavaScriptEnabled(true); | 143 settings->setJavaScriptEnabled(true); |
126 settings->setAcceleratedCompositingEnabled(true); | 144 settings->setAcceleratedCompositingEnabled(true); |
127 settings->setPreferCompositingToLCDTextEnabled(true); | 145 settings->setPreferCompositingToLCDTextEnabled(true); |
128 } | 146 } |
129 | 147 |
130 FrameTestHelpers::WebViewHelper m_helper; | 148 FrameTestHelpers::WebViewHelper m_helper; |
131 }; | 149 }; |
132 | 150 |
133 TEST_F(ScrollingCoordinatorTest, fastScrollingByDefault) { | 151 INSTANTIATE_TEST_CASE_P(All, ScrollingCoordinatorTest, ::testing::Bool()); |
134 navigateTo("about:blank"); | 152 |
153 TEST_P(ScrollingCoordinatorTest, fastScrollingByDefault) { | |
154 webViewImpl()->resize(WebSize(800, 600)); | |
155 loadHTML("<div id='spacer' style='height: 1000px'></div>"); | |
135 forceFullCompositingUpdate(); | 156 forceFullCompositingUpdate(); |
136 | 157 |
137 // Make sure the scrolling coordinator is active. | 158 // Make sure the scrolling coordinator is active. |
138 FrameView* frameView = frame()->view(); | 159 FrameView* frameView = frame()->view(); |
139 Page* page = frame()->page(); | 160 Page* page = frame()->page(); |
140 ASSERT_TRUE(page->scrollingCoordinator()); | 161 ASSERT_TRUE(page->scrollingCoordinator()); |
141 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView( | 162 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView( |
142 frameView)); | 163 frameView)); |
143 | 164 |
144 // Fast scrolling should be enabled by default. | 165 // Fast scrolling should be enabled by default. |
145 WebLayer* rootScrollLayer = getRootScrollLayer(); | 166 WebLayer* rootScrollLayer = getRootScrollLayer(); |
167 ASSERT_TRUE(rootScrollLayer); | |
146 ASSERT_TRUE(rootScrollLayer->scrollable()); | 168 ASSERT_TRUE(rootScrollLayer->scrollable()); |
147 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); | 169 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
148 ASSERT_EQ(WebEventListenerProperties::Nothing, | 170 ASSERT_EQ(WebEventListenerProperties::Nothing, |
149 webLayerTreeView()->eventListenerProperties( | 171 webLayerTreeView()->eventListenerProperties( |
150 WebEventListenerClass::TouchStartOrMove)); | 172 WebEventListenerClass::TouchStartOrMove)); |
151 ASSERT_EQ(WebEventListenerProperties::Nothing, | 173 ASSERT_EQ(WebEventListenerProperties::Nothing, |
152 webLayerTreeView()->eventListenerProperties( | 174 webLayerTreeView()->eventListenerProperties( |
153 WebEventListenerClass::MouseWheel)); | 175 WebEventListenerClass::MouseWheel)); |
154 | 176 |
155 WebLayer* innerViewportScrollLayer = | 177 WebLayer* innerViewportScrollLayer = |
156 page->frameHost().visualViewport().scrollLayer()->platformLayer(); | 178 page->frameHost().visualViewport().scrollLayer()->platformLayer(); |
157 ASSERT_TRUE(innerViewportScrollLayer->scrollable()); | 179 ASSERT_TRUE(innerViewportScrollLayer->scrollable()); |
158 ASSERT_FALSE(innerViewportScrollLayer->shouldScrollOnMainThread()); | 180 ASSERT_FALSE(innerViewportScrollLayer->shouldScrollOnMainThread()); |
159 } | 181 } |
160 | 182 |
161 TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { | 183 TEST_P(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { |
162 navigateTo("about:blank"); | 184 webViewImpl()->resize(WebSize(800, 600)); |
185 loadHTML("<div id='spacer' style='height: 1000px'></div>"); | |
163 webViewImpl()->settings()->setThreadedScrollingEnabled(false); | 186 webViewImpl()->settings()->setThreadedScrollingEnabled(false); |
164 forceFullCompositingUpdate(); | 187 forceFullCompositingUpdate(); |
165 | 188 |
166 // Make sure the scrolling coordinator is active. | 189 // Make sure the scrolling coordinator is active. |
167 FrameView* frameView = frame()->view(); | 190 FrameView* frameView = frame()->view(); |
168 Page* page = frame()->page(); | 191 Page* page = frame()->page(); |
169 ASSERT_TRUE(page->scrollingCoordinator()); | 192 ASSERT_TRUE(page->scrollingCoordinator()); |
170 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView( | 193 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView( |
171 frameView)); | 194 frameView)); |
172 | 195 |
173 // Main scrolling should be enabled with the setting override. | 196 // Main scrolling should be enabled with the setting override. |
174 WebLayer* rootScrollLayer = getRootScrollLayer(); | 197 WebLayer* rootScrollLayer = getRootScrollLayer(); |
198 ASSERT_TRUE(rootScrollLayer); | |
175 ASSERT_TRUE(rootScrollLayer->scrollable()); | 199 ASSERT_TRUE(rootScrollLayer->scrollable()); |
176 ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread()); | 200 ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread()); |
177 | 201 |
178 // Main scrolling should also propagate to inner viewport layer. | 202 // Main scrolling should also propagate to inner viewport layer. |
179 WebLayer* innerViewportScrollLayer = | 203 WebLayer* innerViewportScrollLayer = |
180 page->frameHost().visualViewport().scrollLayer()->platformLayer(); | 204 page->frameHost().visualViewport().scrollLayer()->platformLayer(); |
181 ASSERT_TRUE(innerViewportScrollLayer->scrollable()); | 205 ASSERT_TRUE(innerViewportScrollLayer->scrollable()); |
182 ASSERT_TRUE(innerViewportScrollLayer->shouldScrollOnMainThread()); | 206 ASSERT_TRUE(innerViewportScrollLayer->shouldScrollOnMainThread()); |
183 } | 207 } |
184 | 208 |
185 TEST_F(ScrollingCoordinatorTest, fastFractionalScrollingDiv) { | 209 TEST_P(ScrollingCoordinatorTest, fastFractionalScrollingDiv) { |
186 bool origFractionalOffsetsEnabled = | 210 bool origFractionalOffsetsEnabled = |
187 RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); | 211 RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); |
188 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true); | 212 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true); |
189 | 213 |
190 registerMockedHttpURLLoad("fractional-scroll-div.html"); | 214 registerMockedHttpURLLoad("fractional-scroll-div.html"); |
191 navigateTo(m_baseURL + "fractional-scroll-div.html"); | 215 navigateTo(m_baseURL + "fractional-scroll-div.html"); |
192 forceFullCompositingUpdate(); | 216 forceFullCompositingUpdate(); |
193 | 217 |
194 Document* document = frame()->document(); | 218 Document* document = frame()->document(); |
195 Element* scrollableElement = document->getElementById("scroller"); | 219 Element* scrollableElement = document->getElementById("scroller"); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 if (!layer->hasCompositedLayerMapping()) | 259 if (!layer->hasCompositedLayerMapping()) |
236 return 0; | 260 return 0; |
237 CompositedLayerMapping* compositedLayerMapping = | 261 CompositedLayerMapping* compositedLayerMapping = |
238 layer->compositedLayerMapping(); | 262 layer->compositedLayerMapping(); |
239 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); | 263 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); |
240 if (!graphicsLayer) | 264 if (!graphicsLayer) |
241 return 0; | 265 return 0; |
242 return graphicsLayer->platformLayer(); | 266 return graphicsLayer->platformLayer(); |
243 } | 267 } |
244 | 268 |
245 TEST_F(ScrollingCoordinatorTest, fastScrollingForFixedPosition) { | 269 TEST_P(ScrollingCoordinatorTest, fastScrollingForFixedPosition) { |
246 registerMockedHttpURLLoad("fixed-position.html"); | 270 registerMockedHttpURLLoad("fixed-position.html"); |
247 navigateTo(m_baseURL + "fixed-position.html"); | 271 navigateTo(m_baseURL + "fixed-position.html"); |
248 forceFullCompositingUpdate(); | 272 forceFullCompositingUpdate(); |
249 | 273 |
250 // Fixed position should not fall back to main thread scrolling. | 274 // Fixed position should not fall back to main thread scrolling. |
251 WebLayer* rootScrollLayer = getRootScrollLayer(); | 275 WebLayer* rootScrollLayer = getRootScrollLayer(); |
276 ASSERT_TRUE(rootScrollLayer); | |
252 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); | 277 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
253 | 278 |
254 Document* document = frame()->document(); | 279 Document* document = frame()->document(); |
255 { | 280 { |
256 Element* element = document->getElementById("div-tl"); | 281 Element* element = document->getElementById("div-tl"); |
257 ASSERT_TRUE(element); | 282 ASSERT_TRUE(element); |
258 WebLayer* layer = webLayerFromElement(element); | 283 WebLayer* layer = webLayerFromElement(element); |
259 ASSERT_TRUE(layer); | 284 ASSERT_TRUE(layer); |
260 WebLayerPositionConstraint constraint = layer->positionConstraint(); | 285 WebLayerPositionConstraint constraint = layer->positionConstraint(); |
261 ASSERT_TRUE(constraint.isFixedPosition); | 286 ASSERT_TRUE(constraint.isFixedPosition); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 ASSERT_TRUE(element); | 352 ASSERT_TRUE(element); |
328 WebLayer* layer = webLayerFromElement(element); | 353 WebLayer* layer = webLayerFromElement(element); |
329 ASSERT_TRUE(layer); | 354 ASSERT_TRUE(layer); |
330 WebLayerPositionConstraint constraint = layer->positionConstraint(); | 355 WebLayerPositionConstraint constraint = layer->positionConstraint(); |
331 ASSERT_TRUE(constraint.isFixedPosition); | 356 ASSERT_TRUE(constraint.isFixedPosition); |
332 ASSERT_TRUE(constraint.isFixedToRightEdge && | 357 ASSERT_TRUE(constraint.isFixedToRightEdge && |
333 constraint.isFixedToBottomEdge); | 358 constraint.isFixedToBottomEdge); |
334 } | 359 } |
335 } | 360 } |
336 | 361 |
337 TEST_F(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { | 362 TEST_P(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { |
338 registerMockedHttpURLLoad("sticky-position.html"); | 363 registerMockedHttpURLLoad("sticky-position.html"); |
339 navigateTo(m_baseURL + "sticky-position.html"); | 364 navigateTo(m_baseURL + "sticky-position.html"); |
340 forceFullCompositingUpdate(); | 365 forceFullCompositingUpdate(); |
341 | 366 |
342 // Sticky position should not fall back to main thread scrolling. | 367 // Sticky position should not fall back to main thread scrolling. |
343 WebLayer* rootScrollLayer = getRootScrollLayer(); | 368 WebLayer* rootScrollLayer = getRootScrollLayer(); |
369 ASSERT_TRUE(rootScrollLayer); | |
344 EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); | 370 EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
345 | 371 |
346 Document* document = frame()->document(); | 372 Document* document = frame()->document(); |
347 { | 373 { |
348 Element* element = document->getElementById("div-tl"); | 374 Element* element = document->getElementById("div-tl"); |
349 ASSERT_TRUE(element); | 375 ASSERT_TRUE(element); |
350 WebLayer* layer = webLayerFromElement(element); | 376 WebLayer* layer = webLayerFromElement(element); |
351 ASSERT_TRUE(layer); | 377 ASSERT_TRUE(layer); |
352 WebLayerStickyPositionConstraint constraint = | 378 WebLayerStickyPositionConstraint constraint = |
353 layer->stickyPositionConstraint(); | 379 layer->stickyPositionConstraint(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 EXPECT_TRUE(constraint.isAnchoredTop); | 459 EXPECT_TRUE(constraint.isAnchoredTop); |
434 EXPECT_EQ(IntRect(100, 110, 10, 10), | 460 EXPECT_EQ(IntRect(100, 110, 10, 10), |
435 IntRect(constraint.scrollContainerRelativeStickyBoxRect)); | 461 IntRect(constraint.scrollContainerRelativeStickyBoxRect)); |
436 EXPECT_EQ(IntRect(100, 100, 200, 200), | 462 EXPECT_EQ(IntRect(100, 100, 200, 200), |
437 IntRect(constraint.scrollContainerRelativeContainingBlockRect)); | 463 IntRect(constraint.scrollContainerRelativeContainingBlockRect)); |
438 EXPECT_EQ(IntPoint(0, 10), | 464 EXPECT_EQ(IntPoint(0, 10), |
439 IntPoint(constraint.parentRelativeStickyBoxOffset)); | 465 IntPoint(constraint.parentRelativeStickyBoxOffset)); |
440 } | 466 } |
441 } | 467 } |
442 | 468 |
443 TEST_F(ScrollingCoordinatorTest, touchEventHandler) { | 469 TEST_P(ScrollingCoordinatorTest, touchEventHandler) { |
444 registerMockedHttpURLLoad("touch-event-handler.html"); | 470 registerMockedHttpURLLoad("touch-event-handler.html"); |
445 navigateTo(m_baseURL + "touch-event-handler.html"); | 471 navigateTo(m_baseURL + "touch-event-handler.html"); |
446 forceFullCompositingUpdate(); | 472 forceFullCompositingUpdate(); |
447 | 473 |
448 ASSERT_EQ(WebEventListenerProperties::Blocking, | 474 ASSERT_EQ(WebEventListenerProperties::Blocking, |
449 webLayerTreeView()->eventListenerProperties( | 475 webLayerTreeView()->eventListenerProperties( |
450 WebEventListenerClass::TouchStartOrMove)); | 476 WebEventListenerClass::TouchStartOrMove)); |
451 } | 477 } |
452 | 478 |
453 TEST_F(ScrollingCoordinatorTest, touchEventHandlerPassive) { | 479 TEST_P(ScrollingCoordinatorTest, touchEventHandlerPassive) { |
454 registerMockedHttpURLLoad("touch-event-handler-passive.html"); | 480 registerMockedHttpURLLoad("touch-event-handler-passive.html"); |
455 navigateTo(m_baseURL + "touch-event-handler-passive.html"); | 481 navigateTo(m_baseURL + "touch-event-handler-passive.html"); |
456 forceFullCompositingUpdate(); | 482 forceFullCompositingUpdate(); |
457 | 483 |
458 ASSERT_EQ(WebEventListenerProperties::Passive, | 484 ASSERT_EQ(WebEventListenerProperties::Passive, |
459 webLayerTreeView()->eventListenerProperties( | 485 webLayerTreeView()->eventListenerProperties( |
460 WebEventListenerClass::TouchStartOrMove)); | 486 WebEventListenerClass::TouchStartOrMove)); |
461 } | 487 } |
462 | 488 |
463 TEST_F(ScrollingCoordinatorTest, touchEventHandlerBoth) { | 489 TEST_P(ScrollingCoordinatorTest, touchEventHandlerBoth) { |
464 registerMockedHttpURLLoad("touch-event-handler-both.html"); | 490 registerMockedHttpURLLoad("touch-event-handler-both.html"); |
465 navigateTo(m_baseURL + "touch-event-handler-both.html"); | 491 navigateTo(m_baseURL + "touch-event-handler-both.html"); |
466 forceFullCompositingUpdate(); | 492 forceFullCompositingUpdate(); |
467 | 493 |
468 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive, | 494 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive, |
469 webLayerTreeView()->eventListenerProperties( | 495 webLayerTreeView()->eventListenerProperties( |
470 WebEventListenerClass::TouchStartOrMove)); | 496 WebEventListenerClass::TouchStartOrMove)); |
471 } | 497 } |
472 | 498 |
473 TEST_F(ScrollingCoordinatorTest, wheelEventHandler) { | 499 TEST_P(ScrollingCoordinatorTest, wheelEventHandler) { |
474 registerMockedHttpURLLoad("wheel-event-handler.html"); | 500 registerMockedHttpURLLoad("wheel-event-handler.html"); |
475 navigateTo(m_baseURL + "wheel-event-handler.html"); | 501 navigateTo(m_baseURL + "wheel-event-handler.html"); |
476 forceFullCompositingUpdate(); | 502 forceFullCompositingUpdate(); |
477 | 503 |
478 ASSERT_EQ(WebEventListenerProperties::Blocking, | 504 ASSERT_EQ(WebEventListenerProperties::Blocking, |
479 webLayerTreeView()->eventListenerProperties( | 505 webLayerTreeView()->eventListenerProperties( |
480 WebEventListenerClass::MouseWheel)); | 506 WebEventListenerClass::MouseWheel)); |
481 } | 507 } |
482 | 508 |
483 TEST_F(ScrollingCoordinatorTest, wheelEventHandlerPassive) { | 509 TEST_P(ScrollingCoordinatorTest, wheelEventHandlerPassive) { |
484 registerMockedHttpURLLoad("wheel-event-handler-passive.html"); | 510 registerMockedHttpURLLoad("wheel-event-handler-passive.html"); |
485 navigateTo(m_baseURL + "wheel-event-handler-passive.html"); | 511 navigateTo(m_baseURL + "wheel-event-handler-passive.html"); |
486 forceFullCompositingUpdate(); | 512 forceFullCompositingUpdate(); |
487 | 513 |
488 ASSERT_EQ(WebEventListenerProperties::Passive, | 514 ASSERT_EQ(WebEventListenerProperties::Passive, |
489 webLayerTreeView()->eventListenerProperties( | 515 webLayerTreeView()->eventListenerProperties( |
490 WebEventListenerClass::MouseWheel)); | 516 WebEventListenerClass::MouseWheel)); |
491 } | 517 } |
492 | 518 |
493 TEST_F(ScrollingCoordinatorTest, wheelEventHandlerBoth) { | 519 TEST_P(ScrollingCoordinatorTest, wheelEventHandlerBoth) { |
494 registerMockedHttpURLLoad("wheel-event-handler-both.html"); | 520 registerMockedHttpURLLoad("wheel-event-handler-both.html"); |
495 navigateTo(m_baseURL + "wheel-event-handler-both.html"); | 521 navigateTo(m_baseURL + "wheel-event-handler-both.html"); |
496 forceFullCompositingUpdate(); | 522 forceFullCompositingUpdate(); |
497 | 523 |
498 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive, | 524 ASSERT_EQ(WebEventListenerProperties::BlockingAndPassive, |
499 webLayerTreeView()->eventListenerProperties( | 525 webLayerTreeView()->eventListenerProperties( |
500 WebEventListenerClass::MouseWheel)); | 526 WebEventListenerClass::MouseWheel)); |
501 } | 527 } |
502 | 528 |
503 TEST_F(ScrollingCoordinatorTest, scrollEventHandler) { | 529 TEST_P(ScrollingCoordinatorTest, scrollEventHandler) { |
504 registerMockedHttpURLLoad("scroll-event-handler.html"); | 530 registerMockedHttpURLLoad("scroll-event-handler.html"); |
505 navigateTo(m_baseURL + "scroll-event-handler.html"); | 531 navigateTo(m_baseURL + "scroll-event-handler.html"); |
506 forceFullCompositingUpdate(); | 532 forceFullCompositingUpdate(); |
507 | 533 |
508 ASSERT_TRUE(webLayerTreeView()->haveScrollEventHandlers()); | 534 ASSERT_TRUE(webLayerTreeView()->haveScrollEventHandlers()); |
509 } | 535 } |
510 | 536 |
511 TEST_F(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) { | 537 TEST_P(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) { |
512 registerMockedHttpURLLoad("scroll-event-handler-window.html"); | 538 registerMockedHttpURLLoad("scroll-event-handler-window.html"); |
513 navigateTo(m_baseURL + "scroll-event-handler-window.html"); | 539 navigateTo(m_baseURL + "scroll-event-handler-window.html"); |
514 forceFullCompositingUpdate(); | 540 forceFullCompositingUpdate(); |
515 | 541 |
516 // Simulate detaching the document from its DOM window. This should not | 542 // Simulate detaching the document from its DOM window. This should not |
517 // cause a crash when the WebViewImpl is closed by the test runner. | 543 // cause a crash when the WebViewImpl is closed by the test runner. |
518 frame()->document()->shutdown(); | 544 frame()->document()->shutdown(); |
519 } | 545 } |
520 | 546 |
521 TEST_F(ScrollingCoordinatorTest, clippedBodyTest) { | 547 TEST_P(ScrollingCoordinatorTest, clippedBodyTest) { |
522 registerMockedHttpURLLoad("clipped-body.html"); | 548 registerMockedHttpURLLoad("clipped-body.html"); |
523 navigateTo(m_baseURL + "clipped-body.html"); | 549 navigateTo(m_baseURL + "clipped-body.html"); |
524 forceFullCompositingUpdate(); | 550 forceFullCompositingUpdate(); |
525 | 551 |
526 WebLayer* rootScrollLayer = getRootScrollLayer(); | 552 WebLayer* rootScrollLayer = getRootScrollLayer(); |
553 ASSERT_TRUE(rootScrollLayer); | |
527 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); | 554 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); |
528 } | 555 } |
529 | 556 |
530 TEST_F(ScrollingCoordinatorTest, overflowScrolling) { | 557 TEST_P(ScrollingCoordinatorTest, overflowScrolling) { |
531 registerMockedHttpURLLoad("overflow-scrolling.html"); | 558 registerMockedHttpURLLoad("overflow-scrolling.html"); |
532 navigateTo(m_baseURL + "overflow-scrolling.html"); | 559 navigateTo(m_baseURL + "overflow-scrolling.html"); |
533 forceFullCompositingUpdate(); | 560 forceFullCompositingUpdate(); |
534 | 561 |
535 // Verify the properties of the accelerated scrolling element starting from | 562 // Verify the properties of the accelerated scrolling element starting from |
536 // the LayoutObject all the way to the WebLayer. | 563 // the LayoutObject all the way to the WebLayer. |
537 Element* scrollableElement = | 564 Element* scrollableElement = |
538 frame()->document()->getElementById("scrollable"); | 565 frame()->document()->getElementById("scrollable"); |
539 DCHECK(scrollableElement); | 566 DCHECK(scrollableElement); |
540 | 567 |
(...skipping 25 matching lines...) Expand all Loading... | |
566 // Now verify we've attached impl-side scrollbars onto the scrollbar layers | 593 // Now verify we've attached impl-side scrollbars onto the scrollbar layers |
567 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()); | 594 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()); |
568 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar() | 595 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar() |
569 ->hasContentsLayer()); | 596 ->hasContentsLayer()); |
570 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); | 597 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); |
571 ASSERT_TRUE( | 598 ASSERT_TRUE( |
572 compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); | 599 compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); |
573 #endif | 600 #endif |
574 } | 601 } |
575 | 602 |
576 TEST_F(ScrollingCoordinatorTest, overflowHidden) { | 603 TEST_P(ScrollingCoordinatorTest, overflowHidden) { |
577 registerMockedHttpURLLoad("overflow-hidden.html"); | 604 registerMockedHttpURLLoad("overflow-hidden.html"); |
578 navigateTo(m_baseURL + "overflow-hidden.html"); | 605 navigateTo(m_baseURL + "overflow-hidden.html"); |
579 forceFullCompositingUpdate(); | 606 forceFullCompositingUpdate(); |
580 | 607 |
581 // Verify the properties of the accelerated scrolling element starting from | 608 // Verify the properties of the accelerated scrolling element starting from |
582 // the LayoutObject all the way to the WebLayer. | 609 // the LayoutObject all the way to the WebLayer. |
583 Element* overflowElement = | 610 Element* overflowElement = |
584 frame()->document()->getElementById("unscrollable-y"); | 611 frame()->document()->getElementById("unscrollable-y"); |
585 DCHECK(overflowElement); | 612 DCHECK(overflowElement); |
586 | 613 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 ASSERT_EQ(box->layer()->getScrollableArea(), | 654 ASSERT_EQ(box->layer()->getScrollableArea(), |
628 graphicsLayer->getScrollableArea()); | 655 graphicsLayer->getScrollableArea()); |
629 | 656 |
630 webScrollLayer = | 657 webScrollLayer = |
631 compositedLayerMapping->scrollingContentsLayer()->platformLayer(); | 658 compositedLayerMapping->scrollingContentsLayer()->platformLayer(); |
632 ASSERT_TRUE(webScrollLayer->scrollable()); | 659 ASSERT_TRUE(webScrollLayer->scrollable()); |
633 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 660 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
634 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 661 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
635 } | 662 } |
636 | 663 |
637 TEST_F(ScrollingCoordinatorTest, iframeScrolling) { | 664 TEST_P(ScrollingCoordinatorTest, iframeScrolling) { |
638 registerMockedHttpURLLoad("iframe-scrolling.html"); | 665 registerMockedHttpURLLoad("iframe-scrolling.html"); |
639 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); | 666 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); |
640 navigateTo(m_baseURL + "iframe-scrolling.html"); | 667 navigateTo(m_baseURL + "iframe-scrolling.html"); |
641 forceFullCompositingUpdate(); | 668 forceFullCompositingUpdate(); |
642 | 669 |
643 // Verify the properties of the accelerated scrolling element starting from | 670 // Verify the properties of the accelerated scrolling element starting from |
644 // the LayoutObject all the way to the WebLayer. | 671 // the LayoutObject all the way to the WebLayer. |
645 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); | 672 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); |
646 ASSERT_TRUE(scrollableFrame); | 673 ASSERT_TRUE(scrollableFrame); |
647 | 674 |
648 LayoutObject* layoutObject = scrollableFrame->layoutObject(); | 675 LayoutObject* layoutObject = scrollableFrame->layoutObject(); |
649 ASSERT_TRUE(layoutObject); | 676 ASSERT_TRUE(layoutObject); |
650 ASSERT_TRUE(layoutObject->isLayoutPart()); | 677 ASSERT_TRUE(layoutObject->isLayoutPart()); |
651 | 678 |
652 LayoutPart* layoutPart = toLayoutPart(layoutObject); | 679 LayoutPart* layoutPart = toLayoutPart(layoutObject); |
653 ASSERT_TRUE(layoutPart); | 680 ASSERT_TRUE(layoutPart); |
654 ASSERT_TRUE(layoutPart->widget()); | 681 ASSERT_TRUE(layoutPart->widget()); |
655 ASSERT_TRUE(layoutPart->widget()->isFrameView()); | 682 ASSERT_TRUE(layoutPart->widget()->isFrameView()); |
656 | 683 |
657 FrameView* innerFrameView = toFrameView(layoutPart->widget()); | 684 FrameView* innerFrameView = toFrameView(layoutPart->widget()); |
658 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); | 685 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); |
659 ASSERT_FALSE(innerLayoutViewItem.isNull()); | 686 ASSERT_FALSE(innerLayoutViewItem.isNull()); |
660 | 687 |
661 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); | 688 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
662 ASSERT_TRUE(innerCompositor->inCompositingMode()); | 689 ASSERT_TRUE(innerCompositor->inCompositingMode()); |
663 ASSERT_TRUE(innerCompositor->scrollLayer()); | |
664 | 690 |
665 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); | 691 GraphicsLayer* scrollLayer = |
666 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); | 692 innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); |
693 ASSERT_TRUE(scrollLayer); | |
694 ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(), | |
695 scrollLayer->getScrollableArea()); | |
667 | 696 |
668 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 697 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
669 ASSERT_TRUE(webScrollLayer->scrollable()); | 698 ASSERT_TRUE(webScrollLayer->scrollable()); |
670 | 699 |
671 #if OS(ANDROID) | 700 #if OS(ANDROID) |
672 // Now verify we've attached impl-side scrollbars onto the scrollbar layers | 701 // Now verify we've attached impl-side scrollbars onto the scrollbar layers |
673 ASSERT_TRUE(innerCompositor->layerForHorizontalScrollbar()); | 702 ASSERT_TRUE(innerCompositor->layerForHorizontalScrollbar()); |
674 ASSERT_TRUE( | 703 ASSERT_TRUE( |
675 innerCompositor->layerForHorizontalScrollbar()->hasContentsLayer()); | 704 innerCompositor->layerForHorizontalScrollbar()->hasContentsLayer()); |
676 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); | 705 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); |
677 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()); | 706 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()); |
678 #endif | 707 #endif |
679 } | 708 } |
680 | 709 |
681 TEST_F(ScrollingCoordinatorTest, rtlIframe) { | 710 TEST_P(ScrollingCoordinatorTest, rtlIframe) { |
682 registerMockedHttpURLLoad("rtl-iframe.html"); | 711 registerMockedHttpURLLoad("rtl-iframe.html"); |
683 registerMockedHttpURLLoad("rtl-iframe-inner.html"); | 712 registerMockedHttpURLLoad("rtl-iframe-inner.html"); |
684 navigateTo(m_baseURL + "rtl-iframe.html"); | 713 navigateTo(m_baseURL + "rtl-iframe.html"); |
685 forceFullCompositingUpdate(); | 714 forceFullCompositingUpdate(); |
686 | 715 |
687 // Verify the properties of the accelerated scrolling element starting from | 716 // Verify the properties of the accelerated scrolling element starting from |
688 // the LayoutObject all the way to the WebLayer. | 717 // the LayoutObject all the way to the WebLayer. |
689 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); | 718 Element* scrollableFrame = frame()->document()->getElementById("scrollable"); |
690 ASSERT_TRUE(scrollableFrame); | 719 ASSERT_TRUE(scrollableFrame); |
691 | 720 |
692 LayoutObject* layoutObject = scrollableFrame->layoutObject(); | 721 LayoutObject* layoutObject = scrollableFrame->layoutObject(); |
693 ASSERT_TRUE(layoutObject); | 722 ASSERT_TRUE(layoutObject); |
694 ASSERT_TRUE(layoutObject->isLayoutPart()); | 723 ASSERT_TRUE(layoutObject->isLayoutPart()); |
695 | 724 |
696 LayoutPart* layoutPart = toLayoutPart(layoutObject); | 725 LayoutPart* layoutPart = toLayoutPart(layoutObject); |
697 ASSERT_TRUE(layoutPart); | 726 ASSERT_TRUE(layoutPart); |
698 ASSERT_TRUE(layoutPart->widget()); | 727 ASSERT_TRUE(layoutPart->widget()); |
699 ASSERT_TRUE(layoutPart->widget()->isFrameView()); | 728 ASSERT_TRUE(layoutPart->widget()->isFrameView()); |
700 | 729 |
701 FrameView* innerFrameView = toFrameView(layoutPart->widget()); | 730 FrameView* innerFrameView = toFrameView(layoutPart->widget()); |
702 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); | 731 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); |
703 ASSERT_FALSE(innerLayoutViewItem.isNull()); | 732 ASSERT_FALSE(innerLayoutViewItem.isNull()); |
704 | 733 |
705 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); | 734 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
706 ASSERT_TRUE(innerCompositor->inCompositingMode()); | 735 ASSERT_TRUE(innerCompositor->inCompositingMode()); |
707 ASSERT_TRUE(innerCompositor->scrollLayer()); | |
708 | 736 |
709 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); | 737 GraphicsLayer* scrollLayer = |
710 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); | 738 innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); |
739 ASSERT_TRUE(scrollLayer); | |
740 ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(), | |
741 scrollLayer->getScrollableArea()); | |
711 | 742 |
712 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 743 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
713 ASSERT_TRUE(webScrollLayer->scrollable()); | 744 ASSERT_TRUE(webScrollLayer->scrollable()); |
714 | 745 |
715 int expectedScrollPosition = | 746 int expectedScrollPosition = |
716 958 + | 747 958 + (innerFrameView->layoutViewportScrollableArea() |
717 (innerFrameView->verticalScrollbar()->isOverlayScrollbar() ? 0 : 15); | 748 ->verticalScrollbar() |
749 ->isOverlayScrollbar() | |
750 ? 0 | |
751 : 15); | |
718 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPositionDouble().x); | 752 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPositionDouble().x); |
719 } | 753 } |
720 | 754 |
721 TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) { | 755 TEST_P(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) { |
722 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); | 756 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); |
723 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); | 757 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); |
724 forceFullCompositingUpdate(); | 758 forceFullCompositingUpdate(); |
725 // This test document setup an iframe with scrollbars, then switch to | 759 // This test document setup an iframe with scrollbars, then switch to |
726 // an empty document by javascript. | 760 // an empty document by javascript. |
727 } | 761 } |
728 | 762 |
729 TEST_F(ScrollingCoordinatorTest, | 763 TEST_P(ScrollingCoordinatorTest, |
730 scrollbarsForceMainThreadOrHaveWebScrollbarLayer) { | 764 scrollbarsForceMainThreadOrHaveWebScrollbarLayer) { |
731 registerMockedHttpURLLoad("trivial-scroller.html"); | 765 registerMockedHttpURLLoad("trivial-scroller.html"); |
732 navigateTo(m_baseURL + "trivial-scroller.html"); | 766 navigateTo(m_baseURL + "trivial-scroller.html"); |
733 forceFullCompositingUpdate(); | 767 forceFullCompositingUpdate(); |
734 | 768 |
735 Document* document = frame()->document(); | 769 Document* document = frame()->document(); |
736 Element* scrollableElement = document->getElementById("scroller"); | 770 Element* scrollableElement = document->getElementById("scroller"); |
737 DCHECK(scrollableElement); | 771 DCHECK(scrollableElement); |
738 | 772 |
739 LayoutObject* layoutObject = scrollableElement->layoutObject(); | 773 LayoutObject* layoutObject = scrollableElement->layoutObject(); |
740 ASSERT_TRUE(layoutObject->isBox()); | 774 ASSERT_TRUE(layoutObject->isBox()); |
741 LayoutBox* box = toLayoutBox(layoutObject); | 775 LayoutBox* box = toLayoutBox(layoutObject); |
742 ASSERT_TRUE(box->usesCompositedScrolling()); | 776 ASSERT_TRUE(box->usesCompositedScrolling()); |
743 CompositedLayerMapping* compositedLayerMapping = | 777 CompositedLayerMapping* compositedLayerMapping = |
744 box->layer()->compositedLayerMapping(); | 778 box->layer()->compositedLayerMapping(); |
745 GraphicsLayer* scrollbarGraphicsLayer = | 779 GraphicsLayer* scrollbarGraphicsLayer = |
746 compositedLayerMapping->layerForVerticalScrollbar(); | 780 compositedLayerMapping->layerForVerticalScrollbar(); |
747 ASSERT_TRUE(scrollbarGraphicsLayer); | 781 ASSERT_TRUE(scrollbarGraphicsLayer); |
748 | 782 |
749 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent(); | 783 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent(); |
750 ASSERT_TRUE( | 784 ASSERT_TRUE( |
751 hasWebScrollbarLayer || | 785 hasWebScrollbarLayer || |
752 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); | 786 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); |
753 } | 787 } |
754 | 788 |
755 #if OS(MACOSX) || OS(ANDROID) | 789 #if OS(MACOSX) || OS(ANDROID) |
756 TEST_F(ScrollingCoordinatorTest, | 790 TEST_P(ScrollingCoordinatorTest, |
757 DISABLED_setupScrollbarLayerShouldSetScrollLayerOpaque) | 791 DISABLED_setupScrollbarLayerShouldSetScrollLayerOpaque) |
758 #else | 792 #else |
759 TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) | 793 TEST_P(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) |
760 #endif | 794 #endif |
761 { | 795 { |
762 registerMockedHttpURLLoad("wide_document.html"); | 796 registerMockedHttpURLLoad("wide_document.html"); |
763 navigateTo(m_baseURL + "wide_document.html"); | 797 navigateTo(m_baseURL + "wide_document.html"); |
764 forceFullCompositingUpdate(); | 798 forceFullCompositingUpdate(); |
765 | 799 |
766 FrameView* frameView = frame()->view(); | 800 FrameView* frameView = frame()->view(); |
767 ASSERT_TRUE(frameView); | 801 ASSERT_TRUE(frameView); |
768 | 802 |
769 GraphicsLayer* scrollbarGraphicsLayer = | 803 GraphicsLayer* scrollbarGraphicsLayer = |
770 frameView->layerForHorizontalScrollbar(); | 804 frameView->layoutViewportScrollableArea()->layerForHorizontalScrollbar(); |
771 ASSERT_TRUE(scrollbarGraphicsLayer); | 805 ASSERT_TRUE(scrollbarGraphicsLayer); |
772 | 806 |
773 WebLayer* platformLayer = scrollbarGraphicsLayer->platformLayer(); | 807 WebLayer* platformLayer = scrollbarGraphicsLayer->platformLayer(); |
774 ASSERT_TRUE(platformLayer); | 808 ASSERT_TRUE(platformLayer); |
775 | 809 |
776 WebLayer* contentsLayer = scrollbarGraphicsLayer->contentsLayer(); | 810 WebLayer* contentsLayer = scrollbarGraphicsLayer->contentsLayer(); |
777 ASSERT_TRUE(contentsLayer); | 811 ASSERT_TRUE(contentsLayer); |
778 | 812 |
779 // After scrollableAreaScrollbarLayerDidChange, | 813 // After scrollableAreaScrollbarLayerDidChange, |
780 // if the main frame's scrollbarLayer is opaque, | 814 // if the main frame's scrollbarLayer is opaque, |
781 // contentsLayer should be opaque too. | 815 // contentsLayer should be opaque too. |
782 ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque()); | 816 ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque()); |
783 } | 817 } |
784 | 818 |
785 TEST_F(ScrollingCoordinatorTest, | 819 TEST_P(ScrollingCoordinatorTest, |
786 FixedPositionLosingBackingShouldTriggerMainThreadScroll) { | 820 FixedPositionLosingBackingShouldTriggerMainThreadScroll) { |
787 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 821 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
788 registerMockedHttpURLLoad("fixed-position-losing-backing.html"); | 822 registerMockedHttpURLLoad("fixed-position-losing-backing.html"); |
789 navigateTo(m_baseURL + "fixed-position-losing-backing.html"); | 823 navigateTo(m_baseURL + "fixed-position-losing-backing.html"); |
790 forceFullCompositingUpdate(); | 824 forceFullCompositingUpdate(); |
791 | 825 |
792 WebLayer* scrollLayer = frame() | 826 WebLayer* scrollLayer = getRootScrollLayer(); |
793 ->page() | 827 ASSERT_TRUE(scrollLayer); |
794 ->deprecatedLocalMainFrame() | 828 |
795 ->view() | |
796 ->layerForScrolling() | |
797 ->platformLayer(); | |
798 Document* document = frame()->document(); | 829 Document* document = frame()->document(); |
799 Element* fixedPos = document->getElementById("fixed"); | 830 Element* fixedPos = document->getElementById("fixed"); |
800 | 831 |
801 EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject()) | 832 EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject()) |
802 ->layer() | 833 ->layer() |
803 ->hasCompositedLayerMapping()); | 834 ->hasCompositedLayerMapping()); |
804 EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread()); | 835 EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread()); |
805 | 836 |
806 fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone); | 837 fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone); |
807 forceFullCompositingUpdate(); | 838 forceFullCompositingUpdate(); |
808 | 839 |
809 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject()) | 840 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject()) |
810 ->layer() | 841 ->layer() |
811 ->hasCompositedLayerMapping()); | 842 ->hasCompositedLayerMapping()); |
812 EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread()); | 843 EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread()); |
813 } | 844 } |
814 | 845 |
815 TEST_F(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { | 846 TEST_P(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { |
816 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | 847 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
817 webViewImpl()->setDeviceScaleFactor(2.f); | 848 webViewImpl()->setDeviceScaleFactor(2.f); |
818 registerMockedHttpURLLoad("custom_scrollbar.html"); | 849 registerMockedHttpURLLoad("custom_scrollbar.html"); |
819 navigateTo(m_baseURL + "custom_scrollbar.html"); | 850 navigateTo(m_baseURL + "custom_scrollbar.html"); |
820 forceFullCompositingUpdate(); | 851 forceFullCompositingUpdate(); |
821 | 852 |
822 Document* document = frame()->document(); | 853 Document* document = frame()->document(); |
823 Element* container = document->getElementById("container"); | 854 Element* container = document->getElementById("container"); |
824 Element* content = document->getElementById("content"); | 855 Element* content = document->getElementById("content"); |
825 DCHECK_EQ(container->getAttribute(HTMLNames::classAttr), "custom_scrollbar"); | 856 DCHECK_EQ(container->getAttribute(HTMLNames::classAttr), "custom_scrollbar"); |
(...skipping 20 matching lines...) Expand all Loading... | |
846 container->removeAttribute("class"); | 877 container->removeAttribute("class"); |
847 forceFullCompositingUpdate(); | 878 forceFullCompositingUpdate(); |
848 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); | 879 scrollbarGraphicsLayer = compositedLayerMapping->layerForVerticalScrollbar(); |
849 ASSERT_FALSE( | 880 ASSERT_FALSE( |
850 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); | 881 scrollbarGraphicsLayer->platformLayer()->shouldScrollOnMainThread()); |
851 ASSERT_FALSE( | 882 ASSERT_FALSE( |
852 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & | 883 scrollbarGraphicsLayer->platformLayer()->mainThreadScrollingReasons() & |
853 MainThreadScrollingReason::kCustomScrollbarScrolling); | 884 MainThreadScrollingReason::kCustomScrollbarScrolling); |
854 } | 885 } |
855 | 886 |
856 TEST_F(ScrollingCoordinatorTest, | 887 TEST_P(ScrollingCoordinatorTest, |
857 BackgroundAttachmentFixedShouldTriggerMainThreadScroll) { | 888 BackgroundAttachmentFixedShouldTriggerMainThreadScroll) { |
858 registerMockedHttpURLLoad("iframe-background-attachment-fixed.html"); | 889 registerMockedHttpURLLoad("iframe-background-attachment-fixed.html"); |
859 registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html"); | 890 registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html"); |
860 registerMockedHttpURLLoad("white-1x1.png"); | 891 registerMockedHttpURLLoad("white-1x1.png"); |
861 navigateTo(m_baseURL + "iframe-background-attachment-fixed.html"); | 892 navigateTo(m_baseURL + "iframe-background-attachment-fixed.html"); |
862 forceFullCompositingUpdate(); | 893 forceFullCompositingUpdate(); |
863 | 894 |
864 Element* iframe = frame()->document()->getElementById("iframe"); | 895 Element* iframe = frame()->document()->getElementById("iframe"); |
865 ASSERT_TRUE(iframe); | 896 ASSERT_TRUE(iframe); |
866 | 897 |
867 LayoutObject* layoutObject = iframe->layoutObject(); | 898 LayoutObject* layoutObject = iframe->layoutObject(); |
868 ASSERT_TRUE(layoutObject); | 899 ASSERT_TRUE(layoutObject); |
869 ASSERT_TRUE(layoutObject->isLayoutPart()); | 900 ASSERT_TRUE(layoutObject->isLayoutPart()); |
870 | 901 |
871 LayoutPart* layoutPart = toLayoutPart(layoutObject); | 902 LayoutPart* layoutPart = toLayoutPart(layoutObject); |
872 ASSERT_TRUE(layoutPart); | 903 ASSERT_TRUE(layoutPart); |
873 ASSERT_TRUE(layoutPart->widget()); | 904 ASSERT_TRUE(layoutPart->widget()); |
874 ASSERT_TRUE(layoutPart->widget()->isFrameView()); | 905 ASSERT_TRUE(layoutPart->widget()->isFrameView()); |
875 | 906 |
876 FrameView* innerFrameView = toFrameView(layoutPart->widget()); | 907 FrameView* innerFrameView = toFrameView(layoutPart->widget()); |
877 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); | 908 LayoutViewItem innerLayoutViewItem = innerFrameView->layoutViewItem(); |
878 ASSERT_FALSE(innerLayoutViewItem.isNull()); | 909 ASSERT_FALSE(innerLayoutViewItem.isNull()); |
879 | 910 |
880 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); | 911 PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
881 ASSERT_TRUE(innerCompositor->inCompositingMode()); | 912 ASSERT_TRUE(innerCompositor->inCompositingMode()); |
882 ASSERT_TRUE(innerCompositor->scrollLayer()); | |
883 | 913 |
884 GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); | 914 GraphicsLayer* scrollLayer = |
885 ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); | 915 innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); |
916 ASSERT_TRUE(scrollLayer); | |
917 ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(), | |
918 scrollLayer->getScrollableArea()); | |
886 | 919 |
887 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 920 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
888 ASSERT_TRUE(webScrollLayer->scrollable()); | 921 ASSERT_TRUE(webScrollLayer->scrollable()); |
889 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & | 922 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & |
890 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 923 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
891 | 924 |
892 // Remove fixed background-attachment should make the iframe | 925 // Remove fixed background-attachment should make the iframe |
893 // scroll on cc. | 926 // scroll on cc. |
894 auto* iframeDoc = toHTMLIFrameElement(iframe)->contentDocument(); | 927 auto* iframeDoc = toHTMLIFrameElement(iframe)->contentDocument(); |
895 iframe = iframeDoc->getElementById("scrollable"); | 928 iframe = iframeDoc->getElementById("scrollable"); |
896 ASSERT_TRUE(iframe); | 929 ASSERT_TRUE(iframe); |
897 | 930 |
898 iframe->removeAttribute("class"); | 931 iframe->removeAttribute("class"); |
899 forceFullCompositingUpdate(); | 932 forceFullCompositingUpdate(); |
900 | 933 |
901 layoutObject = iframe->layoutObject(); | 934 layoutObject = iframe->layoutObject(); |
902 ASSERT_TRUE(layoutObject); | 935 ASSERT_TRUE(layoutObject); |
903 | 936 |
904 scrollLayer = layoutObject->frameView()->layerForScrolling(); | 937 scrollLayer = layoutObject->frameView() |
938 ->layoutViewportScrollableArea() | |
939 ->layerForScrolling(); | |
905 ASSERT_TRUE(scrollLayer); | 940 ASSERT_TRUE(scrollLayer); |
906 | 941 |
907 webScrollLayer = scrollLayer->platformLayer(); | 942 webScrollLayer = scrollLayer->platformLayer(); |
908 ASSERT_TRUE(webScrollLayer->scrollable()); | 943 ASSERT_TRUE(webScrollLayer->scrollable()); |
909 ASSERT_FALSE(webScrollLayer->mainThreadScrollingReasons() & | 944 ASSERT_FALSE(webScrollLayer->mainThreadScrollingReasons() & |
910 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 945 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
911 | 946 |
912 // Force main frame to scroll on main thread. All its descendants | 947 // Force main frame to scroll on main thread. All its descendants |
913 // should scroll on main thread as well. | 948 // should scroll on main thread as well. |
914 Element* element = frame()->document()->getElementById("scrollable"); | 949 Element* element = frame()->document()->getElementById("scrollable"); |
915 element->setAttribute( | 950 element->setAttribute( |
916 "style", | 951 "style", |
917 "background-image: url('white-1x1.png'); background-attachment: fixed;", | 952 "background-image: url('white-1x1.png'); background-attachment: fixed;", |
918 ASSERT_NO_EXCEPTION); | 953 ASSERT_NO_EXCEPTION); |
919 | 954 |
920 forceFullCompositingUpdate(); | 955 forceFullCompositingUpdate(); |
921 | 956 |
922 layoutObject = iframe->layoutObject(); | 957 layoutObject = iframe->layoutObject(); |
923 ASSERT_TRUE(layoutObject); | 958 ASSERT_TRUE(layoutObject); |
924 | 959 |
925 scrollLayer = layoutObject->frameView()->layerForScrolling(); | 960 scrollLayer = layoutObject->frameView() |
961 ->layoutViewportScrollableArea() | |
962 ->layerForScrolling(); | |
926 ASSERT_TRUE(scrollLayer); | 963 ASSERT_TRUE(scrollLayer); |
927 | 964 |
928 webScrollLayer = scrollLayer->platformLayer(); | 965 webScrollLayer = scrollLayer->platformLayer(); |
929 ASSERT_TRUE(webScrollLayer->scrollable()); | 966 ASSERT_TRUE(webScrollLayer->scrollable()); |
930 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & | 967 ASSERT_TRUE(webScrollLayer->mainThreadScrollingReasons() & |
931 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 968 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
932 } | 969 } |
933 | 970 |
934 // Upon resizing the content size, the main thread scrolling reason | 971 // Upon resizing the content size, the main thread scrolling reason |
935 // kHasNonLayerViewportConstrainedObject should be updated on all frames | 972 // kHasNonLayerViewportConstrainedObject should be updated on all frames |
936 TEST_F(ScrollingCoordinatorTest, | 973 TEST_P(ScrollingCoordinatorTest, |
937 RecalculateMainThreadScrollingReasonsUponResize) { | 974 RecalculateMainThreadScrollingReasonsUponResize) { |
938 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 975 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
939 registerMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html"); | 976 registerMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html"); |
940 navigateTo(m_baseURL + "has-non-layer-viewport-constrained-objects.html"); | 977 navigateTo(m_baseURL + "has-non-layer-viewport-constrained-objects.html"); |
941 forceFullCompositingUpdate(); | 978 forceFullCompositingUpdate(); |
942 | 979 |
943 LOG(ERROR) << frame()->view()->mainThreadScrollingReasons(); | 980 LOG(ERROR) << frame()->view()->mainThreadScrollingReasons(); |
944 Element* element = frame()->document()->getElementById("scrollable"); | 981 Element* element = frame()->document()->getElementById("scrollable"); |
945 ASSERT_TRUE(element); | 982 ASSERT_TRUE(element); |
946 | 983 |
947 LayoutObject* layoutObject = element->layoutObject(); | 984 LayoutObject* layoutObject = element->layoutObject(); |
948 ASSERT_TRUE(layoutObject); | 985 ASSERT_TRUE(layoutObject); |
949 | 986 |
950 GraphicsLayer* scrollLayer = layoutObject->frameView()->layerForScrolling(); | 987 GraphicsLayer* scrollLayer = layoutObject->frameView() |
951 ASSERT_TRUE(scrollLayer); | 988 ->layoutViewportScrollableArea() |
989 ->layerForScrolling(); | |
990 WebLayer* webScrollLayer; | |
952 | 991 |
953 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 992 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
954 ASSERT_TRUE(webScrollLayer->scrollable()); | 993 // When RLS is enabled, the LayoutView won't have a scrolling contents |
955 ASSERT_FALSE( | 994 // because it does not overflow. |
956 webScrollLayer->mainThreadScrollingReasons() & | 995 ASSERT_FALSE(scrollLayer); |
957 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 996 } else { |
958 | 997 ASSERT_TRUE(scrollLayer); |
959 Element* iframe = frame()->document()->getElementById("iframe"); | 998 webScrollLayer = scrollLayer->platformLayer(); |
960 ASSERT_TRUE(iframe); | 999 ASSERT_TRUE(webScrollLayer->scrollable()); |
961 | 1000 ASSERT_FALSE( |
962 layoutObject = iframe->layoutObject(); | 1001 webScrollLayer->mainThreadScrollingReasons() & |
963 ASSERT_TRUE(layoutObject); | 1002 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
964 | 1003 } |
965 scrollLayer = layoutObject->frameView()->layerForScrolling(); | |
966 ASSERT_TRUE(scrollLayer); | |
967 | |
968 webScrollLayer = scrollLayer->platformLayer(); | |
969 ASSERT_TRUE(webScrollLayer->scrollable()); | |
970 ASSERT_FALSE( | |
971 webScrollLayer->mainThreadScrollingReasons() & | |
972 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | |
973 | 1004 |
974 // When the div becomes to scrollable it should scroll on main thread | 1005 // When the div becomes to scrollable it should scroll on main thread |
975 element->setAttribute("style", | 1006 element->setAttribute("style", |
976 "overflow:scroll;height:2000px;will-change:transform;", | 1007 "overflow:scroll;height:2000px;will-change:transform;", |
977 ASSERT_NO_EXCEPTION); | 1008 ASSERT_NO_EXCEPTION); |
978 forceFullCompositingUpdate(); | 1009 forceFullCompositingUpdate(); |
979 | 1010 |
980 layoutObject = element->layoutObject(); | 1011 layoutObject = element->layoutObject(); |
981 ASSERT_TRUE(layoutObject); | 1012 ASSERT_TRUE(layoutObject); |
982 | 1013 |
983 scrollLayer = layoutObject->frameView()->layerForScrolling(); | 1014 scrollLayer = layoutObject->frameView() |
1015 ->layoutViewportScrollableArea() | |
1016 ->layerForScrolling(); | |
984 ASSERT_TRUE(scrollLayer); | 1017 ASSERT_TRUE(scrollLayer); |
985 | 1018 |
986 webScrollLayer = scrollLayer->platformLayer(); | 1019 webScrollLayer = scrollLayer->platformLayer(); |
987 ASSERT_TRUE(webScrollLayer->scrollable()); | |
988 ASSERT_TRUE( | |
989 webScrollLayer->mainThreadScrollingReasons() & | |
990 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | |
991 | |
992 layoutObject = iframe->layoutObject(); | |
993 ASSERT_TRUE(layoutObject); | |
994 | |
995 scrollLayer = layoutObject->frameView()->layerForScrolling(); | |
996 ASSERT_TRUE(scrollLayer); | |
997 | |
998 webScrollLayer = scrollLayer->platformLayer(); | |
999 ASSERT_TRUE(webScrollLayer->scrollable()); | 1020 ASSERT_TRUE(webScrollLayer->scrollable()); |
1000 ASSERT_TRUE( | 1021 ASSERT_TRUE( |
1001 webScrollLayer->mainThreadScrollingReasons() & | 1022 webScrollLayer->mainThreadScrollingReasons() & |
1002 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 1023 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
1003 | 1024 |
1004 // The main thread scrolling reason should be reset upon the following change | 1025 // The main thread scrolling reason should be reset upon the following change |
1005 element->setAttribute("style", | 1026 element->setAttribute("style", |
1006 "overflow:scroll;height:200px;will-change:transform;", | 1027 "overflow:scroll;height:200px;will-change:transform;", |
1007 ASSERT_NO_EXCEPTION); | 1028 ASSERT_NO_EXCEPTION); |
1008 forceFullCompositingUpdate(); | 1029 forceFullCompositingUpdate(); |
1009 | 1030 |
1010 layoutObject = element->layoutObject(); | 1031 layoutObject = element->layoutObject(); |
1011 ASSERT_TRUE(layoutObject); | 1032 ASSERT_TRUE(layoutObject); |
1012 | 1033 |
1013 scrollLayer = layoutObject->frameView()->layerForScrolling(); | 1034 scrollLayer = layoutObject->frameView() |
1014 ASSERT_TRUE(scrollLayer); | 1035 ->layoutViewportScrollableArea() |
1015 | 1036 ->layerForScrolling(); |
1016 webScrollLayer = scrollLayer->platformLayer(); | 1037 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
1017 ASSERT_TRUE(webScrollLayer->scrollable()); | 1038 // When RLS is enabled, the LayoutView won't have a scrolling contents |
1018 ASSERT_FALSE( | 1039 // because it does not overflow. |
1019 webScrollLayer->mainThreadScrollingReasons() & | 1040 ASSERT_FALSE(scrollLayer); |
1020 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | 1041 } else { |
1021 | 1042 ASSERT_TRUE(scrollLayer); |
1022 layoutObject = iframe->layoutObject(); | 1043 webScrollLayer = scrollLayer->platformLayer(); |
1023 ASSERT_TRUE(layoutObject); | 1044 ASSERT_TRUE(webScrollLayer->scrollable()); |
1024 | 1045 ASSERT_FALSE( |
1025 scrollLayer = layoutObject->frameView()->layerForScrolling(); | 1046 webScrollLayer->mainThreadScrollingReasons() & |
1026 ASSERT_TRUE(scrollLayer); | 1047 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
1027 | 1048 } |
1028 webScrollLayer = scrollLayer->platformLayer(); | |
1029 ASSERT_TRUE(webScrollLayer->scrollable()); | |
1030 ASSERT_FALSE( | |
1031 webScrollLayer->mainThreadScrollingReasons() & | |
1032 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | |
1033 } | 1049 } |
1034 | 1050 |
1035 class StyleRelatedMainThreadScrollingReasonTest | 1051 class StyleRelatedMainThreadScrollingReasonTest |
1036 : public ScrollingCoordinatorTest { | 1052 : public ScrollingCoordinatorTest { |
1037 static const uint32_t m_LCDTextRelatedReasons = | 1053 static const uint32_t m_LCDTextRelatedReasons = |
1038 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1054 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1039 MainThreadScrollingReason::kHasTransformAndLCDText | | 1055 MainThreadScrollingReason::kHasTransformAndLCDText | |
1040 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; | 1056 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText; |
1041 | 1057 |
1042 protected: | 1058 protected: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 | 1101 |
1086 if ((reason & m_LCDTextRelatedReasons) && | 1102 if ((reason & m_LCDTextRelatedReasons) && |
1087 !(reason & ~m_LCDTextRelatedReasons)) { | 1103 !(reason & ~m_LCDTextRelatedReasons)) { |
1088 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); | 1104 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
1089 forceFullCompositingUpdate(); | 1105 forceFullCompositingUpdate(); |
1090 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); | 1106 ASSERT_FALSE(frameView->mainThreadScrollingReasons()); |
1091 } | 1107 } |
1092 } | 1108 } |
1093 }; | 1109 }; |
1094 | 1110 |
1095 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { | 1111 INSTANTIATE_TEST_CASE_P(All, |
1112 StyleRelatedMainThreadScrollingReasonTest, | |
1113 ::testing::Bool()); | |
1114 | |
1115 TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { | |
1096 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); | 1116 testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); |
1097 } | 1117 } |
1098 | 1118 |
1099 TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { | 1119 TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { |
1100 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); | 1120 testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); |
1101 } | 1121 } |
1102 | 1122 |
1103 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { | 1123 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
1104 testStyle("background-not-opaque", | 1124 testStyle("background-not-opaque", |
1105 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); | 1125 MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
1106 } | 1126 } |
1107 | 1127 |
1108 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { | 1128 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { |
1109 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); | 1129 testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); |
1110 } | 1130 } |
1111 | 1131 |
1112 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { | 1132 TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { |
1113 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); | 1133 testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); |
1114 } | 1134 } |
1115 | 1135 |
1116 TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { | 1136 TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { |
1117 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; | 1137 uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
1118 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); | 1138 webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
1119 Document* document = frame()->document(); | 1139 Document* document = frame()->document(); |
1120 // Test ancestor with ClipPath | 1140 // Test ancestor with ClipPath |
1121 Element* element = document->body(); | 1141 Element* element = document->body(); |
1122 DCHECK(element); | 1142 DCHECK(element); |
1123 element->setAttribute(HTMLNames::styleAttr, | 1143 element->setAttribute(HTMLNames::styleAttr, |
1124 "clip-path:circle(115px at 20px 20px);"); | 1144 "clip-path:circle(115px at 20px 20px);"); |
1125 forceFullCompositingUpdate(); | 1145 forceFullCompositingUpdate(); |
1126 | 1146 |
(...skipping 14 matching lines...) Expand all Loading... | |
1141 "clip-path:circle(115px at 20px 20px);"); | 1161 "clip-path:circle(115px at 20px 20px);"); |
1142 forceFullCompositingUpdate(); | 1162 forceFullCompositingUpdate(); |
1143 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); | 1163 ASSERT_TRUE(frameView->mainThreadScrollingReasons() & reason); |
1144 | 1164 |
1145 // Remove clip path from descendant. | 1165 // Remove clip path from descendant. |
1146 element->removeAttribute(HTMLNames::styleAttr); | 1166 element->removeAttribute(HTMLNames::styleAttr); |
1147 forceFullCompositingUpdate(); | 1167 forceFullCompositingUpdate(); |
1148 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); | 1168 ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
1149 } | 1169 } |
1150 | 1170 |
1151 TEST_F(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { | 1171 TEST_P(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
1152 testStyle("transparent border-radius", | 1172 testStyle("transparent border-radius", |
1153 MainThreadScrollingReason::kHasOpacityAndLCDText | | 1173 MainThreadScrollingReason::kHasOpacityAndLCDText | |
1154 MainThreadScrollingReason::kHasBorderRadius); | 1174 MainThreadScrollingReason::kHasBorderRadius); |
1155 } | 1175 } |
1156 | 1176 |
1157 TEST_F(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) { | 1177 TEST_P(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) { |
1158 testStyle("box-shadow", | 1178 testStyle("box-shadow", |
1159 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); | 1179 MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
1160 } | 1180 } |
1161 | 1181 |
1162 } // namespace blink | 1182 } // namespace blink |
OLD | NEW |