| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 ScrollAnimator::~ScrollAnimator() | 51 ScrollAnimator::~ScrollAnimator() |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity,
float step, float multiplier) | 55 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity,
float step, float multiplier) |
| 56 { | 56 { |
| 57 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX :
&m_currentPosY; | 57 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX :
&m_currentPosY; |
| 58 float newPos = std::max(std::min(*currentPos + (step * multiplier), static_c
ast<float>(m_scrollableArea->scrollSize(orientation))), 0.0f); | 58 float newPos = m_scrollableArea->clampScrollPosition(orientation, *currentPo
s + step * multiplier); |
| 59 float delta = *currentPos - newPos; | 59 float delta = *currentPos - newPos; |
| 60 if (*currentPos == newPos) | 60 if (*currentPos == newPos) |
| 61 return false; | 61 return false; |
| 62 *currentPos = newPos; | 62 *currentPos = newPos; |
| 63 | 63 |
| 64 notifyPositionChanged(orientation == HorizontalScrollbar ? FloatSize(delta,
0) : FloatSize(0, delta)); | 64 notifyPositionChanged(orientation == HorizontalScrollbar ? FloatSize(delta,
0) : FloatSize(0, delta)); |
| 65 | 65 |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return FloatPoint(m_currentPosX, m_currentPosY); | 134 return FloatPoint(m_currentPosX, m_currentPosY); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ScrollAnimator::notifyPositionChanged(const FloatSize& delta) | 137 void ScrollAnimator::notifyPositionChanged(const FloatSize& delta) |
| 138 { | 138 { |
| 139 UNUSED_PARAM(delta); | 139 UNUSED_PARAM(delta); |
| 140 m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_cur
rentPosY)); | 140 m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_cur
rentPosY)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace WebCore | 143 } // namespace WebCore |
| OLD | NEW |