OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/input/scroll_elasticity_helper.h" | |
6 | |
7 #include "cc/layers/layer_impl.h" | |
8 #include "cc/trees/layer_tree_host_impl.h" | |
9 | |
10 namespace cc { | |
11 | |
12 ScrollElasticityHelper::ScrollElasticityHelper(LayerTreeHostImpl* layer_tree) | |
13 : layer_tree_(layer_tree), timer_active_(false) { | |
14 } | |
15 | |
16 ScrollElasticityHelper::~ScrollElasticityHelper() { | |
17 } | |
18 | |
19 bool ScrollElasticityHelper::AllowsHorizontalStretching() { | |
20 // The WebKit implementation has this interface because it is written in terms | |
21 // of overscrolling on a per-layer basis, not for the whole layer tree. In | |
22 // that implementation, this always returns true for the frame view's | |
23 // scrollable area. | |
24 // TODO(ccameron): This is function is redundant and may be removed. | |
25 return true; | |
26 } | |
27 | |
28 bool ScrollElasticityHelper::AllowsVerticalStretching() { | |
29 // TODO(ccameron): This is function is redundant and may be removed. | |
30 return true; | |
31 } | |
32 | |
33 gfx::Vector2dF ScrollElasticityHelper::StretchAmount() { | |
34 return stretch_offset_; | |
35 } | |
36 | |
37 bool ScrollElasticityHelper::PinnedInDirection( | |
38 const gfx::Vector2dF& direction) { | |
39 LayerImpl* layer = layer_tree_->InnerViewportScrollLayer(); | |
aelias_OOO_until_Jul13
2014/11/13 02:11:03
Please use layer_tree_->TotalScrollOffset() and la
ccameron
2014/11/13 02:45:57
Done. Btw, I'm helping get pinch virtual viewport
| |
40 bool result = false; | |
41 if (direction.x() < 0) | |
42 result |= layer->TotalScrollOffset().x() <= 0; | |
43 if (direction.x() > 0) | |
44 result |= layer->TotalScrollOffset().x() >= layer->MaxScrollOffset().x(); | |
45 if (direction.y() < 0) | |
46 result |= layer->TotalScrollOffset().y() <= 0; | |
47 if (direction.y() > 0) | |
48 result |= layer->TotalScrollOffset().y() >= layer->MaxScrollOffset().y(); | |
49 return result; | |
50 } | |
51 | |
52 bool ScrollElasticityHelper::CanScrollHorizontally() { | |
53 return layer_tree_->InnerViewportScrollLayer()->user_scrollable(HORIZONTAL); | |
aelias_OOO_until_Jul13
2014/11/13 02:11:03
user_scrollable() just denotes whether the layer i
ccameron
2014/11/13 02:45:57
Thanks, done.
| |
54 } | |
55 | |
56 bool ScrollElasticityHelper::CanScrollVertically() { | |
57 return layer_tree_->InnerViewportScrollLayer()->user_scrollable(VERTICAL); | |
58 } | |
59 | |
60 gfx::Vector2dF ScrollElasticityHelper::AbsoluteScrollPosition() { | |
61 // TODO(ccameron): This is function is redundant and may be removed. | |
62 return stretch_offset_; | |
63 } | |
64 | |
65 void ScrollElasticityHelper::ImmediateScrollBy(const gfx::Vector2dF& scroll) { | |
66 // TODO(ccameron): This is function is redundant and may be removed. | |
67 } | |
68 | |
69 void ScrollElasticityHelper::ImmediateScrollByWithoutContentEdgeConstraints( | |
70 const gfx::Vector2dF& scroll) { | |
71 stretch_offset_ += scroll; | |
72 | |
73 // TODO(ccameron): Update the transform of the appropriate layer in the | |
74 // LayerTreeHostImpl, and request that a frame be drawn. | |
75 } | |
76 | |
77 void ScrollElasticityHelper::StartSnapRubberbandTimer() { | |
78 if (timer_active_) | |
79 return; | |
80 timer_active_ = true; | |
81 layer_tree_->SetNeedsAnimate(); | |
82 } | |
83 | |
84 void ScrollElasticityHelper::StopSnapRubberbandTimer() { | |
85 timer_active_ = false; | |
86 } | |
87 | |
88 void ScrollElasticityHelper::SnapRubberbandTimerFired() { | |
89 if (timer_active_) | |
90 layer_tree_->SetNeedsAnimate(); | |
91 } | |
92 | |
93 void ScrollElasticityHelper::AdjustScrollPositionToBoundsIfNecessary() { | |
94 // TODO(ccameron): This is function is redundant and may be removed. | |
95 } | |
96 | |
97 } // namespace cc | |
OLD | NEW |