Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| index 85f01cb06c32d8b18fb0a53df78cddd1f5f3f1ff..cd53996f54e391c0c4499ec52ed8328db9115971 100644 |
| --- a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp |
| @@ -38,6 +38,7 @@ |
| #include "platform/geometry/IntPoint.h" |
| #include "platform/geometry/IntRect.h" |
| #include "platform/graphics/GraphicsLayer.h" |
| +#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| #include "platform/testing/URLTestHelpers.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebLayer.h" |
| @@ -54,9 +55,13 @@ |
| namespace blink { |
| -class ScrollingCoordinatorTest : public testing::Test { |
| +class ScrollingCoordinatorTest : public testing::Test, |
| + public testing::WithParamInterface<bool>, |
| + private ScopedRootLayerScrollingForTest { |
| public: |
| - ScrollingCoordinatorTest() : m_baseURL("http://www.test.com/") { |
| + ScrollingCoordinatorTest() |
| + : ScopedRootLayerScrollingForTest(GetParam()), |
| + m_baseURL("http://www.test.com/") { |
| m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, |
| &configureSettings); |
| webViewImpl()->resize(IntSize(320, 240)); |
| @@ -84,6 +89,11 @@ class ScrollingCoordinatorTest : public testing::Test { |
| FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); |
| } |
| + void loadHTML(const std::string& html) { |
| + FrameTestHelpers::loadHTMLString(webViewImpl()->mainFrame(), html, |
| + URLTestHelpers::toKURL("about:blank")); |
| + } |
| + |
| void forceFullCompositingUpdate() { |
| webViewImpl()->updateAllLifecyclePhases(); |
| } |
| @@ -94,14 +104,25 @@ class ScrollingCoordinatorTest : public testing::Test { |
| WebString::fromUTF8(fileName.c_str())); |
| } |
| - WebLayer* getRootScrollLayer() { |
| + GraphicsLayer* getFrameScrollLayer(LocalFrame& localFrame) { |
|
skobes
2017/01/28 01:07:45
This looks unused.
szager1
2017/01/31 00:00:28
Removed.
|
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| + LayoutView* layoutView = localFrame.contentLayoutObject(); |
| + DCHECK(layoutView); |
| + DCHECK(layoutView->layer()); |
| + auto* mapping = layoutView->layer()->compositedLayerMapping(); |
| + return mapping ? mapping->scrollingContentsLayer() : nullptr; |
| + } |
| + |
| PaintLayerCompositor* compositor = |
| - frame()->contentLayoutItem().compositor(); |
| + localFrame.contentLayoutItem().compositor(); |
| DCHECK(compositor); |
| - DCHECK(compositor->scrollLayer()); |
| + return compositor->scrollLayer(); |
| + } |
| - WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); |
| - return webScrollLayer; |
| + WebLayer* getRootScrollLayer() { |
| + GraphicsLayer* layer = |
| + frame()->view()->layoutViewportScrollableArea()->layerForScrolling(); |
| + return layer ? layer->platformLayer() : nullptr; |
| } |
| WebViewImpl* webViewImpl() const { return m_helper.webView(); } |
| @@ -113,9 +134,6 @@ class ScrollingCoordinatorTest : public testing::Test { |
| return webViewImpl()->layerTreeView(); |
| } |
| - void styleRelatedMainThreadScrollingReasonTest(const std::string&, |
| - const uint32_t); |
| - |
| protected: |
| std::string m_baseURL; |
| FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
| @@ -130,8 +148,11 @@ class ScrollingCoordinatorTest : public testing::Test { |
| FrameTestHelpers::WebViewHelper m_helper; |
| }; |
| -TEST_F(ScrollingCoordinatorTest, fastScrollingByDefault) { |
| - navigateTo("about:blank"); |
| +INSTANTIATE_TEST_CASE_P(All, ScrollingCoordinatorTest, ::testing::Bool()); |
| + |
| +TEST_P(ScrollingCoordinatorTest, fastScrollingByDefault) { |
| + webViewImpl()->resize(WebSize(800, 600)); |
| + loadHTML("<div id='spacer' style='height: 1000px'></div>"); |
| forceFullCompositingUpdate(); |
| // Make sure the scrolling coordinator is active. |
| @@ -143,6 +164,7 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingByDefault) { |
| // Fast scrolling should be enabled by default. |
| WebLayer* rootScrollLayer = getRootScrollLayer(); |
| + ASSERT_TRUE(rootScrollLayer); |
| ASSERT_TRUE(rootScrollLayer->scrollable()); |
| ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
| ASSERT_EQ(WebEventListenerProperties::Nothing, |
| @@ -158,8 +180,9 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingByDefault) { |
| ASSERT_FALSE(innerViewportScrollLayer->shouldScrollOnMainThread()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { |
| - navigateTo("about:blank"); |
| +TEST_P(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { |
| + webViewImpl()->resize(WebSize(800, 600)); |
| + loadHTML("<div id='spacer' style='height: 1000px'></div>"); |
| webViewImpl()->settings()->setThreadedScrollingEnabled(false); |
| forceFullCompositingUpdate(); |
| @@ -172,6 +195,7 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { |
| // Main scrolling should be enabled with the setting override. |
| WebLayer* rootScrollLayer = getRootScrollLayer(); |
| + ASSERT_TRUE(rootScrollLayer); |
| ASSERT_TRUE(rootScrollLayer->scrollable()); |
| ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread()); |
| @@ -182,7 +206,7 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { |
| ASSERT_TRUE(innerViewportScrollLayer->shouldScrollOnMainThread()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, fastFractionalScrollingDiv) { |
| +TEST_P(ScrollingCoordinatorTest, fastFractionalScrollingDiv) { |
| bool origFractionalOffsetsEnabled = |
| RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); |
| RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true); |
| @@ -242,13 +266,14 @@ static WebLayer* webLayerFromElement(Element* element) { |
| return graphicsLayer->platformLayer(); |
| } |
| -TEST_F(ScrollingCoordinatorTest, fastScrollingForFixedPosition) { |
| +TEST_P(ScrollingCoordinatorTest, fastScrollingForFixedPosition) { |
| registerMockedHttpURLLoad("fixed-position.html"); |
| navigateTo(m_baseURL + "fixed-position.html"); |
| forceFullCompositingUpdate(); |
| // Fixed position should not fall back to main thread scrolling. |
| WebLayer* rootScrollLayer = getRootScrollLayer(); |
| + ASSERT_TRUE(rootScrollLayer); |
| ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
| Document* document = frame()->document(); |
| @@ -334,13 +359,14 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingForFixedPosition) { |
| } |
| } |
| -TEST_F(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { |
| +TEST_P(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { |
| registerMockedHttpURLLoad("sticky-position.html"); |
| navigateTo(m_baseURL + "sticky-position.html"); |
| forceFullCompositingUpdate(); |
| // Sticky position should not fall back to main thread scrolling. |
| WebLayer* rootScrollLayer = getRootScrollLayer(); |
| + ASSERT_TRUE(rootScrollLayer); |
| EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
| Document* document = frame()->document(); |
| @@ -440,7 +466,7 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingForStickyPosition) { |
| } |
| } |
| -TEST_F(ScrollingCoordinatorTest, touchEventHandler) { |
| +TEST_P(ScrollingCoordinatorTest, touchEventHandler) { |
| registerMockedHttpURLLoad("touch-event-handler.html"); |
| navigateTo(m_baseURL + "touch-event-handler.html"); |
| forceFullCompositingUpdate(); |
| @@ -450,7 +476,7 @@ TEST_F(ScrollingCoordinatorTest, touchEventHandler) { |
| WebEventListenerClass::TouchStartOrMove)); |
| } |
| -TEST_F(ScrollingCoordinatorTest, touchEventHandlerPassive) { |
| +TEST_P(ScrollingCoordinatorTest, touchEventHandlerPassive) { |
| registerMockedHttpURLLoad("touch-event-handler-passive.html"); |
| navigateTo(m_baseURL + "touch-event-handler-passive.html"); |
| forceFullCompositingUpdate(); |
| @@ -460,7 +486,7 @@ TEST_F(ScrollingCoordinatorTest, touchEventHandlerPassive) { |
| WebEventListenerClass::TouchStartOrMove)); |
| } |
| -TEST_F(ScrollingCoordinatorTest, touchEventHandlerBoth) { |
| +TEST_P(ScrollingCoordinatorTest, touchEventHandlerBoth) { |
| registerMockedHttpURLLoad("touch-event-handler-both.html"); |
| navigateTo(m_baseURL + "touch-event-handler-both.html"); |
| forceFullCompositingUpdate(); |
| @@ -470,7 +496,7 @@ TEST_F(ScrollingCoordinatorTest, touchEventHandlerBoth) { |
| WebEventListenerClass::TouchStartOrMove)); |
| } |
| -TEST_F(ScrollingCoordinatorTest, wheelEventHandler) { |
| +TEST_P(ScrollingCoordinatorTest, wheelEventHandler) { |
| registerMockedHttpURLLoad("wheel-event-handler.html"); |
| navigateTo(m_baseURL + "wheel-event-handler.html"); |
| forceFullCompositingUpdate(); |
| @@ -480,7 +506,7 @@ TEST_F(ScrollingCoordinatorTest, wheelEventHandler) { |
| WebEventListenerClass::MouseWheel)); |
| } |
| -TEST_F(ScrollingCoordinatorTest, wheelEventHandlerPassive) { |
| +TEST_P(ScrollingCoordinatorTest, wheelEventHandlerPassive) { |
| registerMockedHttpURLLoad("wheel-event-handler-passive.html"); |
| navigateTo(m_baseURL + "wheel-event-handler-passive.html"); |
| forceFullCompositingUpdate(); |
| @@ -490,7 +516,7 @@ TEST_F(ScrollingCoordinatorTest, wheelEventHandlerPassive) { |
| WebEventListenerClass::MouseWheel)); |
| } |
| -TEST_F(ScrollingCoordinatorTest, wheelEventHandlerBoth) { |
| +TEST_P(ScrollingCoordinatorTest, wheelEventHandlerBoth) { |
| registerMockedHttpURLLoad("wheel-event-handler-both.html"); |
| navigateTo(m_baseURL + "wheel-event-handler-both.html"); |
| forceFullCompositingUpdate(); |
| @@ -500,7 +526,7 @@ TEST_F(ScrollingCoordinatorTest, wheelEventHandlerBoth) { |
| WebEventListenerClass::MouseWheel)); |
| } |
| -TEST_F(ScrollingCoordinatorTest, scrollEventHandler) { |
| +TEST_P(ScrollingCoordinatorTest, scrollEventHandler) { |
| registerMockedHttpURLLoad("scroll-event-handler.html"); |
| navigateTo(m_baseURL + "scroll-event-handler.html"); |
| forceFullCompositingUpdate(); |
| @@ -508,7 +534,7 @@ TEST_F(ScrollingCoordinatorTest, scrollEventHandler) { |
| ASSERT_TRUE(webLayerTreeView()->haveScrollEventHandlers()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) { |
| +TEST_P(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) { |
| registerMockedHttpURLLoad("scroll-event-handler-window.html"); |
| navigateTo(m_baseURL + "scroll-event-handler-window.html"); |
| forceFullCompositingUpdate(); |
| @@ -518,16 +544,17 @@ TEST_F(ScrollingCoordinatorTest, updateEventHandlersDuringTeardown) { |
| frame()->document()->shutdown(); |
| } |
| -TEST_F(ScrollingCoordinatorTest, clippedBodyTest) { |
| +TEST_P(ScrollingCoordinatorTest, clippedBodyTest) { |
| registerMockedHttpURLLoad("clipped-body.html"); |
| navigateTo(m_baseURL + "clipped-body.html"); |
| forceFullCompositingUpdate(); |
| WebLayer* rootScrollLayer = getRootScrollLayer(); |
| + ASSERT_TRUE(rootScrollLayer); |
| ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, overflowScrolling) { |
| +TEST_P(ScrollingCoordinatorTest, overflowScrolling) { |
| registerMockedHttpURLLoad("overflow-scrolling.html"); |
| navigateTo(m_baseURL + "overflow-scrolling.html"); |
| forceFullCompositingUpdate(); |
| @@ -573,7 +600,7 @@ TEST_F(ScrollingCoordinatorTest, overflowScrolling) { |
| #endif |
| } |
| -TEST_F(ScrollingCoordinatorTest, overflowHidden) { |
| +TEST_P(ScrollingCoordinatorTest, overflowHidden) { |
| registerMockedHttpURLLoad("overflow-hidden.html"); |
| navigateTo(m_baseURL + "overflow-hidden.html"); |
| forceFullCompositingUpdate(); |
| @@ -634,7 +661,7 @@ TEST_F(ScrollingCoordinatorTest, overflowHidden) { |
| ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, iframeScrolling) { |
| +TEST_P(ScrollingCoordinatorTest, iframeScrolling) { |
| registerMockedHttpURLLoad("iframe-scrolling.html"); |
| registerMockedHttpURLLoad("iframe-scrolling-inner.html"); |
| navigateTo(m_baseURL + "iframe-scrolling.html"); |
| @@ -660,10 +687,12 @@ TEST_F(ScrollingCoordinatorTest, iframeScrolling) { |
| PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
| ASSERT_TRUE(innerCompositor->inCompositingMode()); |
| - ASSERT_TRUE(innerCompositor->scrollLayer()); |
| - GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); |
| - ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); |
| + GraphicsLayer* scrollLayer = |
| + innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); |
| + ASSERT_TRUE(scrollLayer); |
| + ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(), |
| + scrollLayer->getScrollableArea()); |
| WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| ASSERT_TRUE(webScrollLayer->scrollable()); |
| @@ -678,7 +707,7 @@ TEST_F(ScrollingCoordinatorTest, iframeScrolling) { |
| #endif |
| } |
| -TEST_F(ScrollingCoordinatorTest, rtlIframe) { |
| +TEST_P(ScrollingCoordinatorTest, rtlIframe) { |
| registerMockedHttpURLLoad("rtl-iframe.html"); |
| registerMockedHttpURLLoad("rtl-iframe-inner.html"); |
| navigateTo(m_baseURL + "rtl-iframe.html"); |
| @@ -704,21 +733,26 @@ TEST_F(ScrollingCoordinatorTest, rtlIframe) { |
| PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
| ASSERT_TRUE(innerCompositor->inCompositingMode()); |
| - ASSERT_TRUE(innerCompositor->scrollLayer()); |
| - GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); |
| - ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); |
| + GraphicsLayer* scrollLayer = |
| + innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); |
| + ASSERT_TRUE(scrollLayer); |
| + ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(), |
| + scrollLayer->getScrollableArea()); |
| WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| ASSERT_TRUE(webScrollLayer->scrollable()); |
| int expectedScrollPosition = |
| - 958 + |
| - (innerFrameView->verticalScrollbar()->isOverlayScrollbar() ? 0 : 15); |
| + 958 + (innerFrameView->layoutViewportScrollableArea() |
| + ->verticalScrollbar() |
| + ->isOverlayScrollbar() |
| + ? 0 |
| + : 15); |
| ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPositionDouble().x); |
| } |
| -TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) { |
| +TEST_P(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) { |
| registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); |
| navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); |
| forceFullCompositingUpdate(); |
| @@ -726,7 +760,7 @@ TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldNotCrash) { |
| // an empty document by javascript. |
| } |
| -TEST_F(ScrollingCoordinatorTest, |
| +TEST_P(ScrollingCoordinatorTest, |
| scrollbarsForceMainThreadOrHaveWebScrollbarLayer) { |
| registerMockedHttpURLLoad("trivial-scroller.html"); |
| navigateTo(m_baseURL + "trivial-scroller.html"); |
| @@ -753,10 +787,10 @@ TEST_F(ScrollingCoordinatorTest, |
| } |
| #if OS(MACOSX) || OS(ANDROID) |
| -TEST_F(ScrollingCoordinatorTest, |
| +TEST_P(ScrollingCoordinatorTest, |
| DISABLED_setupScrollbarLayerShouldSetScrollLayerOpaque) |
| #else |
| -TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) |
| +TEST_P(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) |
| #endif |
| { |
| registerMockedHttpURLLoad("wide_document.html"); |
| @@ -767,7 +801,7 @@ TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) |
| ASSERT_TRUE(frameView); |
| GraphicsLayer* scrollbarGraphicsLayer = |
| - frameView->layerForHorizontalScrollbar(); |
| + frameView->layoutViewportScrollableArea()->layerForHorizontalScrollbar(); |
| ASSERT_TRUE(scrollbarGraphicsLayer); |
| WebLayer* platformLayer = scrollbarGraphicsLayer->platformLayer(); |
| @@ -782,19 +816,16 @@ TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) |
| ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, |
| +TEST_P(ScrollingCoordinatorTest, |
| FixedPositionLosingBackingShouldTriggerMainThreadScroll) { |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| registerMockedHttpURLLoad("fixed-position-losing-backing.html"); |
| navigateTo(m_baseURL + "fixed-position-losing-backing.html"); |
| forceFullCompositingUpdate(); |
| - WebLayer* scrollLayer = frame() |
| - ->page() |
| - ->deprecatedLocalMainFrame() |
| - ->view() |
| - ->layerForScrolling() |
| - ->platformLayer(); |
| + WebLayer* scrollLayer = getRootScrollLayer(); |
| + ASSERT_TRUE(scrollLayer); |
| + |
| Document* document = frame()->document(); |
| Element* fixedPos = document->getElementById("fixed"); |
| @@ -812,7 +843,7 @@ TEST_F(ScrollingCoordinatorTest, |
| EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread()); |
| } |
| -TEST_F(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { |
| +TEST_P(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| webViewImpl()->setDeviceScaleFactor(2.f); |
| registerMockedHttpURLLoad("custom_scrollbar.html"); |
| @@ -853,7 +884,7 @@ TEST_F(ScrollingCoordinatorTest, CustomScrollbarShouldTriggerMainThreadScroll) { |
| MainThreadScrollingReason::kCustomScrollbarScrolling); |
| } |
| -TEST_F(ScrollingCoordinatorTest, |
| +TEST_P(ScrollingCoordinatorTest, |
| BackgroundAttachmentFixedShouldTriggerMainThreadScroll) { |
| registerMockedHttpURLLoad("iframe-background-attachment-fixed.html"); |
| registerMockedHttpURLLoad("iframe-background-attachment-fixed-inner.html"); |
| @@ -879,10 +910,12 @@ TEST_F(ScrollingCoordinatorTest, |
| PaintLayerCompositor* innerCompositor = innerLayoutViewItem.compositor(); |
| ASSERT_TRUE(innerCompositor->inCompositingMode()); |
| - ASSERT_TRUE(innerCompositor->scrollLayer()); |
| - GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); |
| - ASSERT_EQ(innerFrameView, scrollLayer->getScrollableArea()); |
| + GraphicsLayer* scrollLayer = |
| + innerFrameView->layoutViewportScrollableArea()->layerForScrolling(); |
| + ASSERT_TRUE(scrollLayer); |
| + ASSERT_EQ(innerFrameView->layoutViewportScrollableArea(), |
| + scrollLayer->getScrollableArea()); |
| WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| ASSERT_TRUE(webScrollLayer->scrollable()); |
| @@ -901,7 +934,9 @@ TEST_F(ScrollingCoordinatorTest, |
| layoutObject = iframe->layoutObject(); |
| ASSERT_TRUE(layoutObject); |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| + scrollLayer = layoutObject->frameView() |
| + ->layoutViewportScrollableArea() |
| + ->layerForScrolling(); |
| ASSERT_TRUE(scrollLayer); |
| webScrollLayer = scrollLayer->platformLayer(); |
| @@ -922,7 +957,9 @@ TEST_F(ScrollingCoordinatorTest, |
| layoutObject = iframe->layoutObject(); |
| ASSERT_TRUE(layoutObject); |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| + scrollLayer = layoutObject->frameView() |
| + ->layoutViewportScrollableArea() |
| + ->layerForScrolling(); |
| ASSERT_TRUE(scrollLayer); |
| webScrollLayer = scrollLayer->platformLayer(); |
| @@ -933,7 +970,7 @@ TEST_F(ScrollingCoordinatorTest, |
| // Upon resizing the content size, the main thread scrolling reason |
| // kHasNonLayerViewportConstrainedObject should be updated on all frames |
| -TEST_F(ScrollingCoordinatorTest, |
| +TEST_P(ScrollingCoordinatorTest, |
| RecalculateMainThreadScrollingReasonsUponResize) { |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| registerMockedHttpURLLoad("has-non-layer-viewport-constrained-objects.html"); |
| @@ -947,29 +984,23 @@ TEST_F(ScrollingCoordinatorTest, |
| LayoutObject* layoutObject = element->layoutObject(); |
| ASSERT_TRUE(layoutObject); |
| - GraphicsLayer* scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| - ASSERT_TRUE(scrollLayer); |
| - |
| - WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| - ASSERT_TRUE(webScrollLayer->scrollable()); |
| - ASSERT_FALSE( |
| - webScrollLayer->mainThreadScrollingReasons() & |
| - MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| - |
| - Element* iframe = frame()->document()->getElementById("iframe"); |
| - ASSERT_TRUE(iframe); |
| - |
| - layoutObject = iframe->layoutObject(); |
| - ASSERT_TRUE(layoutObject); |
| - |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| - ASSERT_TRUE(scrollLayer); |
| - |
| - webScrollLayer = scrollLayer->platformLayer(); |
| - ASSERT_TRUE(webScrollLayer->scrollable()); |
| - ASSERT_FALSE( |
| - webScrollLayer->mainThreadScrollingReasons() & |
| - MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| + GraphicsLayer* scrollLayer = layoutObject->frameView() |
| + ->layoutViewportScrollableArea() |
| + ->layerForScrolling(); |
| + WebLayer* webScrollLayer; |
| + |
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| + // When RLS is enabled, the LayoutView won't have a scrolling contents |
| + // because it does not overflow. |
| + ASSERT_FALSE(scrollLayer); |
| + } else { |
| + ASSERT_TRUE(scrollLayer); |
| + webScrollLayer = scrollLayer->platformLayer(); |
| + ASSERT_TRUE(webScrollLayer->scrollable()); |
| + ASSERT_FALSE( |
| + webScrollLayer->mainThreadScrollingReasons() & |
| + MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| + } |
| // When the div becomes to scrollable it should scroll on main thread |
| element->setAttribute("style", |
| @@ -980,19 +1011,9 @@ TEST_F(ScrollingCoordinatorTest, |
| layoutObject = element->layoutObject(); |
| ASSERT_TRUE(layoutObject); |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| - ASSERT_TRUE(scrollLayer); |
| - |
| - webScrollLayer = scrollLayer->platformLayer(); |
| - ASSERT_TRUE(webScrollLayer->scrollable()); |
| - ASSERT_TRUE( |
| - webScrollLayer->mainThreadScrollingReasons() & |
| - MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| - |
| - layoutObject = iframe->layoutObject(); |
| - ASSERT_TRUE(layoutObject); |
| - |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| + scrollLayer = layoutObject->frameView() |
| + ->layoutViewportScrollableArea() |
| + ->layerForScrolling(); |
| ASSERT_TRUE(scrollLayer); |
| webScrollLayer = scrollLayer->platformLayer(); |
| @@ -1010,26 +1031,21 @@ TEST_F(ScrollingCoordinatorTest, |
| layoutObject = element->layoutObject(); |
| ASSERT_TRUE(layoutObject); |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| - ASSERT_TRUE(scrollLayer); |
| - |
| - webScrollLayer = scrollLayer->platformLayer(); |
| - ASSERT_TRUE(webScrollLayer->scrollable()); |
| - ASSERT_FALSE( |
| - webScrollLayer->mainThreadScrollingReasons() & |
| - MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| - |
| - layoutObject = iframe->layoutObject(); |
| - ASSERT_TRUE(layoutObject); |
| - |
| - scrollLayer = layoutObject->frameView()->layerForScrolling(); |
| - ASSERT_TRUE(scrollLayer); |
| - |
| - webScrollLayer = scrollLayer->platformLayer(); |
| - ASSERT_TRUE(webScrollLayer->scrollable()); |
| - ASSERT_FALSE( |
| - webScrollLayer->mainThreadScrollingReasons() & |
| - MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| + scrollLayer = layoutObject->frameView() |
| + ->layoutViewportScrollableArea() |
| + ->layerForScrolling(); |
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| + // When RLS is enabled, the LayoutView won't have a scrolling contents |
| + // because it does not overflow. |
| + ASSERT_FALSE(scrollLayer); |
| + } else { |
| + ASSERT_TRUE(scrollLayer); |
| + webScrollLayer = scrollLayer->platformLayer(); |
| + ASSERT_TRUE(webScrollLayer->scrollable()); |
| + ASSERT_FALSE( |
| + webScrollLayer->mainThreadScrollingReasons() & |
| + MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| + } |
| } |
| class StyleRelatedMainThreadScrollingReasonTest |
| @@ -1092,28 +1108,32 @@ class StyleRelatedMainThreadScrollingReasonTest |
| } |
| }; |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { |
| +INSTANTIATE_TEST_CASE_P(All, |
| + StyleRelatedMainThreadScrollingReasonTest, |
| + ::testing::Bool()); |
| + |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransparentTest) { |
| testStyle("transparent", MainThreadScrollingReason::kHasOpacityAndLCDText); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, TransformTest) { |
| testStyle("transform", MainThreadScrollingReason::kHasTransformAndLCDText); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, BackgroundNotOpaqueTest) { |
| testStyle("background-not-opaque", |
| MainThreadScrollingReason::kBackgroundNotOpaqueInRectAndLCDText); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, BorderRadiusTest) { |
| testStyle("border-radius", MainThreadScrollingReason::kHasBorderRadius); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipTest) { |
| testStyle("clip", MainThreadScrollingReason::kHasClipRelatedProperty); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { |
| uint32_t reason = MainThreadScrollingReason::kHasClipRelatedProperty; |
| webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); |
| Document* document = frame()->document(); |
| @@ -1148,13 +1168,13 @@ TEST_F(StyleRelatedMainThreadScrollingReasonTest, ClipPathTest) { |
| ASSERT_FALSE(frameView->mainThreadScrollingReasons() & reason); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, LCDTextEnabledTest) { |
| testStyle("transparent border-radius", |
| MainThreadScrollingReason::kHasOpacityAndLCDText | |
| MainThreadScrollingReason::kHasBorderRadius); |
| } |
| -TEST_F(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) { |
| +TEST_P(StyleRelatedMainThreadScrollingReasonTest, BoxShadowTest) { |
| testStyle("box-shadow", |
| MainThreadScrollingReason::kHasBoxShadowFromNonRootLayer); |
| } |