Index: cc/trees/tree_scroll_elasticity_client.cc |
diff --git a/cc/trees/tree_scroll_elasticity_client.cc b/cc/trees/tree_scroll_elasticity_client.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..650a21e6072205383edb7bd1ba0349bbcdd6695b |
--- /dev/null |
+++ b/cc/trees/tree_scroll_elasticity_client.cc |
@@ -0,0 +1,88 @@ |
+// 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/tree_scroll_elasticity_client.h" |
+ |
+#include "cc/layers/layer_impl.h" |
+#include "cc/trees/layer_tree_host_impl.h" |
+ |
+namespace cc { |
+ |
+TreeScrollElasticityClient::TreeScrollElasticityClient(LayerTreeHostImpl* tree) |
+ : tree_(tree), timer_active_(false), controller_(NULL) {} |
+ |
+TreeScrollElasticityClient::~TreeScrollElasticityClient() {} |
+ |
+void TreeScrollElasticityClient::BindToController( |
+ ScrollElasticityController* controller) { |
+ controller_ = controller; |
+} |
+ |
+bool TreeScrollElasticityClient::allowsHorizontalStretching() const { |
+ return true; |
+} |
+ |
+bool TreeScrollElasticityClient::allowsVerticalStretching() const { |
+ return true; |
+} |
+ |
+// The amount that the view is stretched past the normal allowable bounds. |
+// The "overhang" amount. |
+gfx::Vector2dF TreeScrollElasticityClient::stretchAmount() const { |
+ return stretch_offset_; |
+} |
+ |
+bool TreeScrollElasticityClient::pinnedInDirection(const gfx::Vector2dF& delta) const { |
+ LayerImpl* layer = tree_->InnerViewportScrollLayer(); |
+ bool result = false; |
+ if (delta.x() < 0) |
+ result |= layer->TotalScrollOffset().x() <= 0; |
+ if (delta.x() > 0) |
+ result |= layer->TotalScrollOffset().x() >= layer->MaxScrollOffset().x(); |
+ if (delta.y() < 0) |
+ result |= layer->TotalScrollOffset().y() <= 0; |
+ if (delta.y() > 0) |
+ result |= layer->TotalScrollOffset().y() >= layer->MaxScrollOffset().y(); |
+ printf("pinned delta=%s offset=%s max=%s : %d\n", |
+ delta.ToString().c_str(), |
+ layer->TotalScrollOffset().ToString().c_str(), |
+ layer->MaxScrollOffset().ToString().c_str(), |
+ result); |
+ return result; |
+} |
+ |
+bool TreeScrollElasticityClient::canScrollHorizontally() const { |
+ return true; |
+} |
+ |
+bool TreeScrollElasticityClient::canScrollVertically() const { |
+ return true; |
+} |
+ |
+// Return the absolute scroll position, not relative to the scroll origin. |
+gfx::Vector2dF TreeScrollElasticityClient::absoluteScrollPosition() const { |
+ return stretchAmount(); |
+} |
+ |
+void TreeScrollElasticityClient::immediateScrollBy(const gfx::Vector2dF& delta) { |
+} |
+ |
+void TreeScrollElasticityClient::immediateScrollByWithoutContentEdgeConstraints(const gfx::Vector2dF& delta) { |
+ stretch_offset_ += delta; |
+ // tree_->UpdateRubberband(-stretch_offset_); |
+} |
+ |
+void TreeScrollElasticityClient::startSnapRubberbandTimer() { |
+ timer_active_ = true; |
+ tree_->SetNeedsAnimate(); |
+} |
+ |
+void TreeScrollElasticityClient::stopSnapRubberbandTimer() { |
+ timer_active_ = false; |
+} |
+ |
+void TreeScrollElasticityClient::adjustScrollPositionToBoundsIfNecessary() { |
+} |
+ |
+} // namespace cc |