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

Unified Diff: cc/input/scroll_elasticity_helper.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/input/scroll_elasticity_helper.h ('k') | cc/layers/content_layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..54da888ff7692951252427bf852f35d471312219
--- /dev/null
+++ b/cc/input/scroll_elasticity_helper.cc
@@ -0,0 +1,101 @@
+// 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"
+#include "cc/trees/layer_tree_impl.h"
+
+namespace cc {
+
+ScrollElasticityHelper::ScrollElasticityHelper(LayerTreeHostImpl* layer_tree)
+ : layer_tree_host_impl_(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) {
+ gfx::ScrollOffset scroll_offset =
+ layer_tree_host_impl_->active_tree()->TotalScrollOffset();
+ gfx::ScrollOffset max_scroll_offset =
+ layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset();
+ bool result = false;
+ if (direction.x() < 0)
+ result |= scroll_offset.x() <= 0;
+ if (direction.x() > 0)
+ result |= scroll_offset.x() >= max_scroll_offset.x();
+ if (direction.y() < 0)
+ result |= scroll_offset.y() <= 0;
+ if (direction.y() > 0)
+ result |= scroll_offset.y() >= max_scroll_offset.y();
+ return result;
+}
+
+bool ScrollElasticityHelper::CanScrollHorizontally() {
+ return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset().x() > 0;
+}
+
+bool ScrollElasticityHelper::CanScrollVertically() {
+ return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset().y() > 0;
+}
+
+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_host_impl_->SetNeedsAnimate();
+}
+
+void ScrollElasticityHelper::StopSnapRubberbandTimer() {
+ timer_active_ = false;
+}
+
+void ScrollElasticityHelper::SnapRubberbandTimerFired() {
+ if (timer_active_)
+ layer_tree_host_impl_->SetNeedsAnimate();
+}
+
+void ScrollElasticityHelper::AdjustScrollPositionToBoundsIfNecessary() {
+ // TODO(ccameron): This is function is redundant and may be removed.
+}
+
+} // namespace cc
« no previous file with comments | « cc/input/scroll_elasticity_helper.h ('k') | cc/layers/content_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698