bool ScrollableArea::hasOverlayScrollbars() const { Scrollbar* vScrollbar = verticalScrollbar(); if (vScrollbar && vScrollbar->isOverlayScrollbar()) return true; Scrollbar* hScrollbar = horizontalScrollbar(); return hScrollbar && hScrollbar->isOverlayScrollbar(); }
void ScrollableArea::scrollPositionChanged(const IntPoint& position) { IntPoint oldPosition = scrollPosition(); // Tell the derived class to scroll its contents. setScrollOffset(position); Scrollbar* verticalScrollbar = this->verticalScrollbar(); // Tell the scrollbars to update their thumb postions. if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { horizontalScrollbar->offsetDidChange(); if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalScrollbar()) { if (!verticalScrollbar) horizontalScrollbar->invalidate(); else { // If there is both a horizontalScrollbar and a verticalScrollbar, // then we must also invalidate the corner between them. IntRect boundsAndCorner = horizontalScrollbar->boundsRect(); boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrollbar->width()); horizontalScrollbar->invalidateRect(boundsAndCorner); } } } if (verticalScrollbar) { verticalScrollbar->offsetDidChange(); if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrollbar()) verticalScrollbar->invalidate(); } if (scrollPosition() != oldPosition) scrollAnimator()->notifyContentAreaScrolled(); }
void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset) { // Tell the derived class to scroll its contents. setScrollOffset(offset); Scrollbar* verticalScrollbar = this->verticalScrollbar(); // Tell the scrollbars to update their thumb postions. if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { horizontalScrollbar->offsetDidChange(); if (horizontalScrollbar->isOverlayScrollbar()) { if (!verticalScrollbar) horizontalScrollbar->invalidate(); else { // If there is both a horizontalScrollbar and a verticalScrollbar, // then we must also invalidate the corner between them. IntRect boundsAndCorner = horizontalScrollbar->boundsRect(); boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrollbar->width()); horizontalScrollbar->invalidateRect(boundsAndCorner); } } } if (verticalScrollbar) { verticalScrollbar->offsetDidChange(); if (verticalScrollbar->isOverlayScrollbar()) verticalScrollbar->invalidate(); } }
void ScrollingCoordinatorChromium::scrollableAreaScrollbarLayerDidChange(ScrollableArea* scrollableArea, ScrollbarOrientation orientation) { #if OS(DARWIN) static const bool platformSupportsCoordinatedScrollbar = false; static const bool platformSupportsMainFrameOnly = false; // Don't care. #elif OS(WINDOWS) static const bool platformSupportsCoordinatedScrollbar = true; static const bool platformSupportsMainFrameOnly = true; #else static const bool platformSupportsCoordinatedScrollbar = true; static const bool platformSupportsMainFrameOnly = false; #endif if (!platformSupportsCoordinatedScrollbar) return; bool isMainFrame = (scrollableArea == static_cast<ScrollableArea*>(m_page->mainFrame()->view())); if (!isMainFrame && platformSupportsMainFrameOnly) return; GraphicsLayer* scrollbarGraphicsLayer = orientation == HorizontalScrollbar ? horizontalScrollbarLayerForScrollableArea(scrollableArea) : verticalScrollbarLayerForScrollableArea(scrollableArea); if (scrollbarGraphicsLayer) { Scrollbar* scrollbar = orientation == HorizontalScrollbar ? scrollableArea->horizontalScrollbar() : scrollableArea->verticalScrollbar(); if (scrollbar->isCustomScrollbar()) { detachScrollbarLayer(scrollbarGraphicsLayer); return; } WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, orientation); if (!scrollbarLayer) scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, createScrollbarLayer(scrollbar)); // Root layer non-overlay scrollbars should be marked opaque to disable // blending. bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar(); if (!scrollbarGraphicsLayer->contentsOpaque()) scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollbar); scrollbarLayer->layer()->setOpaque(scrollbarGraphicsLayer->contentsOpaque()); setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollingWebLayerForScrollableArea(scrollableArea)); } else removeWebScrollbarLayer(scrollableArea, orientation); }
void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollType scrollType) { TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged"); DoublePoint oldPosition = scrollPositionDouble(); DoublePoint truncatedPosition = shouldUseIntegerScrollOffset() ? flooredIntPoint(position) : position; // Tell the derived class to scroll its contents. setScrollOffset(truncatedPosition, scrollType); Scrollbar* verticalScrollbar = this->verticalScrollbar(); // Tell the scrollbars to update their thumb postions. if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { horizontalScrollbar->offsetDidChange(); if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalScrollbar()) { if (!verticalScrollbar) horizontalScrollbar->invalidate(); else { // If there is both a horizontalScrollbar and a verticalScrollbar, // then we must also invalidate the corner between them. IntRect boundsAndCorner = horizontalScrollbar->boundsRect(); boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrollbar->width()); horizontalScrollbar->invalidateRect(boundsAndCorner); } } } if (verticalScrollbar) { verticalScrollbar->offsetDidChange(); if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrollbar()) verticalScrollbar->invalidate(); } if (scrollPositionDouble() != oldPosition) { // FIXME: Pass in DoubleSize. crbug.com/414283. scrollAnimator()->notifyContentAreaScrolled(toFloatSize(scrollPositionDouble() - oldPosition)); } scrollAnimator()->setCurrentPosition(toFloatPoint(position)); }