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..43055affa5f004f524c21be0cf87c70e4b90c6af 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(); |
} |
@@ -95,13 +105,9 @@ class ScrollingCoordinatorTest : public testing::Test { |
} |
WebLayer* getRootScrollLayer() { |
- PaintLayerCompositor* compositor = |
- frame()->contentLayoutItem().compositor(); |
- DCHECK(compositor); |
- DCHECK(compositor->scrollLayer()); |
- |
- WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); |
- return webScrollLayer; |
+ GraphicsLayer* layer = |
+ frame()->view()->layoutViewportScrollableArea()->layerForScrolling(); |
+ return layer ? layer->platformLayer() : nullptr; |
} |
WebViewImpl* webViewImpl() const { return m_helper.webView(); } |
@@ -113,9 +119,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 +133,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 +149,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 +165,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 +180,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 +191,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 +251,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 +344,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 +451,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 +461,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 +471,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 +481,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 +491,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 +501,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 +511,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 +519,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 +529,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 +585,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 +646,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 +672,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 +692,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 +718,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 +745,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 +772,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 +786,7 @@ TEST_F(ScrollingCoordinatorTest, setupScrollbarLayerShouldSetScrollLayerOpaque) |
ASSERT_TRUE(frameView); |
GraphicsLayer* scrollbarGraphicsLayer = |
- frameView->layerForHorizontalScrollbar(); |
+ frameView->layoutViewportScrollableArea()->layerForHorizontalScrollbar(); |
ASSERT_TRUE(scrollbarGraphicsLayer); |
WebLayer* platformLayer = scrollbarGraphicsLayer->platformLayer(); |
@@ -782,19 +801,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 +828,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 +869,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 +895,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 +919,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 +942,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 +955,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 +969,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 +996,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 +1016,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 +1093,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 +1153,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); |
} |