summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/Scrollbar.cpp
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-09-08 12:18:00 +0100
committerKristian Monsen <kristianm@google.com>2010-09-11 12:08:58 +0100
commit5ddde30071f639962dd557c453f2ad01f8f0fd00 (patch)
tree775803c4ab35af50aa5f5472cd1fb95fe9d5152d /WebCore/platform/Scrollbar.cpp
parent3e63d9b33b753ca86d0765d1b3d711114ba9e34f (diff)
downloadexternal_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.zip
external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.tar.gz
external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.tar.bz2
Merge WebKit at r66666 : Initial merge by git.
Change-Id: I57dedeb49859adc9c539e760f0e749768c66626f
Diffstat (limited to 'WebCore/platform/Scrollbar.cpp')
-rw-r--r--WebCore/platform/Scrollbar.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/WebCore/platform/Scrollbar.cpp b/WebCore/platform/Scrollbar.cpp
index 119a9dc..ff8f66f 100644
--- a/WebCore/platform/Scrollbar.cpp
+++ b/WebCore/platform/Scrollbar.cpp
@@ -142,24 +142,20 @@ bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity,
}
#endif
+ // Ignore perpendicular scrolls.
+ if ((m_orientation == HorizontalScrollbar) ? (direction == ScrollUp || direction == ScrollDown) : (direction == ScrollLeft || direction == ScrollRight))
+ return false;
float step = 0;
- if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
- step = -1;
- else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar))
- step = 1;
-
- if (granularity == ScrollByLine)
- step *= m_lineStep;
- else if (granularity == ScrollByPage)
- step *= m_pageStep;
- else if (granularity == ScrollByDocument)
- step *= m_totalSize;
- else if (granularity == ScrollByPixel)
- step *= m_pixelStep;
-
- float newPos = m_currentPos + step * multiplier;
- float maxPos = m_totalSize - m_visibleSize;
- return setCurrentPos(max(min(newPos, maxPos), 0.0f));
+ switch (granularity) {
+ case ScrollByLine: step = m_lineStep; break;
+ case ScrollByPage: step = m_pageStep; break;
+ case ScrollByDocument: step = m_totalSize; break;
+ case ScrollByPixel: step = m_pixelStep; break;
+ }
+ if (direction == ScrollUp || direction == ScrollLeft)
+ multiplier = -multiplier;
+
+ return setCurrentPos(max(min(m_currentPos + (step * multiplier), static_cast<float>(m_totalSize - m_visibleSize)), 0.0f));
}
void Scrollbar::updateThumb()