| 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 "CCScrollbarAnimationController.h" | 7 #include "CCScrollbarAnimationController.h" |
| 8 | 8 |
| 9 #include "CCScrollbarLayerImpl.h" | 9 #include "CCScrollbarLayerImpl.h" |
| 10 #include <wtf/CurrentTime.h> | 10 #include <wtf/CurrentTime.h> |
| 11 | 11 |
| 12 #if OS(ANDROID) | 12 #if OS(ANDROID) |
| 13 #include "CCScrollbarAnimationControllerLinearFade.h" | 13 #include "CCScrollbarAnimationControllerLinearFade.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 #if OS(ANDROID) | 18 #if OS(ANDROID) |
| 19 scoped_ptr<CCScrollbarAnimationController> CCScrollbarAnimationController::creat
e(CCLayerImpl* scrollLayer) | 19 scoped_ptr<ScrollbarAnimationController> ScrollbarAnimationController::create(La
yerImpl* scrollLayer) |
| 20 { | 20 { |
| 21 static const double fadeoutDelay = 0.3; | 21 static const double fadeoutDelay = 0.3; |
| 22 static const double fadeoutLength = 0.3; | 22 static const double fadeoutLength = 0.3; |
| 23 return CCScrollbarAnimationControllerLinearFade::create(scrollLayer, fadeout
Delay, fadeoutLength).PassAs<CCScrollbarAnimationController>(); | 23 return ScrollbarAnimationControllerLinearFade::create(scrollLayer, fadeoutDe
lay, fadeoutLength).PassAs<ScrollbarAnimationController>(); |
| 24 } | 24 } |
| 25 #else | 25 #else |
| 26 scoped_ptr<CCScrollbarAnimationController> CCScrollbarAnimationController::creat
e(CCLayerImpl* scrollLayer) | 26 scoped_ptr<ScrollbarAnimationController> ScrollbarAnimationController::create(La
yerImpl* scrollLayer) |
| 27 { | 27 { |
| 28 return make_scoped_ptr(new CCScrollbarAnimationController(scrollLayer)); | 28 return make_scoped_ptr(new ScrollbarAnimationController(scrollLayer)); |
| 29 } | 29 } |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 CCScrollbarAnimationController::CCScrollbarAnimationController(CCLayerImpl* scro
llLayer) | 32 ScrollbarAnimationController::ScrollbarAnimationController(LayerImpl* scrollLaye
r) |
| 33 : m_horizontalScrollbarLayer(0) | 33 : m_horizontalScrollbarLayer(0) |
| 34 , m_verticalScrollbarLayer(0) | 34 , m_verticalScrollbarLayer(0) |
| 35 { | 35 { |
| 36 CCScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, 0); | 36 ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, 0); |
| 37 } | 37 } |
| 38 | 38 |
| 39 CCScrollbarAnimationController::~CCScrollbarAnimationController() | 39 ScrollbarAnimationController::~ScrollbarAnimationController() |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool CCScrollbarAnimationController::animate(double) | 43 bool ScrollbarAnimationController::animate(double) |
| 44 { | 44 { |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void CCScrollbarAnimationController::didPinchGestureBegin() | 48 void ScrollbarAnimationController::didPinchGestureBegin() |
| 49 { | 49 { |
| 50 didPinchGestureBeginAtTime(monotonicallyIncreasingTime()); | 50 didPinchGestureBeginAtTime(monotonicallyIncreasingTime()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void CCScrollbarAnimationController::didPinchGestureUpdate() | 53 void ScrollbarAnimationController::didPinchGestureUpdate() |
| 54 { | 54 { |
| 55 didPinchGestureUpdateAtTime(monotonicallyIncreasingTime()); | 55 didPinchGestureUpdateAtTime(monotonicallyIncreasingTime()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CCScrollbarAnimationController::didPinchGestureEnd() | 58 void ScrollbarAnimationController::didPinchGestureEnd() |
| 59 { | 59 { |
| 60 didPinchGestureEndAtTime(monotonicallyIncreasingTime()); | 60 didPinchGestureEndAtTime(monotonicallyIncreasingTime()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void CCScrollbarAnimationController::updateScrollOffset(CCLayerImpl* scrollLayer
) | 63 void ScrollbarAnimationController::updateScrollOffset(LayerImpl* scrollLayer) |
| 64 { | 64 { |
| 65 updateScrollOffsetAtTime(scrollLayer, monotonicallyIncreasingTime()); | 65 updateScrollOffsetAtTime(scrollLayer, monotonicallyIncreasingTime()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 IntSize CCScrollbarAnimationController::getScrollLayerBounds(const CCLayerImpl*
scrollLayer) | 68 IntSize ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* scro
llLayer) |
| 69 { | 69 { |
| 70 if (!scrollLayer->children().size()) | 70 if (!scrollLayer->children().size()) |
| 71 return IntSize(); | 71 return IntSize(); |
| 72 // Copy & paste from CCLayerTreeHostImpl... | 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 CCScrollbarAnimationController::updateScrollOffsetAtTime(CCLayerImpl* scrol
lLayer, 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 |