Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: cc/trees/layer_tree_scroll_elasticity_client.cc

Issue 713413002: Hook ScrollElasticityController to InputHandlerProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/trees/layer_tree_scroll_elasticity_client.h"
6
7 #include "cc/layers/layer_impl.h"
8 #include "cc/trees/layer_tree_host_impl.h"
9
10 namespace cc {
11
12 LayerTreeScrollElasticityClient::LayerTreeScrollElasticityClient(
13 LayerTreeHostImpl* layer_tree)
14 : layer_tree_(layer_tree), controller_(NULL), timer_active_(false) {
15 }
16
17 LayerTreeScrollElasticityClient::~LayerTreeScrollElasticityClient() {
18 if (controller_)
19 controller_->WillShutdown();
20 }
21
22 void LayerTreeScrollElasticityClient::Animate(base::TimeTicks monotonic_time) {
23 if (!timer_active_)
24 return;
25
26 if (controller_)
27 controller_->Animate(monotonic_time);
28
29 // If the controller has not indicated that it is done animating, request
30 // another frame.
31 if (timer_active_)
32 layer_tree_->SetNeedsAnimate();
33 }
34
35 void LayerTreeScrollElasticityClient::BindToController(
36 ScrollElasticityController* controller) {
37 DCHECK(!controller_);
38 controller_ = controller;
39 }
40
41 bool LayerTreeScrollElasticityClient::AllowsHorizontalStretching() {
42 // TODO(ccameron): Get this information from the LayerTreeHostImpl.
43 return true;
44 }
45
46 bool LayerTreeScrollElasticityClient::AllowsVerticalStretching() {
47 // TODO(ccameron): Get this information from the LayerTreeHostImpl.
aelias_OOO_until_Jul13 2014/11/12 22:17:59 It's difficult to tell whether the way you've set
ccameron 2014/11/13 00:28:37 This was a reaction against what I perceive to be
48 return true;
49 }
50
51 gfx::Vector2dF LayerTreeScrollElasticityClient::StretchAmount() {
52 return stretch_offset_;
53 }
54
55 bool LayerTreeScrollElasticityClient::PinnedInDirection(
56 const gfx::Vector2dF& direction) {
57 LayerImpl* layer = layer_tree_->InnerViewportScrollLayer();
58 bool result = false;
59 if (direction.x() < 0)
60 result |= layer->TotalScrollOffset().x() <= 0;
61 if (direction.x() > 0)
62 result |= layer->TotalScrollOffset().x() >= layer->MaxScrollOffset().x();
63 if (direction.y() < 0)
64 result |= layer->TotalScrollOffset().y() <= 0;
65 if (direction.y() > 0)
66 result |= layer->TotalScrollOffset().y() >= layer->MaxScrollOffset().y();
67 return result;
68 }
69
70 bool LayerTreeScrollElasticityClient::CanScrollHorizontally() {
71 // TODO(ccameron): This information is likely unnecessary, remove it or get
72 // the correct information from LayerTreeHostImpl.
73 return true;
74 }
75
76 bool LayerTreeScrollElasticityClient::CanScrollVertically() {
77 // TODO(ccameron): This information is likely unnecessary, remove it or get
78 // the correct information from LayerTreeHostImpl.
79 return true;
80 }
81
82 gfx::Vector2dF LayerTreeScrollElasticityClient::AbsoluteScrollPosition() {
83 // TODO(ccameron): This information is likely unnecessary, remove it or get
84 // the correct information from LayerTreeHostImpl.
85 return stretch_offset_;
86 }
87
88 void LayerTreeScrollElasticityClient::ImmediateScrollBy(
89 const gfx::Vector2dF& scroll) {
90 // TODO(ccameron): This is no longer necessary because elasticity is now
91 // decoupled from scrolling. Remove this.
92 }
93
94 void LayerTreeScrollElasticityClient::
95 ImmediateScrollByWithoutContentEdgeConstraints(
96 const gfx::Vector2dF& scroll) {
97 stretch_offset_ += scroll;
98 // TODO(ccameron): Update the transform of the appropriate layer in the
99 // LayerTreeHostImpl, and request that a frame be drawn.
100 }
101
102 void LayerTreeScrollElasticityClient::StartSnapRubberbandTimer() {
103 if (timer_active_)
104 return;
105 timer_active_ = true;
106 layer_tree_->SetNeedsAnimate();
107 }
108
109 void LayerTreeScrollElasticityClient::StopSnapRubberbandTimer() {
110 timer_active_ = false;
111 }
112
113 void LayerTreeScrollElasticityClient::
114 AdjustScrollPositionToBoundsIfNecessary() {
115 // TODO(ccameron): This function is likely unnecessary. Remove it.
116 }
117
118 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698