| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 float deltaY = canScrollY ? e.deltaY() : 0; | 85 float deltaY = canScrollY ? e.deltaY() : 0; |
| 86 | 86 |
| 87 ScrollResult result; | 87 ScrollResult result; |
| 88 | 88 |
| 89 #if !OS(MACOSX) | 89 #if !OS(MACOSX) |
| 90 ScrollGranularity granularity = e.hasPreciseScrollingDeltas() ? ScrollByPrec
isePixel : ScrollByPixel; | 90 ScrollGranularity granularity = e.hasPreciseScrollingDeltas() ? ScrollByPrec
isePixel : ScrollByPixel; |
| 91 #else | 91 #else |
| 92 ScrollGranularity granularity = ScrollByPixel; | 92 ScrollGranularity granularity = ScrollByPixel; |
| 93 #endif | 93 #endif |
| 94 | 94 |
| 95 IntSize maxForwardScrollDelta = m_scrollableArea->maximumScrollPosition() -
m_scrollableArea->scrollPosition(); | 95 if (deltaY) { |
| 96 IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scro
llableArea->minimumScrollPosition(); | 96 if (e.granularity() == ScrollByPageWheelEvent) { |
| 97 if ((deltaX < 0 && maxForwardScrollDelta.width() > 0) | 97 bool negative = deltaY < 0; |
| 98 || (deltaX > 0 && maxBackwardScrollDelta.width() > 0)) | 98 deltaY = m_scrollableArea->pageStep(VerticalScrollbar); |
| 99 result.didScrollX = true; | 99 if (negative) |
| 100 if ((deltaY < 0 && maxForwardScrollDelta.height() > 0) | 100 deltaY = -deltaY; |
| 101 || (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) | |
| 102 result.didScrollY = true; | |
| 103 if (result.didScroll()) { | |
| 104 if (deltaY) { | |
| 105 if (e.granularity() == ScrollByPageWheelEvent) { | |
| 106 bool negative = deltaY < 0; | |
| 107 deltaY = m_scrollableArea->pageStep(VerticalScrollbar); | |
| 108 if (negative) | |
| 109 deltaY = -deltaY; | |
| 110 } | |
| 111 | |
| 112 ScrollResultOneDimensional resultY = userScroll( | |
| 113 VerticalScrollbar, granularity, m_scrollableArea->pixelStep(Vert
icalScrollbar), -deltaY); | |
| 114 | |
| 115 if (e.granularity() != ScrollByPageWheelEvent) { | |
| 116 if (resultY.didScroll) | |
| 117 result.unusedScrollDeltaY = -resultY.unusedScrollDelta; | |
| 118 else | |
| 119 result.unusedScrollDeltaY = deltaY; | |
| 120 } | |
| 121 } | 101 } |
| 122 | 102 |
| 123 if (deltaX) { | 103 ScrollResultOneDimensional resultY = userScroll( |
| 124 if (e.granularity() == ScrollByPageWheelEvent) { | 104 VerticalScrollbar, granularity, m_scrollableArea->pixelStep(Vertical
Scrollbar), -deltaY); |
| 125 bool negative = deltaX < 0; | 105 result.didScrollY = resultY.didScroll; |
| 126 deltaX = m_scrollableArea->pageStep(HorizontalScrollbar); | 106 if (e.granularity() != ScrollByPageWheelEvent) { |
| 127 if (negative) | 107 if (resultY.didScroll) |
| 128 deltaX = -deltaX; | 108 result.unusedScrollDeltaY = -resultY.unusedScrollDelta; |
| 129 } | 109 else |
| 130 | 110 result.unusedScrollDeltaY = deltaY; |
| 131 ScrollResultOneDimensional resultX = userScroll( | |
| 132 HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(Ho
rizontalScrollbar), -deltaX); | |
| 133 | |
| 134 if (e.granularity() != ScrollByPageWheelEvent) { | |
| 135 if (resultX.didScroll) | |
| 136 result.unusedScrollDeltaX = -resultX.unusedScrollDelta; | |
| 137 else | |
| 138 result.unusedScrollDeltaX = deltaX; | |
| 139 } | |
| 140 } | 111 } |
| 141 } | 112 } |
| 142 | 113 |
| 114 if (deltaX) { |
| 115 if (e.granularity() == ScrollByPageWheelEvent) { |
| 116 bool negative = deltaX < 0; |
| 117 deltaX = m_scrollableArea->pageStep(HorizontalScrollbar); |
| 118 if (negative) |
| 119 deltaX = -deltaX; |
| 120 } |
| 121 |
| 122 ScrollResultOneDimensional resultX = userScroll( |
| 123 HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(Horizo
ntalScrollbar), -deltaX); |
| 124 result.didScrollX = resultX.didScroll; |
| 125 if (e.granularity() != ScrollByPageWheelEvent) { |
| 126 if (resultX.didScroll) |
| 127 result.unusedScrollDeltaX = -resultX.unusedScrollDelta; |
| 128 else |
| 129 result.unusedScrollDeltaX = deltaX; |
| 130 } |
| 131 } |
| 143 return result; | 132 return result; |
| 144 } | 133 } |
| 145 | 134 |
| 146 void ScrollAnimator::setCurrentPosition(const FloatPoint& position) | 135 void ScrollAnimator::setCurrentPosition(const FloatPoint& position) |
| 147 { | 136 { |
| 148 m_currentPosX = position.x(); | 137 m_currentPosX = position.x(); |
| 149 m_currentPosY = position.y(); | 138 m_currentPosY = position.y(); |
| 150 } | 139 } |
| 151 | 140 |
| 152 FloatPoint ScrollAnimator::currentPosition() const | 141 FloatPoint ScrollAnimator::currentPosition() const |
| 153 { | 142 { |
| 154 return FloatPoint(m_currentPosX, m_currentPosY); | 143 return FloatPoint(m_currentPosX, m_currentPosY); |
| 155 } | 144 } |
| 156 | 145 |
| 157 void ScrollAnimator::notifyPositionChanged() | 146 void ScrollAnimator::notifyPositionChanged() |
| 158 { | 147 { |
| 159 m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_current
PosY), UserScroll); | 148 m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_current
PosY), UserScroll); |
| 160 } | 149 } |
| 161 | 150 |
| 162 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa
t pos) | 151 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa
t pos) |
| 163 { | 152 { |
| 164 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); | 153 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); |
| 165 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); | 154 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); |
| 166 return std::max(std::min(pos, maxScrollPos), minScrollPos); | 155 return std::max(std::min(pos, maxScrollPos), minScrollPos); |
| 167 } | 156 } |
| 168 | 157 |
| 169 } // namespace blink | 158 } // namespace blink |
| OLD | NEW |