Index: cc/trees/layer_tree_scroll_elasticity_client.cc |
diff --git a/cc/trees/layer_tree_scroll_elasticity_client.cc b/cc/trees/layer_tree_scroll_elasticity_client.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fa9ccf2c0fe9519beb6a8e25a48d8a1ea3d2c850 |
--- /dev/null |
+++ b/cc/trees/layer_tree_scroll_elasticity_client.cc |
@@ -0,0 +1,118 @@ |
+// Copyright 2014 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 "cc/trees/layer_tree_scroll_elasticity_client.h" |
+ |
+#include "cc/layers/layer_impl.h" |
+#include "cc/trees/layer_tree_host_impl.h" |
+ |
+namespace cc { |
+ |
+LayerTreeScrollElasticityClient::LayerTreeScrollElasticityClient( |
+ LayerTreeHostImpl* layer_tree) |
+ : layer_tree_(layer_tree), controller_(NULL), timer_active_(false) { |
+} |
+ |
+LayerTreeScrollElasticityClient::~LayerTreeScrollElasticityClient() { |
+ if (controller_) |
+ controller_->WillShutdown(); |
+} |
+ |
+void LayerTreeScrollElasticityClient::Animate(base::TimeTicks monotonic_time) { |
+ if (!timer_active_) |
+ return; |
+ |
+ if (controller_) |
+ controller_->Animate(monotonic_time); |
+ |
+ // If the controller has not indicated that it is done animating, request |
+ // another frame. |
+ if (timer_active_) |
+ layer_tree_->SetNeedsAnimate(); |
+} |
+ |
+void LayerTreeScrollElasticityClient::BindToController( |
+ ScrollElasticityController* controller) { |
+ DCHECK(!controller_); |
+ controller_ = controller; |
+} |
+ |
+bool LayerTreeScrollElasticityClient::AllowsHorizontalStretching() { |
+ // TODO(ccameron): Get this information from the LayerTreeHostImpl. |
+ return true; |
+} |
+ |
+bool LayerTreeScrollElasticityClient::AllowsVerticalStretching() { |
+ // 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
|
+ return true; |
+} |
+ |
+gfx::Vector2dF LayerTreeScrollElasticityClient::StretchAmount() { |
+ return stretch_offset_; |
+} |
+ |
+bool LayerTreeScrollElasticityClient::PinnedInDirection( |
+ const gfx::Vector2dF& direction) { |
+ LayerImpl* layer = layer_tree_->InnerViewportScrollLayer(); |
+ bool result = false; |
+ if (direction.x() < 0) |
+ result |= layer->TotalScrollOffset().x() <= 0; |
+ if (direction.x() > 0) |
+ result |= layer->TotalScrollOffset().x() >= layer->MaxScrollOffset().x(); |
+ if (direction.y() < 0) |
+ result |= layer->TotalScrollOffset().y() <= 0; |
+ if (direction.y() > 0) |
+ result |= layer->TotalScrollOffset().y() >= layer->MaxScrollOffset().y(); |
+ return result; |
+} |
+ |
+bool LayerTreeScrollElasticityClient::CanScrollHorizontally() { |
+ // TODO(ccameron): This information is likely unnecessary, remove it or get |
+ // the correct information from LayerTreeHostImpl. |
+ return true; |
+} |
+ |
+bool LayerTreeScrollElasticityClient::CanScrollVertically() { |
+ // TODO(ccameron): This information is likely unnecessary, remove it or get |
+ // the correct information from LayerTreeHostImpl. |
+ return true; |
+} |
+ |
+gfx::Vector2dF LayerTreeScrollElasticityClient::AbsoluteScrollPosition() { |
+ // TODO(ccameron): This information is likely unnecessary, remove it or get |
+ // the correct information from LayerTreeHostImpl. |
+ return stretch_offset_; |
+} |
+ |
+void LayerTreeScrollElasticityClient::ImmediateScrollBy( |
+ const gfx::Vector2dF& scroll) { |
+ // TODO(ccameron): This is no longer necessary because elasticity is now |
+ // decoupled from scrolling. Remove this. |
+} |
+ |
+void LayerTreeScrollElasticityClient:: |
+ ImmediateScrollByWithoutContentEdgeConstraints( |
+ const gfx::Vector2dF& scroll) { |
+ stretch_offset_ += scroll; |
+ // TODO(ccameron): Update the transform of the appropriate layer in the |
+ // LayerTreeHostImpl, and request that a frame be drawn. |
+} |
+ |
+void LayerTreeScrollElasticityClient::StartSnapRubberbandTimer() { |
+ if (timer_active_) |
+ return; |
+ timer_active_ = true; |
+ layer_tree_->SetNeedsAnimate(); |
+} |
+ |
+void LayerTreeScrollElasticityClient::StopSnapRubberbandTimer() { |
+ timer_active_ = false; |
+} |
+ |
+void LayerTreeScrollElasticityClient:: |
+ AdjustScrollPositionToBoundsIfNecessary() { |
+ // TODO(ccameron): This function is likely unnecessary. Remove it. |
+} |
+ |
+} // namespace cc |