TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingForFixedPosition) { registerMockedHttpURLLoad("fixed-position.html"); navigateTo(m_baseURL + "fixed-position.html"); Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); ASSERT_TRUE(page->scrollingCoordinator()->supportsFixedPositionLayers()); // Fixed position should not fall back to main thread scrolling. WebLayer* rootScrollLayer = getRootScrollLayer(); ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); // Verify the properties of the fixed position element starting from the RenderObject all the // way to the WebLayer. Element* fixedElement = m_webViewImpl->mainFrameImpl()->frame()->document()->getElementById("fixed"); ASSERT(fixedElement); RenderObject* renderer = fixedElement->renderer(); ASSERT_TRUE(renderer->isBoxModelObject()); ASSERT_TRUE(renderer->hasLayer()); RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); ASSERT_TRUE(layer->isComposited()); RenderLayerBacking* layerBacking = layer->backing(); WebLayer* webLayer = static_cast<WebLayer*>(layerBacking->graphicsLayer()->platformLayer()); ASSERT_TRUE(webLayer->fixedToContainerLayer()); }
TEST_F(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(); Document* document = frame()->document(); Element* fixedPos = document->getElementById("fixed"); EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())->layer()->hasCompositedLayerMapping()); EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread()); fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone); forceFullCompositingUpdate(); EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())->layer()->hasCompositedLayerMapping()); EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread()); }
TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) { navigateTo("about:blank"); // Make sure the scrolling coordinator is active. FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView(); Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); ASSERT_TRUE(page->scrollingCoordinator()); ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(frameView)); // Fast scrolling should be enabled by default. WebLayer* rootScrollLayer = getRootScrollLayer(); ASSERT_TRUE(rootScrollLayer->scrollable()); ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); ASSERT_FALSE(rootScrollLayer->haveWheelEventHandlers()); }
TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting) { navigateTo("about:blank"); webViewImpl()->settings()->setThreadedScrollingEnabled(false); forceFullCompositingUpdate(); // Make sure the scrolling coordinator is active. FrameView* frameView = frame()->view(); Page* page = frame()->page(); ASSERT_TRUE(page->scrollingCoordinator()); ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(frameView)); // Main scrolling should be enabled with the setting override. WebLayer* rootScrollLayer = getRootScrollLayer(); ASSERT_TRUE(rootScrollLayer->scrollable()); ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread()); }
TEST_F(ScrollingCoordinatorTest, fractionalScrollingNonLayerFixedPosition) { registerMockedHttpURLLoad("fractional-scroll-fixed-position.html"); navigateTo(m_baseURL + "fractional-scroll-fixed-position.html"); // Prevent fixed-position element from getting its own layer. webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false); forceFullCompositingUpdate(); FrameView* frameView = frame()->view(); frameView->scrollTo(DoublePoint(1.5, 1.5)); WebLayer* rootScrollLayer = getRootScrollLayer(); // Scroll on main if there is non-composited fixed position element. // And the containing scroll layer should not get fractional scroll offset. ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread()); ASSERT_EQ(1.0, rootScrollLayer->scrollPositionDouble().x); ASSERT_EQ(1.0, rootScrollLayer->scrollPositionDouble().y); ASSERT_EQ(0.0, rootScrollLayer->position().x); ASSERT_EQ(0.0, rootScrollLayer->position().y); }
TEST_F(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_FALSE(rootScrollLayer->shouldScrollOnMainThread()); Document* document = frame()->document(); { Element* element = document->getElementById("div-tl"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(!constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("div-tr"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("div-bl"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(!constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("div-br"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("span-tl"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(!constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("span-tr"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(constraint.isFixedToRightEdge && !constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("span-bl"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(!constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge); } { Element* element = document->getElementById("span-br"); ASSERT_TRUE(element); WebLayer* layer = webLayerFromElement(element); ASSERT_TRUE(layer); WebLayerPositionConstraint constraint = layer->positionConstraint(); ASSERT_TRUE(constraint.isFixedPosition); ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomEdge); } }