| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orien
tation, ScrollGranularity, float step, float delta) | 53 ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orien
tation, ScrollGranularity, float step, float delta) |
| 54 { | 54 { |
| 55 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m
_currentPosY; | 55 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m
_currentPosY; |
| 56 float newPos = clampScrollPosition(orientation, currentPos + step * delta); | 56 float newPos = clampScrollPosition(orientation, currentPos + step * delta); |
| 57 if (currentPos == newPos) | 57 if (currentPos == newPos) |
| 58 return ScrollResultOneDimensional(false, delta); | 58 return ScrollResultOneDimensional(false, delta); |
| 59 | 59 |
| 60 float usedDelta = (newPos - currentPos) / step; | 60 float usedDelta = (newPos - currentPos) / step; |
| 61 currentPos = newPos; | 61 currentPos = newPos; |
| 62 | 62 |
| 63 notifyPositionChanged(); | 63 notifyPositionChanged(UserScroll); |
| 64 | 64 |
| 65 return ScrollResultOneDimensional(true, delta - usedDelta); | 65 return ScrollResultOneDimensional(true, delta - usedDelta); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset) | 68 void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, Sc
rollType scrollType) |
| 69 { | 69 { |
| 70 m_currentPosX = offset.x(); | 70 m_currentPosX = offset.x(); |
| 71 m_currentPosY = offset.y(); | 71 m_currentPosY = offset.y(); |
| 72 notifyPositionChanged(); | 72 notifyPositionChanged(scrollType); |
| 73 } | 73 } |
| 74 | 74 |
| 75 ScrollResult ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e) | 75 ScrollResult ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e) |
| 76 { | 76 { |
| 77 bool canScrollX = m_scrollableArea->userInputScrollable(HorizontalScrollbar) | 77 bool canScrollX = m_scrollableArea->userInputScrollable(HorizontalScrollbar) |
| 78 && e.railsMode() != PlatformEvent::RailsModeVertical; | 78 && e.railsMode() != PlatformEvent::RailsModeVertical; |
| 79 bool canScrollY = m_scrollableArea->userInputScrollable(VerticalScrollbar) | 79 bool canScrollY = m_scrollableArea->userInputScrollable(VerticalScrollbar) |
| 80 && e.railsMode() != PlatformEvent::RailsModeHorizontal; | 80 && e.railsMode() != PlatformEvent::RailsModeHorizontal; |
| 81 | 81 |
| 82 // Accept the event if we are scrollable in that direction and can still | 82 // Accept the event if we are scrollable in that direction and can still |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 { | 147 { |
| 148 m_currentPosX = position.x(); | 148 m_currentPosX = position.x(); |
| 149 m_currentPosY = position.y(); | 149 m_currentPosY = position.y(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 FloatPoint ScrollAnimator::currentPosition() const | 152 FloatPoint ScrollAnimator::currentPosition() const |
| 153 { | 153 { |
| 154 return FloatPoint(m_currentPosX, m_currentPosY); | 154 return FloatPoint(m_currentPosX, m_currentPosY); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ScrollAnimator::notifyPositionChanged() | 157 void ScrollAnimator::notifyPositionChanged(ScrollType scrollType) |
| 158 { | 158 { |
| 159 if (!m_scrollableArea->shouldUseIntegerScrollOffset()) | 159 if (!m_scrollableArea->shouldUseIntegerScrollOffset()) |
| 160 m_scrollableArea->setScrollOffsetFromAnimation(DoublePoint(m_currentPosX
, m_currentPosY)); | 160 m_scrollableArea->setScrollOffsetFromAnimation(DoublePoint(m_currentPosX
, m_currentPosY), scrollType); |
| 161 else | 161 else |
| 162 m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m
_currentPosY)); | 162 m_scrollableArea->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m
_currentPosY), scrollType); |
| 163 } | 163 } |
| 164 | 164 |
| 165 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa
t pos) | 165 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa
t pos) |
| 166 { | 166 { |
| 167 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); | 167 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); |
| 168 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); | 168 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); |
| 169 return std::max(std::min(pos, maxScrollPos), minScrollPos); | 169 return std::max(std::min(pos, maxScrollPos), minScrollPos); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |