TEST_F(ScrollingCoordinatorTest, overflowHidden) { registerMockedHttpURLLoad("overflow-hidden.html"); navigateTo(m_baseURL + "overflow-hidden.html"); forceFullCompositingUpdate(); // Verify the properties of the accelerated scrolling element starting from the LayoutObject // all the way to the WebLayer. Element* overflowElement = frame()->document()->getElementById("unscrollable-y"); ASSERT(overflowElement); LayoutObject* layoutObject = overflowElement->layoutObject(); ASSERT_TRUE(layoutObject->isBox()); ASSERT_TRUE(layoutObject->hasLayer()); LayoutBox* box = toLayoutBox(layoutObject); ASSERT_TRUE(box->usesCompositedScrolling()); ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLayerMapping(); ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); ASSERT(compositedLayerMapping->scrollingContentsLayer()); GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLayer(); ASSERT_EQ(box->layer()->scrollableArea(), graphicsLayer->scrollableArea()); WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()->platformLayer(); ASSERT_TRUE(webScrollLayer->scrollable()); ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); ASSERT_FALSE(webScrollLayer->userScrollableVertical()); overflowElement = frame()->document()->getElementById("unscrollable-x"); ASSERT(overflowElement); layoutObject = overflowElement->layoutObject(); ASSERT_TRUE(layoutObject->isBox()); ASSERT_TRUE(layoutObject->hasLayer()); box = toLayoutBox(layoutObject); ASSERT_TRUE(box->scrollableArea()->usesCompositedScrolling()); ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); compositedLayerMapping = box->layer()->compositedLayerMapping(); ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); ASSERT(compositedLayerMapping->scrollingContentsLayer()); graphicsLayer = compositedLayerMapping->scrollingContentsLayer(); ASSERT_EQ(box->layer()->scrollableArea(), graphicsLayer->scrollableArea()); webScrollLayer = compositedLayerMapping->scrollingContentsLayer()->platformLayer(); ASSERT_TRUE(webScrollLayer->scrollable()); ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); ASSERT_TRUE(webScrollLayer->userScrollableVertical()); }
TEST_F(ScrollingCoordinatorChromiumTest, touchOverflowScrolling) { registerMockedHttpURLLoad("touch-overflow-scrolling.html"); navigateTo(m_baseURL + "touch-overflow-scrolling.html"); // Verify the properties of the accelerated scrolling element starting from the RenderObject // all the way to the WebLayer. Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->document()->getElementById("scrollable"); ASSERT(scrollableElement); RenderObject* renderer = scrollableElement->renderer(); ASSERT_TRUE(renderer->isBoxModelObject()); ASSERT_TRUE(renderer->hasLayer()); RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); ASSERT_TRUE(layer->usesCompositedScrolling()); ASSERT_TRUE(layer->isComposited()); RenderLayerBacking* layerBacking = layer->backing(); ASSERT_TRUE(layerBacking->hasScrollingLayer()); ASSERT(layerBacking->scrollingContentsLayer()); GraphicsLayerChromium* graphicsLayerChromium = static_cast<GraphicsLayerChromium*>(layerBacking->scrollingContentsLayer()); ASSERT_EQ(layer, graphicsLayerChromium->scrollableArea()); WebLayer* webScrollLayer = static_cast<WebLayer*>(layerBacking->scrollingContentsLayer()->platformLayer()); ASSERT_TRUE(webScrollLayer->scrollable()); }
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, iframeScrolling) { registerMockedHttpURLLoad("iframe-scrolling.html"); registerMockedHttpURLLoad("iframe-scrolling-inner.html"); navigateTo(m_baseURL + "iframe-scrolling.html"); forceFullCompositingUpdate(); // Verify the properties of the accelerated scrolling element starting from the LayoutObject // all the way to the WebLayer. Element* scrollableFrame = frame()->document()->getElementById("scrollable"); ASSERT_TRUE(scrollableFrame); LayoutObject* layoutObject = scrollableFrame->layoutObject(); ASSERT_TRUE(layoutObject); ASSERT_TRUE(layoutObject->isLayoutPart()); LayoutPart* layoutPart = toLayoutPart(layoutObject); ASSERT_TRUE(layoutPart); ASSERT_TRUE(layoutPart->widget()); ASSERT_TRUE(layoutPart->widget()->isFrameView()); FrameView* innerFrameView = toFrameView(layoutPart->widget()); LayoutView* innerLayoutView = innerFrameView->layoutView(); ASSERT_TRUE(innerLayoutView); PaintLayerCompositor* innerCompositor = innerLayoutView->compositor(); ASSERT_TRUE(innerCompositor->inCompositingMode()); ASSERT_TRUE(innerCompositor->scrollLayer()); GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); ASSERT_EQ(innerFrameView, scrollLayer->scrollableArea()); WebLayer* webScrollLayer = scrollLayer->platformLayer(); ASSERT_TRUE(webScrollLayer->scrollable()); #if OS(ANDROID) // Now verify we've attached impl-side scrollbars onto the scrollbar layers ASSERT_TRUE(innerCompositor->layerForHorizontalScrollbar()); ASSERT_TRUE(innerCompositor->layerForHorizontalScrollbar()->hasContentsLayer()); ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()); #endif }
TEST_F(ScrollingCoordinatorTest, overflowScrolling) { registerMockedHttpURLLoad("overflow-scrolling.html"); navigateTo(m_baseURL + "overflow-scrolling.html"); forceFullCompositingUpdate(); // Verify the properties of the accelerated scrolling element starting from the LayoutObject // all the way to the WebLayer. Element* scrollableElement = frame()->document()->getElementById("scrollable"); ASSERT(scrollableElement); LayoutObject* layoutObject = scrollableElement->layoutObject(); ASSERT_TRUE(layoutObject->isBox()); ASSERT_TRUE(layoutObject->hasLayer()); LayoutBox* box = toLayoutBox(layoutObject); ASSERT_TRUE(box->usesCompositedScrolling()); ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLayerMapping(); ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); ASSERT(compositedLayerMapping->scrollingContentsLayer()); GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLayer(); ASSERT_EQ(box->layer()->scrollableArea(), graphicsLayer->scrollableArea()); WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()->platformLayer(); ASSERT_TRUE(webScrollLayer->scrollable()); ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); ASSERT_TRUE(webScrollLayer->userScrollableVertical()); #if OS(ANDROID) // Now verify we've attached impl-side scrollbars onto the scrollbar layers ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()); ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()->hasContentsLayer()); ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContentsLayer()); #endif }
TEST_F(ScrollingCoordinatorTest, rtlIframe) { registerMockedHttpURLLoad("rtl-iframe.html"); registerMockedHttpURLLoad("rtl-iframe-inner.html"); navigateTo(m_baseURL + "rtl-iframe.html"); forceFullCompositingUpdate(); // Verify the properties of the accelerated scrolling element starting from the LayoutObject // all the way to the WebLayer. Element* scrollableFrame = frame()->document()->getElementById("scrollable"); ASSERT_TRUE(scrollableFrame); LayoutObject* layoutObject = scrollableFrame->layoutObject(); ASSERT_TRUE(layoutObject); ASSERT_TRUE(layoutObject->isLayoutPart()); LayoutPart* layoutPart = toLayoutPart(layoutObject); ASSERT_TRUE(layoutPart); ASSERT_TRUE(layoutPart->widget()); ASSERT_TRUE(layoutPart->widget()->isFrameView()); FrameView* innerFrameView = toFrameView(layoutPart->widget()); LayoutView* innerLayoutView = innerFrameView->layoutView(); ASSERT_TRUE(innerLayoutView); PaintLayerCompositor* innerCompositor = innerLayoutView->compositor(); ASSERT_TRUE(innerCompositor->inCompositingMode()); ASSERT_TRUE(innerCompositor->scrollLayer()); GraphicsLayer* scrollLayer = innerCompositor->scrollLayer(); ASSERT_EQ(innerFrameView, scrollLayer->scrollableArea()); WebLayer* webScrollLayer = scrollLayer->platformLayer(); ASSERT_TRUE(webScrollLayer->scrollable()); int expectedScrollPosition = 958 + (innerFrameView->verticalScrollbar()->isOverlayScrollbar() ? 0 : 15); ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPositionDouble().x); }