Chromium Code Reviews| Index: Source/core/platform/ScrollableArea.cpp |
| diff --git a/Source/core/platform/ScrollableArea.cpp b/Source/core/platform/ScrollableArea.cpp |
| index 0f02cf04bc2b3ff3a325ea00e11de5e29b5a5752..00b262cc61007bbfce56467260d6412ed5d37929 100644 |
| --- a/Source/core/platform/ScrollableArea.cpp |
| +++ b/Source/core/platform/ScrollableArea.cpp |
| @@ -52,6 +52,12 @@ struct SameSizeAsScrollableArea { |
| COMPILE_ASSERT(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), ScrollableArea_should_stay_small); |
| +int ScrollableArea::maxOverlapBetweenPages() |
| +{ |
| + static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetweenPages(); |
| + return maxOverlapBetweenPages; |
| +} |
| + |
| ScrollableArea::ScrollableArea() |
| : m_constrainsScrollingToContentEdge(true) |
| , m_inLiveResize(false) |
| @@ -85,32 +91,30 @@ void ScrollableArea::setScrollOrigin(const IntPoint& origin) |
| bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier) |
| { |
| ScrollbarOrientation orientation; |
| - Scrollbar* scrollbar; |
| - if (direction == ScrollUp || direction == ScrollDown) { |
| + |
| + if (direction == ScrollUp || direction == ScrollDown) |
| orientation = VerticalScrollbar; |
| - scrollbar = verticalScrollbar(); |
| - } else { |
| + else |
| orientation = HorizontalScrollbar; |
| - scrollbar = horizontalScrollbar(); |
| - } |
| - if (!scrollbar) |
| + if (!userInputScrollable(orientation)) |
| return false; |
| float step = 0; |
| + |
|
aelias_OOO_until_Jul13
2013/06/19 22:25:12
nit: accidental newline
bokan
2013/06/19 23:50:58
Done.
|
| switch (granularity) { |
| case ScrollByLine: |
| - step = scrollbar->lineStep(); |
| + step = lineStep(orientation); |
| break; |
| case ScrollByPage: |
| - step = scrollbar->pageStep(); |
| + step = pageStep(orientation); |
| break; |
| case ScrollByDocument: |
| - step = scrollbar->totalSize(); |
| + step = documentStep(orientation); |
| break; |
| case ScrollByPixel: |
| case ScrollByPrecisePixel: |
| - step = scrollbar->pixelStep(); |
| + step = pixelStep(orientation); |
| break; |
| } |
| @@ -364,13 +368,6 @@ void ScrollableArea::serviceScrollAnimations() |
| scrollAnimator->serviceScrollAnimations(); |
| } |
| -IntPoint ScrollableArea::scrollPosition() const |
| -{ |
| - int x = horizontalScrollbar() ? horizontalScrollbar()->value() : 0; |
| - int y = verticalScrollbar() ? verticalScrollbar()->value() : 0; |
| - return IntPoint(x, y); |
| -} |
| - |
| IntPoint ScrollableArea::minimumScrollPosition() const |
| { |
| return IntPoint(); |
| @@ -410,4 +407,28 @@ void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| info.addMember(m_scrollAnimator, "scrollAnimator"); |
| } |
| +int ScrollableArea::lineStep(ScrollbarOrientation) const |
| +{ |
| + return pixelsPerLineStep(); |
| +} |
| + |
| +int ScrollableArea::pageStep(ScrollbarOrientation orientation) const |
|
aelias_OOO_until_Jul13
2013/06/19 22:25:12
This code appears specific to ScrollView so I sugg
bokan
2013/06/19 23:50:58
Done.
|
| +{ |
| + 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); |
| +} |
| + |
| +int ScrollableArea::documentStep(ScrollbarOrientation orientation) const |
| +{ |
| + return scrollSize(orientation); |
| +} |
| + |
| +float ScrollableArea::pixelStep(ScrollbarOrientation) const |
| +{ |
| + return 1.0f; |
| +} |
| + |
| } // namespace WebCore |