Index: cc/input/scroll_elasticity_helper.cc |
diff --git a/cc/input/scroll_elasticity_helper.cc b/cc/input/scroll_elasticity_helper.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..916757b99482ba6d819e07e26a147e93382e8bdd |
--- /dev/null |
+++ b/cc/input/scroll_elasticity_helper.cc |
@@ -0,0 +1,97 @@ |
+// 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/input/scroll_elasticity_helper.h" |
+ |
+#include "cc/layers/layer_impl.h" |
+#include "cc/trees/layer_tree_host_impl.h" |
+ |
+namespace cc { |
+ |
+ScrollElasticityHelper::ScrollElasticityHelper(LayerTreeHostImpl* layer_tree) |
+ : layer_tree_(layer_tree), timer_active_(false) { |
+} |
+ |
+ScrollElasticityHelper::~ScrollElasticityHelper() { |
+} |
+ |
+bool ScrollElasticityHelper::AllowsHorizontalStretching() { |
+ // The WebKit implementation has this interface because it is written in terms |
+ // of overscrolling on a per-layer basis, not for the whole layer tree. In |
+ // that implementation, this always returns true for the frame view's |
+ // scrollable area. |
+ // TODO(ccameron): This is function is redundant and may be removed. |
+ return true; |
+} |
+ |
+bool ScrollElasticityHelper::AllowsVerticalStretching() { |
+ // TODO(ccameron): This is function is redundant and may be removed. |
+ return true; |
+} |
+ |
+gfx::Vector2dF ScrollElasticityHelper::StretchAmount() { |
+ return stretch_offset_; |
+} |
+ |
+bool ScrollElasticityHelper::PinnedInDirection( |
+ const gfx::Vector2dF& direction) { |
+ 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
|
+ 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 ScrollElasticityHelper::CanScrollHorizontally() { |
+ 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.
|
+} |
+ |
+bool ScrollElasticityHelper::CanScrollVertically() { |
+ return layer_tree_->InnerViewportScrollLayer()->user_scrollable(VERTICAL); |
+} |
+ |
+gfx::Vector2dF ScrollElasticityHelper::AbsoluteScrollPosition() { |
+ // TODO(ccameron): This is function is redundant and may be removed. |
+ return stretch_offset_; |
+} |
+ |
+void ScrollElasticityHelper::ImmediateScrollBy(const gfx::Vector2dF& scroll) { |
+ // TODO(ccameron): This is function is redundant and may be removed. |
+} |
+ |
+void ScrollElasticityHelper::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 ScrollElasticityHelper::StartSnapRubberbandTimer() { |
+ if (timer_active_) |
+ return; |
+ timer_active_ = true; |
+ layer_tree_->SetNeedsAnimate(); |
+} |
+ |
+void ScrollElasticityHelper::StopSnapRubberbandTimer() { |
+ timer_active_ = false; |
+} |
+ |
+void ScrollElasticityHelper::SnapRubberbandTimerFired() { |
+ if (timer_active_) |
+ layer_tree_->SetNeedsAnimate(); |
+} |
+ |
+void ScrollElasticityHelper::AdjustScrollPositionToBoundsIfNecessary() { |
+ // TODO(ccameron): This is function is redundant and may be removed. |
+} |
+ |
+} // namespace cc |