| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 : m_scrollableArea(scrollableArea) | 42 : m_scrollableArea(scrollableArea) |
| 43 , m_currentPosX(0) | 43 , m_currentPosX(0) |
| 44 , m_currentPosY(0) | 44 , m_currentPosY(0) |
| 45 { | 45 { |
| 46 } | 46 } |
| 47 | 47 |
| 48 ScrollAnimator::~ScrollAnimator() | 48 ScrollAnimator::~ScrollAnimator() |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassOwnPtr<ScrollAnimator> ScrollAnimator::create(ScrollableArea* scrollableArea
) |
| 53 { |
| 54 return adoptPtr(new ScrollAnimator(scrollableArea)); |
| 55 } |
| 56 |
| 52 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity,
float step, float delta) | 57 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity,
float step, float delta) |
| 53 { | 58 { |
| 54 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m
_currentPosY; | 59 float& currentPos = (orientation == HorizontalScrollbar) ? m_currentPosX : m
_currentPosY; |
| 55 float newPos = clampScrollPosition(orientation, currentPos + step * delta); | 60 float newPos = clampScrollPosition(orientation, currentPos + step * delta); |
| 56 if (currentPos == newPos) | 61 if (currentPos == newPos) |
| 57 return false; | 62 return false; |
| 58 currentPos = newPos; | 63 currentPos = newPos; |
| 59 | 64 |
| 60 notifyPositionChanged(); | 65 notifyPositionChanged(); |
| 61 | 66 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 142 } |
| 138 | 143 |
| 139 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa
t pos) | 144 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa
t pos) |
| 140 { | 145 { |
| 141 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); | 146 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); |
| 142 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); | 147 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); |
| 143 return std::max(std::min(pos, maxScrollPos), minScrollPos); | 148 return std::max(std::min(pos, maxScrollPos), minScrollPos); |
| 144 } | 149 } |
| 145 | 150 |
| 146 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |