void PinchViewport::setupScrollbar(WebScrollbar::Orientation orientation) { bool isHorizontal = orientation == WebScrollbar::Horizontal; GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; const int overlayScrollbarThickness = m_frameHost.settings().pinchOverlayScrollbarThickness(); if (!webScrollbarLayer) { ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordinator(); ASSERT(coordinator); ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrollbar : VerticalScrollbar; webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreOrientation, overlayScrollbarThickness, 0, false); webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformLayer()); scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->layer()); scrollbarGraphicsLayer->setDrawsContent(false); } int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().width() - overlayScrollbarThickness; int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height() - overlayScrollbarThickness : 0; int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - overlayScrollbarThickness : overlayScrollbarThickness; int height = isHorizontal ? overlayScrollbarThickness : m_innerViewportContainerLayer->size().height() - overlayScrollbarThickness; // Use the GraphicsLayer to position the scrollbars. scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition)); scrollbarGraphicsLayer->setSize(IntSize(width, height)); scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height)); }
void VisualViewport::setupScrollbar(WebScrollbar::Orientation orientation) { bool isHorizontal = orientation == WebScrollbar::Horizontal; GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); std::unique_ptr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; ScrollbarThemeOverlay& theme = ScrollbarThemeOverlay::mobileTheme(); int thumbThickness = theme.thumbThickness(); int scrollbarThickness = theme.scrollbarThickness(RegularScrollbar); int scrollbarMargin = theme.scrollbarMargin(); if (!webScrollbarLayer) { ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordinator(); ASSERT(coordinator); ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrollbar : VerticalScrollbar; webScrollbarLayer = coordinator->createSolidColorScrollbarLayer( webcoreOrientation, thumbThickness, scrollbarMargin, false); // The compositor will control the scrollbar's visibility. Set to invisible // by default so scrollbars don't show up in layout tests. webScrollbarLayer->layer()->setOpacity(0); scrollbarGraphicsLayer->setContentsToPlatformLayer( webScrollbarLayer->layer()); scrollbarGraphicsLayer->setDrawsContent(false); } int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().width() - scrollbarThickness; int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height() - scrollbarThickness : 0; int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - scrollbarThickness : scrollbarThickness; int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLayer->size().height() - scrollbarThickness; // Use the GraphicsLayer to position the scrollbars. scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition)); scrollbarGraphicsLayer->setSize(FloatSize(width, height)); scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height)); }