Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/FrameView.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp |
| index 339c4a34e08392b1de941669adde04b4b49fcaf1..35b002ae04a158215f994404375ce7392bef7b12 100644 |
| --- a/third_party/WebKit/Source/core/frame/FrameView.cpp |
| +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp |
| @@ -430,6 +430,53 @@ void FrameView::ScrollbarManager::destroyScrollbar( |
| scrollbar = nullptr; |
| } |
| +ScrollableArea* FrameView::ScrollbarManager::scrollableArea() const { |
| + return m_scrollableArea.get(); |
| +} |
| + |
| +void FrameView::ScrollbarManager::updateScrollbarGeometry(IntSize viewSize) { |
| + if (!hasHorizontalScrollbar() && !hasVerticalScrollbar()) |
| + return; |
| + |
| + bool scrollbarOnLeft = m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft(); |
| + |
| + if (hasHorizontalScrollbar()) { |
| + int thickness = m_hBar->scrollbarThickness(); |
| + IntRect oldRect(m_hBar->frameRect()); |
| + IntRect hBarRect( |
| + (scrollbarOnLeft && hasVerticalScrollbar()) ? m_vBar->width() : 0, |
| + viewSize.height() - thickness, |
| + viewSize.width() - (hasVerticalScrollbar() ? m_vBar->width() : 0), |
| + thickness); |
| + m_hBar->setFrameRect(hBarRect); |
| + if (oldRect != m_hBar->frameRect()) |
| + m_scrollableArea->setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); |
| + |
| + int visibleWidth = m_scrollableArea->visibleWidth(); |
| + int contentsWidth = m_scrollableArea->contentsSize().width(); |
| + m_hBar->setEnabled(contentsWidth > visibleWidth); |
| + m_hBar->setProportion(visibleWidth, contentsWidth); |
| + m_hBar->offsetDidChange(); |
| + } |
| + |
| + if (hasVerticalScrollbar()) { |
| + int thickness = m_vBar->scrollbarThickness(); |
| + IntRect oldRect(m_vBar->frameRect()); |
| + IntRect vBarRect( |
| + scrollbarOnLeft ? 0 : (viewSize.width() - thickness), 0, thickness, |
| + viewSize.height() - (hasHorizontalScrollbar() ? m_hBar->height() : 0)); |
| + m_vBar->setFrameRect(vBarRect); |
| + if (oldRect != m_vBar->frameRect()) |
| + m_scrollableArea->setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
| + |
| + int clientHeight = m_scrollableArea->visibleHeight(); |
| + int contentsHeight = m_scrollableArea->contentsSize().height(); |
| + m_vBar->setEnabled(contentsHeight > clientHeight); |
| + m_vBar->setProportion(clientHeight, contentsHeight); |
| + m_vBar->offsetDidChange(); |
| + } |
| +} |
| + |
| void FrameView::recalculateCustomScrollbarStyle() { |
| bool didStyleChange = false; |
| if (horizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar()) { |
| @@ -441,7 +488,7 @@ void FrameView::recalculateCustomScrollbarStyle() { |
| didStyleChange = true; |
| } |
| if (didStyleChange) { |
| - updateScrollbarGeometry(); |
| + m_scrollbarManager.updateScrollbarGeometry(size()); |
| updateScrollCorner(); |
| positionScrollbarLayers(); |
| } |
| @@ -788,7 +835,7 @@ void FrameView::recalcOverflowAfterStyleChange() { |
| } |
| adjustViewSize(); |
| - updateScrollbarGeometry(); |
| + m_scrollbarManager.updateScrollbarGeometry(size()); |
| if (scrollOriginChanged()) |
| setNeedsLayout(); |
| @@ -2390,6 +2437,16 @@ void FrameView::invalidatePaintForTickmarks() { |
| static_cast<ScrollbarPart>(~ThumbPart)); |
| } |
| +void FrameView::setTickmarks(const Vector<IntRect>& tickmarks) { |
| + // Tickmarks for main frame are stored in RFV. |
| + if (m_frame->isMainFrame()) |
|
bokan
2016/11/03 19:59:59
You'll need a similar check in getTickmarks.
ymalik
2016/11/04 18:54:17
So RFV::getTickmarks calls layoutViewport().getTic
|
| + m_viewportScrollableArea->setTickmarks(tickmarks); |
| + else |
| + m_tickmarks = tickmarks; |
| + |
| + invalidatePaintForTickmarks(); |
| +} |
| + |
| void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const { |
| if (!m_tickmarks.isEmpty()) |
| tickmarks = m_tickmarks; |
| @@ -2553,6 +2610,8 @@ void FrameView::didAttachDocument() { |
| RootFrameViewport::create(visualViewport, *layoutViewport); |
| m_viewportScrollableArea = rootFrameViewport; |
| + m_scrollbarManager.setScroller(rootFrameViewport); |
| + |
| frameHost->globalRootScrollerController().initializeViewportScrollCallback( |
| *rootFrameViewport); |
| } |
| @@ -3697,12 +3756,6 @@ void FrameView::clearScrollAnchor() { |
| m_scrollAnchor.clear(); |
| } |
| -bool FrameView::hasOverlayScrollbars() const { |
| - return (horizontalScrollbar() && |
| - horizontalScrollbar()->isOverlayScrollbar()) || |
| - (verticalScrollbar() && verticalScrollbar()->isOverlayScrollbar()); |
| -} |
| - |
| void FrameView::computeScrollbarExistence( |
| bool& newHasHorizontalScrollbar, |
| bool& newHasVerticalScrollbar, |
| @@ -3735,15 +3788,17 @@ void FrameView::computeScrollbarExistence( |
| (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto)) |
| return; |
| + ScrollableArea* scroller = m_scrollbarManager.scrollableArea(); |
| if (hScroll == ScrollbarAuto) |
| - newHasHorizontalScrollbar = docSize.width() > visibleWidth(); |
| + newHasHorizontalScrollbar = docSize.width() > scroller->visibleWidth(); |
| if (vScroll == ScrollbarAuto) |
| - newHasVerticalScrollbar = docSize.height() > visibleHeight(); |
| + newHasVerticalScrollbar = docSize.height() > scroller->visibleHeight(); |
| if (hasOverlayScrollbars()) |
| return; |
| - IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size(); |
| + IntSize fullVisibleSize = |
| + scroller->visibleContentRect(IncludeScrollbars).size(); |
| bool attemptToRemoveScrollbars = |
| (option == FirstPass && docSize.width() <= fullVisibleSize.width() && |
| @@ -3756,48 +3811,6 @@ void FrameView::computeScrollbarExistence( |
| } |
| } |
| -void FrameView::updateScrollbarGeometry() { |
| - if (horizontalScrollbar()) { |
| - int thickness = horizontalScrollbar()->scrollbarThickness(); |
| - int clientWidth = visibleWidth(); |
| - IntRect oldRect(horizontalScrollbar()->frameRect()); |
| - IntRect hBarRect( |
| - (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar()) |
| - ? verticalScrollbar()->width() |
| - : 0, |
| - height() - thickness, |
| - width() - (verticalScrollbar() ? verticalScrollbar()->width() : 0), |
| - thickness); |
| - horizontalScrollbar()->setFrameRect(hBarRect); |
| - if (oldRect != horizontalScrollbar()->frameRect()) |
| - setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); |
| - |
| - horizontalScrollbar()->setEnabled(contentsWidth() > clientWidth && |
| - !scrollbarsHidden()); |
| - horizontalScrollbar()->setProportion(clientWidth, contentsWidth()); |
| - horizontalScrollbar()->offsetDidChange(); |
| - } |
| - |
| - if (verticalScrollbar()) { |
| - int thickness = verticalScrollbar()->scrollbarThickness(); |
| - int clientHeight = visibleHeight(); |
| - IntRect oldRect(verticalScrollbar()->frameRect()); |
| - IntRect vBarRect( |
| - shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - thickness), 0, |
| - thickness, |
| - height() - |
| - (horizontalScrollbar() ? horizontalScrollbar()->height() : 0)); |
| - verticalScrollbar()->setFrameRect(vBarRect); |
| - if (oldRect != verticalScrollbar()->frameRect()) |
| - setScrollbarNeedsPaintInvalidation(VerticalScrollbar); |
| - |
| - verticalScrollbar()->setEnabled(contentsHeight() > clientHeight && |
| - !scrollbarsHidden()); |
| - verticalScrollbar()->setProportion(clientHeight, contentsHeight()); |
| - verticalScrollbar()->offsetDidChange(); |
| - } |
| -} |
| - |
| bool FrameView::adjustScrollbarExistence( |
| ComputeScrollbarExistenceOption option) { |
| ASSERT(m_inUpdateScrollbars); |
| @@ -3900,7 +3913,7 @@ void FrameView::updateScrollbars() { |
| scrollbarExistenceChanged = true; |
| } |
| - updateScrollbarGeometry(); |
| + m_scrollbarManager.updateScrollbarGeometry(size()); |
| if (scrollbarExistenceChanged) { |
| // FIXME: Is frameRectsChanged really necessary here? Have any frame rects |