| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 : m_scrollableArea(scrollableArea) | 43 : m_scrollableArea(scrollableArea) |
| 44 , m_currentPosX(0) | 44 , m_currentPosX(0) |
| 45 , m_currentPosY(0) | 45 , m_currentPosY(0) |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 ScrollAnimatorBase::~ScrollAnimatorBase() | 49 ScrollAnimatorBase::~ScrollAnimatorBase() |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 float ScrollAnimatorBase::usedScrollDelta(ScrollbarOrientation orientation, floa
t pixelDelta) const |
| 54 { |
| 55 float currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m_
currentPosY; |
| 56 float newPos = clampScrollPosition(orientation, currentPos + pixelDelta); |
| 57 return (currentPos == newPos) ? 0.0f : (newPos - currentPos); |
| 58 } |
| 59 |
| 53 ScrollResultOneDimensional ScrollAnimatorBase::userScroll(ScrollbarOrientation o
rientation, ScrollGranularity, float step, float delta) | 60 ScrollResultOneDimensional ScrollAnimatorBase::userScroll(ScrollbarOrientation o
rientation, ScrollGranularity, float step, float delta) |
| 54 { | 61 { |
| 55 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m
_currentPosY; | 62 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m
_currentPosY; |
| 56 float newPos = clampScrollPosition(orientation, currentPos + step * delta); | 63 float newPos = clampScrollPosition(orientation, currentPos + step * delta); |
| 57 if (currentPos == newPos) | 64 if (currentPos == newPos) |
| 58 return ScrollResultOneDimensional(false, delta); | 65 return ScrollResultOneDimensional(false, delta); |
| 59 | 66 |
| 60 float usedDelta = (newPos - currentPos) / step; | 67 float usedDelta = (newPos - currentPos) / step; |
| 61 currentPos = newPos; | 68 currentPos = newPos; |
| 62 | 69 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 FloatPoint ScrollAnimatorBase::currentPosition() const | 88 FloatPoint ScrollAnimatorBase::currentPosition() const |
| 82 { | 89 { |
| 83 return FloatPoint(m_currentPosX, m_currentPosY); | 90 return FloatPoint(m_currentPosX, m_currentPosY); |
| 84 } | 91 } |
| 85 | 92 |
| 86 void ScrollAnimatorBase::notifyPositionChanged() | 93 void ScrollAnimatorBase::notifyPositionChanged() |
| 87 { | 94 { |
| 88 m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_current
PosY), UserScroll); | 95 m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_current
PosY), UserScroll); |
| 89 } | 96 } |
| 90 | 97 |
| 91 float ScrollAnimatorBase::clampScrollPosition(ScrollbarOrientation orientation,
float pos) | 98 float ScrollAnimatorBase::clampScrollPosition(ScrollbarOrientation orientation,
float pos) const |
| 92 { | 99 { |
| 93 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); | 100 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); |
| 94 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); | 101 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); |
| 95 return std::max(std::min(pos, maxScrollPos), minScrollPos); | 102 return std::max(std::min(pos, maxScrollPos), minScrollPos); |
| 96 } | 103 } |
| 97 | 104 |
| 98 DEFINE_TRACE(ScrollAnimatorBase) | 105 DEFINE_TRACE(ScrollAnimatorBase) |
| 99 { | 106 { |
| 100 visitor->trace(m_scrollableArea); | 107 visitor->trace(m_scrollableArea); |
| 101 } | 108 } |
| 102 | 109 |
| 103 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |