Chromium Code Reviews| Index: Source/core/platform/ScrollView.cpp |
| diff --git a/Source/core/platform/ScrollView.cpp b/Source/core/platform/ScrollView.cpp |
| index 67382df3ce5fa01bef3a3f530315221e5d5ff54f..b3ff4f6df099cea08c1c4395d4dd0e7e74357bfd 100644 |
| --- a/Source/core/platform/ScrollView.cpp |
| +++ b/Source/core/platform/ScrollView.cpp |
| @@ -43,7 +43,6 @@ ScrollView::ScrollView() |
| , m_verticalScrollbarMode(ScrollbarAuto) |
| , m_horizontalScrollbarLock(false) |
| , m_verticalScrollbarLock(false) |
| - , m_prohibitsScrolling(false) |
| , m_canBlitOnScroll(true) |
| , m_scrollbarsAvoidingResizer(0) |
| , m_scrollbarsSuppressed(false) |
| @@ -284,15 +283,16 @@ IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint |
| int ScrollView::scrollSize(ScrollbarOrientation orientation) const |
| { |
| + Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get(); |
| + |
| // If no scrollbars are present, it does not indicate content is not be scrollable. |
|
tdanderson
2013/07/15 23:17:44
I know you didn't write this comment in the first
bokan
2013/07/22 15:08:47
Done.
|
| - if (!m_horizontalScrollbar && !m_verticalScrollbar && !prohibitsScrolling()) { |
| + if (!scrollbar) { |
| IntSize scrollSize = m_contentsSize - visibleContentRect().size(); |
| scrollSize.clampNegativeToZero(); |
| return orientation == HorizontalScrollbar ? scrollSize.width() : scrollSize.height(); |
| } |
| - Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get(); |
| - return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0; |
| + return scrollbar->totalSize() - scrollbar->visibleSize(); |
| } |
| void ScrollView::notifyPageThatContentAreaWillPaint() const |
| @@ -319,20 +319,8 @@ void ScrollView::scrollTo(const IntSize& newOffset) |
| updateFixedElementsAfterScrolling(); |
| } |
| -int ScrollView::scrollPosition(Scrollbar* scrollbar) const |
| -{ |
| - if (scrollbar->orientation() == HorizontalScrollbar) |
| - return scrollPosition().x() + scrollOrigin().x(); |
| - if (scrollbar->orientation() == VerticalScrollbar) |
| - return scrollPosition().y() + scrollOrigin().y(); |
| - return 0; |
| -} |
| - |
| void ScrollView::setScrollPosition(const IntPoint& scrollPoint) |
| { |
| - if (prohibitsScrolling()) |
| - return; |
| - |
| IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint); |
| if (newScrollPosition == scrollPosition()) |
| @@ -374,7 +362,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; |
| void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
| { |
| - if (m_inUpdateScrollbars || prohibitsScrolling()) |
| + if (m_inUpdateScrollbars) |
| return; |
| // If we came in here with the view already needing a layout, then go ahead and do that |
| @@ -475,7 +463,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
| } |
| } |
| - // Set up the range (and page step/line step), but only do this if we're not in a nested call (to avoid |
| + // Set up the range, but only do this if we're not in a nested call (to avoid |
| // doing it multiple times). |
| if (m_updateScrollbarsPass) |
| return; |
| @@ -484,7 +472,6 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
| if (m_horizontalScrollbar) { |
| int clientWidth = visibleWidth(); |
| - int pageStep = max(max<int>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1); |
| IntRect oldRect(m_horizontalScrollbar->frameRect()); |
| IntRect hBarRect(0, |
| height() - m_horizontalScrollbar->height(), |
| @@ -497,7 +484,6 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
| if (m_scrollbarsSuppressed) |
| m_horizontalScrollbar->setSuppressInvalidation(true); |
| m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); |
| - m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); |
| m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); |
| if (m_scrollbarsSuppressed) |
| m_horizontalScrollbar->setSuppressInvalidation(false); |
| @@ -505,7 +491,6 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
| if (m_verticalScrollbar) { |
| int clientHeight = visibleHeight(); |
| - int pageStep = max(max<int>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1); |
| IntRect oldRect(m_verticalScrollbar->frameRect()); |
| IntRect vBarRect(width() - m_verticalScrollbar->width(), |
| 0, |
| @@ -518,7 +503,6 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) |
| if (m_scrollbarsSuppressed) |
| m_verticalScrollbar->setSuppressInvalidation(true); |
| m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
| - m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); |
| m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
| if (m_scrollbarsSuppressed) |
| m_verticalScrollbar->setSuppressInvalidation(false); |
| @@ -822,6 +806,14 @@ void ScrollView::positionScrollbarLayers() |
| positionScrollCornerLayer(layerForScrollCorner(), scrollCornerRect()); |
| } |
| +bool ScrollView::userInputScrollable(ScrollbarOrientation orientation) const |
| +{ |
| + ScrollbarMode mode = (orientation == HorizontalScrollbar) ? |
| + m_horizontalScrollbarMode : m_verticalScrollbarMode; |
| + |
| + return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; |
| +} |
| + |
| void ScrollView::repaintContentRectangle(const IntRect& rect) |
| { |
| IntRect paintRect = rect; |
| @@ -1259,5 +1251,13 @@ bool ScrollView::platformIsOffscreen() const |
| return false; |
| } |
| +int ScrollView::pageStep(ScrollbarOrientation orientation) const |
| +{ |
| + int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visibleHeight(); |
| + int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging(); |
| + int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); |
| + return std::max(pageStep, 1); |
| } |
| + |
| +} // namespace WebCore |