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