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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 #if !OS(WINDOWS) | 39 #if !OS(WINDOWS) |
40 ScrollAnimator* ScrollAnimator::create(ScrollbarClient* client) | 40 ScrollAnimator* ScrollAnimator::create(ScrollbarClient* client) |
41 { | 41 { |
42 return new ScrollAnimator(client); | 42 return new ScrollAnimator(client); |
43 } | 43 } |
44 #endif | 44 #endif |
45 | 45 |
| 46 ScrollAnimator::ScrollAnimator(ScrollbarClient* client) |
| 47 : m_client(client) |
| 48 , m_currentPosX(0) |
| 49 , m_currentPosY(0) |
| 50 { |
| 51 } |
| 52 |
| 53 ScrollAnimator::~ScrollAnimator() |
| 54 { |
| 55 } |
| 56 |
46 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity,
float step, float multiplier) | 57 bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity,
float step, float multiplier) |
47 { | 58 { |
48 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX :
&m_currentPosY; | 59 float* currentPos = (orientation == HorizontalScrollbar) ? &m_currentPosX :
&m_currentPosY; |
49 float newPos = std::max(std::min(*currentPos + (step * multiplier), static_c
ast<float>(m_client->scrollSize(orientation))), 0.0f); | 60 float newPos = std::max(std::min(*currentPos + (step * multiplier), static_c
ast<float>(m_client->scrollSize(orientation))), 0.0f); |
50 if (*currentPos == newPos) | 61 if (*currentPos == newPos) |
51 return false; | 62 return false; |
52 *currentPos = newPos; | 63 *currentPos = newPos; |
53 m_client->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY
)); | 64 m_client->setScrollOffsetFromAnimation(IntPoint(m_currentPosX, m_currentPosY
)); |
54 return true; | 65 return true; |
55 } | 66 } |
56 | 67 |
57 void ScrollAnimator::setScrollPositionAndStopAnimation(ScrollbarOrientation orie
ntation, float pos) | 68 void ScrollAnimator::setScrollPositionAndStopAnimation(ScrollbarOrientation orie
ntation, float pos) |
58 { | 69 { |
59 if (orientation == HorizontalScrollbar) | 70 if (orientation == HorizontalScrollbar) |
60 m_currentPosX = pos; | 71 m_currentPosX = pos; |
61 else | 72 else |
62 m_currentPosY = pos; | 73 m_currentPosY = pos; |
63 } | 74 } |
64 | 75 |
65 } // namespace WebCore | 76 } // namespace WebCore |
OLD | NEW |