Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 IntSize maxForwardScrollDelta = m_scrollableArea->maximumScrollPosition() - m_scrollableArea->scrollPosition(); |
| 96 IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scro llableArea->minimumScrollPosition(); | 96 IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scro llableArea->minimumScrollPosition(); |
| 97 if ((deltaX < 0 && maxForwardScrollDelta.width() > 0) | 97 result.didScrollX = (deltaX < 0 && maxForwardScrollDelta.width() > 0) || (de ltaX > 0 && maxBackwardScrollDelta.width() > 0); |
| 98 || (deltaX > 0 && maxBackwardScrollDelta.width() > 0)) | 98 result.didScrollY = (deltaY < 0 && maxForwardScrollDelta.height() > 0) || (d eltaY > 0 && maxBackwardScrollDelta.height() > 0); |
|
bokan
2015/06/23 16:20:45
Since we're going to try to scroll now anyways, it
MuVen
2015/06/25 12:55:51
Done.
| |
| 99 result.didScrollX = true; | |
| 100 if ((deltaY < 0 && maxForwardScrollDelta.height() > 0) | |
| 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 | 99 |
| 112 ScrollResultOneDimensional resultY = userScroll( | 100 if (deltaY) { |
| 113 VerticalScrollbar, granularity, m_scrollableArea->pixelStep(Vert icalScrollbar), -deltaY); | 101 if (e.granularity() == ScrollByPageWheelEvent) { |
| 114 | 102 bool negative = deltaY < 0; |
| 115 if (e.granularity() != ScrollByPageWheelEvent) { | 103 deltaY = m_scrollableArea->pageStep(VerticalScrollbar); |
| 116 if (resultY.didScroll) | 104 if (negative) |
| 117 result.unusedScrollDeltaY = -resultY.unusedScrollDelta; | 105 deltaY = -deltaY; |
| 118 else | |
| 119 result.unusedScrollDeltaY = deltaY; | |
| 120 } | |
| 121 } | 106 } |
| 122 | 107 |
| 123 if (deltaX) { | 108 ScrollResultOneDimensional resultY = userScroll( |
| 124 if (e.granularity() == ScrollByPageWheelEvent) { | 109 VerticalScrollbar, granularity, m_scrollableArea->pixelStep(Vertical Scrollbar), -deltaY); |
| 125 bool negative = deltaX < 0; | |
| 126 deltaX = m_scrollableArea->pageStep(HorizontalScrollbar); | |
| 127 if (negative) | |
| 128 deltaX = -deltaX; | |
| 129 } | |
| 130 | 110 |
| 131 ScrollResultOneDimensional resultX = userScroll( | 111 if (e.granularity() != ScrollByPageWheelEvent) { |
| 132 HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(Ho rizontalScrollbar), -deltaX); | 112 if (resultY.didScroll) |
| 133 | 113 result.unusedScrollDeltaY = -resultY.unusedScrollDelta; |
| 134 if (e.granularity() != ScrollByPageWheelEvent) { | 114 else |
| 135 if (resultX.didScroll) | 115 result.unusedScrollDeltaY = deltaY; |
| 136 result.unusedScrollDeltaX = -resultX.unusedScrollDelta; | |
| 137 else | |
| 138 result.unusedScrollDeltaX = deltaX; | |
| 139 } | |
| 140 } | 116 } |
| 141 } | 117 } |
| 142 | 118 |
| 119 if (deltaX) { | |
| 120 if (e.granularity() == ScrollByPageWheelEvent) { | |
| 121 bool negative = deltaX < 0; | |
| 122 deltaX = m_scrollableArea->pageStep(HorizontalScrollbar); | |
| 123 if (negative) | |
| 124 deltaX = -deltaX; | |
| 125 } | |
| 126 | |
| 127 ScrollResultOneDimensional resultX = userScroll( | |
| 128 HorizontalScrollbar, granularity, m_scrollableArea->pixelStep(Horizo ntalScrollbar), -deltaX); | |
| 129 | |
| 130 if (e.granularity() != ScrollByPageWheelEvent) { | |
| 131 if (resultX.didScroll) | |
| 132 result.unusedScrollDeltaX = -resultX.unusedScrollDelta; | |
| 133 else | |
| 134 result.unusedScrollDeltaX = deltaX; | |
| 135 } | |
| 136 } | |
| 137 | |
| 143 return result; | 138 return result; |
| 144 } | 139 } |
| 145 | 140 |
| 146 void ScrollAnimator::setCurrentPosition(const FloatPoint& position) | 141 void ScrollAnimator::setCurrentPosition(const FloatPoint& position) |
| 147 { | 142 { |
| 148 m_currentPosX = position.x(); | 143 m_currentPosX = position.x(); |
| 149 m_currentPosY = position.y(); | 144 m_currentPosY = position.y(); |
| 150 } | 145 } |
| 151 | 146 |
| 152 FloatPoint ScrollAnimator::currentPosition() const | 147 FloatPoint ScrollAnimator::currentPosition() const |
| 153 { | 148 { |
| 154 return FloatPoint(m_currentPosX, m_currentPosY); | 149 return FloatPoint(m_currentPosX, m_currentPosY); |
| 155 } | 150 } |
| 156 | 151 |
| 157 void ScrollAnimator::notifyPositionChanged() | 152 void ScrollAnimator::notifyPositionChanged() |
| 158 { | 153 { |
| 159 m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_current PosY), UserScroll); | 154 m_scrollableArea->scrollPositionChanged(DoublePoint(m_currentPosX, m_current PosY), UserScroll); |
| 160 } | 155 } |
| 161 | 156 |
| 162 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa t pos) | 157 float ScrollAnimator::clampScrollPosition(ScrollbarOrientation orientation, floa t pos) |
| 163 { | 158 { |
| 164 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); | 159 float maxScrollPos = m_scrollableArea->maximumScrollPosition(orientation); |
| 165 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); | 160 float minScrollPos = m_scrollableArea->minimumScrollPosition(orientation); |
| 166 return std::max(std::min(pos, maxScrollPos), minScrollPos); | 161 return std::max(std::min(pos, maxScrollPos), minScrollPos); |
| 167 } | 162 } |
| 168 | 163 |
| 169 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |