OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/scrollbar_animation_controller.h" | 7 #include "cc/scrollbar_animation_controller.h" |
8 | 8 |
9 #include "cc/scrollbar_layer_impl.h" | 9 #include "cc/scrollbar_layer_impl.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void ScrollbarAnimationController::didPinchGestureEnd() | 58 void ScrollbarAnimationController::didPinchGestureEnd() |
59 { | 59 { |
60 didPinchGestureEndAtTime((base::TimeTicks::Now() - base::TimeTicks()).InSeco
ndsF()); | 60 didPinchGestureEndAtTime((base::TimeTicks::Now() - base::TimeTicks()).InSeco
ndsF()); |
61 } | 61 } |
62 | 62 |
63 void ScrollbarAnimationController::updateScrollOffset(LayerImpl* scrollLayer) | 63 void ScrollbarAnimationController::updateScrollOffset(LayerImpl* scrollLayer) |
64 { | 64 { |
65 updateScrollOffsetAtTime(scrollLayer, (base::TimeTicks::Now() - base::TimeTi
cks()).InSecondsF()); | 65 updateScrollOffsetAtTime(scrollLayer, (base::TimeTicks::Now() - base::TimeTi
cks()).InSecondsF()); |
66 } | 66 } |
67 | 67 |
68 IntSize ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* scro
llLayer) | 68 gfx::Size ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* sc
rollLayer) |
69 { | 69 { |
70 if (!scrollLayer->children().size()) | 70 if (!scrollLayer->children().size()) |
71 return IntSize(); | 71 return gfx::Size(); |
72 // Copy & paste from LayerTreeHostImpl... | 72 // Copy & paste from LayerTreeHostImpl... |
73 // FIXME: Hardcoding the first child here is weird. Think of | 73 // FIXME: Hardcoding the first child here is weird. Think of |
74 // a cleaner way to get the contentBounds on the Impl side. | 74 // a cleaner way to get the contentBounds on the Impl side. |
75 return scrollLayer->children()[0]->bounds(); | 75 return scrollLayer->children()[0]->bounds(); |
76 } | 76 } |
77 | 77 |
78 void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLay
er, double) | 78 void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLay
er, double) |
79 { | 79 { |
80 m_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta(); | 80 m_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta(); |
81 m_totalSize = getScrollLayerBounds(scrollLayer); | 81 m_totalSize = getScrollLayerBounds(scrollLayer); |
82 m_maximum = scrollLayer->maxScrollPosition(); | 82 m_maximum = scrollLayer->maxScrollPosition(); |
83 | 83 |
84 if (m_horizontalScrollbarLayer) { | 84 if (m_horizontalScrollbarLayer) { |
85 m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x()); | 85 m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x()); |
86 m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width()); | 86 m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width()); |
87 m_horizontalScrollbarLayer->setMaximum(m_maximum.width()); | 87 m_horizontalScrollbarLayer->setMaximum(m_maximum.width()); |
88 } | 88 } |
89 | 89 |
90 if (m_verticalScrollbarLayer) { | 90 if (m_verticalScrollbarLayer) { |
91 m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y()); | 91 m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y()); |
92 m_verticalScrollbarLayer->setTotalSize(m_totalSize.height()); | 92 m_verticalScrollbarLayer->setTotalSize(m_totalSize.height()); |
93 m_verticalScrollbarLayer->setMaximum(m_maximum.height()); | 93 m_verticalScrollbarLayer->setMaximum(m_maximum.height()); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 } // namespace cc | 97 } // namespace cc |
OLD | NEW |