| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 NOTREACHED(); | 177 NOTREACHED(); |
| 178 return 0; | 178 return 0; |
| 179 } | 179 } |
| 180 | 180 |
| 181 gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll) | 181 gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll) |
| 182 { | 182 { |
| 183 gfx::Vector2dF minDelta = -m_scrollOffset; | 183 gfx::Vector2dF minDelta = -m_scrollOffset; |
| 184 gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset; | 184 gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset; |
| 185 // Clamp newDelta so that position + delta stays within scroll bounds. | 185 // Clamp newDelta so that position + delta stays within scroll bounds. |
| 186 gfx::Vector2dF newDelta = (m_scrollDelta + scroll); | 186 gfx::Vector2dF newDelta = (m_scrollDelta + scroll); |
| 187 newDelta = ClampFromBelow(newDelta, minDelta); | 187 newDelta.ClampToMin(minDelta); |
| 188 newDelta = ClampFromAbove(newDelta, maxDelta); | 188 newDelta.ClampToMax(maxDelta); |
| 189 gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta; | 189 gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta; |
| 190 | 190 |
| 191 if (m_scrollDelta == newDelta) | 191 if (m_scrollDelta == newDelta) |
| 192 return unscrolled; | 192 return unscrolled; |
| 193 | 193 |
| 194 m_scrollDelta = newDelta; | 194 m_scrollDelta = newDelta; |
| 195 if (m_scrollbarAnimationController) | 195 if (m_scrollbarAnimationController) |
| 196 m_scrollbarAnimationController->updateScrollOffset(this); | 196 m_scrollbarAnimationController->updateScrollOffset(this); |
| 197 noteLayerPropertyChangedForSubtree(); | 197 noteLayerPropertyChangedForSubtree(); |
| 198 | 198 |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 | 701 |
| 702 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 702 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
| 703 { | 703 { |
| 704 if (!m_scrollbarAnimationController) | 704 if (!m_scrollbarAnimationController) |
| 705 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 705 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
| 706 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 706 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 707 m_scrollbarAnimationController->updateScrollOffset(this); | 707 m_scrollbarAnimationController->updateScrollOffset(this); |
| 708 } | 708 } |
| 709 | 709 |
| 710 } // namespace cc | 710 } // namespace cc |
| OLD | NEW |