blob: 0cc5f6314260caf30fed6b2ecb7b4824d4838e1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "CCScrollbarAnimationController.h"
#include "CCScrollbarLayerImpl.h"
#include "base/time.h"
#if OS(ANDROID)
#include "CCScrollbarAnimationControllerLinearFade.h"
#endif
namespace cc {
#if OS(ANDROID)
scoped_ptr<ScrollbarAnimationController> ScrollbarAnimationController::create(LayerImpl* scrollLayer)
{
static const double fadeoutDelay = 0.3;
static const double fadeoutLength = 0.3;
return ScrollbarAnimationControllerLinearFade::create(scrollLayer, fadeoutDelay, fadeoutLength).PassAs<ScrollbarAnimationController>();
}
#else
scoped_ptr<ScrollbarAnimationController> ScrollbarAnimationController::create(LayerImpl* scrollLayer)
{
return make_scoped_ptr(new ScrollbarAnimationController(scrollLayer));
}
#endif
ScrollbarAnimationController::ScrollbarAnimationController(LayerImpl* scrollLayer)
: m_horizontalScrollbarLayer(0)
, m_verticalScrollbarLayer(0)
{
ScrollbarAnimationController::updateScrollOffsetAtTime(scrollLayer, 0);
}
ScrollbarAnimationController::~ScrollbarAnimationController()
{
}
bool ScrollbarAnimationController::animate(double)
{
return false;
}
void ScrollbarAnimationController::didPinchGestureBegin()
{
didPinchGestureBeginAtTime((base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
}
void ScrollbarAnimationController::didPinchGestureUpdate()
{
didPinchGestureUpdateAtTime((base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
}
void ScrollbarAnimationController::didPinchGestureEnd()
{
didPinchGestureEndAtTime((base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
}
void ScrollbarAnimationController::updateScrollOffset(LayerImpl* scrollLayer)
{
updateScrollOffsetAtTime(scrollLayer, (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
}
IntSize ScrollbarAnimationController::getScrollLayerBounds(const LayerImpl* scrollLayer)
{
if (!scrollLayer->children().size())
return IntSize();
// Copy & paste from LayerTreeHostImpl...
// FIXME: Hardcoding the first child here is weird. Think of
// a cleaner way to get the contentBounds on the Impl side.
return scrollLayer->children()[0]->bounds();
}
void ScrollbarAnimationController::updateScrollOffsetAtTime(LayerImpl* scrollLayer, double)
{
m_currentPos = scrollLayer->scrollPosition() + scrollLayer->scrollDelta();
m_totalSize = getScrollLayerBounds(scrollLayer);
m_maximum = scrollLayer->maxScrollPosition();
if (m_horizontalScrollbarLayer) {
m_horizontalScrollbarLayer->setCurrentPos(m_currentPos.x());
m_horizontalScrollbarLayer->setTotalSize(m_totalSize.width());
m_horizontalScrollbarLayer->setMaximum(m_maximum.width());
}
if (m_verticalScrollbarLayer) {
m_verticalScrollbarLayer->setCurrentPos(m_currentPos.y());
m_verticalScrollbarLayer->setTotalSize(m_totalSize.height());
m_verticalScrollbarLayer->setMaximum(m_maximum.height());
}
}
} // namespace cc
|